@remit/ui 0.0.166 → 0.0.168
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 +1 -1
- package/src/components/compose-quote-missing-banner.tsx +36 -0
- package/src/components/role-appointment-list.render.test.ts +51 -1
- package/src/components/role-appointment-list.stories.tsx +12 -6
- package/src/components/role-appointment-list.tsx +17 -14
- package/src/components/self-update-section.tsx +51 -16
- package/src/components/self-update.render.test.ts +14 -0
- package/src/index.ts +8 -0
package/package.json
CHANGED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Banner } from "./banner.js";
|
|
2
|
+
|
|
3
|
+
/** Which of the two composers is looking at a source it cannot quote. */
|
|
4
|
+
export type ComposeQuoteMode = "reply" | "forward";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The source has no text or html part — it is attachments and nothing else.
|
|
8
|
+
*
|
|
9
|
+
* A forward of one has nothing of the original to carry: the composer sends a
|
|
10
|
+
* text body and an html body, and no attachments, so the message would arrive
|
|
11
|
+
* holding only what the sender typed. Send refuses with these words. A reply
|
|
12
|
+
* still carries the answer and the thread it belongs to, so it goes out and
|
|
13
|
+
* these words say the original is not quoted in it. See #1030.
|
|
14
|
+
*/
|
|
15
|
+
export const NO_QUOTABLE_BODY_FORWARD_MESSAGE =
|
|
16
|
+
"This message is attachments only, and attachments aren't forwarded — a forward would arrive with nothing of the original in it.";
|
|
17
|
+
|
|
18
|
+
export const NO_QUOTABLE_BODY_REPLY_MESSAGE =
|
|
19
|
+
"This message is attachments only, so there's nothing to quote and your reply goes out without the original.";
|
|
20
|
+
|
|
21
|
+
export const composeQuoteMissingMessage = (mode: ComposeQuoteMode): string =>
|
|
22
|
+
mode === "forward"
|
|
23
|
+
? NO_QUOTABLE_BODY_FORWARD_MESSAGE
|
|
24
|
+
: NO_QUOTABLE_BODY_REPLY_MESSAGE;
|
|
25
|
+
|
|
26
|
+
export interface ComposeQuoteMissingBannerProps {
|
|
27
|
+
mode: ComposeQuoteMode;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const ComposeQuoteMissingBanner = ({
|
|
31
|
+
mode,
|
|
32
|
+
}: ComposeQuoteMissingBannerProps) => (
|
|
33
|
+
<Banner tone="warning" data-testid="compose-quote-missing">
|
|
34
|
+
<span>{composeQuoteMissingMessage(mode)}</span>
|
|
35
|
+
</Banner>
|
|
36
|
+
);
|
|
@@ -58,6 +58,21 @@ function render(
|
|
|
58
58
|
);
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
function picker(html: string, roleLabel: string): string {
|
|
62
|
+
const start = html.indexOf(`aria-label="Folder for ${roleLabel}"`);
|
|
63
|
+
assert.ok(start >= 0, `${roleLabel} has a picker`);
|
|
64
|
+
return html.slice(start, html.indexOf("</select>", start));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Option texts a user could choose that would leave the role unfilled. */
|
|
68
|
+
function clearingOptions(markup: string): string[] {
|
|
69
|
+
return [...markup.matchAll(/<option([^>]*)>([^<]*)</g)]
|
|
70
|
+
.filter(
|
|
71
|
+
([, attrs]) => attrs.includes('value=""') && !attrs.includes("disabled"),
|
|
72
|
+
)
|
|
73
|
+
.map(([, , text]) => text);
|
|
74
|
+
}
|
|
75
|
+
|
|
61
76
|
describe("RoleAppointmentList", () => {
|
|
62
77
|
it("titles the section with the account email", () => {
|
|
63
78
|
const html = render({ inbox: appointed("mb-inbox") });
|
|
@@ -83,7 +98,6 @@ describe("RoleAppointmentList", () => {
|
|
|
83
98
|
const html = render({});
|
|
84
99
|
assert.match(html, /Concepten · 340 msgs/);
|
|
85
100
|
assert.match(html, /Drafts · 0 msgs/);
|
|
86
|
-
assert.match(html, /None/);
|
|
87
101
|
});
|
|
88
102
|
|
|
89
103
|
it("shows the appointed folder's path and count under the role", () => {
|
|
@@ -287,3 +301,39 @@ describe("RoleAppointmentList — the server’s own delimiter (#877)", () => {
|
|
|
287
301
|
assert.doesNotMatch(other, />INBOX.Projects.Nieuwsbrieven</);
|
|
288
302
|
});
|
|
289
303
|
});
|
|
304
|
+
|
|
305
|
+
describe("a canonical role cannot be unset (#873)", () => {
|
|
306
|
+
it("offers no choice that clears an appointed role", () => {
|
|
307
|
+
const drafts = picker(
|
|
308
|
+
render({ drafts: appointed("mb-concepten") }),
|
|
309
|
+
"Drafts",
|
|
310
|
+
);
|
|
311
|
+
assert.deepEqual(clearingOptions(drafts), []);
|
|
312
|
+
assert.doesNotMatch(drafts, />None</);
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
it("offers no choice that clears an unfilled role either", () => {
|
|
316
|
+
const archive = picker(
|
|
317
|
+
render({ archive: { mailboxId: null, source: "None" } }),
|
|
318
|
+
"Archive",
|
|
319
|
+
);
|
|
320
|
+
assert.deepEqual(clearingOptions(archive), []);
|
|
321
|
+
assert.doesNotMatch(archive, />None</);
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
it("names the unfilled picker with a placeholder nobody can pick", () => {
|
|
325
|
+
const archive = picker(
|
|
326
|
+
render({ archive: { mailboxId: null, source: "None" } }),
|
|
327
|
+
"Archive",
|
|
328
|
+
);
|
|
329
|
+
assert.match(archive, /<option[^>]*disabled[^>]*>Choose a folder</);
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
it("drops the placeholder once a folder fills the role", () => {
|
|
333
|
+
const drafts = picker(
|
|
334
|
+
render({ drafts: appointed("mb-concepten") }),
|
|
335
|
+
"Drafts",
|
|
336
|
+
);
|
|
337
|
+
assert.doesNotMatch(drafts, /Choose a folder/);
|
|
338
|
+
});
|
|
339
|
+
});
|
|
@@ -99,12 +99,10 @@ function Harness({
|
|
|
99
99
|
const [appointments, setAppointments] = useState(initial);
|
|
100
100
|
const [displayNames, setDisplayNames] = useState<Record<string, string>>({});
|
|
101
101
|
|
|
102
|
-
const handleAppoint = (role: FolderRole, mailboxId: string
|
|
102
|
+
const handleAppoint = (role: FolderRole, mailboxId: string) => {
|
|
103
103
|
setAppointments((prev) => ({
|
|
104
104
|
...prev,
|
|
105
|
-
[role]: mailboxId
|
|
106
|
-
? { mailboxId, source: "Appointed" }
|
|
107
|
-
: { mailboxId: null, source: "None" },
|
|
105
|
+
[role]: { mailboxId, source: "Appointed" },
|
|
108
106
|
}));
|
|
109
107
|
};
|
|
110
108
|
|
|
@@ -158,7 +156,11 @@ export const ProposedDefaults: Story = {
|
|
|
158
156
|
},
|
|
159
157
|
};
|
|
160
158
|
|
|
161
|
-
/**
|
|
159
|
+
/**
|
|
160
|
+
* `Appointed` — a person decided, and the row says so. Every picker offers
|
|
161
|
+
* folders only: a canonical role is mandatory, so a wrong choice is fixed by
|
|
162
|
+
* naming another folder, never by clearing the row.
|
|
163
|
+
*/
|
|
162
164
|
export const AppointedSource: Story = {
|
|
163
165
|
name: "appointed",
|
|
164
166
|
args: { folders: HOSTNET_FOLDERS, initial: SETTLED },
|
|
@@ -244,7 +246,11 @@ export const StaleSource: Story = {
|
|
|
244
246
|
},
|
|
245
247
|
};
|
|
246
248
|
|
|
247
|
-
/**
|
|
249
|
+
/**
|
|
250
|
+
* `None` — a decision waiting to be made. No icon, no danger colour. Trash and
|
|
251
|
+
* Archive show the disabled "Choose a folder" placeholder; the settled rows
|
|
252
|
+
* around them have no such option left to fall back to.
|
|
253
|
+
*/
|
|
248
254
|
export const NoneSource: Story = {
|
|
249
255
|
name: "none",
|
|
250
256
|
args: {
|
|
@@ -58,8 +58,8 @@ export interface RoleAppointment {
|
|
|
58
58
|
staleFolderPath?: string;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
/**
|
|
62
|
-
const
|
|
61
|
+
/** Value of the placeholder <option>, which is never selectable. */
|
|
62
|
+
const PLACEHOLDER = "";
|
|
63
63
|
|
|
64
64
|
const UNRESOLVED: RoleAppointment = { mailboxId: null, source: "None" };
|
|
65
65
|
|
|
@@ -94,7 +94,7 @@ interface RoleAppointmentRowProps {
|
|
|
94
94
|
appointment: RoleAppointment;
|
|
95
95
|
/** Committed display-name override for the appointed folder. */
|
|
96
96
|
displayName: string;
|
|
97
|
-
onAppoint: (role: FolderRole, mailboxId: string
|
|
97
|
+
onAppoint: (role: FolderRole, mailboxId: string) => void;
|
|
98
98
|
onRename: (mailboxId: string, name: string) => void;
|
|
99
99
|
}
|
|
100
100
|
|
|
@@ -180,21 +180,20 @@ function RoleAppointmentRow({
|
|
|
180
180
|
<Select
|
|
181
181
|
ref={selectRef}
|
|
182
182
|
className="w-56 shrink-0"
|
|
183
|
-
value={mailboxId ??
|
|
183
|
+
value={appointed?.mailboxId ?? PLACEHOLDER}
|
|
184
184
|
aria-label={`Folder for ${label}`}
|
|
185
185
|
// Whichever line the row renders — the provenance subtitle or the
|
|
186
186
|
// stale callout — is the one that explains this control.
|
|
187
187
|
aria-describedby={
|
|
188
188
|
subtitle || source === "Stale" ? subtitleId : undefined
|
|
189
189
|
}
|
|
190
|
-
onChange={(event) =>
|
|
191
|
-
onAppoint(
|
|
192
|
-
role,
|
|
193
|
-
event.target.value === NONE ? null : event.target.value,
|
|
194
|
-
)
|
|
195
|
-
}
|
|
190
|
+
onChange={(event) => onAppoint(role, event.target.value)}
|
|
196
191
|
>
|
|
197
|
-
|
|
192
|
+
{!appointed && (
|
|
193
|
+
<option value={PLACEHOLDER} disabled>
|
|
194
|
+
Choose a folder
|
|
195
|
+
</option>
|
|
196
|
+
)}
|
|
198
197
|
{folders.map((folder) => (
|
|
199
198
|
<option key={folder.mailboxId} value={folder.mailboxId}>
|
|
200
199
|
{folderOptionLabel(folder)}
|
|
@@ -289,7 +288,7 @@ export interface RoleAppointmentListProps {
|
|
|
289
288
|
appointments: Readonly<Record<string, RoleAppointment>>;
|
|
290
289
|
/** mailboxId → committed display-name override. */
|
|
291
290
|
displayNames?: Readonly<Record<string, string>>;
|
|
292
|
-
onAppoint: (role: FolderRole, mailboxId: string
|
|
291
|
+
onAppoint: (role: FolderRole, mailboxId: string) => void;
|
|
293
292
|
onRename: (mailboxId: string, name: string) => void;
|
|
294
293
|
}
|
|
295
294
|
|
|
@@ -297,8 +296,12 @@ export interface RoleAppointmentListProps {
|
|
|
297
296
|
* The per-account folder-roles settings section. Lists the canonical roles,
|
|
298
297
|
* each appointing one existing folder, then the leftover unappointed folders as
|
|
299
298
|
* plain folders. Controlled — the caller owns the appointment map and routes
|
|
300
|
-
* each change back. Pure kit primitives (Select/Input/Button)
|
|
301
|
-
*
|
|
299
|
+
* each change back. Pure kit primitives (Select/Input/Button).
|
|
300
|
+
*
|
|
301
|
+
* A canonical role is mandatory, so the picker has no unset: a wrong
|
|
302
|
+
* appointment is fixed by pointing the role at another folder. The only thing
|
|
303
|
+
* a row can offer besides a folder is a disabled placeholder, and only until
|
|
304
|
+
* the role has one.
|
|
302
305
|
*/
|
|
303
306
|
export function RoleAppointmentList({
|
|
304
307
|
accountEmail,
|
|
@@ -82,6 +82,16 @@ export function SelfUpdateSection({
|
|
|
82
82
|
onCheck();
|
|
83
83
|
};
|
|
84
84
|
|
|
85
|
+
// The pane renders one state at a time, and an undismissed run outcome wins
|
|
86
|
+
// over any check in flight — so a check pressed from the success row would
|
|
87
|
+
// leave the screen unchanged and surface its verdict, right or wrong, only
|
|
88
|
+
// once the banner was dismissed. Retiring the outcome is what makes the
|
|
89
|
+
// press visible, and pressing it is the acknowledgement that retires it.
|
|
90
|
+
const handleCheckAfterResult = () => {
|
|
91
|
+
onDismissResult();
|
|
92
|
+
handleCheck();
|
|
93
|
+
};
|
|
94
|
+
|
|
85
95
|
const handleInstall = () => {
|
|
86
96
|
if (
|
|
87
97
|
!installable &&
|
|
@@ -281,23 +291,48 @@ export function SelfUpdateSection({
|
|
|
281
291
|
|
|
282
292
|
case "succeeded":
|
|
283
293
|
return (
|
|
284
|
-
|
|
285
|
-
<
|
|
286
|
-
<
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
+
<>
|
|
295
|
+
<Banner tone="success" onDismiss={onDismissResult}>
|
|
296
|
+
<div className="space-y-1">
|
|
297
|
+
<p className="font-semibold">
|
|
298
|
+
Updated to Remit {state.version}.
|
|
299
|
+
</p>
|
|
300
|
+
<p>
|
|
301
|
+
You were on {state.previousVersion}.{" "}
|
|
302
|
+
<a
|
|
303
|
+
href={state.releaseNotesUrl}
|
|
304
|
+
target="_blank"
|
|
305
|
+
rel="noopener noreferrer"
|
|
306
|
+
className="underline"
|
|
307
|
+
>
|
|
308
|
+
See what changed
|
|
309
|
+
</a>
|
|
310
|
+
.
|
|
311
|
+
</p>
|
|
312
|
+
</div>
|
|
313
|
+
</Banner>
|
|
314
|
+
<SectionRow>
|
|
315
|
+
<div className="flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between">
|
|
316
|
+
<div className="flex min-w-0 items-center gap-2">
|
|
317
|
+
<CheckCircle2
|
|
318
|
+
className="size-4 shrink-0 text-positive"
|
|
319
|
+
aria-hidden
|
|
320
|
+
/>
|
|
321
|
+
<p className="text-sm text-fg">
|
|
322
|
+
Remit {state.version} is running.
|
|
323
|
+
</p>
|
|
324
|
+
</div>
|
|
325
|
+
<Button
|
|
326
|
+
variant="secondary"
|
|
327
|
+
size="sm"
|
|
328
|
+
className="shrink-0"
|
|
329
|
+
onClick={handleCheckAfterResult}
|
|
294
330
|
>
|
|
295
|
-
|
|
296
|
-
</
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
</Banner>
|
|
331
|
+
Check for updates
|
|
332
|
+
</Button>
|
|
333
|
+
</div>
|
|
334
|
+
</SectionRow>
|
|
335
|
+
</>
|
|
301
336
|
);
|
|
302
337
|
|
|
303
338
|
case "rolledBack":
|
|
@@ -204,6 +204,20 @@ describe("SelfUpdateSection", () => {
|
|
|
204
204
|
assert.doesNotMatch(html, /running 0\.9\.3 again/);
|
|
205
205
|
});
|
|
206
206
|
|
|
207
|
+
it("keeps the pane's control reachable while the success banner is up", () => {
|
|
208
|
+
const html = section({
|
|
209
|
+
status: "succeeded",
|
|
210
|
+
runId: demoRunId,
|
|
211
|
+
version: "0.9.4",
|
|
212
|
+
previousVersion: CURRENT,
|
|
213
|
+
releaseNotesUrl: demoRelease.releaseNotesUrl,
|
|
214
|
+
});
|
|
215
|
+
assert.match(html, /Updated to Remit 0\.9\.4/);
|
|
216
|
+
assert.match(html, /0\.9\.4 is running/);
|
|
217
|
+
assert.match(html, /Check for updates/);
|
|
218
|
+
assert.doesNotMatch(html, /disabled=/);
|
|
219
|
+
});
|
|
220
|
+
|
|
207
221
|
it("renders an abandoned run as a no-op that changed nothing", () => {
|
|
208
222
|
const html = section({
|
|
209
223
|
status: "abandoned",
|
package/src/index.ts
CHANGED
|
@@ -258,6 +258,14 @@ export {
|
|
|
258
258
|
ComposeLanguageSetting,
|
|
259
259
|
type ComposeLanguageSettingProps,
|
|
260
260
|
} from "./components/compose-language-setting.js";
|
|
261
|
+
export {
|
|
262
|
+
ComposeQuoteMissingBanner,
|
|
263
|
+
type ComposeQuoteMissingBannerProps,
|
|
264
|
+
type ComposeQuoteMode,
|
|
265
|
+
composeQuoteMissingMessage,
|
|
266
|
+
NO_QUOTABLE_BODY_FORWARD_MESSAGE,
|
|
267
|
+
NO_QUOTABLE_BODY_REPLY_MESSAGE,
|
|
268
|
+
} from "./components/compose-quote-missing-banner.js";
|
|
261
269
|
export {
|
|
262
270
|
ComposeSmtpMissingBanner,
|
|
263
271
|
type ComposeSmtpMissingBannerProps,
|