@remit/ui 0.0.186 → 0.0.188

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remit/ui",
3
- "version": "0.0.186",
3
+ "version": "0.0.188",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "src"
@@ -165,7 +165,19 @@ const deleteFailedWithLabels: ThreadRowData = {
165
165
  labels: [{ labelId: "l1", name: "Receipts", color: "Blue" }],
166
166
  };
167
167
 
168
- const unsettled = [deleteFailed, deleteFailedWithLabels, read];
168
+ const moveFailed: ThreadRowData = {
169
+ id: "r-move-failed",
170
+ accountId: "a1",
171
+ fromName: "Wren Adeyemi",
172
+ fromEmail: "wren@example.com",
173
+ subject: "Q3 filing, countersigned",
174
+ snippet: "Filed here; Remit stopped trying to finish the move on the server.",
175
+ timeLabel: "Fri",
176
+ isRead: false,
177
+ settlement: "move_failed",
178
+ };
179
+
180
+ const unsettled = [deleteFailed, deleteFailedWithLabels, moveFailed, read];
169
181
 
170
182
  const labeled = [noLabel, oneLabel, twoLabels, severalLabels, longLabelName];
171
183
 
@@ -34,18 +34,28 @@ const compactRow = (settlement?: RowSettlement) =>
34
34
  }),
35
35
  );
36
36
 
