FEATURE: Show the slow mode indicator in composer (#12720)

This commit is contained in:
Andrei Prigorshnev 2021-04-17 23:40:09 +04:00 committed by GitHub
parent 75abe8d295
commit 8c6ea967ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,13 +5,13 @@ import {
PRIVATE_MESSAGE, PRIVATE_MESSAGE,
REPLY, REPLY,
} from "discourse/models/composer"; } from "discourse/models/composer";
import discourseComputed from "discourse-common/utils/decorators";
import Draft from "discourse/models/draft"; import Draft from "discourse/models/draft";
import DropdownSelectBoxComponent from "select-kit/components/dropdown-select-box"; import DropdownSelectBoxComponent from "select-kit/components/dropdown-select-box";
import I18n from "I18n"; import I18n from "I18n";
import bootbox from "bootbox"; import bootbox from "bootbox";
import { camelize } from "@ember/string"; import { camelize } from "@ember/string";
import { computed } from "@ember/object"; import { equal, gt } from "@ember/object/computed";
import { equal } from "@ember/object/computed";
import { isEmpty } from "@ember/utils"; import { isEmpty } from "@ember/utils";
// Component can get destroyed and lose state // Component can get destroyed and lose state
@ -30,6 +30,7 @@ export default DropdownSelectBoxComponent.extend({
pluginApiIdentifiers: ["composer-actions"], pluginApiIdentifiers: ["composer-actions"],
classNames: ["composer-actions"], classNames: ["composer-actions"],
isEditing: equal("action", EDIT), isEditing: equal("action", EDIT),
isInSlowMode: gt("topic.slow_mode_seconds", 0),
selectKitOptions: { selectKitOptions: {
icon: "iconForComposerAction", icon: "iconForComposerAction",
@ -38,23 +39,26 @@ export default DropdownSelectBoxComponent.extend({
preventHeaderFocus: true, preventHeaderFocus: true,
}, },
iconForComposerAction: computed("action", "whisper", "noBump", function () { @discourseComputed("isEditing", "action", "whisper", "noBump", "isInSlowMode")
if (this.isEditing) { iconForComposerAction(isEditing, action, whisper, noBump, isInSlowMode) {
return "pencil-alt"; if (action === CREATE_TOPIC) {
} else if (this.action === CREATE_TOPIC) {
return "plus"; return "plus";
} else if (this.action === PRIVATE_MESSAGE) { } else if (action === PRIVATE_MESSAGE) {
return "envelope"; return "envelope";
} else if (this.action === CREATE_SHARED_DRAFT) { } else if (action === CREATE_SHARED_DRAFT) {
return "far-clipboard"; return "far-clipboard";
} else if (this.whisper) { } else if (whisper) {
return "far-eye-slash"; return "far-eye-slash";
} else if (this.noBump) { } else if (noBump) {
return "anchor"; return "anchor";
} else if (isInSlowMode) {
return "hourglass-start";
} else if (isEditing) {
return "pencil-alt";
} else { } else {
return "share"; return "share";
} }
}), },
contentChanged() { contentChanged() {
this.set("seq", this.seq + 1); this.set("seq", this.seq + 1);
@ -96,7 +100,8 @@ export default DropdownSelectBoxComponent.extend({
return {}; return {};
}, },
content: computed("seq", function () { @discourseComputed("seq")
content() {
let items = []; let items = [];
if ( if (
@ -251,7 +256,7 @@ export default DropdownSelectBoxComponent.extend({
} }
return items; return items;
}), },
_replyFromExisting(options, post, topic) { _replyFromExisting(options, post, topic) {
this.closeComposer(); this.closeComposer();