A platform for community discussion. Free, open, simple.
UX: minor admin chart improvements (#37299)
Kris0caa6e34fe45
diff --git a/app/assets/stylesheets/admin/admin_base.scss b/app/assets/stylesheets/admin/admin_base.scssindex f2b3e94b7cf..5c6b5521873 100644--- a/app/assets/stylesheets/admin/admin_base.scss+++ b/app/assets/stylesheets/admin/admin_base.scss@@ -124,6 +124,10 @@ $mobile-breakpoint: 700px;padding: 8px;}+ td {+ overflow-wrap: break-word;+ }+tr.selected {background-color: var(--primary-low);}diff --git a/app/assets/stylesheets/admin/admin_report.scss b/app/assets/stylesheets/admin/admin_report.scssindex 4e3181b3543..770655677d4 100644--- a/app/assets/stylesheets/admin/admin_report.scss+++ b/app/assets/stylesheets/admin/admin_report.scss@@ -96,11 +96,11 @@border: 1px solid transparent;a {- color: var(--primary-medium);+ color: var(--primary-high);}.d-icon {- color: currentcolor;+ color: var(--primary-medium);font-size: var(--font-up-5);display: block;margin: 0.25em auto;@@ -110,7 +110,7 @@&.rate-limited {background: var(--secondary);border-color: var(--primary-low);- color: var(--primary-low-mid);+ color: var(--primary);}&.rate-limited .d-icon {@@ -125,12 +125,11 @@}.average-chart {- padding: 0.5em;- border: 1px solid var(--highlight);- color: var(--highlight);- margin-bottom: 1em;+ font-style: italic;text-align: center;- background: var(--highlight-bg);+ color: var(--primary-high);+ margin-bottom: 1em;+ line-height: var(--line-height-medium);}.filters {diff --git a/app/assets/stylesheets/admin/admin_report_table.scss b/app/assets/stylesheets/admin/admin_report_table.scssindex d834274ead9..ba1c5082e97 100644--- a/app/assets/stylesheets/admin/admin_report_table.scss+++ b/app/assets/stylesheets/admin/admin_report_table.scss@@ -2,9 +2,9 @@&.two-columns {.table .admin-report-table-cell:first-child,.table .admin-report-table-header:first-child {- @include ellipsis;text-align: left;width: 80%;+ overflow-wrap: break-word;}.table .admin-report-table-cell:last-child,@@ -27,9 +27,9 @@.table .admin-report-table-header {.sort-btn {- outline: none;- background: none;- padding: 3px 8px;+ padding: 0;+ flex-direction: row-reverse;+ gap: var(--space-1);@include ellipsis;}@@ -38,23 +38,11 @@.d-icon {color: var(--tertiary);}-- .sort-btn:hover {- color: var(--primary-medium);- background: var(--primary-low);- }}&:not(.is-current-sort) .sort-btn {- background: none;-- &:hover {- color: var(--primary-medium);- background: var(--primary-low);-- .d-icon {- color: var(--primary-medium);- }+ .d-icon {+ visibility: hidden;}}}diff --git a/app/assets/stylesheets/common/components/buttons.scss b/app/assets/stylesheets/common/components/buttons.scssindex 784fb0a459a..2212ab0706b 100644--- a/app/assets/stylesheets/common/components/buttons.scss+++ b/app/assets/stylesheets/common/components/buttons.scss@@ -520,7 +520,7 @@}}- /* The full classname is the dld way of combining transparent buttons with colours – no longer use like this+ /* The full classname is the old way of combining transparent buttons with colours – no longer use like thisUse the --modifiers approach instead*/diff --git a/config/locales/client.en.yml b/config/locales/client.en.ymlindex 752899db53a..d369a8080da 100644--- a/config/locales/client.en.yml+++ b/config/locales/client.en.yml@@ -6416,7 +6416,11 @@ en:trending_search:more: '<a href="%{basePath}/admin/logs/search_logs">Search logs</a>'disabled: 'Trending search report is disabled. Enable <a href="%{basePath}/admin/site_settings/category/all_results?filter=log%20search%20queries">log search queries</a> to collect data.'- average_chart_label: Average+ average_chart_label: Showing averages, not totals+ sort_button: "Sort by %{column}"+ sort_button_current: "Sorted by %{column}, %{direction}"+ sort_ascending: "ascending"+ sort_descending: "descending"filters:file_extension:label: File extensiondiff --git a/frontend/discourse/admin/components/admin-report-table-header.gjs b/frontend/discourse/admin/components/admin-report-table-header.gjsindex 1103c8d73e7..ba9aca3a633 100644--- a/frontend/discourse/admin/components/admin-report-table-header.gjs+++ b/frontend/discourse/admin/components/admin-report-table-header.gjs@@ -1,43 +1,61 @@-/* eslint-disable ember/no-classic-components */-import Component from "@ember/component";+import Component from "@glimmer/component";import { htmlSafe } from "@ember/template";-import {- attributeBindings,- classNameBindings,- classNames,- tagName,-} from "@ember-decorators/component";import DButton from "discourse/components/d-button";-import discourseComputed from "discourse/lib/decorators";+import { i18n } from "discourse-i18n";-@tagName("th")-@classNames("admin-report-table-header")-@classNameBindings("label.mainProperty", "label.type", "isCurrentSort")-@attributeBindings("label.title:title")export default class AdminReportTableHeader extends Component {- @discourseComputed("currentSortLabel.sortProperty", "label.sortProperty")- isCurrentSort(currentSortField, labelSortField) {- return currentSortField === labelSortField;+ get isCurrentSort() {+ return (+ this.args.currentSortLabel?.sortProperty === this.args.label?.sortProperty+ );}- @discourseComputed("currentSortDirection")- sortIcon(currentSortDirection) {- return currentSortDirection === 1 ? "caret-up" : "caret-down";+ get sortIcon() {+ return this.args.currentSortDirection === 1 ? "caret-up" : "caret-down";}- <template>- {{#if this.showSortingUI}}- <DButton- @action={{this.sortByLabel}}- @icon={{this.sortIcon}}- class="sort-btn"- />- {{/if}}+ get sortButtonTitle() {+ const labelTitle = this.args.label?.title;+ if (this.isCurrentSort) {+ const direction =+ this.args.currentSortDirection === 1 ? "ascending" : "descending";+ return i18n("admin.dashboard.reports.sort_button_current", {+ column: labelTitle,+ direction: i18n(`admin.dashboard.reports.sort_${direction}`),+ });+ }+ return i18n("admin.dashboard.reports.sort_button", { column: labelTitle });+ }- {{#if this.label.htmlTitle}}- <span class="title">{{htmlSafe this.label.htmlTitle}}</span>- {{else}}- <span class="title">{{this.label.title}}</span>- {{/if}}+ get thClass() {+ const classes = ["admin-report-table-header"];+ if (this.args.label?.mainProperty) {+ classes.push(this.args.label.mainProperty);+ }+ if (this.args.label?.type) {+ classes.push(this.args.label.type);+ }+ if (this.isCurrentSort) {+ classes.push("is-current-sort");+ }+ return classes.join(" ");+ }++ <template>+ <th class={{this.thClass}} title={{@label.title}}>+ {{#if @showSortingUI}}+ <DButton+ @action={{@sortByLabel}}+ @icon={{this.sortIcon}}+ @translatedLabel={{@label.title}}+ @translatedTitle={{this.sortButtonTitle}}+ class="btn-primary btn-transparent sort-btn"+ />+ {{else if @label.htmlTitle}}+ <span class="title">{{htmlSafe @label.htmlTitle}}</span>+ {{else}}+ <span class="title">{{@label.title}}</span>+ {{/if}}+ </th></template>}diff --git a/frontend/discourse/tests/integration/components/admin-report-test.gjs b/frontend/discourse/tests/integration/components/admin-report-test.gjsindex 56013462a1e..b8a8ca641b5 100644--- a/frontend/discourse/tests/integration/components/admin-report-test.gjs+++ b/frontend/discourse/tests/integration/components/admin-report-test.gjs@@ -30,11 +30,11 @@ module("Integration | Component | admin-report", function (hooks) {);assert- .dom(".admin-report-table thead tr th:first-child .title")+ .dom(".admin-report-table thead tr th:first-child .sort-btn").hasText("Day", "has col headers");assert- .dom(".admin-report-table thead tr th:nth-child(2) .title")+ .dom(".admin-report-table thead tr th:nth-child(2) .sort-btn").hasText("Count", "has col headers");assert