-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DEV: Upgrade post menu buttons to the Glimmer API (#22)
- Loading branch information
Showing
6 changed files
with
67 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
< 3.4.0.beta3-dev: 7ee4963dbcfb9daa1d9391cf9f917b19b7be8ef7 | ||
< 3.4.0.beta1-dev: ebdcb7c5fd4fed3beaa4f96a535a038dcfabaa1c | ||
< 3.3.0.beta1-dev: 68e25649fb16deba5caab0e63e37103fedd8313e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
# raw-post-button | ||
# ** raw-post-button ** | ||
|
||
Raw Post Button will add a button to the post menu. When you click the button, you’ll get a modal / popover with the raw (markdown) version of the post. | ||
|
||
For more information, please see: https://meta.discourse.org/t/raw-post-button/152542 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import Component from "@glimmer/component"; | ||
import { action } from "@ember/object"; | ||
import { service } from "@ember/service"; | ||
import DButton from "discourse/components/d-button"; | ||
import FullscreenCode from "discourse/components/modal/fullscreen-code"; | ||
import { ajax } from "discourse/lib/ajax"; | ||
import { popupAjaxError } from "discourse/lib/ajax-error"; | ||
|
||
export default class ShowRawButton extends Component { | ||
static hidden = true; | ||
|
||
@service modal; | ||
|
||
@action | ||
async showRaw() { | ||
try { | ||
const response = await ajax(`/posts/${this.args.post.id}/raw`, { | ||
dataType: "text", | ||
}); | ||
await this.modal.show(FullscreenCode, { | ||
model: { | ||
code: response, | ||
}, | ||
}); | ||
} catch (e) { | ||
popupAjaxError(e); | ||
} | ||
} | ||
|
||
<template> | ||
<DButton | ||
class="post-action-menu__raw-post raw-post" | ||
...attributes | ||
@action={{this.showRaw}} | ||
@icon="file-lines" | ||
@label={{if @showLabel (themePrefix "button_label")}} | ||
@title={{themePrefix "button_title"}} | ||
/> | ||
</template> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
en: | ||
button_label: "Raw Post" | ||
button_title: "Raw Post" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters