@remit/ui 0.0.186 → 0.0.187

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.187",
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 && (