Skip to content

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

UX: admin dashboard design fixes (#40476)

chapoi9d6605bf0df6
diff --git a/app/assets/stylesheets/admin/admin_dashboard.scss b/app/assets/stylesheets/admin/admin_dashboard.scss
index 7f54e9a06f0..800f0bd276f 100644
--- a/app/assets/stylesheets/admin/admin_dashboard.scss
+++ b/app/assets/stylesheets/admin/admin_dashboard.scss
@@ -4,9 +4,10 @@
display: flex;
flex-direction: column;
gap: var(--space-12);
+ margin-bottom: var(--space-12);
}
-.db-toolbar {
+.db-header {
display: flex;
align-items: center;
padding: var(--space-3) 0;
@@ -16,29 +17,21 @@
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) {
- position: fixed;
- bottom: calc(env(safe-area-inset-bottom) + var(--space-4));
- right: 50%;
- transform: translateX(50%);
- z-index: 2;
- margin-left: 0;
- align-items: center;
- gap: var(--space-2);
- transition: bottom 0.3s ease;
-
- .footer-nav-visible & {
- bottom: calc(
- var(--footer-nav-height) + env(safe-area-inset-bottom) +
- var(--space-4)
- );
- }
- }
+ @include viewport.until(sm) {
+ flex-direction: column-reverse;
+ align-items: flex-start;
}
}
@@ -58,47 +51,9 @@
background: var(--primary-very-low);
color: var(--primary);
}
-
- @include viewport.until(sm) {
- border-radius: 999px;
- box-shadow: var(--shadow-dropdown);
- }
- }
-
- &__popover {
- padding: 0;
- }
-}
-
-.db-toolbar__actions .btn[data-identifier="db-configure"] {
- height: var(--space-9);
- padding: var(--space-1) var(--space-3);
- border-radius: var(--d-border-radius);
-
- @include viewport.until(sm) {
- width: var(--space-9);
- padding: 0;
- min-height: 0;
- display: inline-flex;
- align-items: center;
- justify-content: center;
- border-radius: 999px;
- box-shadow: var(--shadow-dropdown);
-
- .d-button-label {
- display: none;
- }
-
- .d-icon {
- margin-right: 0;
- }
}
}
-h1 {
- margin: 0; // to be done proper
-}
-
.db-delta {
font-size: var(--font-down-2-rem);
font-weight: bold;
@@ -118,6 +73,7 @@ h1 {
padding: var(--space-half) var(--space-2);
background: var(--primary-low);
color: var(--primary-medium);
+ white-space: nowrap;
&.--pos {
background: var(--success-low);
@@ -153,6 +109,7 @@ h1 {
padding: var(--space-1) 0;
border-top: 2px solid transparent;
border-bottom: 2px solid transparent;
+ cursor: grab;
&.dragging {
opacity: 0.5;
@@ -255,6 +212,11 @@ h1 {
display: flex;
justify-content: space-between;
gap: var(--space-8);
+
+ @include viewport.until(sm) {
+ flex-direction: column;
+ gap: var(--space-4);
+ }
}
&__subintro {
@@ -270,17 +232,30 @@ h1 {
justify-content: flex-end;
flex-grow: 1;
gap: var(--space-10);
+
+ @include viewport.until(sm) {
+ border-top: 1px solid var(--primary-low);
+ padding-top: var(--space-2);
+ }
}
&__metric-number {
white-space: nowrap;
font-size: var(--font-up-3);
+
+ @include viewport.until(sm) {
+ font-size: var(--font-up-2);
+ }
}
&__metric-label {
white-space: nowrap;
font-size: var(--font-down-2-rem);
color: var(--primary-medium);
+
+ @include viewport.until(sm) {
+ white-space: wrap;
+ }
}
&__callout {
@@ -339,26 +314,53 @@ h1 {
gap: var(--space-4);
border-top: 1px solid var(--primary-low);
margin-inline: calc(var(--space-4) * -1);
+
+ @include viewport.until(sm) {
+ flex-direction: column;
+ }
}
&__row-block {
flex: 1;
+ min-width: 0;
padding: var(--space-4);
+ box-sizing: border-box;
&:not(:last-child) {
border-right: 1px solid var(--primary-low);
}
+
+ @include viewport.until(sm) {
+ border-bottom: 1px solid var(--primary-low);
+
+ .--highlights & {
+ border-radius: var(--d-border-radius-large);
+ flex-basis: calc(50% - var(--space-1));
+ border: 1px solid var(--primary-low);
+ }
+ }
}
&__row-block-header {
display: flex;
align-items: center;
justify-content: space-between;
+ margin-bottom: var(--space-2);
+
+ .select-kit.combo-box.category-chooser {
+ width: 100%;
+ max-width: 300px;
+ }
+
+ .db-whos-posting &,
+ .db-activity & {
+ align-items: center;
+ gap: var(--space-2);
+ }
}
&__row-block-title {
color: var(--primary);
- margin-bottom: var(--space-2);
font-weight: bold;
font-size: var(--font-down-1-rem);
@@ -412,11 +414,21 @@ h1 {
display: grid;
grid-template-columns: 1fr 1fr;
gap: var(--space-4);
+
+ @include viewport.until(sm) {
+ grid-template-columns: 1fr;
+ }
}
&.--row {
display: flex;
flex-wrap: nowrap;
+
+ @include viewport.until(sm) {
+ flex-wrap: wrap;
+ gap: var(--space-1);
+ border: none;
+ }
}
&.--column {
@@ -437,10 +449,20 @@ h1 {
flex-direction: column;
gap: var(--space-3);
+ th,
+ td {
+ white-space: nowrap;
+ }
+
+ &__table-scroll-container {
+ min-width: 0;
+ overflow-x: auto;
+ }
+
&__header {
display: flex;
justify-content: space-between;
- align-items: flex-start;
+ align-items: center;
gap: var(--space-4);
}
@@ -462,15 +484,7 @@ h1 {
border-collapse: collapse;
font-size: var(--font-down-1-rem);
- th,
- td {
- padding: var(--space-3) var(--space-2);
- text-align: left;
- vertical-align: middle;
- }
-
thead th {
- border-bottom: 1px solid var(--primary-low);
color: var(--primary-medium);
font-weight: 600;
text-transform: uppercase;
@@ -478,17 +492,9 @@ h1 {
font-size: var(--font-down-2-rem);
}
- tbody tr {
- border-bottom: 1px solid var(--primary-very-low);
-
- &:last-child {
- border-bottom: none;
- }
- }
-
&__col-number,
&__cell-number {
- text-align: right;
+ text-align: center;
font-variant-numeric: tabular-nums;
}
@@ -502,6 +508,12 @@ h1 {
cursor: pointer;
text-transform: inherit;
letter-spacing: inherit;
+
+ .d-icon {
+ &.is-hidden {
+ visibility: hidden;
+ }
+ }
}
&__cell-category {
@@ -525,15 +537,12 @@ h1 {
flex-direction: column;
gap: var(--space-3);
- .db-section__row-block-header {
- align-items: flex-start;
- }
-
&__filter {
display: flex;
flex-direction: column;
align-items: flex-end;
gap: var(--space-1);
+ flex-grow: 1;
}
&__subcategories {
@@ -736,19 +745,22 @@ h1 {
}
}
-.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 {
position: relative;
display: flex;
flex-direction: column;
gap: var(--space-2);
+ &:first-of-type {
+ border-top-left-radius: var(--d-border-radius-large);
+ border-bottom-left-radius: var(--d-border-radius-large);
+ }
+
+ &:last-of-type {
+ border-top-right-radius: var(--d-border-radius-large);
+ border-bottom-right-radius: var(--d-border-radius-large);
+ }
+
.db-link-arrow {
top: var(--space-4);
inset-inline-end: var(--space-4);
@@ -791,6 +803,12 @@ h1 {
height: 320px;
display: flex;
flex-direction: column;
+ gap: var(--space-2);
+
+ @include viewport.until(sm) {
+ position: relative;
+ padding-inline: 0;
+ }
}
&__header {
@@ -798,6 +816,10 @@ h1 {
align-items: center;
gap: var(--space-2);
flex: 0 0 auto;
+
+ @include viewport.until(sm) {
+ padding-inline: var(--space-4);
+ }
}
&__name {
@@ -805,6 +827,13 @@ h1 {
align-items: center;
font-size: var(--font-down-1-rem);
font-weight: 600;
+ color: var(--primary);
+
+ &:visited,
+ &:hover,
+ &:active {
+ color: var(--primary);
+ }
}
&__label {
@@ -814,6 +843,18 @@ h1 {
font-size: var(--font-down-3);
padding: var(--space-half) var(--space-2);
font-weight: 400;
+
+ @include viewport.until(sm) {
+ position: absolute;
+ top: 0;
+ right: var(--space-3);
+ transform: translateY(-40%);
+ }
+
+ &.--data_explorer_query {
+ background: var(--tertiary-low);
+ color: var(--tertiary);
+ }
}
&__remove {
@@ -821,14 +862,16 @@ h1 {
}
&__chart {
- margin-top: var(--space-2);
overflow: hidden;
flex: 1 1 auto;
min-height: 0;
+ .admin-report,
+ .admin-report-chart,
+ .chart-canvas-container,
.chart-canvas {
- width: 100%;
- height: 100%;
+ width: 100% !important; // no other way to overrule the JS inline styling
+ height: 100% !important;
}
}
diff --git a/app/assets/stylesheets/common/modal/manage-reports-modal.scss b/app/assets/stylesheets/common/modal/manage-reports-modal.scss
index a17e52e10d6..5ab6af4b37e 100644
--- a/app/assets/stylesheets/common/modal/manage-reports-modal.scss
+++ b/app/assets/stylesheets/common/modal/manage-reports-modal.scss
@@ -89,16 +89,6 @@
min-width: 0;
}
- &__label {
- color: var(--primary-high);
- background: var(--primary-low);
- border-radius: 4px;
- font-size: var(--font-down-3);
- white-space: nowrap;
- padding: var(--space-half) var(--space-2);
- line-height: normal;
- }
-
&__description {
margin: 0;
color: var(--primary-medium);
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index bee40c5b82d..ced1281538e 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -6908,6 +6908,7 @@ en:
not_found_error: Sorry, this report doesn’t exist
custom_date_range: Custom date range
loading: "Loading dashboard…"
+ stable: "stable"
sections:
highlights:
@@ -6952,7 +6953,6 @@ en:
dropping:
one: "-%{count} dropping"
other: "-%{count} dropping"
- stable: "stable"
moves_in_aria:
one: "%{count} member moved up"
other: "%{count} members moved up"
@@ -6979,7 +6979,10 @@ en:
no_signal:
title: "Not enough activity yet to summarise engagement."
summary: "Pick a longer date range or come back once your community has more activity."
-
+ metrics:
+ new_signups: "New sign-ups"
+ dau_mau: "DAU / MAU stickiness"
+ daily_engaged_users: "Daily engaged"
reports_section:
description: "Pin standard reports or Data Explorer queries to track what matters to your community."
add: "Add report"
@@ -7013,16 +7016,16 @@ en:
kpi:
new_signups:
label: "New sign-ups"
- tooltip: "Accounts created in this period, including unactivated and staged accounts."
+ tooltip: "Accounts created, including unactivated and staged accounts."
dau_mau:
label: "DAU / MAU stickiness"
- tooltip: 'The share of monthly active users who returned to the community in the last day. This shows how "sticky" your community is based on how often people come back.'
+ tooltip: 'The share of monthly active users who returned to the community. This shows how "sticky" your community is based on how often people come back.'
new_contributors:
label: "New contributors"
- tooltip: "The number of members who made their first post in this period."
+ tooltip: "The number of members who made their first post."
daily_engaged_users:
label: "Daily engaged"
- tooltip: "The number of members who liked or posted in the community in the last day."
+ tooltip: "The average number of members who liked or posted in the community each day."
comparison:
last_7_days: "vs last 7 days"
last_30_days: "vs last 30 days"
diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml
index 4bc0fbf3ac9..e03142842e9 100644
--- a/config/locales/server.en.yml
+++ b/config/locales/server.en.yml
@@ -1824,9 +1824,6 @@ en:
admin_sidebar_deprecation: "The old admin layout is deprecated in favour of the new <a href='https://meta.discourse.org/t/-/289281'>sidebar layout</a> and will be removed in the next release. You can <a href='%{base_path}/admin/config/navigation?filter=admin%20sidebar'>configure</a> the new sidebar layout now to opt in before that."
starttls_disabled: "The outgoing email configuration has STARTTLS disabled. This is almost never necessary. Consider removing <pre>DISCOURSE_SMTP_ENABLE_START_TLS=false</pre> from your environment. Please refer to <a href='https://meta.discourse.org/t/387286'>this topic</a> for more details."
back_from_logster_text: "Back to site"
- reports_section:
- providers:
- core_report: "Standard"
site_settings:
allow_bulk_invite: "Allow bulk invites by uploading a CSV file"
diff --git a/frontend/discourse/admin/components/dashboard/engagement/activity-by-category.gjs b/frontend/discourse/admin/components/dashboard/engagement/activity-by-category.gjs
index 8f5a1b2c2eb..6e1055450fb 100644
--- a/frontend/discourse/admin/components/dashboard/engagement/activity-by-category.gjs
+++ b/frontend/discourse/admin/components/dashboard/engagement/activity-by-category.gjs
@@ -1,5 +1,6 @@
import Component from "@glimmer/component";
import { tracked } from "@glimmer/tracking";
+import { fn } from "@ember/helper";
import { on } from "@ember/modifier";
import { action } from "@ember/object";
import didUpdate from "@ember/render-modifiers/modifiers/did-update";
@@ -12,6 +13,7 @@ import Category from "discourse/models/category";
import CategorySelector from "discourse/select-kit/components/category-selector";
import { eq } from "discourse/truth-helpers";
import dCategoryBadge from "discourse/ui-kit/helpers/d-category-badge";
+import dIcon from "discourse/ui-kit/helpers/d-icon";
import I18n, { i18n } from "discourse-i18n";
export default class ActivityByCategory extends Component {
@@ -58,10 +60,6 @@ export default class ActivityByCategory extends Component {
return (this.activity?.rows ?? []).length > 0;
}
- get shareSortIndicator() {
- return this.sortDir === "desc" ? "↓" : "↑";
- }
-
#safeHex(color) {
return /^[0-9a-fA-F]{6}$/.test(color) ? color : "cccccc";
}
@@ -82,11 +80,11 @@ export default class ActivityByCategory extends Component {
}
@action
- toggleShareSort() {
- if (this.sortBy === "share") {
+ updateSort(field) {
+ if (this.sortBy === field) {
this.sortDir = this.sortDir === "desc" ? "asc" : "desc";
} else {
- this.sortBy = "share";
+ this.sortBy = field;
this.sortDir = "desc";
}
}
@@ -124,108 +122,181 @@ export default class ActivityByCategory extends Component {
class="db-activity"
{{didUpdate this.onPeriodChange @startDate @endDate}}
>
- <div class="db-activity__header">
+ <div class="db-section__row-block-header">
<LinkTo
@route="adminReports.show"
@model="activity_by_category"
- class="db-section__row-block-title"
+ class="db-section__row-block-title --label"
>
{{i18n
"admin.dashboard.sections.engagement.activity_by_category.title"
}}
</LinkTo>
+
<CategorySelector
@categories={{this.selectedCategories}}
@onChange={{this.onCategoriesChange}}
/>
</div>
- <p class="db-activity__description">
- {{i18n
- "admin.dashboard.sections.engagement.activity_by_category.description"
- }}
- </p>
-
{{#if this.hasData}}
- <table class="db-activity-table">
- <thead>
- <tr>
- <th class="db-activity-table__col-category">
- {{i18n
- "admin.dashboard.sections.engagement.activity_by_category.category"
- }}
- </th>
- <th class="db-activity-table__col-number">
- {{i18n
- "admin.dashboard.sections.engagement.activity_by_category.topics"
- }}
- </th>
- <th class="db-activity-table__col-number">
- {{i18n
- "admin.dashboard.sections.engagement.activity_by_category.posts"
- }}
- </th>
- <th class="db-activity-table__col-number">
- {{i18n
- "admin.dashboard.sections.engagement.activity_by_category.page_views"
- }}
- </th>
- <th class="db-activity-table__col-number">
- <button
- type="button"
- class="db-activity-table__sort-button"
- {{on "click" this.toggleShareSort}}
- >
+ <div class="db-activity__table-scroll-container">
+ <table class="db-activity-table">
+ <thead>
+ <tr>
+ <th class="db-activity-table__col-category">
{{i18n
- "admin.dashboard.sections.engagement.activity_by_category.share"
+ "admin.dashboard.sections.engagement.activity_by_category.category"
}}
- {{#if (eq this.sortBy "share")}}
- <span aria-hidden="true">{{this.shareSortIndicator}}</span>
- {{/if}}
- </button>
- </th>
- <th class="db-activity-table__col-number">
- {{i18n
- "admin.dashboard.sections.engagement.activity_by_category.vs_prior"
- }}
- </th>
- </tr>
- </thead>
- <tbody>
- {{#each this.rows as |row|}}
- <tr>
- <td class="db-activity-table__cell-category">
- {{#if row.category}}
- {{dCategoryBadge row.category}}
- {{else}}
- <span
- class="db-activity-table__swatch"
- style={{row.swatchStyle}}
- aria-hidden="true"
- ></span>
- {{row.name}}
- {{/if}}
- </td>
- <td
- class="db-activity-table__cell-number"
- >{{row.topicsFormatted}}</td>
- <td
- class="db-activity-table__cell-number"
- >{{row.postsFormatted}}</td>
- <td
- class="db-activity-table__cell-number"
- >{{row.pageViewsFormatted}}</td>
- <td
- class="db-activity-table__cell-number"
- >{{row.share_formatted}}</td>
- <td
- class="db-activity-table__cell-number db-delta
- {{row.changeClass}}"
- >{{row.share_change_formatted}}</td>
+ </th>
+ <th
+ class="db-activity-table__col-number"
+ aria-sort={{if
+ (eq this.sortBy "topics")
+ (if (eq this.sortDir "asc") "ascending" "descending")
+ "none"
+ }}
+ >
+ <button
+ type="button"
+ class="db-activity-table__sort-button"
+ {{on "click" (fn this.updateSort "topics")}}
+ >
+ {{i18n
+ "admin.dashboard.sections.engagement.activity_by_category.topics"
+ }}
+ {{dIcon
+ (if (eq this.sortDir "asc") "chevron-up" "chevron-down")
+ class=(if (eq this.sortBy "topics") "" "is-hidden")
+ }}
+ </button>
+ </th>
+ <th
+ class="db-activity-table__col-number"
+ aria-sort={{if
+ (eq this.sortBy "posts")
+ (if (eq this.sortDir "asc") "ascending" "descending")
+ "none"
+ }}
+ >
+ <button
+ type="button"
+ class="db-activity-table__sort-button"
+ {{on "click" (fn this.updateSort "posts")}}
+ >
+ {{i18n
+ "admin.dashboard.sections.engagement.activity_by_category.posts"
+ }}
+ {{dIcon
+ (if (eq this.sortDir "asc") "chevron-up" "chevron-down")
+ class=(if (eq this.sortBy "posts") "" "is-hidden")
+ }}
+ </button>
+ </th>
+ <th
+ class="db-activity-table__col-number"
+ aria-sort={{if
+ (eq this.sortBy "page_views")
+ (if (eq this.sortDir "asc") "ascending" "descending")
+ "none"
+ }}
+ >
+ <button
+ type="button"
+ class="db-activity-table__sort-button"
+ {{on "click" (fn this.updateSort "page_views")}}
+ >
+ {{i18n
+ "admin.dashboard.sections.engagement.activity_by_category.page_views"
+ }}
+ {{dIcon
+ (if (eq this.sortDir "asc") "chevron-up" "chevron-down")
+ class=(if (eq this.sortBy "page_views") "" "is-hidden")
+ }}
+ </button>
+ </th>
+ <th
+ class="db-activity-table__col-number"
+ aria-sort={{if
+ (eq this.sortBy "share")
+ (if (eq this.sortDir "asc") "ascending" "descending")
+ "none"
+ }}
+ >
+ <button
+ type="button"
+ class="db-activity-table__sort-button"
+ {{on "click" (fn this.updateSort "share")}}
+ >
+ {{i18n
+ "admin.dashboard.sections.engagement.activity_by_category.share"
+ }}
+ {{dIcon
+ (if (eq this.sortDir "asc") "chevron-up" "chevron-down")
+ class=(if (eq this.sortBy "share") "" "is-hidden")
+ }}
+ </button>
+ </th>
+ <th
+ class="db-activity-table__col-number"
+ aria-sort={{if
+ (eq this.sortBy "share_change")
+ (if (eq this.sortDir "asc") "ascending" "descending")
+ "none"
+ }}
+ >
+ <button
+ type="button"
+ class="db-activity-table__sort-button"
+ {{on "click" (fn this.updateSort "share_change")}}
+ >
+ {{i18n
+ "admin.dashboard.sections.engagement.activity_by_category.vs_prior"
+ }}
+ {{dIcon
+ (if (eq this.sortDir "asc") "chevron-up" "chevron-down")
+ class=(if (eq this.sortBy "share_change") "" "is-hidden")
+ }}
+ </button>
+ </th>
</tr>
- {{/each}}
- </tbody>
- </table>
+ </thead>
+ <tbody>
+ {{#each this.rows as |row|}}
+ <tr>
+ <td class="db-activity-table__cell-category">
+ {{#if row.category}}
+ {{dCategoryBadge row.category}}
+ {{else}}
+ <span
+ class="db-activity-table__swatch"
+ style={{row.swatchStyle}}
+ aria-hidden="true"
+ ></span>
+ {{row.name}}
+ {{/if}}
+ </td>
+ <td
+ class="db-activity-table__cell-number"
+ >{{row.topicsFormatted}}</td>
+ <td
+ class="db-activity-table__cell-number"
+ >{{row.postsFormatted}}</td>
+ <td
+ class="db-activity-table__cell-number"
+ >{{row.pageViewsFormatted}}</td>
+ <td
+ class="db-activity-table__cell-number"
+ >{{row.share_formatted}}</td>
+ <td
+ class="db-activity-table__cell-number db-delta
+ {{row.changeClass}}"
+ >{{row.share_change_formatted}}</td>
+ </tr>
+ {{/each}}
+ </tbody>
+ </table>
+ </div>
{{else}}
<p class="db-activity__empty">
{{i18n
diff --git a/frontend/discourse/admin/components/dashboard/engagement/headline.gjs b/frontend/discourse/admin/components/dashboard/engagement/headline.gjs
index 73c3f9dc69c..6ebd9a5903d 100644
--- a/frontend/discourse/admin/components/dashboard/engagement/headline.gjs
+++ b/frontend/discourse/admin/components/dashboard/engagement/headline.gjs
@@ -1,8 +1,90 @@
import Component from "@glimmer/component";
-import KpiTile from "discourse/admin/components/dashboard/kpi-tile";
-import { i18n } from "discourse-i18n";
+import { concat } from "@ember/helper";
+import DTooltip from "discourse/float-kit/components/d-tooltip";
+import { eq } from "discourse/truth-helpers";
+import I18n, { i18n } from "discourse-i18n";
const PRESET_PERIODS = ["last_7_days", "last_30_days", "last_3_months"];
+const PERCENTAGE_KPIS = ["dau_mau"];
+
+class MetricItem extends Component {
+ get isPercentage() {
+ return PERCENTAGE_KPIS.includes(this.args.metric.type);
+ }
+
+ get displayValue() {
+ const value = this.args.metric.value;
+ if (value == null) {
+ return "—";
+ }
+ if (this.isPercentage) {
+ return `${I18n.toNumber(value, { precision: 1 })}%`;
+ }
+ return I18n.toNumber(value, { precision: 0 });
+ }
+
+ get hasDelta() {
+ return this.args.metric.percent_change != null;
+ }
+
+ get deltaClass() {
+ const change = this.args.metric.percent_change;
+ if (change > 0) {
+ return "--pos";
+ } else if (change < 0) {
+ return "--neg";
+ }
+ return "--neutral";
+ }
+
+ get deltaText() {
+ const value = this.args.metric.percent_change;
+ const abs = Math.abs(value);
+
+ if (abs > 0 && abs < 1) {
+ const sign = value > 0 ? "+" : "-";
+ return `${sign}${I18n.toNumber(abs, { precision: 1 })}%`;
+ }
+
+ const rounded = Math.round(value);
+ const sign = rounded > 0 ? "+" : "";
+ return `${sign}${I18n.toNumber(rounded, { precision: 0 })}%`;
+ }
+
+ <template>
+ <div class="db-section__metric">
+ <div class="db-section__metric-number">{{this.displayValue}}</div>
+ <div class="db-section__metric-label">
+ {{i18n
+ (concat
+ "admin.dashboard.sections.engagement.headline.metrics." @metric.type
+ )
+ }}
+ <DTooltip
+ class="db-section__info"
+ @identifier={{concat "engagement-headline-" @metric.type "-tooltip"}}
+ @icon="far-circle-question"
+ >
+ <:content>
+ {{i18n
+ (concat "admin.dashboard.highlights.kpi." @metric.type ".tooltip")
+ }}
+ </:content>
+ </DTooltip>
+ </div>
+ {{#if this.hasDelta}}
+ {{#if (eq this.deltaClass "--neutral")}}
+ <span class="db-pill">{{i18n "admin.dashboard.stable"}}</span>
+ {{else}}
+ <div class={{concat "db-delta " this.deltaClass}}>
+ {{this.deltaText}}
+ <span class="db-delta__label">{{@comparisonLabel}}</span>
+ </div>
+ {{/if}}
+ {{/if}}
+ </div>
+ </template>
+}
export default class EngagementHeadline extends Component {
get titleKey() {
@@ -27,16 +109,8 @@ export default class EngagementHeadline extends Component {
<p>{{i18n this.summaryKey}}</p>
</div>
<div class="db-section__metrics">
- {{#each @kpis as |kpi|}}
- <KpiTile
- @type={{kpi.type}}
- @value={{kpi.value}}
- @previousValue={{kpi.previous_value}}
- @percentChange={{kpi.percent_change}}
- @reportType={{kpi.report_type}}
- @reportQuery={{kpi.report_query}}
- @comparisonLabel={{this.comparisonLabel}}
- />
+ {{#each @kpis as |metric|}}
+ <MetricItem @metric={{metric}} />
{{/each}}
</div>
</div>
diff --git a/frontend/discourse/admin/components/dashboard/engagement/trust-level-pipeline.gjs b/frontend/discourse/admin/components/dashboard/engagement/trust-level-pipeline.gjs
index e43480978bf..368cba195d5 100644
--- a/frontend/discourse/admin/components/dashboard/engagement/trust-level-pipeline.gjs
+++ b/frontend/discourse/admin/components/dashboard/engagement/trust-level-pipeline.gjs
@@ -53,9 +53,7 @@ export default class TrustLevelPipeline extends Component {
return null;
}
if (trend.direction === "stable") {
- return i18n(
- "admin.dashboard.sections.engagement.trust_level_pipeline.trend.stable"
- );
+ return i18n("admin.dashboard.stable");
}
return i18n(
`admin.dashboard.sections.engagement.trust_level_pipeline.trend.${trend.direction}`,
@@ -112,7 +110,7 @@ export default class TrustLevelPipeline extends Component {
</div>
{{else}}
<span class="db-pill">{{i18n
- "admin.dashboard.sections.engagement.trust_level_pipeline.trend.stable"
+ "admin.dashboard.stable"
}}</span>
{{/if}}
</div>
@@ -135,7 +133,7 @@ export default class TrustLevelPipeline extends Component {
↑</span>
{{else}}
<span class="db-pill">{{i18n
- "admin.dashboard.sections.engagement.trust_level_pipeline.trend.stable"
+ "admin.dashboard.stable"
}}</span>
{{/if}}
</div>
diff --git a/frontend/discourse/admin/components/dashboard/engagement/whos-posting.gjs b/frontend/discourse/admin/components/dashboard/engagement/whos-posting.gjs
index dc0c4f085dc..873ef1eb1be 100644
--- a/frontend/discourse/admin/components/dashboard/engagement/whos-posting.gjs
+++ b/frontend/discourse/admin/components/dashboard/engagement/whos-posting.gjs
@@ -1,5 +1,6 @@
import Component from "@glimmer/component";
import { tracked } from "@glimmer/tracking";
+import { hash } from "@ember/helper";
import { on } from "@ember/modifier";
import { action } from "@ember/object";
import didUpdate from "@ember/render-modifiers/modifiers/did-update";
@@ -8,7 +9,7 @@ import { trustHTML } from "@ember/template";
import { ajax } from "discourse/lib/ajax";
import { popupAjaxError } from "discourse/lib/ajax-error";
import Category from "discourse/models/category";
-import SearchAdvancedCategoryChooser from "discourse/select-kit/components/search-advanced-category-chooser";
+import CategoryChooser from "discourse/select-kit/components/category-chooser";
import { i18n } from "discourse-i18n";
const ROW_ORDER = ["new_members", "returning", "staff"];
@@ -147,9 +148,10 @@ export default class WhosPosting extends Component {
{{i18n "admin.dashboard.sections.engagement.whos_posting.title"}}
</LinkTo>
<div class="db-whos-posting__filter">
- <SearchAdvancedCategoryChooser
+ <CategoryChooser
@value={{this.categoryId}}
@onChange={{this.onCategoryChange}}
+ @options={{hash none="category.all" autoInsertNoneItem=true}}
/>
{{#if this.hasSubcategories}}
<label class="db-whos-posting__subcategories">
diff --git a/frontend/discourse/admin/components/dashboard/highlights.gjs b/frontend/discourse/admin/components/dashboard/highlights.gjs
index b2d9f76c28b..d2702c21aa0 100644
--- a/frontend/discourse/admin/components/dashboard/highlights.gjs
+++ b/frontend/discourse/admin/components/dashboard/highlights.gjs
@@ -44,12 +44,6 @@ export default class Highlights extends Component {
{{/each}}
{{/if}}
</: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/kpi-tile.gjs b/frontend/discourse/admin/components/dashboard/kpi-tile.gjs
index a827698802e..7fe20de845b 100644
--- a/frontend/discourse/admin/components/dashboard/kpi-tile.gjs
+++ b/frontend/discourse/admin/components/dashboard/kpi-tile.gjs
@@ -93,7 +93,7 @@ export default class KpiTile extends Component {
{{this.label}}
<DTooltip
class="db-kpi__tooltip"
- @icon="circle-question"
+ @icon="far-circle-question"
@content={{this.tooltip}}
{{on "click" this.stopPropagation}}
/>
diff --git a/frontend/discourse/admin/components/dashboard/reports.gjs b/frontend/discourse/admin/components/dashboard/reports.gjs
index 5c18eced511..f22f5d42a26 100644
--- a/frontend/discourse/admin/components/dashboard/reports.gjs
+++ b/frontend/discourse/admin/components/dashboard/reports.gjs
@@ -1,6 +1,6 @@
import Component from "@glimmer/component";
import { cached, tracked } from "@glimmer/tracking";
-import { fn, hash } from "@ember/helper";
+import { concat, hash } from "@ember/helper";
import { on } from "@ember/modifier";
import { action } from "@ember/object";
import didUpdate from "@ember/render-modifiers/modifiers/did-update";
@@ -14,7 +14,7 @@ import PluginOutlet from "discourse/components/plugin-outlet";
import lazyHash from "discourse/helpers/lazy-hash";
import { ajax } from "discourse/lib/ajax";
import { popupAjaxError } from "discourse/lib/ajax-error";
-import DButton from "discourse/ui-kit/d-button";
+import dConcatClass from "discourse/ui-kit/helpers/d-concat-class";
import dIcon from "discourse/ui-kit/helpers/d-icon";
import { i18n } from "discourse-i18n";
@@ -39,10 +39,6 @@ export default class DashboardReports extends Component {
return this.args.data?.items ?? [];
}
- get showLabels() {
- return this.args.data?.show_labels ?? false;
- }
-
get canEdit() {
return this.currentUser?.admin;
}
@@ -143,23 +139,16 @@ export default class DashboardReports extends Component {
{{#each this.cards key="key" as |card|}}
<div class="db-report__card" data-identifier={{card.key}}>
<div class="db-report__header">
- <span class="db-report__name">{{card.title}}</span>
- {{#if this.showLabels}}
+ <a href={{card.url}} class="db-report__name">{{card.title}}</a>
+ {{#if card.label}}
<div
- class="db-report__label"
+ class={{dConcatClass
+ "db-report__label"
+ (concat "--" card.source)
+ }}
data-source={{card.source}}
>{{card.label}}</div>
{{/if}}
- {{#if this.canEdit}}
- <DButton
- @icon="xmark"
- @translatedAriaLabel={{i18n
- "admin.dashboard.reports_section.remove"
- }}
- @action={{fn this.removeReport card}}
- class="db-report__remove btn-transparent btn-small"
- />
- {{/if}}
</div>
<div class="db-report__chart">
{{#if card.payload}}
diff --git a/frontend/discourse/admin/components/dashboard/traffic.gjs b/frontend/discourse/admin/components/dashboard/traffic.gjs
index 27f9cd8fa1c..72fad15affb 100644
--- a/frontend/discourse/admin/components/dashboard/traffic.gjs
+++ b/frontend/discourse/admin/components/dashboard/traffic.gjs
@@ -211,7 +211,7 @@ export default class DashboardTraffic extends Component {
<DTooltip
class="db-section__info"
@identifier="site-traffic-comparison-tooltip"
- @icon="circle-question"
+ @icon="far-circle-question"
>
<:content>{{this.comparisonTooltipText}}</:content>
</DTooltip>
@@ -237,7 +237,7 @@ export default class DashboardTraffic extends Component {
<DTooltip
class="db-section__info"
@identifier="site-traffic-logged-in-share-tooltip"
- @icon="circle-question"
+ @icon="far-circle-question"
>
<:content>
{{i18n
diff --git a/frontend/discourse/admin/components/modal/manage-reports.gjs b/frontend/discourse/admin/components/modal/manage-reports.gjs
index f6798190f25..b4e6bfb7884 100644
--- a/frontend/discourse/admin/components/modal/manage-reports.gjs
+++ b/frontend/discourse/admin/components/modal/manage-reports.gjs
@@ -45,10 +45,6 @@ export default class ManageReports extends Component {
this.load();
}
- get showLabels() {
- return this.providers.length > 1;
- }
-
get enabledKeys() {
return new Set(this.enabledOrder);
}
@@ -342,9 +338,9 @@ export default class ManageReports extends Component {
<div class="manage-reports__row-text">
<div class="manage-reports__row-heading">
<span class="manage-reports__title">{{row.title}}</span>
- {{#if this.showLabels}}
+ {{#if row.label}}
<span
- class="manage-reports__label"
+ class="db-report__label"
data-source={{row.source}}
>{{row.label}}</span>
{{/if}}
diff --git a/frontend/discourse/admin/components/redesigned-admin-dashboard.gjs b/frontend/discourse/admin/components/redesigned-admin-dashboard.gjs
index fdbed34c024..21d4ff8c531 100644
--- a/frontend/discourse/admin/components/redesigned-admin-dashboard.gjs
+++ b/frontend/discourse/admin/components/redesigned-admin-dashboard.gjs
@@ -86,10 +86,9 @@ export default class RedesignedAdminDashboard extends Component {
}
<template>
- <div class="db-toolbar">
- <h1>Dashboard</h1>
-
- <div class="db-toolbar__actions">
+ <div class="db-header">
+ <h1 class="db-header__title">Dashboard</h1>
+ <div class="db-header__actions">
<DashboardDateRange
@period={{@requestedPeriod}}
@startDate={{@requestedStartDate}}
diff --git a/frontend/discourse/tests/integration/components/dashboard/engagement-test.gjs b/frontend/discourse/tests/integration/components/dashboard/engagement-test.gjs
index a07d8abb44e..149526d793f 100644
--- a/frontend/discourse/tests/integration/components/dashboard/engagement-test.gjs
+++ b/frontend/discourse/tests/integration/components/dashboard/engagement-test.gjs
@@ -39,7 +39,7 @@ module("Integration | Component | Dashboard | Engagement", function (hooks) {
],
};
- test("renders the headline title, summary and one KpiTile per kpi", async function (assert) {
+ test("renders the headline title, summary and one metric per kpi", async function (assert) {
await render(
<template>
<DashboardEngagement
@@ -55,17 +55,21 @@ module("Integration | Component | Dashboard | Engagement", function (hooks) {
.dom(".db-section__subintro h3")
.hasText("Members are forming a habit of coming back.");
assert.dom(".db-section__subintro p").exists();
- assert.dom(".db-kpi").exists({ count: 3 });
+ assert.dom(".db-section__metric").exists({ count: 3 });
assert
- .dom('a.db-kpi[href*="/admin/reports/dau_by_mau"] .db-kpi__value')
+ .dom(
+ ".db-section__metrics .db-section__metric:nth-child(1) .db-section__metric-number"
+ )
.hasText("21.6%");
assert
.dom(
- 'a.db-kpi[href*="/admin/reports/daily_engaged_users"] .db-kpi__value'
+ ".db-section__metrics .db-section__metric:nth-child(2) .db-section__metric-number"
)
.hasText("150");
assert
- .dom('a.db-kpi[href*="/admin/reports/signups"] .db-kpi__value')
+ .dom(
+ ".db-section__metrics .db-section__metric:nth-child(3) .db-section__metric-number"
+ )
.hasText("248");
});
@@ -82,7 +86,7 @@ module("Integration | Component | Dashboard | Engagement", function (hooks) {
);
assert.dom(".db-section__error").exists();
- assert.dom(".db-kpi").doesNotExist();
+ assert.dom(".db-section__metric").doesNotExist();
});
test("omits the headline block when the engagement payload is missing", async function (assert) {
diff --git a/frontend/discourse/tests/integration/components/dashboard/highlights-test.gjs b/frontend/discourse/tests/integration/components/dashboard/highlights-test.gjs
index 1639de2977f..016c22c8ea4 100644
--- a/frontend/discourse/tests/integration/components/dashboard/highlights-test.gjs
+++ b/frontend/discourse/tests/integration/components/dashboard/highlights-test.gjs
@@ -109,68 +109,6 @@ module("Integration | Component | Dashboard | Highlights", function (hooks) {
);
assert.dom(".db-kpi").doesNotExist();
- assert.dom(".db-highlights__comparison").doesNotExist();
- });
-
- test("renders the comparison label tied to the active period", async function (assert) {
- const highlights = {
- kpis: [
- {
- type: "new_signups",
- value: 1100,
- percent_change: 12,
- report_type: "signups",
- report_query: reportQuery,
- },
- ],
- };
-
- await render(
- <template>
- <DashboardHighlights
- @highlights={{highlights}}
- @period="last_30_days"
- @startDate={{start}}
- @endDate={{end}}
- />
- </template>
- );
-
- assert.dom(".db-highlights__comparison").hasText("vs last 30 days");
- assert
- .dom("a.db-kpi")
- .hasAttribute(
- "aria-label",
- /vs last 30 days$/,
- "comparison label flows into the child tile's aria-label"
- );
- });
-
- test("falls back to 'vs previous period' for custom ranges", async function (assert) {
- const highlights = {
- kpis: [
- {
- type: "new_signups",
- value: 1100,
- percent_change: 12,
- report_type: "signups",
- report_query: reportQuery,
- },
- ],
- };
-
- await render(
- <template>
- <DashboardHighlights
- @highlights={{highlights}}
- @period="custom"
- @startDate={{start}}
- @endDate={{end}}
- />
- </template>
- );
-
- assert.dom(".db-highlights__comparison").hasText("vs previous period");
});
test("does not render a description headline", async function (assert) {
diff --git a/frontend/discourse/tests/integration/components/dashboard/kpi-tile-test.gjs b/frontend/discourse/tests/integration/components/dashboard/kpi-tile-test.gjs
index 330e9cdc075..5cc945b6ae8 100644
--- a/frontend/discourse/tests/integration/components/dashboard/kpi-tile-test.gjs
+++ b/frontend/discourse/tests/integration/components/dashboard/kpi-tile-test.gjs
@@ -217,7 +217,7 @@ module("Integration | Component | Dashboard | KpiTile", function (hooks) {
assert
.dom(".fk-d-tooltip__content")
.includesText(
- "Accounts created in this period, including unactivated and staged accounts."
+ "Accounts created, including unactivated and staged accounts."
);
});
diff --git a/lib/admin_dashboard/reports/core_report_provider.rb b/lib/admin_dashboard/reports/core_report_provider.rb
index 4fdc9384bce..bdc5f031ac7 100644
--- a/lib/admin_dashboard/reports/core_report_provider.rb
+++ b/lib/admin_dashboard/reports/core_report_provider.rb
@@ -9,8 +9,11 @@ module AdminDashboard
SOURCE_NAME
end
+ # The standard/default provider intentionally has no label, so its
+ # reports render without a pill. Labels exist only to distinguish
+ # non-standard (plugin-contributed) sources.
def self.label
- I18n.t("dashboard.reports_section.providers.core_report")
+ nil
end
def self.resolve_many(identifiers, guardian:)
diff --git a/lib/admin_dashboard/reports/section.rb b/lib/admin_dashboard/reports/section.rb
index 6d9b1044a30..e13e3553421 100644
--- a/lib/admin_dashboard/reports/section.rb
+++ b/lib/admin_dashboard/reports/section.rb
@@ -16,7 +16,7 @@ module AdminDashboard
items = visible_items.map { |_row, resolved| serialize(resolved) }
items = filter_by_search(items) if @search
- { items: items, show_labels: AdminDashboard::Reports::Registry.providers.length > 1 }
+ { items: items }
end
private
diff --git a/lib/admin_dashboard/reports/source_provider.rb b/lib/admin_dashboard/reports/source_provider.rb
index b8abb49a578..3dc0d73b680 100644
--- a/lib/admin_dashboard/reports/source_provider.rb
+++ b/lib/admin_dashboard/reports/source_provider.rb
@@ -18,9 +18,10 @@ module AdminDashboard
raise NotImplementedError
end
- # @return [String] a short, translated label rendered as a tag pill in
- # the UI to distinguish this provider from others.
- # Only shown when more than one provider is registered.
+ # @return [String, nil] a short, translated label rendered as a tag pill
+ # in the UI to distinguish this provider's reports from
+ # the standard ones. Return nil for the standard/default
+ # provider so its reports render without a pill.
def self.label
raise NotImplementedError
end
diff --git a/plugins/discourse-solved/config/locales/client.en.yml b/plugins/discourse-solved/config/locales/client.en.yml
index db4758aeb54..7e16cc80599 100644
--- a/plugins/discourse-solved/config/locales/client.en.yml
+++ b/plugins/discourse-solved/config/locales/client.en.yml
@@ -9,7 +9,7 @@ en:
kpi:
accepted_solutions:
label: "Accepted solutions"
- tooltip: "The number of topics that had a post marked as the solution in this period."
+ tooltip: "The number of topics that had a post marked as the solution."
js:
notifications:
alt:
diff --git a/spec/lib/admin_dashboard/reports/core_report_provider_spec.rb b/spec/lib/admin_dashboard/reports/core_report_provider_spec.rb
index 0c4443ac3b7..9c926f40674 100644
--- a/spec/lib/admin_dashboard/reports/core_report_provider_spec.rb
+++ b/spec/lib/admin_dashboard/reports/core_report_provider_spec.rb
@@ -11,8 +11,8 @@ RSpec.describe AdminDashboard::Reports::CoreReportProvider do
end
describe ".label" do
- it "returns the localized provider label" do
- expect(described_class.label).to eq(I18n.t("dashboard.reports_section.providers.core_report"))
+ it "is nil because the standard provider's reports render without a pill" do
+ expect(described_class.label).to be_nil
end
end
@@ -26,7 +26,7 @@ RSpec.describe AdminDashboard::Reports::CoreReportProvider do
expect(resolved.source).to eq("core_report")
expect(resolved.identifier).to eq("signups")
expect(resolved.title).to be_present
- expect(resolved.label).to eq(described_class.label)
+ expect(resolved.label).to be_nil
end
it "omits identifiers that don't correspond to a built-in report" do
diff --git a/spec/lib/admin_dashboard/reports/section_spec.rb b/spec/lib/admin_dashboard/reports/section_spec.rb
index 868c6959438..d2c6fa80570 100644
--- a/spec/lib/admin_dashboard/reports/section_spec.rb
+++ b/spec/lib/admin_dashboard/reports/section_spec.rb
@@ -45,17 +45,6 @@ RSpec.describe AdminDashboard::Reports::Section do
expect(result[:items]).to eq([])
end
- it "sets show_labels to true when more than one provider is registered" do
- expect(described_class.build(guardian: guardian)[:show_labels]).to eq(true)
- end
-
- it "sets show_labels to false when only one provider is registered" do
- DiscoursePluginRegistry._raw_admin_dashboard_report_sources.reject! do |entry|
- entry[:value] == fake_provider
- end
- expect(described_class.build(guardian: guardian)[:show_labels]).to eq(false)
- end
-
it "returns items in position order, ignoring insertion order" do
AdminDashboardReport.create!(source: "fake", identifier: "a", position: 1)
AdminDashboardReport.create!(source: "fake", identifier: "b", position: 0)
diff --git a/spec/requests/admin/dashboard_controller_spec.rb b/spec/requests/admin/dashboard_controller_spec.rb
index fadef8d64fb..69679d3feef 100644
--- a/spec/requests/admin/dashboard_controller_spec.rb
+++ b/spec/requests/admin/dashboard_controller_spec.rb
@@ -329,7 +329,6 @@ RSpec.describe Admin::DashboardController do
expect(response.status).to eq(200)
expect(reports_data["items"]).to eq([])
- expect(reports_data).to have_key("show_labels")
end
it "serializes configured rows resolved via the registered providers" do
diff --git a/spec/system/admin_dashboard_redesign/reports_section_spec.rb b/spec/system/admin_dashboard_redesign/reports_section_spec.rb
index 7d4e779e4a5..676bad2ec88 100644
--- a/spec/system/admin_dashboard_redesign/reports_section_spec.rb
+++ b/spec/system/admin_dashboard_redesign/reports_section_spec.rb
@@ -61,21 +61,6 @@ describe "Admin Dashboard Redesign | Reports section" do
)
end
- it "removes a card directly via the X-to-remove button" do
- AdminDashboardReport.create!(source: "core_report", identifier: "signups", position: 0)
- AdminDashboardReport.create!(source: "core_report", identifier: "topics", position: 1)
-
- page.visit("/admin")
- expect(dashboard).to have_card("core_report:signups")
-
- dashboard.remove_card("core_report:signups")
- expect(dashboard).to have_no_card("core_report:signups")
-
- page.refresh
- expect(dashboard).to have_no_card("core_report:signups")
- expect(dashboard).to have_card("core_report:topics")
- end
-
it "hides the Add Report tile when the cap is reached" do
identifiers =
Reports::ListQuery
@@ -100,7 +85,7 @@ describe "Admin Dashboard Redesign | Reports section" do
expect(dashboard).to have_no_add_tile
end
- it "hides provider label pills when only one provider is registered" do
+ it "does not render a label pill for standard reports" do
AdminDashboardReport.create!(source: "core_report", identifier: "signups", position: 0)
page.visit("/admin")
diff --git a/spec/system/page_objects/pages/admin_dashboard_reports.rb b/spec/system/page_objects/pages/admin_dashboard_reports.rb
index 09f0b10dfb3..edc7b4a2177 100644
--- a/spec/system/page_objects/pages/admin_dashboard_reports.rb
+++ b/spec/system/page_objects/pages/admin_dashboard_reports.rb
@@ -21,13 +21,6 @@ module PageObjects
has_no_css?("#{SECTION_SELECTOR} .db-report__card[data-identifier='#{identifier}']")
end
- def remove_card(identifier)
- within("#{SECTION_SELECTOR} .db-report__card[data-identifier='#{identifier}']") do
- find(".db-report__remove").click
- end
- self
- end
-
def has_add_tile?
has_css?("#{SECTION_SELECTOR} .db-report__add-report")
end