♻️ Use DS controls in the dashboard progress notification (#13294)

* 🐛 Show the hint of the dashboard progress notification

Restoring or deleting files from the trash showed the progress
notification with no text, and every update would mark it as slow:

- The dashboard passed its hints as :progress, but the progress events
  read :normal.
- update-progress read the threshold from :slow-progress-threshold,
  while initialize-progress stores it as :threshold, so the time check
  was always false.
- update-progress checked its params against the initialize schema,
  which requires :hints, so dev builds threw on every update.

Unit tests cover the initial hint and the healthy and slow updates.

AI-assisted-by: claude-opus-5-5

* ♻️ Use DS controls in the dashboard progress notification

The close button of the progress notification (restore or delete from
the trash) becomes a DS ghost icon button with a label and a top-left
tooltip, and its status icons move from the old icon set to the DS
icon*. The close column grows to the button, so the X stays where it
was.

A zero-tolerance visual test holds a restore open and captures the
notification at rest and with the close button on hover, then closes
it.

AI-assisted-by: claude-opus-5-5

* ♻️ Move the progress notification styles to the DS

progress.scss drops the refactor/ import: DS spacing, sizes, borders
and typography, the alert and modal aliases resolved to their DS
colors, and the notification z-index token (300 to 500).

The retry link takes body-small (line height 1.4 to 1.3); it only
shows on errors.

Removed (no use left in frontend/src): .progress-widget and
.close-icon.

AI-assisted-by: claude-opus-5-5

* ♻️ Use the action variant for the progress notification close

The ghost close button is 32px tall and made the notification 11px
taller. The action variant is 24px, so it grows only 3px, and the X
keeps its place with a 4px end margin.

AI-assisted-by: claude-opus-5-5
This commit is contained in:
Eva Marco 2026-11-27 12:09:13 +01:00 committed by GitHub
parent f29187aaec
commit c3ce46ed9a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 128 additions and 72 deletions

View File

@ -579,6 +579,42 @@ test.describe("Dashboard list controls", () => {
});
});
test.describe("Progress notification controls", () => {
test("Restore progress and close button", async ({ page }) => {
const shot = { maxDiffPixelRatio: 0, threshold: 0 };
await DashboardPage.mockConfigFlags(page, ["disable-onboarding"]);
const dashboardPage = new DashboardPage(page);
await dashboardPage.setupDashboardFull();
// Deleted files due in 2100, so the trash keeps them.
await dashboardPage.mockRPC(
"get-team-deleted-files?team-id=*",
"dashboard/get-team-deleted-files-pending.json",
);
await dashboardPage.mockRPC(
"get-projects?team-id=*",
"dashboard/get-projects-deleted.json",
);
// Never answer the restore, so the notification stays on screen.
await page.route(/restore-deleted-team-files/, () => {});
await dashboardPage.goToDeleted();
await page.getByRole("button", { name: "Restore All" }).click();
await page.getByRole("button", { name: "Continue" }).click();
const notification = page.locator(
"[class*='components_progress__progress-modal']",
);
await expect(notification).toBeVisible();
await page.mouse.move(10, 10);
await expect(notification).toHaveScreenshot(shot);
await notification.getByRole("button").hover();
await expect(notification).toHaveScreenshot(shot);
await notification.getByRole("button").click();
await expect(notification).toBeHidden();
});
});
test.describe("Team modals controls", () => {
const shot = { maxDiffPixelRatio: 0, threshold: 0 };

View File

@ -348,6 +348,14 @@
(def ^:private check-progress-params
(sm/check-fn schema:progress-params))
(def ^:private schema:progress-update-params
[:map {:title "ProgressUpdate"}
[:index ::sm/int]
[:total ::sm/int]])
(def ^:private check-progress-update-params
(sm/check-fn schema:progress-update-params))
(defn initialize-progress
[& {:keys [key index total hints slow-progress-threshold] :as params}]
@ -372,7 +380,7 @@
(defn update-progress
[{:keys [index total] :as params}]
(assert (check-progress-params params))
(assert (check-progress-update-params params))
(ptk/reify ::update-progress
ptk/UpdateEvent
@ -381,7 +389,7 @@
(fn [state]
(let [last-update (get state :last-update)
hints (get state :hints)
threshold (get state :slow-progress-threshold)
threshold (get state :threshold)
time-diff (ct/diff-ms last-update (ct/now))
healthy? (< time-diff threshold)

View File

@ -822,7 +822,7 @@
{:slow-progress-threshold
mconst/default-slow-progress-threshold
:total (count ids)
:hints {:progress progress-hint
:hints {:normal progress-hint
:slow slow-hint}}))
(->> stream
@ -942,7 +942,7 @@
{:slow-progress-threshold
mconst/default-slow-progress-threshold
:total (count ids)
:hints {:progress progress-hint
:hints {:normal progress-hint
:slow slow-hint}}))
(let [stream (->> (rp/cmd! ::sse/restore-deleted-team-files {:team-id team-id :ids ids})

View File

@ -13,20 +13,12 @@
[app.main.data.common :as dcm]
[app.main.refs :as refs]
[app.main.store :as st]
[app.main.ui.icons :as deprecated-icons]
[app.main.ui.ds.buttons.icon-button :refer [icon-button*]]
[app.main.ui.ds.foundations.assets.icon :as i :refer [icon*]]
[app.util.i18n :as i18n :refer [tr]]
[app.util.theme :as theme]
[rumext.v2 :as mf]))
(def ^:private neutral-icon
(deprecated-icons/icon-xref :msg-neutral (stl/css :icon)))
(def ^:private error-icon
(deprecated-icons/icon-xref :delete-text (stl/css :icon)))
(def ^:private close-icon
(deprecated-icons/icon-xref :close (stl/css :close-icon)))
(mf/defc progress-notification-widget*
[]
(let [state (mf/deref refs/progress)
@ -67,9 +59,8 @@
(when visible?
[:div {:class (stl/css-case :progress-modal true
:has-error error?)}
(if error?
error-icon
neutral-icon)
[:> icon* {:icon-id (if error? i/delete-text i/msg-neutral)
:class (stl/css :icon)}]
[:div {:class (stl/css :title)}
[:div {:class (stl/css :title-text)} hint]
@ -82,9 +73,12 @@
[:span {:class (stl/css :progress)}
(dm/str progress " / " total)])]
[:button {:class (stl/css :progress-close-button)
:on-click toggle-detail-visibility}
close-icon]
[:> icon-button* {:variant "action"
:aria-label (tr "labels.close")
:tooltip-class (stl/css :progress-close-button)
:tooltip-placement "top-left"
:on-click toggle-detail-visibility
:icon i/close}]
(when-not error?
[:svg {:class (stl/css :progress-bar)

View File

@ -4,66 +4,58 @@
//
// Copyright (c) KALEIDOS SUBSIDIARY SL
@use "refactor/common-refactor.scss" as deprecated;
@use "ds/_borders.scss" as *;
@use "ds/_sizes.scss" as *;
@use "ds/_utils.scss" as *;
@use "ds/typography.scss" as *;
// PROGRESS WIDGET
.progress-widget {
@include deprecated.flex-center;
width: deprecated.$s-28;
height: deprecated.$s-28;
}
// PROGRESS MODAL
.progress-modal {
--export-modal-bg-color: var(--alert-background-color-default);
--export-modal-fg-color: var(--alert-text-foreground-color-default);
--export-modal-icon-color: var(--alert-icon-foreground-color-default);
--export-modal-border-color: var(--alert-border-color-default);
--export-modal-bg-color: var(--color-background-primary);
--export-modal-fg-color: var(--color-foreground-primary);
--export-modal-icon-color: var(--color-foreground-primary);
--export-modal-border-color: var(--color-background-quaternary);
position: absolute;
right: deprecated.$s-16;
top: deprecated.$s-48;
inset-inline-end: var(--sp-l);
inset-block-start: px2rem(48);
display: grid;
grid-template-columns: deprecated.$s-24 1fr deprecated.$s-24;
grid-template-columns: $sz-24 1fr auto;
grid-template-areas:
"icon text close"
"bar bar bar";
gap: deprecated.$s-4 deprecated.$s-8;
padding-block-start: deprecated.$s-8;
gap: var(--sp-xs) var(--sp-s);
padding-block-start: var(--sp-s);
background-color: var(--export-modal-bg-color);
border: deprecated.$s-1 solid var(--export-modal-border-color);
border-radius: deprecated.$br-8;
z-index: deprecated.$z-index-modal;
border: $b-1 solid var(--export-modal-border-color);
border-radius: $br-8;
z-index: var(--z-index-notifications);
overflow: hidden;
}
.has-error {
--export-modal-bg-color: var(--alert-background-color-error);
--export-modal-fg-color: var(--alert-text-foreground-color-error);
--export-modal-icon-color: var(--alert-icon-foreground-color-error);
--export-modal-border-color: var(--alert-border-color-error);
--export-modal-bg-color: var(--color-background-error);
--export-modal-fg-color: var(--color-foreground-primary);
--export-modal-icon-color: var(--color-accent-error);
--export-modal-border-color: var(--color-accent-error);
grid-template-areas: "icon text close";
gap: deprecated.$s-8;
padding-block: deprecated.$s-8;
gap: var(--sp-s);
padding-block: var(--sp-s);
}
.icon {
@extend %button-icon;
grid-area: icon;
align-self: center;
margin-inline-start: deprecated.$s-8;
stroke: var(--export-modal-icon-color);
margin-inline-start: var(--sp-s);
color: var(--export-modal-icon-color);
}
.title {
@include deprecated.body-medium-typography;
@include use-typography("body-medium");
display: grid;
grid-template-columns: auto 1fr;
gap: deprecated.$s-8;
gap: var(--sp-s);
grid-area: text;
align-self: center;
padding: 0;
@ -72,39 +64,33 @@
}
.progress {
@include deprecated.body-medium-typography;
@include use-typography("body-medium");
padding-left: deprecated.$s-8;
padding-inline-start: var(--sp-s);
margin: 0;
align-self: center;
color: var(--modal-text-foreground-color);
color: var(--color-foreground-secondary);
}
.retry-btn {
@include deprecated.button-style;
@include deprecated.body-small-typography;
@include use-typography("body-small");
display: inline;
text-align: left;
color: var(--modal-link-foreground-color);
text-align: start;
color: var(--color-accent-primary);
margin: 0;
padding: 0;
border: none;
background: none;
cursor: pointer;
}
.progress-close-button {
@include deprecated.button-style;
padding: 0;
margin-inline-end: deprecated.$s-8;
}
.close-icon {
@extend %button-icon;
stroke: var(--export-modal-icon-color);
grid-area: close;
margin-inline-end: var(--sp-xs);
}
.progress-bar {
margin-top: 0;
margin-block-start: 0;
grid-area: bar;
}

View File

@ -207,3 +207,35 @@
(t/is (false? (get-in state [:team :permissions :can-edit])))
(t/is (false? (get-in state [:teams current-team-id :permissions :can-edit])))
(t/is (true? (get-in state [:teams other-team-id :permissions :can-edit])))))
;; --- Progress notification
(def ^:private progress-hints
{:normal (constantly "Restoring files…")
:slow (constantly "Restore unexpectedly slow")})
(defn- progress-state
[threshold]
(ptk/update (dcm/initialize-progress {:total 3
:slow-progress-threshold threshold
:hints progress-hints})
{}))
(t/deftest initialize-progress-shows-the-normal-hint
(let [progress (:progress (progress-state 60000))]
(t/is (= "Restoring files…" (:hint progress)))
(t/is (true? (:healthy progress)))
(t/is (= 0 (:progress progress)))))
(t/deftest update-progress-within-the-threshold-stays-healthy
(let [state (progress-state 60000)
progress (:progress (ptk/update (dcm/update-progress {:index 1 :total 3}) state))]
(t/is (= 1 (:progress progress)))
(t/is (true? (:healthy progress)))
(t/is (= "Restoring files…" (:hint progress)))))
(t/deftest update-progress-past-the-threshold-shows-the-slow-hint
(let [state (progress-state 0)
progress (:progress (ptk/update (dcm/update-progress {:index 1 :total 3}) state))]
(t/is (false? (:healthy progress)))
(t/is (= "Restore unexpectedly slow" (:hint progress)))))