37
- describe("a row whose delete gave up says so", () => {
37
+ describe("a row whose mutation gave up says so, and says which", () => {
38
38
  it("marks the row", () => {
39
39
  const html = row("delete_failed");
40
40
  assert.match(html, /data-settlement="delete_failed"/);
41
41
  assert.match(html, new RegExp(messageSettlementCopy.delete_failed.label));
42
42
  });
43
43
 
44
+ // Issue #1229: a move that handed back used to render the delete chip, so
45
+ // the row named an operation the user never asked to fail.
46
+ it("marks a move that gave up as a move, never as a delete", () => {
47
+ const html = row("move_failed");
48
+ assert.match(html, /data-settlement="move_failed"/);
49
+ assert.match(html, new RegExp(messageSettlementCopy.move_failed.label));
50
+ assert.doesNotMatch(html, /Not deleted/);
51
+ });
52
+
44
53
  it("carries the same mark in compact density", () => {
45
54
  assert.match(
46
55
  compactRow("delete_failed"),
47
56
  /data-settlement="delete_failed"/,
48
57
  );
58
+ assert.match(compactRow("move_failed"), /data-settlement="move_failed"/);
49
59
  });
50
60
 
51
61
  it("leaves every other row exactly as it was", () => {
@@ -73,6 +83,22 @@ describe("the reading-pane notice", () => {
73
83
  assert.match(html, /https:\/\/example\.test\/new-issue/);
74
84
  });
75
85
 
86
+ // The retry has to repeat the operation that failed. A move cannot: the
87
+ // destination the give-up discarded is on no row, so its way out is the
88
+ // caller's folder picker, passed in as the action.
89
+ it("states a move that failed and takes the caller's retry in place of a button", () => {
90
+ const html = renderToString(
91
+ createElement(MessageSettlementNotice, {
92
+ settlement: "move_failed",
93
+ action: createElement("button", { type: "button" }, "Move again"),
94
+ reportHref: "https://example.test/new-issue",
95
+ }),
96
+ );
97
+ assert.match(html, new RegExp(messageSettlementCopy.move_failed.title));
98
+ assert.match(html, /Move again/);
99
+ assert.doesNotMatch(html, /Delete again/);
100
+ });
101
+
76
102
  it("disables the retry while one is in flight rather than dropping it", () => {
77
103
  const html = renderToString(
78
104
  createElement(MessageSettlementNotice, {
@@ -16,15 +16,15 @@ const reportHref =
16
16
  "https://github.com/remit-mail/reader/issues/new?title=This+message+was+not+deleted";
17
17
 
18
18
  /**
19
- * The one unsettled state the wire can prove (issue #1002): a delete Remit
20
- * abandoned before it reached the server — most often because the Trash folder
21
- * the event named is gone — which handed the row back to the folder the server
22
- * still holds the message in.
19
+ * A mutation Remit gave up on (issue #1002), named by the row itself (#1229).
23
20
  *
24
- * It gets a real Retry, not a report-only dead end: abandoning puts `status`
25
- * back to `active`, so the ordinary delete endpoint accepts the row and
26
- * re-drives it. A move that gave up leaves exactly the fields a move mid-retry
27
- * leaves, so it gets no treatment at all — no chip, no notice, no promise.
21
+ * A delete gets a real Retry, not a report-only dead end: giving up puts
22
+ * `status` back to `active`, so the ordinary delete endpoint accepts the row
23
+ * and re-drives it. A move cannot retry that way — the destination the give-up
24
+ * discarded is recorded nowhere — so its way out is the same folder picker
25
+ * every other move goes through, passed in as `action`. Naming the wrong one
26
+ * is the defect this replaces: a move that handed back rendered the delete
27
+ * copy, under a button that deleted the message.
28
28
  */
29
29
  export const Notice: Story = {
30
30
  render: () => (
@@ -40,6 +40,15 @@ export const Notice: Story = {
40
40
  retryPending
41
41
  reportHref={reportHref}
42
42
  />
43
+ <MessageSettlementNotice
44
+ settlement="move_failed"
45
+ action={
46
+ <button type="button" className="font-medium text-accent">
47
+ Move again
48
+ </button>
49
+ }
50
+ reportHref={reportHref}
51
+ />
43
52
  </div>
44
53
  ),
45
54
  };
@@ -64,6 +73,7 @@ export const Badge: Story = {
64
73
  render: () => (
65
74
  <div className="flex items-center gap-2">
66
75
  <MessageSettlementBadge settlement="delete_failed" />
76
+ <MessageSettlementBadge settlement="move_failed" />
67
77
  </div>
68
78
  ),
69
79
  };
@@ -1,20 +1,20 @@
1
1
  import { CloudOff } from "lucide-react";
2
+ import type { ReactNode } from "react";
2
3
  import { cn } from "../lib/cn.js";
3
4
  import { Badge } from "./badge.js";
4
5
 
5
6
  /**
6
- * The one unsettled state a message row can prove from the wire: a delete Remit
7
- * abandoned before running it, which handed the row back to the folder the mail
8
- * server still holds the message in (`hasAbandonedDelete` in @remit/data-ports,
9
- * which enumerates what this can and cannot see).
7
+ * What a message row can prove from the wire about a mutation that gave up: the
8
+ * operation it gave up on, and nothing else. `abandonedMutationOf` in
9
+ * @remit/data-ports owns which values prove it and enumerates the give-ups it
10
+ * cannot see.
10
11
  *
11
- * A one-member union on purpose. A move that gave up leaves exactly the state a
12
- * move mid-retry leaves, so it is not derivable and gets no treatment here —
13
- * saying "Remit stopped retrying" over a push about to succeed would be a
14
- * louder lie than the silence this replaces. Adding a member is what a new
15
- * persisted signal would earn.
12
+ * One member per operation the user can watch fail, because naming the wrong
13
+ * one is worse than naming none: a move that handed back used to render the
14
+ * delete copy, under a button that deleted the message (issue #1229). A copy
15
+ * that gave up has no member — its row is `deleted`, so no listing carries it.
16
16
  */
17
- export type RowSettlement = "delete_failed";
17
+ export type RowSettlement = "delete_failed" | "move_failed";
18
18
 
19
19
  export const messageSettlementCopy = {
20
20
  delete_failed: {
@@ -23,6 +23,15 @@ export const messageSettlementCopy = {
23
23
  detail:
24
24
  "Remit removed it here first, then refused to finish the delete on the mail server — most often because the Trash folder it was headed for is not there any more. The message is back in this folder because that is where the server still has it.",
25
25
  retryLabel: "Delete again",
26
+ retryPendingLabel: "Deleting…",
27
+ },
28
+ move_failed: {
29
+ label: "Not moved",
30
+ title: "This message was not moved",
31
+ detail:
32
+ "Remit filed it here first, then could not finish the move on the mail server and stopped trying. The message is back in this folder because that is where the server still has it. The folder you picked is not recorded, so moving it again means choosing one.",
33
+ retryLabel: "Move again",
34
+ retryPendingLabel: "Moving…",
26
35
  },
27
36
  } as const;
28
37
 
@@ -57,11 +66,19 @@ export function MessageSettlementBadge({
57
66
  export interface MessageSettlementNoticeProps {
58
67
  settlement: RowSettlement;
59
68
  /**
60
- * Re-drives the delete through the ordinary delete endpoint, which accepts
61
- * this row: the give-up put `status` back to `active`, so the placement
62
- * guard passes it through. Omit only where no delete action is available.
69
+ * Repeats the operation that failed, and only that one. For a delete that
70
+ * is the ordinary delete endpoint, which accepts this row: the give-up put
71
+ * `status` back to `active`, so the placement guard passes it through.
72
+ * Omit where the retry needs input from the user, and pass {@link action}
73
+ * instead.
63
74
  */
64
75
  onRetry?: () => void;
76
+ /**
77
+ * The retry, where repeating the operation needs the user to say more than
78
+ * "again" — a move has to be told which folder, because the destination the
79
+ * give-up discarded is not on the row. Rendered in place of the button.
80
+ */
81
+ action?: ReactNode;
65
82
  retryPending?: boolean;
66
83
  /** Prefilled issue link, for a retry that keeps failing. */
67
84
  reportHref?: string;
@@ -69,12 +86,14 @@ export interface MessageSettlementNoticeProps {
69
86
  }
70
87
 
71
88
  /**
72
- * Reading-pane notice for a delete that gave up: what failed, where the message
73
- * actually is, and the two ways out — delete it again, or report it.
89
+ * Reading-pane notice for a mutation that gave up: which operation failed,
90
+ * where the message actually is, and the two ways out — repeat that same
91
+ * operation, or report it.
74
92
  */
75
93
  export function MessageSettlementNotice({
76
94
  settlement,
77
95
  onRetry,
96
+ action,
78
97
  retryPending,
79
98
  reportHref,
80
99
  className,
@@ -95,6 +114,7 @@ export function MessageSettlementNotice({
95
114
  <p className="font-medium text-danger">{copy.title}</p>
96
115
  <p className="mt-1 break-words text-fg-muted">{copy.detail}</p>
97
116
  <div className="mt-1 flex flex-wrap items-center gap-3">
117
+ {action}
98
118
  {onRetry && (
99
119
  <button
100
120
  type="button"
@@ -102,7 +122,7 @@ export function MessageSettlementNotice({
102
122
  disabled={retryPending}
103
123
  className="font-medium text-accent hover:underline disabled:opacity-50"
104
124
  >
105
- {retryPending ? "Deleting…" : copy.retryLabel}
125
+ {retryPending ? copy.retryPendingLabel : copy.retryLabel}
106
126
  </button>
107
127
  )}
108
128
  {reportHref && (
@@ -308,47 +308,6 @@ describe("NavSidebar", () => {
308
308
  });
309
309
  });
310
310
 
311
- describe("NavSidebar saved searches", () => {
312
- it("omits the group when there are no saved searches and no active query", () => {
313
- const html = renderToString(
314
- createElement(NavSidebar, {
315
- accounts,
316
- selectedNavId: "brief",
317
- onSelectNav: () => undefined,
318
- }),
319
- );
320
- assert.doesNotMatch(html, /Saved searches/);
321
- });
322
-
323
- it("renders every saved search", () => {
324
- const html = renderToString(
325
- createElement(NavSidebar, {
326
- accounts,
327
- selectedNavId: "brief",
328
- onSelectNav: () => undefined,
329
- savedSearches: ["from:alice", "has:attachment invoice"],
330
- }),
331
- );
332
- assert.match(html, /Saved searches/);
333
- assert.match(html, /from:alice/);
334
- assert.match(html, /has:attachment invoice/);
335
- });
336
-
337
- it("shows a save row for an active, unsaved query", () => {
338
- const html = renderToString(
339
- createElement(NavSidebar, {
340
- accounts,
341
- selectedNavId: "brief",
342
- onSelectNav: () => undefined,
343
- saveableQuery: "from:dhl",
344
- }),
345
- );
346
- assert.match(html, /Saved searches/);
347
- assert.match(html, /Save/);
348
- assert.match(html, /from:dhl/);
349
- });
350
- });
351
-
352
311
  describe("NavSidebar collapse persistence", () => {
353
312
  afterEach(() => {
354
313
  Reflect.deleteProperty(globalThis, "localStorage");
@@ -185,21 +185,6 @@ export const LoadError: Story = {
185
185
  },
186
186
  };
187
187
 
188
- /**
189
- * The reserved "Saved searches" group (#428 follow-up): saved queries plus a
190
- * "Save «query»" row when the active search isn't saved yet.
191
- */
192
- export const WithSavedSearches: Story = {
193
- args: {
194
- selectedNavId: "personal-inbox",
195
- savedSearches: ["from:alice has:attachment", "account:work is:unread"],
196
- saveableQuery: "in:archive invoice",
197
- onSelectSavedSearch: () => undefined,
198
- onRemoveSavedSearch: () => undefined,
199
- onSaveCurrentSearch: () => undefined,
200
- },
201
- };
202
-
203
188
  /** Each nav row is a real anchor: the linkComponent renders <a href>. */
204
189
  export const AsLinks: Story = {
205
190
  args: {
@@ -3,7 +3,6 @@ import {
3
3
  AlertOctagon,
4
4
  Archive,
5
5
  BellOff,
6
- BookmarkPlus,
7
6
  CalendarDays,
8
7
  ChevronDown,
9
8
  ChevronRight,
@@ -11,12 +10,10 @@ import {
11
10
  Folder,
12
11
  Inbox,
13
12
  Mails,
14
- Search,
15
13
  Send,
16
14
  Sparkles,
17
15
  Star,
18
16
  Trash2,
19
- X,
20
17
  } from "lucide-react";
21
18
  import type { ReactNode } from "react";
22
19
  import { useRef, useState } from "react";
@@ -231,104 +228,6 @@ export function writeOpen(prefix: string, id: string, open: boolean): void {
231
228
  export const NAV_FOLDER_OPEN_KEY = FOLDER_OPEN_KEY;
232
229
  export const NAV_ACCOUNT_OPEN_KEY = ACCOUNT_OPEN_KEY;
233
230
 
234
- /**
235
- * One row in the "Saved searches" group: a plain query string (local-only MVP
236
- * — no separate label, see doc/design/flows/06-search.md). Hover reveals a
237
- * remove control, mirroring `SearchTokenChip`'s dismiss affordance.
238
- */
239
- function SavedSearchRow({
240
- query,
241
- onSelect,
242
- onRemove,
243
- }: {
244
- query: string;
245
- onSelect?: () => void;
246
- onRemove?: () => void;
247
- }) {
248
- return (
249
- <div className="group flex w-full items-center gap-1 rounded-md pr-1 hover:bg-surface">
250
- <button
251
- type="button"
252
- onClick={onSelect}
253
- className={cn(
254
- "flex min-w-0 flex-1 items-center gap-2 px-2 py-1 text-left text-sm text-fg-muted transition-colors hover:text-fg",
255
- FOCUS_RING,
256
- )}
257
- >
258
- <Search className="size-4 shrink-0 text-fg-subtle" />
259
- <span className="min-w-0 flex-1 truncate">{query}</span>
260
- </button>
261
- {onRemove && (
262
- <button
263
- type="button"
264
- onClick={onRemove}
265
- aria-label={`Remove saved search: ${query}`}
266
- className={cn(
267
- "shrink-0 rounded-full p-1 text-fg-subtle opacity-0 transition-opacity hover:bg-surface-sunken hover:text-fg group-hover:opacity-100 focus-visible:opacity-100",
268
- FOCUS_RING,
269
- )}
270
- >
271
- <X className="size-3.5" />
272
- </button>
273
- )}
274
- </div>
275
- );
276
- }
277
-
278
- /**
279
- * The reserved "Saved searches" group (#428 follow-up): a "Save «query»" row
280
- * when the active search isn't saved yet, then every saved query as a
281
- * removable row. Renders nothing when there is neither an active query to
282
- * save nor any saved searches — an always-empty group would just be noise.
283
- */
284
- function SavedSearchesGroup({
285
- savedSearches,
286
- saveableQuery,
287
- onSelectSavedSearch,
288
- onRemoveSavedSearch,
289
- onSaveCurrentSearch,
290
- }: {
291
- savedSearches: string[];
292
- saveableQuery?: string;
293
- onSelectSavedSearch?: (query: string) => void;
294
- onRemoveSavedSearch?: (query: string) => void;
295
- onSaveCurrentSearch?: () => void;
296
- }) {
297
- if (savedSearches.length === 0 && !saveableQuery) return null;
298
- return (
299
- <div className="mt-3">
300
- <div className="px-2 pb-1 text-2xs font-semibold uppercase tracking-wider text-fg-subtle">
301
- Saved searches
302
- </div>
303
- {saveableQuery && (
304
- <button
305
- type="button"
306
- onClick={onSaveCurrentSearch}
307
- className={cn(
308
- "flex w-full items-center gap-2 rounded-md px-2 py-1 text-left text-sm text-accent transition-colors hover:bg-surface",
309
- FOCUS_RING,
310
- )}
311
- >
312
- <BookmarkPlus className="size-4 shrink-0" />
313
- <span className="min-w-0 flex-1 truncate">
314
- Save &ldquo;{saveableQuery}&rdquo;
315
- </span>
316
- </button>
317
- )}
318
- {savedSearches.map((query) => (
319
- <SavedSearchRow
320
- key={query}
321
- query={query}
322
- onSelect={() => onSelectSavedSearch?.(query)}
323
- onRemove={
324
- onRemoveSavedSearch ? () => onRemoveSavedSearch(query) : undefined
325
- }
326
- />
327
- ))}
328
- </div>
329
- );
330
- }
331
-
332
231
  function AccountNav({
333
232
  account,
334
233
  selectedNavId,
@@ -565,16 +464,6 @@ export interface NavSidebarProps
565
464
  * that leads nowhere.
566
465
  */
567
466
  calendarNav?: "hidden" | "shown";
568
- /** Every saved query, most recently saved first. See `SavedSearchesGroup`. */
569
- savedSearches?: string[];
570
- /**
571
- * The active search query, when it's non-empty and not already saved — shows
572
- * the "Save «query»" row. Omit (or pass an already-saved query) to hide it.
573
- */
574
- saveableQuery?: string;
575
- onSelectSavedSearch?: (query: string) => void;
576
- onRemoveSavedSearch?: (query: string) => void;
577
- onSaveCurrentSearch?: () => void;
578
467
  }
579
468
 
580
469
  export function NavSidebar({
@@ -585,11 +474,6 @@ export function NavSidebar({
585
474
  variant = "desktop",
586
475
  linkComponent,
587
476
  calendarNav = "hidden",
588
- savedSearches = [],
589
- saveableQuery,
590
- onSelectSavedSearch,
591
- onRemoveSavedSearch,
592
- onSaveCurrentSearch,
593
477
  }: NavSidebarProps) {
594
478
  const containerRef = useRef<HTMLElement>(null);
595
479
  useRovingFocus({ containerRef, itemSelector: NAV_ITEM_SELECTOR });
@@ -634,14 +518,6 @@ export function NavSidebar({
634
518
  onClick={() => onSelectNav?.("flagged")}
635
519
  />
636
520
 
637
- <SavedSearchesGroup
638
- savedSearches={savedSearches}
639
- saveableQuery={saveableQuery}
640
- onSelectSavedSearch={onSelectSavedSearch}
641
- onRemoveSavedSearch={onRemoveSavedSearch}
642
- onSaveCurrentSearch={onSaveCurrentSearch}
643
- />
644
-
645
521
  {accounts.length === 0 ? (
646
522
  <div className="px-2 py-4 text-center text-sm text-fg-muted">
647
523
  No accounts configured