@remit/ui 0.0.205 → 0.0.206

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.205",
3
+ "version": "0.0.206",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "src"
@@ -188,6 +188,8 @@ export interface NavMailbox {
188
188
  * localized leaf name still reveals where it lives. Defaults to `name`.
189
189
  */
190
190
  fullPath?: string;
191
+ /** Present when the last change to this folder failed: what went wrong, in words. */
192
+ failure?: string;
191
193
  }
192
194
 
193
195
  /** Per-account mailbox-load status, so the nav can show loading/error inline. */
@@ -175,6 +175,31 @@ export const JustTheInbox: Story = {
175
175
  ),
176
176
  };
177
177
 
178
+ /** A folder the mail server refused to delete says why, on its own row. */
179
+ export const RefusedDelete: Story = {
180
+ name: "A delete the mail server refused",
181
+ render: () => (
182
+ <Frame>
183
+ <FolderManager
184
+ folders={[
185
+ folders[0] as ManagedFolder,
186
+ {
187
+ id: "mbx-locked",
188
+ label: "Locked",
189
+ path: "Locked",
190
+ failure:
191
+ "The mail server refused the last change: Permission denied",
192
+ },
193
+ folders[11] as ManagedFolder,
194
+ ]}
195
+ onCreateFolder={createFolder}
196
+ onRename={() => {}}
197
+ onDelete={() => {}}
198
+ />
199
+ </Frame>
200
+ ),
201
+ };
202
+
178
203
  /** The surface as it sits on a phone: full width, one branch open at a time. */
