mirror of
https://github.com/discourse/discourse.git
synced 2024-12-21 16:14:01 +08:00
ec7703e622
Dismissing admin notices is an admin-only action. This is enforced on the back-end both by a routing constraint and a policy in the relevant service. However, we still unconditionally display the "Dismiss" button to anyone with access to the admin dashboard. When clicked, it results in a 404 modal (due to the routing constraint.) With this change we only render the dismiss button for admins.
35 lines
829 B
Plaintext
35 lines
829 B
Plaintext
import Component from "@glimmer/component";
|
|
import { action } from "@ember/object";
|
|
import { service } from "@ember/service";
|
|
import { htmlSafe } from "@ember/template";
|
|
import DButton from "discourse/components/d-button";
|
|
import icon from "discourse-common/helpers/d-icon";
|
|
|
|
export default class AdminNotice extends Component {
|
|
@service currentUser;
|
|
|
|
@action
|
|
dismiss() {
|
|
this.args.dismissCallback(this.args.problem);
|
|
}
|
|
|
|
get canDismiss() {
|
|
return this.currentUser.admin;
|
|
}
|
|
|
|
<template>
|
|
<div class="notice">
|
|
<div class="message">
|
|
{{if @icon (icon @icon)}}
|
|
{{htmlSafe @problem.message}}
|
|
</div>
|
|
{{#if this.canDismiss}}
|
|
<DButton
|
|
@action={{this.dismiss}}
|
|
@label="admin.dashboard.dismiss_notice"
|
|
/>
|
|
{{/if}}
|
|
</div>
|
|
</template>
|
|
}
|