Skip to content

A platform for community discussion. Free, open, simple.

DEV: Use DPageHeader component in new dashboard (#41033)

Jordan Vidrine2bd85f6bc087
diff --git a/app/assets/stylesheets/admin/admin_dashboard.scss b/app/assets/stylesheets/admin/admin_dashboard.scss
index 91af2848177..147efc5aac6 100644
--- a/app/assets/stylesheets/admin/admin_dashboard.scss
+++ b/app/assets/stylesheets/admin/admin_dashboard.scss
@@ -79,34 +79,6 @@
margin-bottom: var(--space-12);
}
-.db-header {
- display: flex;
- align-items: center;
- padding: var(--space-3) 0;
- margin-bottom: var(--space-8);
- position: sticky;
- top: var(--header-offset, 60px);
- z-index: 1;
- background: var(--d-content-background, var(--secondary));
-
- &__title {
- @include viewport.until(sm) {
- font-size: var(--font-up-3-rem);
- }
- }
-
- &__actions {
- display: flex;
- gap: var(--space-4);
- margin-left: auto;
- }
-
- @include viewport.until(sm) {
- flex-direction: column-reverse;
- align-items: flex-start;
- }
-}
-
.db-delta {
font-size: var(--font-down-2-rem);
font-weight: bold;
@@ -120,6 +92,18 @@
}
}
+.dashboard-next .d-page-header__actions {
+ @include viewport.until(md) {
+ flex-direction: row;
+ gap: var(--space-1);
+ margin-block: var(--space-4);
+ }
+
+ @include viewport.until(sm) {
+ width: 100%;
+ }
+}
+
.db-pill {
font-size: var(--font-down-3);
border-radius: 6.25rem;
diff --git a/frontend/discourse/admin/components/redesigned-admin-dashboard.gjs b/frontend/discourse/admin/components/redesigned-admin-dashboard.gjs
index 78405b3815b..473dd045a5f 100644
--- a/frontend/discourse/admin/components/redesigned-admin-dashboard.gjs
+++ b/frontend/discourse/admin/components/redesigned-admin-dashboard.gjs
@@ -13,6 +13,8 @@ import DashboardTraffic from "discourse/admin/components/dashboard/traffic";
import PluginOutlet from "discourse/components/plugin-outlet";
import DMenu from "discourse/float-kit/components/d-menu";
import { eq } from "discourse/truth-helpers";
+import DBreadcrumbsItem from "discourse/ui-kit/d-breadcrumbs-item";
+import DPageHeader from "discourse/ui-kit/d-page-header";
import { i18n } from "discourse-i18n";
export default class RedesignedAdminDashboard extends Component {
@@ -23,9 +25,20 @@ export default class RedesignedAdminDashboard extends Component {
}
<template>
- <div class="db-header">
- <h1 class="db-header__title">Dashboard</h1>
- <div class="db-header__actions">
+ <DPageHeader
+ @titleLabel={{i18n "admin.dashboard.title"}}
+ @hideTabs={{true}}
+ @collapseActionsOnMobile={{false}}
+ >
+ <:breadcrumbs>
+ <DBreadcrumbsItem @path="/admin" @label={{i18n "admin_title"}} />
+ <DBreadcrumbsItem
+ @path="/admin"
+ @label={{i18n "admin.dashboard.title"}}
+ />
+ </:breadcrumbs>
+
+ <:actions>
<DashboardDateRange
@period={{@requestedPeriod}}
@startDate={{@requestedStartDate}}
@@ -33,7 +46,6 @@ export default class RedesignedAdminDashboard extends Component {
@setPeriod={{@setPeriod}}
@setCustomDateRange={{@setCustomDateRange}}
/>
-
{{#if this.currentUser.admin}}
<DMenu
@identifier="db-configure"
@@ -52,8 +64,8 @@ export default class RedesignedAdminDashboard extends Component {
</:content>
</DMenu>
{{/if}}
- </div>
- </div>
+ </:actions>
+ </DPageHeader>
<PluginOutlet
@name="redesigned-admin-dashboard-after-header"
diff --git a/spec/system/page_objects/pages/admin_dashboard.rb b/spec/system/page_objects/pages/admin_dashboard.rb
index 339bf4abfd4..a58662038c1 100644
--- a/spec/system/page_objects/pages/admin_dashboard.rb
+++ b/spec/system/page_objects/pages/admin_dashboard.rb
@@ -120,6 +120,12 @@ module PageObjects
end
def open_configure_menu
+ ensure_redesigned_dashboard
+
+ if has_css?(".d-page-header-mobile-actions-trigger", wait: 0)
+ find(".d-page-header-mobile-actions-trigger").click
+ end
+
find(".btn[data-identifier='db-configure']").click
has_css?(".db-configure")
self
@@ -186,6 +192,12 @@ module PageObjects
private
+ def ensure_redesigned_dashboard
+ page.refresh unless has_css?(".db-main", wait: 0)
+ has_css?(".db-main [data-section-id], .db-main__empty")
+ self
+ end
+
def preset_label(period)
case period
when "last_7_days"