179
204
  export const Phone: Story = {
180
205
  name: "Phone",
@@ -8,6 +8,8 @@ import {
8
8
  export interface ManagedFolder extends FolderTreeNode {
9
9
  /** Why this folder can't be deleted; absent means it can. */
10
10
  deleteBlockedReason?: string;
11
+ /** Present when the last change to this folder failed: what went wrong, in words. */
12
+ failure?: string;
11
13
  }
12
14
 
13
15
  export interface FolderManagerLabels extends FolderTreePickerLabels {
@@ -58,6 +60,7 @@ export const FolderManager = ({
58
60
  optionLabel: (folder) => folder.label,
59
61
  ...labels,
60
62
  }}
63
+ rowFailure={(folder) => byId.get(folder.id)?.failure}
61
64
  rowActions={(folder) => {
62
65
  const managed = byId.get(folder.id);
63
66
  if (!managed) return null;
@@ -16,6 +16,12 @@ const render = (props: Partial<FolderRowProps>) =>
16
16
  );
17
17
 
18
18
  describe("FolderRow", () => {
19
+ it("shows and announces why the last change to the folder failed", () => {
20
+ const html = render({ failure: "Permission denied" });
21
+ assert.match(html, />Permission denied</);
22
+ assert.match(html, /aria-label="Move to Travel — Permission denied"/);
23
+ });
24
+
19
25
  it("is a tree item that carries its nesting and its label", () => {
20
26
  const html = render({ depth: 2 });
21
27
  assert.match(html, /<button[^>]*role="treeitem"/);
@@ -34,6 +34,22 @@ export const Closed: Story = {
34
34
  ),
35
35
  };
36
36
 
37
+ export const Failed: Story = {
38
+ name: "The last change was refused",
39
+ render: () => (
40
+ <List>
41
+ <FolderRow
42
+ label="Locked"
43
+ depth={0}
44
+ expanded={false}
45
+ ariaLabel="Locked"
46
+ failure="The mail server refused the last change: Permission denied"
47
+ tabIndex={0}
48
+ />
49
+ </List>
50
+ ),
51
+ };
52
+
37
53
  export const Open: Story = {
38
54
  name: "Open, with its children indented under it",
39
55
  render: () => (
@@ -1,4 +1,4 @@
1
- import { Check, ChevronRight, Folder } from "lucide-react";
1
+ import { AlertCircle, Check, ChevronRight, Folder } from "lucide-react";
2
2
  import type { ReactNode, Ref } from "react";
3
3
  import { cn } from "../lib/cn.js";
4
4
 
@@ -56,6 +56,8 @@ export interface FolderRowProps {
56
56
  * in there rather than relying on this.
57
57
  */
58
58
  messageCount?: number;
59
+ /** Present when the last change to this folder failed: what went wrong, in words. */
60
+ failure?: string;
59
61
  /** A hairline under the label, drawn for every row but the last. */
60
62
  separated?: boolean;
61
63
  /**
@@ -84,6 +86,7 @@ export const FolderRow = ({
84
86
  current = false,
85
87
  currentTag,
86
88
  messageCount,
89
+ failure,
87
90
  separated = false,
88
91
  actions,
89
92
  tabIndex,
@@ -109,6 +112,18 @@ export const FolderRow = ({
109
112
  {messageCount} {messageCount === 1 ? "msg" : "msgs"}
110
113
  </span>
111
114
  );
115
+ const name = (
116
+ <span className="min-w-0 flex-1">
117
+ <span className="block truncate">{label}</span>
118
+ {failure && (
119
+ <span className="flex items-center gap-1 text-2xs text-danger">
120
+ <AlertCircle className="size-3 shrink-0" aria-hidden="true" />
121
+ <span className="truncate">{failure}</span>
122
+ </span>
123
+ )}
124
+ </span>
125
+ );
126
+ const announced = failure ? `${ariaLabel} — ${failure}` : ariaLabel;
112
127
  if (context) {
113
128
  return (
114
129
  <div className="relative flex items-center">
@@ -118,13 +133,13 @@ export const FolderRow = ({
118
133
  aria-level={depth + 1}
119
134
  aria-selected={false}
120
135
  aria-expanded={expanded}
121
- aria-label={ariaLabel}
136
+ aria-label={announced}
122
137
  className={cn(FOLDER_ROW_BASE, "opacity-60")}
123
138
  >
124
139
  <FolderRowIndent depth={depth} />
125
140
  {chevron}
126
141
  {icon}
127
- <span className="min-w-0 flex-1 truncate">{label}</span>
142
+ {name}
128
143
  {count}
129
144
  </div>
130
145
  {actions}
@@ -142,7 +157,7 @@ export const FolderRow = ({
142
157
  aria-selected={selected}
143
158
  aria-expanded={expanded}
144
159
  aria-current={current ? "true" : undefined}
145
- aria-label={ariaLabel}
160
+ aria-label={announced}
146
161
  tabIndex={tabIndex}
147
162
  onClick={onActivate}
148
163
  onFocus={onFocus}
@@ -155,7 +170,7 @@ export const FolderRow = ({
155
170
  <FolderRowIndent depth={depth} />
156
171
  {chevron}
157
172
  {icon}
158
- <span className="min-w-0 flex-1 truncate">{label}</span>
173
+ {name}
159
174
  {count}
160
175
  {current && currentTag && (
161
176
  <span className="shrink-0 text-xs text-fg-muted">{currentTag}</span>
@@ -87,6 +87,8 @@ export interface FolderTreePickerProps {
87
87
  onSelect?: (folderId: string) => void;
88
88
  /** Controls beside each row, for a surface that acts on folders themselves. */
89
89
  rowActions?: (folder: FolderTreeNode) => ReactNode;
90
+ /** What went wrong with each folder whose last change failed. */
91
+ rowFailure?: (folder: FolderTreeNode) => string | undefined;
90
92
  /**
91
93
  * Creating a folder is an IMAP mutation, so this resolves only once the mail
92
94
  * server confirms the folder (docs/architecture/imap-mutations.md). The form
@@ -149,6 +151,7 @@ export const FolderTreePicker = ({
149
151
  selectedId,
150
152
  onSelect,
151
153
  rowActions,
154
+ rowFailure,
152
155
  onCreateFolder,
153
156
  onCancel,
154
157
  delimiter = "/",
@@ -414,6 +417,7 @@ export const FolderTreePicker = ({
414
417
  messageCount={folder.messageCount}
415
418
  selected={selectable && folder.id === selectedId}
416
419
  separated={separated}
420
+ failure={rowFailure?.(folder)}
417
421
  actions={rowActions?.(folder)}
418
422
  ariaLabel={rowAriaLabel(row)}
419
423
  tabIndex={index === focusedIndex ? 0 : -1}
@@ -95,6 +95,30 @@ describe("NavSidebar", () => {
95
95
  assert.match(html, /Travel/);
96
96
  });
97
97
 
98
+ it("marks a folder whose last change failed and names the reason", () => {
99
+ const html = renderToString(
100
+ createElement(NavSidebar, {
101
+ accounts: [
102
+ {
103
+ ...(accounts[0] as NavAccount),
104
+ mailboxes: [
105
+ {
106
+ id: "personal-locked",
107
+ name: "Locked",
108
+ fullPath: "Locked",
109
+ failure: "Permission denied",
110
+ },
111
+ ],
112
+ },
113
+ ],
114
+ selectedNavId: "personal-inbox",
115
+ onSelectNav: () => undefined,
116
+ }),
117
+ );
118
+ assert.match(html, /aria-label="Locked — Permission denied"/);
119
+ assert.match(html, /title="Locked — Permission denied"/);
120
+ });
121
+
98
122
  it("gives the selected item its active accent styling", () => {
99
123
  const html = renderToString(
100
124
  createElement(NavSidebar, {
@@ -139,6 +139,27 @@ const hostnetAccount: NavAccount = {
139
139
  ],
140
140
  };
141
141
 
142
+ export const RefusedFolderChange: Story = {
143
+ args: {
144
+ accounts: [
145
+ {
146
+ ...hostnetAccount,
147
+ mailboxes: [
148
+ ...hostnetAccount.mailboxes,
149
+ {
150
+ id: "hn-locked",
151
+ name: "Locked",
152
+ fullPath: "INBOX/Locked",
153
+ failure:
154
+ "The mail server refused the last change: Permission denied",
155
+ },
156
+ ],
157
+ },
158
+ ],
159
+ selectedNavId: "hn-inbox",
160
+ },
161
+ };
162
+
142
163
  export const Hostnet: Story = {
143
164
  args: {
144
165
  accounts: [hostnetAccount],
@@ -65,11 +65,13 @@ function NavItemInner({
65
65
  label,
66
66
  count,
67
67
  active,
68
+ failure,
68
69
  }: {
69
70
  icon?: ReactNode;
70
71
  label: string;
71
72
  count?: number;
72
73
  active?: boolean;
74
+ failure?: string;
73
75
  }) {
74
76
  return (
75
77
  <>
@@ -84,6 +86,12 @@ function NavItemInner({
84
86
  </span>
85
87
  )}
86
88
  <span className="flex-1 truncate">{label}</span>
89
+ {failure && (
90
+ <AlertCircle
91
+ className="size-3.5 shrink-0 text-danger"
92
+ aria-hidden="true"
93
+ />
94
+ )}
87
95
  {count != null && count > 0 && (
88
96
  <span
89
97
  className={cn(
@@ -114,11 +122,13 @@ function NavItem({
114
122
  linkComponent,
115
123
  ariaLabel,
116
124
  title,
125
+ failure,
117
126
  onClick,
118
127
  }: {
119
128
  icon?: ReactNode;
120
129
  label: string;
121
130
  count?: number;
131
+ failure?: string;
122
132
  active?: boolean;
123
133
  dimmed?: boolean;
124
134
  indent?: boolean;
@@ -130,15 +140,24 @@ function NavItem({
130
140
  }) {
131
141
  const className = navItemClassName({ active, dimmed, indent });
132
142
  const inner = (
133
- <NavItemInner icon={icon} label={label} count={count} active={active} />
143
+ <NavItemInner
144
+ icon={icon}
145
+ label={label}
146
+ count={count}
147
+ active={active}
148
+ failure={failure}
149
+ />
134
150
  );
151
+ const name = ariaLabel ?? label;
152
+ const announced = failure ? `${name} — ${failure}` : name;
153
+ const tooltip = failure ? `${title ?? label} — ${failure}` : title;
135
154
 
136
155
  if (navId && linkComponent) {
137
156
  return linkComponent({
138
157
  navId,
139
158
  className,
140
- ariaLabel: ariaLabel ?? label,
141
- title,
159
+ ariaLabel: announced,
160
+ title: tooltip,
142
161
  onClick,
143
162
  children: inner,
144
163
  });
@@ -149,8 +168,8 @@ function NavItem({
149
168
  type="button"
150
169
  onClick={onClick}
151
170
  className={className}
152
- aria-label={ariaLabel}
153
- title={title}
171
+ aria-label={failure ? announced : ariaLabel}
172
+ title={tooltip}
154
173
  >
155
174
  {inner}
156
175
  </button>
@@ -365,6 +384,7 @@ function AccountNav({
365
384
  label={mb.name}
366
385
  ariaLabel={mb.name}
367
386
  title={mb.fullPath ?? mb.name}
387
+ failure={mb.failure}
368
388
  count={mb.unseen}
369
389
  active={selectedNavId === mb.id}
370
390
  dimmed={account.muted}
@@ -422,6 +442,7 @@ function AccountNav({
422
442
  label={mb.name}
423
443
  ariaLabel={mb.name}
424
444
  title={mb.fullPath ?? mb.name}
445
+ failure={mb.failure}
425
446
  count={mb.unseen}
426
447
  active={selectedNavId === mb.id}
427
448
  dimmed={account.muted}