@remit/ui 0.0.206 → 0.0.208
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/account-service-change-dialog.stories.tsx +0 -1
- package/src/components/account-service-choice.stories.tsx +0 -1
- package/src/components/account-service-toggles.render.test.ts +5 -0
- package/src/components/account-service-toggles.stories.tsx +21 -2
- package/src/components/account-service-toggles.tsx +8 -1
- package/src/components/compose-action-bar.stories.tsx +19 -0
package/package.json
CHANGED
|
@@ -8,7 +8,6 @@ import { AccountServiceChangeDialog } from "./account-service-change-dialog.js";
|
|
|
8
8
|
*/
|
|
9
9
|
const meta: Meta<typeof AccountServiceChangeDialog> = {
|
|
10
10
|
title: "Design System/Settings/AccountServiceChangeDialog",
|
|
11
|
-
tags: ["proposed"],
|
|
12
11
|
component: AccountServiceChangeDialog,
|
|
13
12
|
parameters: { layout: "fullscreen" },
|
|
14
13
|
args: {
|
|
@@ -14,7 +14,6 @@ import { Button } from "./button.js";
|
|
|
14
14
|
*/
|
|
15
15
|
const meta: Meta<typeof AccountServiceChoice> = {
|
|
16
16
|
title: "Design System/Settings/AccountServiceChoice",
|
|
17
|
-
tags: ["proposed"],
|
|
18
17
|
component: AccountServiceChoice,
|
|
19
18
|
parameters: { layout: "padded" },
|
|
20
19
|
decorators: [
|
|
@@ -120,4 +120,9 @@ describe("AccountServiceToggles", () => {
|
|
|
120
120
|
{ service: "Calendar", intent: "on" },
|
|
121
121
|
]);
|
|
122
122
|
});
|
|
123
|
+
|
|
124
|
+
it("holds every switch still while the host has a change in flight", () => {
|
|
125
|
+
assert.deepEqual(pressSwitch(1, { enabled: ["Mail"], disabled: true }), []);
|
|
126
|
+
assert.equal(render({ disabled: true }).match(/disabled=""/g)?.length, 2);
|
|
127
|
+
});
|
|
123
128
|
});
|
|
@@ -12,8 +12,7 @@ import {
|
|
|
12
12
|
* host confirms and commits.
|
|
13
13
|
*/
|
|
14
14
|
const meta: Meta<typeof AccountServiceToggles> = {
|
|
15
|
-
title: "Playground/
|
|
16
|
-
tags: ["proposed"],
|
|
15
|
+
title: "Playground/Shipped/Settings/Accounts/AccountServiceToggles",
|
|
17
16
|
component: AccountServiceToggles,
|
|
18
17
|
parameters: { layout: "padded" },
|
|
19
18
|
decorators: [
|
|
@@ -120,3 +119,23 @@ export const ImapAccount: Story = {
|
|
|
120
119
|
</>
|
|
121
120
|
),
|
|
122
121
|
};
|
|
122
|
+
|
|
123
|
+
/** A change is in flight: neither switch takes a press until it lands. */
|
|
124
|
+
export const Saving: Story = {
|
|
125
|
+
render: () => (
|
|
126
|
+
<AccountServiceToggles
|
|
127
|
+
providerName="Microsoft"
|
|
128
|
+
offered={bothServices}
|
|
129
|
+
enabled={bothServices}
|
|
130
|
+
consented={bothServices}
|
|
131
|
+
disabled
|
|
132
|
+
onRequestChange={() => {}}
|
|
133
|
+
/>
|
|
134
|
+
),
|
|
135
|
+
play: async ({ canvasElement }) => {
|
|
136
|
+
const canvas = within(canvasElement);
|
|
137
|
+
await expect(
|
|
138
|
+
canvas.getByRole("switch", { name: "Sync mail" }),
|
|
139
|
+
).toBeDisabled();
|
|
140
|
+
},
|
|
141
|
+
};
|
|
@@ -22,6 +22,8 @@ export interface AccountServiceTogglesProps {
|
|
|
22
22
|
enabled: AccountService[];
|
|
23
23
|
/** Services the account's grant already covers. The rest cost a sign-in. */
|
|
24
24
|
consented: AccountService[];
|
|
25
|
+
/** Holds every switch still while the host has a change in flight. */
|
|
26
|
+
disabled?: boolean;
|
|
25
27
|
/** Asks the host for a change. The host owns the question and the commit. */
|
|
26
28
|
onRequestChange: (
|
|
27
29
|
service: AccountService,
|
|
@@ -33,11 +35,13 @@ function ServiceSwitch({
|
|
|
33
35
|
checked,
|
|
34
36
|
label,
|
|
35
37
|
describedBy,
|
|
38
|
+
disabled,
|
|
36
39
|
onToggle,
|
|
37
40
|
}: {
|
|
38
41
|
checked: boolean;
|
|
39
42
|
label: string;
|
|
40
43
|
describedBy: string;
|
|
44
|
+
disabled: boolean;
|
|
41
45
|
onToggle: () => void;
|
|
42
46
|
}) {
|
|
43
47
|
return (
|
|
@@ -47,10 +51,11 @@ function ServiceSwitch({
|
|
|
47
51
|
aria-checked={checked}
|
|
48
52
|
aria-label={label}
|
|
49
53
|
aria-describedby={describedBy}
|
|
54
|
+
disabled={disabled}
|
|
50
55
|
onClick={onToggle}
|
|
51
56
|
className={cn(
|
|
52
57
|
"relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors",
|
|
53
|
-
"outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-surface",
|
|
58
|
+
"outline-none disabled:cursor-not-allowed disabled:opacity-60 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-surface",
|
|
54
59
|
checked
|
|
55
60
|
? "border-positive bg-positive"
|
|
56
61
|
: "border-line-strong bg-surface-sunken",
|
|
@@ -80,6 +85,7 @@ export function AccountServiceToggles({
|
|
|
80
85
|
offered,
|
|
81
86
|
enabled,
|
|
82
87
|
consented,
|
|
88
|
+
disabled = false,
|
|
83
89
|
onRequestChange,
|
|
84
90
|
}: AccountServiceTogglesProps) {
|
|
85
91
|
const groupId = useId();
|
|
@@ -114,6 +120,7 @@ export function AccountServiceToggles({
|
|
|
114
120
|
checked={on}
|
|
115
121
|
label={`Sync ${row.label.toLowerCase()}`}
|
|
116
122
|
describedBy={noteId}
|
|
123
|
+
disabled={disabled}
|
|
117
124
|
onToggle={() => onRequestChange(row.id, on ? "off" : "on")}
|
|
118
125
|
/>
|
|
119
126
|
</div>
|
|
@@ -137,3 +137,22 @@ export const SmtpMissing: Story = {
|
|
|
137
137
|
},
|
|
138
138
|
},
|
|
139
139
|
};
|
|
140
|
+
|
|
141
|
+
export const MailOff: Story = {
|
|
142
|
+
name: "Blocked — mail is off for this account",
|
|
143
|
+
args: {
|
|
144
|
+
send: {
|
|
145
|
+
status: "blocked",
|
|
146
|
+
reason:
|
|
147
|
+
"Mail is turned off for this account, so it cannot send. Turn Mail back on for this account in Settings to send from it.",
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
play: async ({ args, canvasElement }) => {
|
|
151
|
+
const canvas = within(canvasElement);
|
|
152
|
+
await userEvent.click(canvas.getByRole("button", { name: "Send" }));
|
|
153
|
+
await expect(args.onBlocked).toHaveBeenCalledWith(
|
|
154
|
+
"Mail is turned off for this account, so it cannot send. Turn Mail back on for this account in Settings to send from it.",
|
|
155
|
+
);
|
|
156
|
+
await expect(args.onSend).not.toHaveBeenCalled();
|
|
157
|
+
},
|
|
158
|
+
};
|