Skip to content

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

UX: restructure sections (#40296)

chapoi7859b3136f56
diff --git a/app/assets/stylesheets/admin/admin_dashboard.scss b/app/assets/stylesheets/admin/admin_dashboard.scss
index e3648b0b179..fda4397d920 100644
--- a/app/assets/stylesheets/admin/admin_dashboard.scss
+++ b/app/assets/stylesheets/admin/admin_dashboard.scss
@@ -653,36 +653,11 @@ h1 {
}
}
-.db-highlights {
- display: flex;
- flex-direction: column;
- gap: var(--space-2);
-
- &__comparison {
- align-self: flex-end;
- font-size: var(--font-down-1-rem);
- color: var(--primary-medium);
- }
-
- &__error {
- flex: 1;
- padding: var(--space-4);
- color: var(--primary-medium);
- font-size: var(--font-down-1-rem);
- }
-}
-
-.db-engagement {
- .db-engagement-headline {
- .db-section__metrics {
- gap: 0;
-
- .db-kpi {
- border: none;
- padding-top: 0;
- }
- }
- }
+.db-highlights__comparison {
+ align-self: flex-end;
+ margin-top: calc(var(--space-4) * -1);
+ font-size: var(--font-down-1-rem);
+ color: var(--primary-medium);
}
.db-kpi {
diff --git a/frontend/discourse/admin/components/dashboard/engagement.gjs b/frontend/discourse/admin/components/dashboard/engagement.gjs
index 32a49bc435b..b5f9e76cd29 100644
--- a/frontend/discourse/admin/components/dashboard/engagement.gjs
+++ b/frontend/discourse/admin/components/dashboard/engagement.gjs
@@ -6,55 +6,52 @@ import DashboardSection from "discourse/admin/components/dashboard/section";
import { i18n } from "discourse-i18n";
<template>
- <div class="db-engagement">
- <DashboardSection
- @title={{i18n "admin.dashboard.sections.engagement.title"}}
- @startDate={{@startDate}}
- @endDate={{@endDate}}
- >
- {{#if @fetchError}}
- <div class="db-section__error" role="alert">
- {{i18n "admin.dashboard.sections.engagement.fetch_error"}}
- </div>
- {{else}}
- {{#if @engagement.headline}}
- <EngagementHeadline
- @headline={{@engagement.headline}}
- @kpis={{@engagement.kpis}}
- @period={{@period}}
- />
- {{/if}}
+ <DashboardSection
+ @title={{i18n "admin.dashboard.sections.engagement.title"}}
+ @startDate={{@startDate}}
+ @endDate={{@endDate}}
+ ...attributes
+ >
+ {{#if @fetchError}}
+ <div class="db-section__error" role="alert">
+ {{i18n "admin.dashboard.sections.engagement.fetch_error"}}
+ </div>
+ {{else}}
+ {{#if @engagement.headline}}
+ <EngagementHeadline
+ @headline={{@engagement.headline}}
+ @kpis={{@engagement.kpis}}
+ @period={{@period}}
+ />
+ {{/if}}
- <div class="db-section__row-group">
+ <div class="db-section__row-group">
+ <div class="db-section__row">
+ <div class="db-section__row-block">
+ {{#if @engagement.trust_level_pipeline}}
+ <TrustLevelPipeline @data={{@engagement.trust_level_pipeline}} />
+ {{/if}}
+ </div>
+ <div class="db-section__row-block">
+ <WhosPosting
+ @posters={{@engagement.posters}}
+ @startDate={{@startDate}}
+ @endDate={{@endDate}}
+ />
+ </div>
+ </div>
+ {{#if @engagement.activity_by_category}}
<div class="db-section__row">
<div class="db-section__row-block">
- {{#if @engagement.trust_level_pipeline}}
- <TrustLevelPipeline
- @data={{@engagement.trust_level_pipeline}}
- />
- {{/if}}
- </div>
- <div class="db-section__row-block">
- <WhosPosting
- @posters={{@engagement.posters}}
+ <ActivityByCategory
+ @activity={{@engagement.activity_by_category}}
@startDate={{@startDate}}
@endDate={{@endDate}}
/>
</div>
</div>
- {{#if @engagement.activity_by_category}}
- <div class="db-section__row">
- <div class="db-section__row-block">
- <ActivityByCategory
- @activity={{@engagement.activity_by_category}}
- @startDate={{@startDate}}
- @endDate={{@endDate}}
- />
- </div>
- </div>
- {{/if}}
- </div>
- {{/if}}
- </DashboardSection>
- </div>
+ {{/if}}
+ </div>
+ {{/if}}
+ </DashboardSection>
</template>
diff --git a/frontend/discourse/admin/components/dashboard/engagement/headline.gjs b/frontend/discourse/admin/components/dashboard/engagement/headline.gjs
index da6682eecee..73c3f9dc69c 100644
--- a/frontend/discourse/admin/components/dashboard/engagement/headline.gjs
+++ b/frontend/discourse/admin/components/dashboard/engagement/headline.gjs
@@ -21,7 +21,7 @@ export default class EngagementHeadline extends Component {
}
<template>
- <div class="db-section__subheader db-engagement-headline">
+ <div class="db-section__subheader">
<div class="db-section__subintro">
<h3>{{i18n this.titleKey}}</h3>
<p>{{i18n this.summaryKey}}</p>
diff --git a/frontend/discourse/admin/components/dashboard/highlights.gjs b/frontend/discourse/admin/components/dashboard/highlights.gjs
index c4488321171..b2d9f76c28b 100644
--- a/frontend/discourse/admin/components/dashboard/highlights.gjs
+++ b/frontend/discourse/admin/components/dashboard/highlights.gjs
@@ -18,13 +18,14 @@ export default class Highlights extends Component {
}
<template>
- <div class="db-highlights">
- <DashboardSection
- @title={{i18n "admin.dashboard.sections.highlights.title"}}
- @layout="row"
- @startDate={{@startDate}}
- @endDate={{@endDate}}
- >
+ <DashboardSection
+ @title={{i18n "admin.dashboard.sections.highlights.title"}}
+ @layout="row"
+ @startDate={{@startDate}}
+ @endDate={{@endDate}}
+ ...attributes
+ >
+ <:default>
{{#if @fetchError}}
<div class="db-highlights__error" role="alert">
{{i18n "admin.dashboard.highlights.fetch_error"}}
@@ -42,10 +43,13 @@ export default class Highlights extends Component {
/>
{{/each}}
{{/if}}
- </DashboardSection>
- {{#if this.hasKpis}}
- <div class="db-highlights__comparison">{{this.comparisonLabel}}</div>
- {{/if}}
- </div>
+ </:default>
+
+ <:footer>
+ {{#if this.hasKpis}}
+ <div class="db-highlights__comparison">{{this.comparisonLabel}}</div>
+ {{/if}}
+ </:footer>
+ </DashboardSection>
</template>
}
diff --git a/frontend/discourse/admin/components/dashboard/reports.gjs b/frontend/discourse/admin/components/dashboard/reports.gjs
index aec312aac98..cc166073f15 100644
--- a/frontend/discourse/admin/components/dashboard/reports.gjs
+++ b/frontend/discourse/admin/components/dashboard/reports.gjs
@@ -133,6 +133,7 @@ export default class DashboardReports extends Component {
@headerAction={{if this.canEdit this.openReportsConfig}}
@startDate={{@startDate}}
@endDate={{@endDate}}
+ ...attributes
>
<div
class="db-reports"
diff --git a/frontend/discourse/admin/components/dashboard/section.gjs b/frontend/discourse/admin/components/dashboard/section.gjs
index 3053af0536c..873d6a555d9 100644
--- a/frontend/discourse/admin/components/dashboard/section.gjs
+++ b/frontend/discourse/admin/components/dashboard/section.gjs
@@ -41,6 +41,7 @@ export default class DashboardSection extends Component {
>
{{yield (hash startDate=@startDate endDate=@endDate)}}
</div>
+ {{yield to="footer"}}
</section>
</template>
}
diff --git a/frontend/discourse/admin/components/dashboard/traffic.gjs b/frontend/discourse/admin/components/dashboard/traffic.gjs
index 431a34decc5..6e79a668044 100644
--- a/frontend/discourse/admin/components/dashboard/traffic.gjs
+++ b/frontend/discourse/admin/components/dashboard/traffic.gjs
@@ -196,6 +196,7 @@ export default class DashboardTraffic extends Component {
@title={{i18n "admin.dashboard.sections.traffic.title"}}
@startDate={{@startDate}}
@endDate={{@endDate}}
+ ...attributes
>
<div class="db-traffic {{if @loading 'is-loading'}}">
<div class="db-section__subheader">
diff --git a/frontend/discourse/admin/components/redesigned-admin-dashboard.gjs b/frontend/discourse/admin/components/redesigned-admin-dashboard.gjs
index 21bfc767557..fdbed34c024 100644
--- a/frontend/discourse/admin/components/redesigned-admin-dashboard.gjs
+++ b/frontend/discourse/admin/components/redesigned-admin-dashboard.gjs
@@ -1,5 +1,6 @@
import Component from "@glimmer/component";
import { tracked } from "@glimmer/tracking";
+import { concat } from "@ember/helper";
import { action } from "@ember/object";
import { service } from "@ember/service";
import ConfigureMenu from "discourse/admin/components/dashboard/configure-menu";
@@ -123,43 +124,49 @@ export default class RedesignedAdminDashboard extends Component {
<div class="db-main">
{{#if @loadedSections}}
{{#each @loadedSections.sections key="id" as |section|}}
- <div class="db-main__section" data-section-id={{section.id}}>
- {{#if (eq section.id "highlights")}}
- <DashboardHighlights
- @highlights={{section.data}}
- @period={{@loadedSections.period}}
- @loading={{@loadingSections}}
- @fetchError={{@sectionsFetchError}}
- @startDate={{@loadedSections.startDate}}
- @endDate={{@loadedSections.endDate}}
- />
- {{else if (eq section.id "reports")}}
- <DashboardReports
- @data={{section.data}}
- @startDate={{@loadedSections.startDate}}
- @endDate={{@loadedSections.endDate}}
- @refreshSections={{@refreshSections}}
- />
- {{else if (eq section.id "traffic")}}
- <DashboardTraffic
- @traffic={{section.data}}
- @period={{@loadedSections.period}}
- @loading={{@loadingSections}}
- @fetchError={{@sectionsFetchError}}
- @startDate={{@loadedSections.startDate}}
- @endDate={{@loadedSections.endDate}}
- />
- {{else if (eq section.id "engagement")}}
- <DashboardEngagement
- @engagement={{section.data}}
- @period={{@loadedSections.period}}
- @loading={{@loadingSections}}
- @fetchError={{@sectionsFetchError}}
- @startDate={{@loadedSections.startDate}}
- @endDate={{@loadedSections.endDate}}
- />
- {{/if}}
- </div>
+ {{#if (eq section.id "highlights")}}
+ <DashboardHighlights
+ class={{concat "--" section.id}}
+ data-section-id={{section.id}}
+ @highlights={{section.data}}
+ @period={{@loadedSections.period}}
+ @loading={{@loadingSections}}
+ @fetchError={{@sectionsFetchError}}
+ @startDate={{@loadedSections.startDate}}
+ @endDate={{@loadedSections.endDate}}
+ />
+ {{else if (eq section.id "reports")}}
+ <DashboardReports
+ class={{concat "--" section.id}}
+ data-section-id={{section.id}}
+ @data={{section.data}}
+ @startDate={{@loadedSections.startDate}}
+ @endDate={{@loadedSections.endDate}}
+ @refreshSections={{@refreshSections}}
+ />
+ {{else if (eq section.id "traffic")}}
+ <DashboardTraffic
+ class={{concat "--" section.id}}
+ data-section-id={{section.id}}
+ @traffic={{section.data}}
+ @period={{@loadedSections.period}}
+ @loading={{@loadingSections}}
+ @fetchError={{@sectionsFetchError}}
+ @startDate={{@loadedSections.startDate}}
+ @endDate={{@loadedSections.endDate}}
+ />
+ {{else if (eq section.id "engagement")}}
+ <DashboardEngagement
+ class={{concat "--" section.id}}
+ data-section-id={{section.id}}
+ @engagement={{section.data}}
+ @period={{@loadedSections.period}}
+ @loading={{@loadingSections}}
+ @fetchError={{@sectionsFetchError}}
+ @startDate={{@loadedSections.startDate}}
+ @endDate={{@loadedSections.endDate}}
+ />
+ {{/if}}
{{/each}}
{{#unless @loadedSections.sections.length}}
diff --git a/spec/system/admin_dashboard_configure_spec.rb b/spec/system/admin_dashboard_configure_spec.rb
index a514a488ec8..980ff32016c 100644
--- a/spec/system/admin_dashboard_configure_spec.rb
+++ b/spec/system/admin_dashboard_configure_spec.rb
@@ -51,7 +51,7 @@ describe "Admin Dashboard Configure menu" do
dashboard.open_configure_menu.move_section_up("reports").close_configure_menu
- expect(page).to have_css(".db-main__section:first-child[data-section-id='reports']")
+ expect(dashboard).to have_first_section("reports")
expect(dashboard.section_ids_in_order.first(2)).to eq(%w[reports highlights])
end
end
diff --git a/spec/system/page_objects/pages/admin_dashboard.rb b/spec/system/page_objects/pages/admin_dashboard.rb
index 40ea1a1e27e..73b77d42fd1 100644
--- a/spec/system/page_objects/pages/admin_dashboard.rb
+++ b/spec/system/page_objects/pages/admin_dashboard.rb
@@ -5,13 +5,13 @@ module PageObjects
class AdminDashboard < PageObjects::Pages::Base
def visit
page.visit("/admin")
- has_css?(".db-main__section, .db-main__empty, .nav-pills")
+ has_css?(".db-main [data-section-id], .db-main__empty, .nav-pills")
self
end
def visit_with_query(params)
page.visit("/admin?#{params.to_query}")
- has_css?(".db-main__section, .db-main__empty, .nav-pills")
+ has_css?(".db-main [data-section-id], .db-main__empty, .nav-pills")
self
end
@@ -74,11 +74,15 @@ module PageObjects
end
def has_section?(id)
- has_css?(".db-main__section[data-section-id='#{id}']")
+ has_css?(".db-main [data-section-id='#{id}']")
end
def has_no_section?(id)
- has_no_css?(".db-main__section[data-section-id='#{id}']")
+ has_no_css?(".db-main [data-section-id='#{id}']")
+ end
+
+ def has_first_section?(id)
+ has_css?(".db-main > :first-child[data-section-id='#{id}']")
end
def site_traffic
@@ -86,7 +90,7 @@ module PageObjects
end
def section_ids_in_order
- all(".db-main__section").map { |el| el["data-section-id"] }
+ all(".db-main [data-section-id]").map { |el| el["data-section-id"] }
end
def has_empty_state?
diff --git a/spec/system/page_objects/pages/admin_dashboard_reports.rb b/spec/system/page_objects/pages/admin_dashboard_reports.rb
index bdb2d1f9e8c..09f0b10dfb3 100644
--- a/spec/system/page_objects/pages/admin_dashboard_reports.rb
+++ b/spec/system/page_objects/pages/admin_dashboard_reports.rb
@@ -3,7 +3,7 @@
module PageObjects
module Pages
class AdminDashboardReports < PageObjects::Pages::Base
- SECTION_SELECTOR = ".db-main__section[data-section-id='reports']"
+ SECTION_SELECTOR = ".db-main [data-section-id='reports']"
def has_section?
has_css?(SECTION_SELECTOR)