mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 09:42:07 +08:00
d9a02d1336
This reverts commit20780a1eee
. * SECURITY: re-adds accidentally reverted commit: 03d26cd6: ensure embed_url contains valid http(s) uri * when the merge commite62a85cf
was reverted, git chose the2660c2e2
parent to land on instead of the03d26cd6
parent (which contains security fixes)
64 lines
1.6 KiB
JavaScript
64 lines
1.6 KiB
JavaScript
import I18n from "I18n";
|
|
import DropdownSelectBoxComponent from "select-kit/components/dropdown-select-box";
|
|
import { computed, action } from "@ember/object";
|
|
|
|
const UNPINNED = "unpinned";
|
|
const PINNED = "pinned";
|
|
|
|
export default DropdownSelectBoxComponent.extend({
|
|
pluginApiIdentifiers: ["pinned-options"],
|
|
classNames: ["pinned-options"],
|
|
|
|
selectKitOptions: {
|
|
showCaret: true
|
|
},
|
|
|
|
modifySelection(content) {
|
|
const pinnedGlobally = this.get("topic.pinned_globally");
|
|
const pinned = this.value;
|
|
const globally = pinnedGlobally ? "_globally" : "";
|
|
const state = pinned ? `pinned${globally}` : UNPINNED;
|
|
const title = I18n.t(`topic_statuses.${state}.title`);
|
|
|
|
content.label = `<span>${title}</span>`.htmlSafe();
|
|
content.title = title;
|
|
content.name = state;
|
|
content.icon = `thumbtack${state === UNPINNED ? " unpinned" : ""}`;
|
|
return content;
|
|
},
|
|
|
|
content: computed(function() {
|
|
const globally = this.topic.pinned_globally ? "_globally" : "";
|
|
|
|
return [
|
|
{
|
|
id: PINNED,
|
|
name: I18n.t(`topic_statuses.pinned${globally}.title`),
|
|
description: this.site.mobileView
|
|
? null
|
|
: I18n.t(`topic_statuses.pinned${globally}.help`),
|
|
icon: "thumbtack"
|
|
},
|
|
{
|
|
id: UNPINNED,
|
|
name: I18n.t("topic_statuses.unpinned.title"),
|
|
icon: "thumbtack unpinned",
|
|
description: this.site.mobileView
|
|
? null
|
|
: I18n.t("topic_statuses.unpinned.help")
|
|
}
|
|
];
|
|
}),
|
|
|
|
@action
|
|
onChange(value) {
|
|
const topic = this.topic;
|
|
|
|
if (value === UNPINNED) {
|
|
return topic.clearPin();
|
|
} else {
|
|
return topic.rePin();
|
|
}
|
|
}
|
|
});
|