@remit/ui 0.0.39 → 0.0.40

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.39",
3
+ "version": "0.0.40",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "src"
@@ -39,4 +39,27 @@ describe("AutoMovedBadge", () => {
39
39
  );
40
40
  assert.match(html, /Move back to Junk/);
41
41
  });
42
+
43
+ it("renders no filter link when filtersHref is omitted (classifier move)", () => {
44
+ const html = renderToString(
45
+ createElement(AutoMovedBadge, {
46
+ label: "Moved from Junk by Remit",
47
+ onUndo: () => undefined,
48
+ }),
49
+ );
50
+ assert.doesNotMatch(html, /Manage filter/);
51
+ assert.doesNotMatch(html, /settings\/filters/);
52
+ });
53
+
54
+ it("renders a Manage filter link to Settings when filtersHref is set", () => {
55
+ const html = renderToString(
56
+ createElement(AutoMovedBadge, {
57
+ label: "Moved from Inbox by Remit",
58
+ onUndo: () => undefined,
59
+ filtersHref: "/settings/filters",
60
+ }),
61
+ );
62
+ assert.match(html, /Manage filter/);
63
+ assert.match(html, /href="\/settings\/filters"/);
64
+ });
42
65
  });
@@ -34,6 +34,24 @@ export const WithoutUndoAction: Story = {
34
34
  args: { label: "Moved from Junk by Remit", size: "md" },
35
35
  };
36
36
 
37
+ export const FilterMoveWithManageLink: Story = {
38
+ args: {
39
+ label: "Moved from Inbox by Remit",
40
+ size: "md",
41
+ onUndo: () => alert("Undo"),
42
+ filtersHref: "/settings/filters",
43
+ },
44
+ };
45
+
46
+ export const FilterMoveListRow: Story = {
47
+ // The list row is icon + label only — the app gates the Manage link (and
48
+ // Undo) to the reading-view `md` size, so no `filtersHref` here.
49
+ args: {
50
+ label: "Moved from Inbox by Remit",
51
+ size: "sm",
52
+ },
53
+ };
54
+
37
55
  export const SideBySide: Story = {
38
56
  render: () => (
39
57
  <div className="flex flex-col items-start gap-3">
@@ -43,6 +61,12 @@ export const SideBySide: Story = {
43
61
  size="md"
44
62
  onUndo={() => undefined}
45
63
  />
64
+ <AutoMovedBadge
65
+ label="Moved from Inbox by Remit"
66
+ size="md"
67
+ onUndo={() => undefined}
68
+ filtersHref="/settings/filters"
69
+ />
46
70
  </div>
47
71
  ),
48
72
  };
@@ -13,21 +13,31 @@ export interface AutoMovedBadgeProps {
13
13
  */
14
14
  onUndo?: () => void;
15
15
  undoLabel?: string;
16
+ /**
17
+ * Settings › Filters link, present only for a standing-filter move: undo
18
+ * returns the message but never disables the filter, so the badge offers a
19
+ * way to reach the filter that keeps moving mail. Omit for a classifier move.
20
+ */
21
+ filtersHref?: string;
22
+ manageLabel?: string;
16
23
  className?: string;
17
24
  }
18
25
 
19
26
  /**
20
27
  * Unobtrusive indicator that Remit auto-moved this message, with an optional
21
- * inline one-click undo. Purely presentational the label text and whether
22
- * the move is still in effect (so the badge should render at all) are the
23
- * caller's responsibility; this component has no notion of placement/mailbox
24
- * state.
28
+ * inline one-click undo and, for a standing-filter move, a link to the filter
29
+ * in Settings. Purely presentational the label text, whether the move is
30
+ * still in effect (so the badge should render at all), and whether a filter
31
+ * link applies are the caller's responsibility; this component has no notion of
32
+ * placement/mailbox state.
25
33
  */
26
34
  export function AutoMovedBadge({
27
35
  label,
28
36
  size = "sm",
29
37
  onUndo,
30
38
  undoLabel = "Undo",
39
+ filtersHref,
40
+ manageLabel = "Manage filter",
31
41
  className,
32
42
  }: AutoMovedBadgeProps) {
33
43
  return (
@@ -52,6 +62,17 @@ export function AutoMovedBadge({
52
62
  {undoLabel}
53
63
  </button>
54
64
  )}
65
+ {filtersHref && (
66
+ <a
67
+ href={filtersHref}
68
+ onClick={(event) => {
69
+ event.stopPropagation();
70
+ }}
71
+ className="font-semibold underline decoration-dotted underline-offset-2 hover:decoration-solid"
72
+ >
73
+ {manageLabel}
74
+ </a>
75
+ )}
55
76
  </Badge>
56
77
  );
57
78
  }