discourse-topic-voting/assets/javascripts/discourse/widgets/vote-options.js.es6
Natalie Tay 6bbc982477
DEV: Plugin rename (#126)
Update metadata, Rename ruby module, Rename folders and filenames, Rename i18n keys
2022-11-02 13:42:06 +08:00

36 lines
829 B
JavaScript

import I18n from "I18n";
import { createWidget } from "discourse/widgets/widget";
import { h } from "virtual-dom";
export default createWidget("vote-options", {
tagName: "div.vote-options",
buildClasses() {
return "voting-popup-menu popup-menu hidden";
},
html(attrs) {
let contents = [];
if (attrs.user_voted) {
contents.push(this.attach("remove-vote", attrs));
} else if (
this.currentUser &&
this.currentUser.votes_exceeded &&
!attrs.user_voted
) {
contents.push([
h("div", I18n.t("topic_voting.reached_limit")),
h(
"p",
h(
"a",
{ href: this.currentUser.get("path") + "/activity/votes" },
I18n.t("topic_voting.list_votes")
)
),
]);
}
return contents;
},
});