mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Do not show topic admin menu button to regular users (#26820)
This commit is contained in:
parent
3930064fd1
commit
ff8e1f4ed6
@ -72,240 +72,261 @@ 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`);
|
||||||
}
|
}
|
||||||
|
|
||||||
<template>
|
get showAdminButton() {
|
||||||
<span class="topic-admin-menu-button-container">
|
return (
|
||||||
<span class="topic-admin-menu-button">
|
this.currentUser?.canManageTopic ||
|
||||||
<DMenu
|
this.details?.can_archive_topic ||
|
||||||
@onRegisterApi={{this.onRegisterApi}}
|
this.details?.can_close_topic
|
||||||
@triggerClass="toggle-admin-menu"
|
);
|
||||||
@modalForMobile={{true}}
|
}
|
||||||
>
|
|
||||||
<:trigger>
|
|
||||||
{{icon "wrench"}}
|
|
||||||
</:trigger>
|
|
||||||
<:content>
|
|
||||||
<div class="popup-menu topic-admin-popup-menu">
|
|
||||||
<ul>
|
|
||||||
<ul class="topic-admin-menu-topic">
|
|
||||||
{{#if
|
|
||||||
(or
|
|
||||||
this.currentUser.canManageTopic
|
|
||||||
this.details.can_split_merge_topic
|
|
||||||
)
|
|
||||||
}}
|
|
||||||
<li class="topic-admin-multi-select">
|
|
||||||
<DButton
|
|
||||||
class="btn-transparent"
|
|
||||||
@label="topic.actions.multi_select"
|
|
||||||
@action={{fn this.onButtonAction "toggleMultiSelect"}}
|
|
||||||
@icon="tasks"
|
|
||||||
/>
|
|
||||||
</li>
|
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
{{#if
|
<template>
|
||||||
(or
|
{{#if this.showAdminButton}}
|
||||||
this.currentUser.canManageTopic
|
<span class="topic-admin-menu-button-container">
|
||||||
this.details.can_moderate_category
|
<span class="topic-admin-menu-button">
|
||||||
)
|
<DMenu
|
||||||
}}
|
@onRegisterApi={{this.onRegisterApi}}
|
||||||
{{#if this.canDelete}}
|
@triggerClass="toggle-admin-menu"
|
||||||
<li class="topic-admin-delete">
|
@modalForMobile={{true}}
|
||||||
<DButton
|
>
|
||||||
@label="topic.actions.delete"
|
<:trigger>
|
||||||
@action={{fn this.onButtonAction "deleteTopic"}}
|
{{icon "wrench"}}
|
||||||
@icon="far-trash-alt"
|
</:trigger>
|
||||||
class="popup-menu-btn-danger btn-danger btn-transparent"
|
<:content>
|
||||||
/>
|
<div class="popup-menu topic-admin-popup-menu">
|
||||||
</li>
|
<ul>
|
||||||
{{else if this.canRecover}}
|
<ul class="topic-admin-menu-topic">
|
||||||
<li class="topic-admin-recover">
|
{{#if
|
||||||
|
(or
|
||||||
|
this.currentUser.canManageTopic
|
||||||
|
this.details.can_split_merge_topic
|
||||||
|
)
|
||||||
|
}}
|
||||||
|
<li class="topic-admin-multi-select">
|
||||||
<DButton
|
<DButton
|
||||||
class="btn-transparent"
|
class="btn-transparent"
|
||||||
@label="topic.actions.recover"
|
@label="topic.actions.multi_select"
|
||||||
@action={{fn this.onButtonAction "recoverTopic"}}
|
@action={{fn this.onButtonAction "toggleMultiSelect"}}
|
||||||
@icon="undo"
|
@icon="tasks"
|
||||||
/>
|
/>
|
||||||
</li>
|
</li>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
{{#if this.details.can_close_topic}}
|
{{#if
|
||||||
<li
|
(or
|
||||||
class={{if
|
this.currentUser.canManageTopic
|
||||||
@topic.closed
|
this.details.can_moderate_category
|
||||||
"topic-admin-open"
|
)
|
||||||
"topic-admin-close"
|
}}
|
||||||
}}
|
{{#if this.canDelete}}
|
||||||
>
|
<li class="topic-admin-delete">
|
||||||
<DButton
|
<DButton
|
||||||
class="btn-transparent"
|
@label="topic.actions.delete"
|
||||||
@label={{if
|
@action={{fn this.onButtonAction "deleteTopic"}}
|
||||||
|
@icon="far-trash-alt"
|
||||||
|
class="popup-menu-btn-danger btn-danger btn-transparent"
|
||||||
|
/>
|
||||||
|
</li>
|
||||||
|
{{else if this.canRecover}}
|
||||||
|
<li class="topic-admin-recover">
|
||||||
|
<DButton
|
||||||
|
class="btn-transparent"
|
||||||
|
@label="topic.actions.recover"
|
||||||
|
@action={{fn this.onButtonAction "recoverTopic"}}
|
||||||
|
@icon="undo"
|
||||||
|
/>
|
||||||
|
</li>
|
||||||
|
{{/if}}
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{#if this.details.can_close_topic}}
|
||||||
|
<li
|
||||||
|
class={{if
|
||||||
@topic.closed
|
@topic.closed
|
||||||
"topic.actions.open"
|
"topic-admin-open"
|
||||||
"topic.actions.close"
|
"topic-admin-close"
|
||||||
}}
|
}}
|
||||||
@action={{fn this.onButtonAction "toggleClosed"}}
|
>
|
||||||
@icon={{if @topic.closed "unlock" "lock"}}
|
|
||||||
/>
|
|
||||||
</li>
|
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
{{#if
|
|
||||||
(and
|
|
||||||
this.details.can_pin_unpin_topic
|
|
||||||
(not this.isPrivateMessage)
|
|
||||||
(or this.visible this.featured)
|
|
||||||
)
|
|
||||||
}}
|
|
||||||
<li class="topic-admin-pin">
|
|
||||||
<DButton
|
|
||||||
class="btn-transparent"
|
|
||||||
@label={{if
|
|
||||||
this.featured
|
|
||||||
"topic.actions.unpin"
|
|
||||||
"topic.actions.pin"
|
|
||||||
}}
|
|
||||||
@action={{fn this.onButtonAction "showFeatureTopic"}}
|
|
||||||
@icon="thumbtack"
|
|
||||||
/>
|
|
||||||
</li>
|
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
{{#if
|
|
||||||
(and
|
|
||||||
this.details.can_archive_topic (not this.isPrivateMessage)
|
|
||||||
)
|
|
||||||
}}
|
|
||||||
<li class="topic-admin-archive">
|
|
||||||
<DButton
|
|
||||||
class="btn-transparent"
|
|
||||||
@label={{if
|
|
||||||
this.archived
|
|
||||||
"topic.actions.unarchive"
|
|
||||||
"topic.actions.archive"
|
|
||||||
}}
|
|
||||||
@action={{fn this.onButtonAction "toggleArchived"}}
|
|
||||||
@icon="folder"
|
|
||||||
/>
|
|
||||||
</li>
|
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
{{#if this.details.can_toggle_topic_visibility}}
|
|
||||||
<li class="topic-admin-visible">
|
|
||||||
<DButton
|
|
||||||
class="btn-transparent"
|
|
||||||
@label={{if
|
|
||||||
this.visible
|
|
||||||
"topic.actions.invisible"
|
|
||||||
"topic.actions.visible"
|
|
||||||
}}
|
|
||||||
@action={{fn this.onButtonAction "toggleVisibility"}}
|
|
||||||
@icon={{if this.visible "far-eye-slash" "far-eye"}}
|
|
||||||
/>
|
|
||||||
</li>
|
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
{{#if (and this.details.can_convert_topic)}}
|
|
||||||
<li class="topic-admin-convert">
|
|
||||||
<DButton
|
|
||||||
class="btn-transparent"
|
|
||||||
@label={{if
|
|
||||||
this.isPrivateMessage
|
|
||||||
"topic.actions.make_public"
|
|
||||||
"topic.actions.make_private"
|
|
||||||
}}
|
|
||||||
@action={{fn
|
|
||||||
this.onButtonAction
|
|
||||||
(if
|
|
||||||
this.isPrivateMessage
|
|
||||||
"convertToPublicTopic"
|
|
||||||
"convertToPrivateMessage"
|
|
||||||
)
|
|
||||||
}}
|
|
||||||
@icon={{if this.isPrivateMessage "comment" "envelope"}}
|
|
||||||
/>
|
|
||||||
</li>
|
|
||||||
{{/if}}
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<ul class="topic-admin-menu-time">
|
|
||||||
{{#if this.currentUser.canManageTopic}}
|
|
||||||
<li class="admin-topic-timer-update">
|
|
||||||
<DButton
|
|
||||||
class="btn-transparent"
|
|
||||||
@label="topic.actions.timed_update"
|
|
||||||
@action={{fn this.onButtonAction "showTopicTimerModal"}}
|
|
||||||
@icon="far-clock"
|
|
||||||
/>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
{{#if this.currentUser.staff}}
|
|
||||||
<li class="topic-admin-change-timestamp">
|
|
||||||
<DButton
|
<DButton
|
||||||
class="btn-transparent"
|
class="btn-transparent"
|
||||||
@label="topic.change_timestamp.title"
|
@label={{if
|
||||||
|
@topic.closed
|
||||||
|
"topic.actions.open"
|
||||||
|
"topic.actions.close"
|
||||||
|
}}
|
||||||
|
@action={{fn this.onButtonAction "toggleClosed"}}
|
||||||
|
@icon={{if @topic.closed "unlock" "lock"}}
|
||||||
|
/>
|
||||||
|
</li>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{#if
|
||||||
|
(and
|
||||||
|
this.details.can_pin_unpin_topic
|
||||||
|
(not this.isPrivateMessage)
|
||||||
|
(or this.visible this.featured)
|
||||||
|
)
|
||||||
|
}}
|
||||||
|
<li class="topic-admin-pin">
|
||||||
|
<DButton
|
||||||
|
class="btn-transparent"
|
||||||
|
@label={{if
|
||||||
|
this.featured
|
||||||
|
"topic.actions.unpin"
|
||||||
|
"topic.actions.pin"
|
||||||
|
}}
|
||||||
|
@action={{fn this.onButtonAction "showFeatureTopic"}}
|
||||||
|
@icon="thumbtack"
|
||||||
|
/>
|
||||||
|
</li>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{#if
|
||||||
|
(and
|
||||||
|
this.details.can_archive_topic
|
||||||
|
(not this.isPrivateMessage)
|
||||||
|
)
|
||||||
|
}}
|
||||||
|
<li class="topic-admin-archive">
|
||||||
|
<DButton
|
||||||
|
class="btn-transparent"
|
||||||
|
@label={{if
|
||||||
|
this.archived
|
||||||
|
"topic.actions.unarchive"
|
||||||
|
"topic.actions.archive"
|
||||||
|
}}
|
||||||
|
@action={{fn this.onButtonAction "toggleArchived"}}
|
||||||
|
@icon="folder"
|
||||||
|
/>
|
||||||
|
</li>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{#if this.details.can_toggle_topic_visibility}}
|
||||||
|
<li class="topic-admin-visible">
|
||||||
|
<DButton
|
||||||
|
class="btn-transparent"
|
||||||
|
@label={{if
|
||||||
|
this.visible
|
||||||
|
"topic.actions.invisible"
|
||||||
|
"topic.actions.visible"
|
||||||
|
}}
|
||||||
|
@action={{fn this.onButtonAction "toggleVisibility"}}
|
||||||
|
@icon={{if this.visible "far-eye-slash" "far-eye"}}
|
||||||
|
/>
|
||||||
|
</li>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{#if (and this.details.can_convert_topic)}}
|
||||||
|
<li class="topic-admin-convert">
|
||||||
|
<DButton
|
||||||
|
class="btn-transparent"
|
||||||
|
@label={{if
|
||||||
|
this.isPrivateMessage
|
||||||
|
"topic.actions.make_public"
|
||||||
|
"topic.actions.make_private"
|
||||||
|
}}
|
||||||
@action={{fn
|
@action={{fn
|
||||||
this.onButtonAction
|
this.onButtonAction
|
||||||
"showChangeTimestamp"
|
(if
|
||||||
|
this.isPrivateMessage
|
||||||
|
"convertToPublicTopic"
|
||||||
|
"convertToPrivateMessage"
|
||||||
|
)
|
||||||
}}
|
}}
|
||||||
@icon="calendar-alt"
|
@icon={{if
|
||||||
|
this.isPrivateMessage
|
||||||
|
"comment"
|
||||||
|
"envelope"
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</li>
|
||||||
|
{{/if}}
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<ul class="topic-admin-menu-time">
|
||||||
|
{{#if this.currentUser.canManageTopic}}
|
||||||
|
<li class="admin-topic-timer-update">
|
||||||
|
<DButton
|
||||||
|
class="btn-transparent"
|
||||||
|
@label="topic.actions.timed_update"
|
||||||
|
@action={{fn
|
||||||
|
this.onButtonAction
|
||||||
|
"showTopicTimerModal"
|
||||||
|
}}
|
||||||
|
@icon="far-clock"
|
||||||
|
/>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
{{#if this.currentUser.staff}}
|
||||||
|
<li class="topic-admin-change-timestamp">
|
||||||
|
<DButton
|
||||||
|
class="btn-transparent"
|
||||||
|
@label="topic.change_timestamp.title"
|
||||||
|
@action={{fn
|
||||||
|
this.onButtonAction
|
||||||
|
"showChangeTimestamp"
|
||||||
|
}}
|
||||||
|
@icon="calendar-alt"
|
||||||
|
/>
|
||||||
|
</li>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
<li class="topic-admin-reset-bump-date">
|
||||||
|
<DButton
|
||||||
|
class="btn-transparent"
|
||||||
|
@label="topic.actions.reset_bump_date"
|
||||||
|
@action={{fn this.onButtonAction "resetBumpDate"}}
|
||||||
|
@icon="anchor"
|
||||||
|
/>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="topic-admin-slow-mode">
|
||||||
|
<DButton
|
||||||
|
class="btn-transparent"
|
||||||
|
@label="topic.actions.slow_mode"
|
||||||
|
@action={{fn
|
||||||
|
this.onButtonAction
|
||||||
|
"showTopicSlowModeUpdate"
|
||||||
|
}}
|
||||||
|
@icon="hourglass-start"
|
||||||
|
/>
|
||||||
|
</li>
|
||||||
|
{{/if}}
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<ul class="topic-admin-menu-undefined">
|
||||||
|
{{#if this.currentUser.staff}}
|
||||||
|
<li class="topic-admin-moderation-history">
|
||||||
|
<DButton
|
||||||
|
class="btn-transparent"
|
||||||
|
@label="review.moderation_history"
|
||||||
|
@href={{this.topicModerationHistoryUrl}}
|
||||||
|
@icon="list"
|
||||||
/>
|
/>
|
||||||
</li>
|
</li>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
<li class="topic-admin-reset-bump-date">
|
{{#each this.extraButtons as |button|}}
|
||||||
<DButton
|
<li>
|
||||||
class="btn-transparent"
|
<DButton
|
||||||
@label="topic.actions.reset_bump_date"
|
@label={{button.label}}
|
||||||
@action={{fn this.onButtonAction "resetBumpDate"}}
|
@translatedLabel={{button.translatedLabel}}
|
||||||
@icon="anchor"
|
@icon={{button.icon}}
|
||||||
/>
|
class={{concatClass
|
||||||
</li>
|
"btn-transparent"
|
||||||
|
button.className
|
||||||
<li class="topic-admin-slow-mode">
|
}}
|
||||||
<DButton
|
@action={{fn this.onExtraButtonAction button.action}}
|
||||||
class="btn-transparent"
|
/>
|
||||||
@label="topic.actions.slow_mode"
|
</li>
|
||||||
@action={{fn
|
{{/each}}
|
||||||
this.onButtonAction
|
</ul>
|
||||||
"showTopicSlowModeUpdate"
|
|
||||||
}}
|
|
||||||
@icon="hourglass-start"
|
|
||||||
/>
|
|
||||||
</li>
|
|
||||||
{{/if}}
|
|
||||||
</ul>
|
</ul>
|
||||||
|
</div>
|
||||||
<ul class="topic-admin-menu-undefined">
|
</:content>
|
||||||
{{#if this.currentUser.staff}}
|
</DMenu>
|
||||||
<li class="topic-admin-moderation-history">
|
</span>
|
||||||
<DButton
|
|
||||||
class="btn-transparent"
|
|
||||||
@label="review.moderation_history"
|
|
||||||
@href={{this.topicModerationHistoryUrl}}
|
|
||||||
@icon="list"
|
|
||||||
/>
|
|
||||||
</li>
|
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
{{#each this.extraButtons as |button|}}
|
|
||||||
<li>
|
|
||||||
<DButton
|
|
||||||
@label={{button.label}}
|
|
||||||
@translatedLabel={{button.translatedLabel}}
|
|
||||||
@icon={{button.icon}}
|
|
||||||
class={{concatClass "btn-transparent" button.className}}
|
|
||||||
@action={{fn this.onExtraButtonAction button.action}}
|
|
||||||
/>
|
|
||||||
</li>
|
|
||||||
{{/each}}
|
|
||||||
</ul>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</:content>
|
|
||||||
</DMenu>
|
|
||||||
</span>
|
</span>
|
||||||
</span>
|
{{/if}}
|
||||||
</template>
|
</template>
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user