A platform for community discussion. Free, open, simple.
DEV: Delete AdminPageHeader and AdminPageSubheader components (#30337)
Martin Brennan553784f91930
diff --git a/app/assets/javascripts/admin/addon/components/admin-page-header.gjs b/app/assets/javascripts/admin/addon/components/admin-page-header.gjsdeleted file mode 100644index 57dedb08a8d..00000000000--- a/app/assets/javascripts/admin/addon/components/admin-page-header.gjs+++ /dev/null@@ -1,161 +0,0 @@-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";-import { or } from "truth-helpers";-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,- DangerButton,- DefaultActionListItem,- DefaultButton,- PrimaryActionListItem,- PrimaryButton,- WrappedActionListItem,- WrappedButton,-} 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) {- return this.args.titleLabelTranslated;- } else if (this.args.titleLabel) {- return i18n(this.args.titleLabel);- }- }-- get description() {- if (this.args.descriptionLabelTranslated) {- return this.args.descriptionLabelTranslated;- } else if (this.args.descriptionLabel) {- return i18n(this.args.descriptionLabel);- }- }-- @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));- }-- <template>- {{#if this.shouldDisplay}}- <div class="admin-page-header">- <div class="admin-page-header__breadcrumbs">- <DBreadcrumbsContainer />- <DBreadcrumbsItem @path="/admin" @label={{i18n "admin_title"}} />- {{yield to="breadcrumbs"}}- </div>-- <div class="admin-page-header__title-row">- {{#if this.title}}- <h1 class="admin-page-header__title">{{this.title}}</h1>- {{/if}}-- {{#if (or (has-block "actions") @headerActionComponent)}}- <div class="admin-page-header__actions">- {{#if this.site.mobileView}}- <DMenu- @identifier="admin-page-header-mobile-actions"- @title={{i18n "more_options"}}- @icon="ellipsis-vertical"- class="btn-small"- >- <:content>- <DropdownMenu class="admin-page-header__mobile-actions">- {{#let- (hash- Primary=PrimaryActionListItem- Default=DefaultActionListItem- Danger=DangerActionListItem- Wrapped=WrappedActionListItem- )- as |actions|- }}- {{#if (has-block "actions")}}- {{yield actions to="actions"}}- {{else}}- <@headerActionComponent @actions={{actions}} />- {{/if}}- {{/let}}- </DropdownMenu>- </:content>- </DMenu>- {{else}}- {{#let- (hash- Primary=PrimaryButton- Default=DefaultButton- Danger=DangerButton- Wrapped=WrappedButton- )- as |actions|- }}- {{#if (has-block "actions")}}- {{yield actions to="actions"}}- {{else}}- <@headerActionComponent @actions={{actions}} />- {{/if}}- {{/let}}- {{/if}}- </div>- {{/if}}- </div>-- {{#if this.description}}- <p class="admin-page-header__description">- {{htmlSafe this.description}}- {{#if @learnMoreUrl}}- <span class="admin-page-header__learn-more">{{htmlSafe- (i18n "learn_more_with_link" url=@learnMoreUrl)- }}</span>- {{/if}}- </p>- {{/if}}-- {{#unless @hideTabs}}- <div class="admin-nav-submenu">- <HorizontalOverflowNav class="admin-nav-submenu__tabs">- {{yield to="tabs"}}- </HorizontalOverflowNav>- </div>- {{/unless}}- </div>- {{/if}}- </template>-}diff --git a/app/assets/javascripts/admin/addon/components/admin-page-subheader.gjs b/app/assets/javascripts/admin/addon/components/admin-page-subheader.gjsdeleted file mode 100644index 79cbd282be7..00000000000--- a/app/assets/javascripts/admin/addon/components/admin-page-subheader.gjs+++ /dev/null@@ -1,93 +0,0 @@-import Component from "@glimmer/component";-import { hash } from "@ember/helper";-import { service } from "@ember/service";-import { htmlSafe } from "@ember/template";-import DropdownMenu from "discourse/components/dropdown-menu";-import { i18n } from "discourse-i18n";-import {- DangerActionListItem,- DangerButton,- DefaultActionListItem,- DefaultButton,- PrimaryActionListItem,- PrimaryButton,- WrappedActionListItem,- WrappedButton,-} from "admin/components/admin-page-action-button";-import DMenu from "float-kit/components/d-menu";--export default class AdminPageSubheader extends Component {- @service site;-- get title() {- if (this.args.titleLabelTranslated) {- return this.args.titleLabelTranslated;- } else if (this.args.titleLabel) {- return i18n(this.args.titleLabel);- }- }-- get description() {- if (this.args.descriptionLabelTranslated) {- return this.args.descriptionLabelTranslated;- } else if (this.args.descriptionLabel) {- return i18n(this.args.descriptionLabel);- }- }-- <template>- <div class="admin-page-subheader">- <div class="admin-page-subheader__title-row">- <h2 class="admin-page-subheader__title">{{this.title}}</h2>- {{#if (has-block "actions")}}- <div class="admin-page-subheader__actions">- {{#if this.site.mobileView}}- <DMenu- @identifier="admin-page-subheader-mobile-actions"- @title={{i18n "more_options"}}- @icon="ellipsis-vertical"- class="btn-small"- >- <:content>- <DropdownMenu class="admin-page-subheader__mobile-actions">- {{yield- (hash- Primary=PrimaryActionListItem- Default=DefaultActionListItem- Danger=DangerActionListItem- Wrapped=WrappedActionListItem- )- to="actions"- }}- </DropdownMenu>- </:content>- </DMenu>- {{else}}- {{yield- (hash- Primary=PrimaryButton- Default=DefaultButton- Danger=DangerButton- Wrapped=WrappedButton- )- to="actions"- }}- {{/if}}- </div>- {{/if}}- </div>-- {{#if this.description}}- <p class="admin-page-subheader__description">- {{htmlSafe this.description}}- {{#if @learnMoreUrl}}- <span class="admin-page-subheader__learn-more">- {{htmlSafe- (i18n "learn_more_with_link" url=@learnMoreUrl)- }}</span>- {{/if}}- </p>- {{/if}}- </div>- </template>-}diff --git a/app/assets/javascripts/discourse/tests/integration/components/d-page-header-test.gjs b/app/assets/javascripts/discourse/tests/integration/components/d-page-header-test.gjsindex 76da99bf52f..7638abe502c 100644--- a/app/assets/javascripts/discourse/tests/integration/components/d-page-header-test.gjs+++ b/app/assets/javascripts/discourse/tests/integration/components/d-page-header-test.gjs@@ -38,7 +38,7 @@ module("Integration | Component | DPageHeader", function (hooks) {await render(<template><DPageHeader @titleLabel="Wow so cool" @shouldDisplay={{false}} /></template>);- assert.dom(".admin-page-header").doesNotExist();+ assert.dom(".d-page-header").doesNotExist();});test("renders base breadcrumbs and yielded <:breadcrumbs>", async function (assert) {diff --git a/app/assets/stylesheets/common/admin/admin_base.scss b/app/assets/stylesheets/common/admin/admin_base.scssindex 177b1e5e30a..8bde1ca1a9a 100644--- a/app/assets/stylesheets/common/admin/admin_base.scss+++ b/app/assets/stylesheets/common/admin/admin_base.scss@@ -1102,7 +1102,6 @@ a.inline-editable-field {@import "common/admin/admin_report_table";@import "common/admin/admin_report_inline_table";@import "common/admin/admin_section_landing_page";-@import "common/admin/admin_page_header";@import "common/admin/admin_intro";@import "common/admin/mini_profiler";@import "common/admin/schema_theme_setting_editor";diff --git a/app/assets/stylesheets/common/admin/admin_page_header.scss b/app/assets/stylesheets/common/admin/admin_page_header.scssdeleted file mode 100644index fa8be9cfab1..00000000000--- a/app/assets/stylesheets/common/admin/admin_page_header.scss+++ /dev/null@@ -1,90 +0,0 @@-.admin-page-header,-.admin-page-subheader {- &__title-row {- display: flex;- justify-content: space-between;- align-items: stretch;- margin-bottom: var(--space-2);-- h1,- h2 {- margin: 0;- }-- h2 {- font-size: var(--font-up-2);- }-- .admin-page-header__actions {- display: flex;- align-items: center;- justify-content: flex-end;-- @media (max-width: $mobile-breakpoint) {- flex-direction: column;- }-- button {- margin-left: var(--space-2);-- @media (max-width: $mobile-breakpoint) {- width: 100%;- margin-bottom: var(--space-2);- margin-left: 0;- }- }- }- }-- .admin-nav-submenu {- background: transparent;- border-bottom: 1px solid var(--primary-low);-- .horizontal-overflow-nav {- background: transparent;-- &:before {- display: none;- }-- &:after {- display: none;- }- }-- .nav-pills {- width: auto;- margin: 0;- }- }-}--.admin-page-header {- &__title-row {- @media (max-width: $mobile-breakpoint) {- flex-direction: row;- align-items: center;-- .admin-page-header__actions {- button {- margin-bottom: 0;- }- }- }- }-}--.admin-page-subheader {- &__title-row {- @media (max-width: $mobile-breakpoint) {- flex-direction: row;- align-items: center;- }- }-}--.admin-page-action-list-item {- .btn-primary {- color: var(--primary);- }-}diff --git a/app/assets/stylesheets/common/admin/customize.scss b/app/assets/stylesheets/common/admin/customize.scssindex 6ca35e0d95d..94b3f013ee2 100644--- a/app/assets/stylesheets/common/admin/customize.scss+++ b/app/assets/stylesheets/common/admin/customize.scss@@ -805,7 +805,6 @@.admin-permalinks {@include breakpoint(tablet) {- .admin-page-subheader,.d-page-subheader,.admin-config-area,.admin-config-area__primary-content,diff --git a/spec/system/page_objects/components/admin_header.rb b/spec/system/page_objects/components/admin_header.rbdeleted file mode 100644index 556211e02e6..00000000000--- a/spec/system/page_objects/components/admin_header.rb+++ /dev/null@@ -1,20 +0,0 @@-# frozen_string_literal: true--module PageObjects- module Components- # TODO (martin) Delete this after plugins have been updated to use DPageHeader- class AdminHeader < PageObjects::Pages::Base- def has_tabs?(names)- expect(page.all(".d-nav-submenu__tabs a").map(&:text)).to eq(names)- end-- def visible?- has_css?(".d-page-header")- end-- def hidden?- has_no_css?(".d-page-header")- end- end- end-end