FIX: Do not show topic admin menu button to regular users (#26820)

This commit is contained in:
Jan Cernik 2024-04-30 11:47:36 -05:00 committed by GitHub
parent 3930064fd1
commit ff8e1f4ed6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -72,7 +72,16 @@ export default class TopicAdminMenu extends Component {
return getURL(`/review?topic_id=${this.args.topic.id}&status=all`); return getURL(`/review?topic_id=${this.args.topic.id}&status=all`);
} }
get showAdminButton() {
return (
this.currentUser?.canManageTopic ||
this.details?.can_archive_topic ||
this.details?.can_close_topic
);
}
<template> <template>
{{#if this.showAdminButton}}
<span class="topic-admin-menu-button-container"> <span class="topic-admin-menu-button-container">
<span class="topic-admin-menu-button"> <span class="topic-admin-menu-button">
<DMenu <DMenu
@ -174,7 +183,8 @@ export default class TopicAdminMenu extends Component {
{{#if {{#if
(and (and
this.details.can_archive_topic (not this.isPrivateMessage) this.details.can_archive_topic
(not this.isPrivateMessage)
) )
}} }}
<li class="topic-admin-archive"> <li class="topic-admin-archive">
@ -223,7 +233,11 @@ export default class TopicAdminMenu extends Component {
"convertToPrivateMessage" "convertToPrivateMessage"
) )
}} }}
@icon={{if this.isPrivateMessage "comment" "envelope"}} @icon={{if
this.isPrivateMessage
"comment"
"envelope"
}}
/> />
</li> </li>
{{/if}} {{/if}}
@ -235,7 +249,10 @@ export default class TopicAdminMenu extends Component {
<DButton <DButton
class="btn-transparent" class="btn-transparent"
@label="topic.actions.timed_update" @label="topic.actions.timed_update"
@action={{fn this.onButtonAction "showTopicTimerModal"}} @action={{fn
this.onButtonAction
"showTopicTimerModal"
}}
@icon="far-clock" @icon="far-clock"
/> />
</li> </li>
@ -295,7 +312,10 @@ export default class TopicAdminMenu extends Component {
@label={{button.label}} @label={{button.label}}
@translatedLabel={{button.translatedLabel}} @translatedLabel={{button.translatedLabel}}
@icon={{button.icon}} @icon={{button.icon}}
class={{concatClass "btn-transparent" button.className}} class={{concatClass
"btn-transparent"
button.className
}}
@action={{fn this.onExtraButtonAction button.action}} @action={{fn this.onExtraButtonAction button.action}}
/> />
</li> </li>
@ -307,5 +327,6 @@ export default class TopicAdminMenu extends Component {
</DMenu> </DMenu>
</span> </span>
</span> </span>
{{/if}}
</template> </template>
} }