diff --git a/app/assets/javascripts/admin/addon/components/admin-notice.gjs b/app/assets/javascripts/admin/addon/components/admin-notice.gjs new file mode 100644 index 00000000000..07138307c7d --- /dev/null +++ b/app/assets/javascripts/admin/addon/components/admin-notice.gjs @@ -0,0 +1,25 @@ +import Component from "@glimmer/component"; +import { action } from "@ember/object"; +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 { + @action + dismiss() { + this.args.dismissCallback(this.args.problem); + } + + +} diff --git a/app/assets/javascripts/admin/addon/components/dashboard-problems.gjs b/app/assets/javascripts/admin/addon/components/dashboard-problems.gjs index 7f34df878b4..882d65501d6 100644 --- a/app/assets/javascripts/admin/addon/components/dashboard-problems.gjs +++ b/app/assets/javascripts/admin/addon/components/dashboard-problems.gjs @@ -1,15 +1,33 @@ import Component from "@glimmer/component"; -import { htmlSafe } from "@ember/template"; +import { concat } from "@ember/helper"; +import { action } from "@ember/object"; +import { eq } from "truth-helpers"; import ConditionalLoadingSection from "discourse/components/conditional-loading-section"; import DButton from "discourse/components/d-button"; import concatClass from "discourse/helpers/concat-class"; +import { ajax } from "discourse/lib/ajax"; +import { popupAjaxError } from "discourse/lib/ajax-error"; import icon from "discourse-common/helpers/d-icon"; import i18n from "discourse-common/helpers/i18n"; +import AdminNotice from "admin/components/admin-notice"; -// eslint-disable-next-line ember/no-empty-glimmer-component-classes export default class DashboardProblems extends Component { + @action + async dismissProblem(problem) { + try { + await ajax(`/admin/admin_notices/${problem.id}`, { type: "DELETE" }); + this.args.problems.removeObject(problem); + } catch (error) { + popupAjaxError(error); + } + } + + get problems() { + return this.args.problems.sortBy("priority"); + } +