diff --git a/app/assets/javascripts/admin/addon/components/admin-page-header.gjs b/app/assets/javascripts/admin/addon/components/admin-page-header.gjs index 8b77c0b0a12..57dedb08a8d 100644 --- a/app/assets/javascripts/admin/addon/components/admin-page-header.gjs +++ b/app/assets/javascripts/admin/addon/components/admin-page-header.gjs @@ -1,4 +1,5 @@ import Component from "@glimmer/component"; +import { tracked } from "@glimmer/tracking"; import { hash } from "@ember/helper"; import { service } from "@ember/service"; import { htmlSafe } from "@ember/template"; @@ -7,6 +8,7 @@ import DBreadcrumbsContainer from "discourse/components/d-breadcrumbs-container" import DBreadcrumbsItem from "discourse/components/d-breadcrumbs-item"; import DropdownMenu from "discourse/components/dropdown-menu"; import HorizontalOverflowNav from "discourse/components/horizontal-overflow-nav"; +import { bind } from "discourse-common/utils/decorators"; import { i18n } from "discourse-i18n"; import { DangerActionListItem, @@ -20,8 +22,23 @@ import { } from "admin/components/admin-page-action-button"; import DMenu from "float-kit/components/d-menu"; +const HEADLESS_ACTIONS = ["new", "edit"]; + export default class AdminPageHeader extends Component { @service site; + @service router; + @tracked shouldDisplay = true; + + constructor() { + super(...arguments); + this.router.on("routeDidChange", this, this.#checkIfShouldDisplay); + this.#checkIfShouldDisplay(); + } + + willDestroy() { + super.willDestroy(...arguments); + this.router.off("routeDidChange", this, this.#checkIfShouldDisplay); + } get title() { if (this.args.titleLabelTranslated) { @@ -39,87 +56,106 @@ export default class AdminPageHeader extends Component { } } + @bind + #checkIfShouldDisplay() { + if (this.args.shouldDisplay !== undefined) { + return (this.shouldDisplay = this.args.shouldDisplay); + } + + const currentPath = this.router._router.currentPath; + if (!currentPath) { + return (this.shouldDisplay = true); + } + + const pathSegments = currentPath.split("."); + this.shouldDisplay = + !pathSegments.includes("admin") || + !HEADLESS_ACTIONS.find((segment) => pathSegments.includes(segment)); + } + } diff --git a/app/assets/javascripts/admin/addon/controllers/admin-config-flags.js b/app/assets/javascripts/admin/addon/controllers/admin-config-flags.js deleted file mode 100644 index 83bf552fffe..00000000000 --- a/app/assets/javascripts/admin/addon/controllers/admin-config-flags.js +++ /dev/null @@ -1,12 +0,0 @@ -import Controller from "@ember/controller"; -import { service } from "@ember/service"; - -export default class AdminConfigFlagsController extends Controller { - @service router; - - get hideTabs() { - return ["adminConfig.flags.new", "adminConfig.flags.edit"].includes( - this.router.currentRouteName - ); - } -} diff --git a/app/assets/javascripts/admin/addon/templates/config-flags-index.hbs b/app/assets/javascripts/admin/addon/templates/config-flags-index.hbs index 152e04087ca..eb2faa393b2 100644 --- a/app/assets/javascripts/admin/addon/templates/config-flags-index.hbs +++ b/app/assets/javascripts/admin/addon/templates/config-flags-index.hbs @@ -1,38 +1 @@ - - <:breadcrumbs> - - - <:actions as |actions|> - - - <:tabs> - - - - - -
- -
\ No newline at end of file + \ No newline at end of file diff --git a/app/assets/javascripts/admin/addon/templates/config-flags.hbs b/app/assets/javascripts/admin/addon/templates/config-flags.hbs new file mode 100644 index 00000000000..f0706ea7e07 --- /dev/null +++ b/app/assets/javascripts/admin/addon/templates/config-flags.hbs @@ -0,0 +1,37 @@ + + <:breadcrumbs> + + + <:actions as |actions|> + + + <:tabs> + + + + + +
+ {{outlet}} +
\ No newline at end of file diff --git a/app/assets/javascripts/discourse/tests/integration/components/admin-page-header-test.gjs b/app/assets/javascripts/discourse/tests/integration/components/admin-page-header-test.gjs index 1ccfe12bc02..6148162d2e2 100644 --- a/app/assets/javascripts/discourse/tests/integration/components/admin-page-header-test.gjs +++ b/app/assets/javascripts/discourse/tests/integration/components/admin-page-header-test.gjs @@ -44,6 +44,16 @@ module("Integration | Component | AdminPageHeader", function (hooks) { assert.dom(".admin-page-header__title").exists().hasText("Wow so cool"); }); + test("@shouldDisplay", async function (assert) { + await render(); + assert.dom(".admin-page-header").doesNotExist(); + }); + test("renders base breadcrumbs and yielded <:breadcrumbs>", async function (assert) { await render(