oneslash-design-system 2.28.0 → 2.29.0
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/README.md +1 -1
- package/dist/DESIGN.md +31 -1
- package/dist/cases/about-page.md +2 -0
- package/dist/cases/accept-invite.md +2 -0
- package/dist/cases/account-menu.md +2 -0
- package/dist/cases/activity-timeline.md +2 -0
- package/dist/cases/admin-inbox.md +2 -0
- package/dist/cases/agent-asks-before-risky-action.md +3 -1
- package/dist/cases/agent-cancels-when-unanswered.md +2 -0
- package/dist/cases/agent-changes-review/all-at-once.d.ts +1 -0
- package/dist/cases/agent-changes-review/all-at-once.jsx +238 -0
- package/dist/cases/agent-changes-review/per-change.d.ts +1 -0
- package/dist/cases/agent-changes-review/per-change.jsx +203 -0
- package/dist/cases/agent-changes-review.md +585 -0
- package/dist/cases/agent-handoff/to-agent.d.ts +1 -0
- package/dist/cases/agent-handoff/to-agent.jsx +53 -0
- package/dist/cases/agent-handoff/to-person.d.ts +1 -0
- package/dist/cases/agent-handoff/to-person.jsx +84 -0
- package/dist/cases/agent-handoff.md +231 -0
- package/dist/cases/agent-memory/list.d.ts +1 -0
- package/dist/cases/agent-memory/list.jsx +256 -0
- package/dist/cases/agent-memory.md +354 -0
- package/dist/cases/agent-options.md +2 -0
- package/dist/cases/agent-pending-reply/steps.jsx +70 -21
- package/dist/cases/agent-pending-reply.md +74 -27
- package/dist/cases/agent-permissions/levels.d.ts +3 -0
- package/dist/cases/agent-permissions/levels.jsx +49 -0
- package/dist/cases/agent-permissions/per-tool.d.ts +3 -0
- package/dist/cases/agent-permissions/per-tool.jsx +178 -0
- package/dist/cases/agent-permissions.md +314 -0
- package/dist/cases/agent-plan-proposal/changes.jsx +18 -11
- package/dist/cases/agent-plan-proposal/steps.jsx +11 -4
- package/dist/cases/agent-plan-proposal.md +36 -21
- package/dist/cases/agent-question.md +2 -0
- package/dist/cases/agent-refuses-clearly.md +2 -0
- package/dist/cases/agent-run-failure/limit-reached.d.ts +1 -0
- package/dist/cases/agent-run-failure/limit-reached.jsx +172 -0
- package/dist/cases/agent-run-failure/step-failed.d.ts +3 -0
- package/dist/cases/agent-run-failure/step-failed.jsx +187 -0
- package/dist/cases/agent-run-failure.md +500 -0
- package/dist/cases/agent-says-what-it-is.md +2 -0
- package/dist/cases/agent-says-where-it-stopped.md +27 -0
- package/dist/cases/agent-settings.md +2 -0
- package/dist/cases/agent-shows-progress.md +2 -0
- package/dist/cases/agent-shows-sources.md +2 -0
- package/dist/cases/api-keys/list.jsx +30 -3
- package/dist/cases/api-keys.md +37 -3
- package/dist/cases/app-shell.md +2 -0
- package/dist/cases/artifact-card.md +2 -0
- package/dist/cases/ask-page.md +2 -0
- package/dist/cases/auth-gate-loading.md +2 -0
- package/dist/cases/billing-page.md +2 -0
- package/dist/cases/blog-index.md +2 -0
- package/dist/cases/breadcrumb.md +2 -0
- package/dist/cases/breakdown-list.md +2 -0
- package/dist/cases/bulk-actions/list.d.ts +1 -0
- package/dist/cases/bulk-actions/list.jsx +209 -0
- package/dist/cases/bulk-actions/paged-table.d.ts +1 -0
- package/dist/cases/bulk-actions/paged-table.jsx +246 -0
- package/dist/cases/bulk-actions.md +559 -0
- package/dist/cases/changelog.md +2 -0
- package/dist/cases/chart.md +2 -0
- package/dist/cases/check-your-email.md +2 -0
- package/dist/cases/code-sample.md +2 -0
- package/dist/cases/collapsible-search.md +2 -0
- package/dist/cases/comment-thread.md +2 -0
- package/dist/cases/comparison-page/table.d.ts +1 -0
- package/dist/cases/comparison-page/table.jsx +97 -0
- package/dist/cases/comparison-page.md +156 -0
- package/dist/cases/composer-limit.md +2 -0
- package/dist/cases/confirm-destructive-action.md +2 -0
- package/dist/cases/confirm-dialogs.md +2 -0
- package/dist/cases/connection-status/card.d.ts +1 -0
- package/dist/cases/connection-status/card.jsx +97 -0
- package/dist/cases/connection-status/row.d.ts +1 -0
- package/dist/cases/connection-status/row.jsx +120 -0
- package/dist/cases/connection-status.md +330 -0
- package/dist/cases/contact-page.md +2 -0
- package/dist/cases/conversation-starters.md +2 -0
- package/dist/cases/cookie-choice.md +2 -0
- package/dist/cases/create-modal.md +2 -0
- package/dist/cases/danger-zone.md +2 -0
- package/dist/cases/dashboard.md +2 -0
- package/dist/cases/data-table-page.md +2 -0
- package/dist/cases/date-field.md +2 -0
- package/dist/cases/device-login.md +2 -0
- package/dist/cases/docs-component-page.md +2 -0
- package/dist/cases/email-confirmed.md +2 -0
- package/dist/cases/empty-list.md +2 -0
- package/dist/cases/empty-lists.md +2 -0
- package/dist/cases/empty-not-set-up.md +2 -0
- package/dist/cases/empty-search.md +2 -0
- package/dist/cases/error-page.md +2 -0
- package/dist/cases/faq.md +2 -0
- package/dist/cases/feature-grid.md +2 -0
- package/dist/cases/feedback-form.md +2 -0
- package/dist/cases/file-upload.md +2 -0
- package/dist/cases/filter-menu.md +2 -0
- package/dist/cases/forgot-password.md +2 -0
- package/dist/cases/form-errors.md +2 -0
- package/dist/cases/image-viewer.md +2 -0
- package/dist/cases/import-checklist.md +2 -0
- package/dist/cases/inline-form-feedback.md +2 -0
- package/dist/cases/integrations-list/nested.jsx +1 -1
- package/dist/cases/integrations-list/rows.jsx +1 -1
- package/dist/cases/integrations-list.md +6 -4
- package/dist/cases/invite-member.md +2 -0
- package/dist/cases/invoice-list.md +2 -0
- package/dist/cases/landing-hero.md +2 -0
- package/dist/cases/leaderboard.md +2 -0
- package/dist/cases/legal-page.md +2 -0
- package/dist/cases/load-failure.md +2 -0
- package/dist/cases/log-out-confirm.md +2 -0
- package/dist/cases/login-page.md +2 -0
- package/dist/cases/long-form-page.md +2 -0
- package/dist/cases/master-detail.md +2 -0
- package/dist/cases/members-list/rows.jsx +37 -6
- package/dist/cases/members-list/table.jsx +37 -6
- package/dist/cases/members-list.md +83 -12
- package/dist/cases/mention-list.md +2 -0
- package/dist/cases/message-actions.md +2 -0
- package/dist/cases/message-attachments.md +2 -0
- package/dist/cases/message-composer/with-tools.jsx +17 -7
- package/dist/cases/message-composer.md +28 -11
- package/dist/cases/message-edit.md +2 -0
- package/dist/cases/message-reactions.md +2 -0
- package/dist/cases/message-row.md +2 -0
- package/dist/cases/message-send-failure/needs-a-person.d.ts +1 -0
- package/dist/cases/message-send-failure/needs-a-person.jsx +116 -0
- package/dist/cases/message-send-failure/retrying.d.ts +1 -0
- package/dist/cases/message-send-failure/retrying.jsx +116 -0
- package/dist/cases/message-send-failure.md +308 -0
- package/dist/cases/mobile-menu.md +2 -0
- package/dist/cases/newsletter-signup.md +2 -0
- package/dist/cases/no-access/page.d.ts +1 -0
- package/dist/cases/no-access/page.jsx +37 -0
- package/dist/cases/no-access/read-only.d.ts +1 -0
- package/dist/cases/no-access/read-only.jsx +33 -0
- package/dist/cases/no-access.md +147 -0
- package/dist/cases/not-found-page.md +2 -0
- package/dist/cases/notification-menu.md +2 -0
- package/dist/cases/number-format.md +2 -0
- package/dist/cases/oauth-consent.md +2 -0
- package/dist/cases/on-off-settings.md +2 -0
- package/dist/cases/on-this-page.md +2 -0
- package/dist/cases/onboarding.md +2 -0
- package/dist/cases/one-main-action.md +2 -0
- package/dist/cases/overflow-menu.md +2 -0
- package/dist/cases/page-end.md +2 -0
- package/dist/cases/page-header.md +2 -0
- package/dist/cases/paged-card.md +2 -0
- package/dist/cases/password-gate.md +2 -0
- package/dist/cases/payment-method.md +2 -0
- package/dist/cases/people-row.md +2 -0
- package/dist/cases/phone-navigation.md +2 -0
- package/dist/cases/plan-change-confirm.md +2 -0
- package/dist/cases/plan-comparison.md +3 -1
- package/dist/cases/plan-picker.md +4 -1
- package/dist/cases/plan-sign-off.md +2 -0
- package/dist/cases/pricing-section.md +5 -1
- package/dist/cases/product-cards.md +2 -0
- package/dist/cases/product-demo/scripted.d.ts +3 -0
- package/dist/cases/product-demo/scripted.jsx +95 -0
- package/dist/cases/product-demo/still.d.ts +1 -0
- package/dist/cases/product-demo/still.jsx +20 -0
- package/dist/cases/product-demo.md +221 -0
- package/dist/cases/profile-form.md +2 -0
- package/dist/cases/quick-switcher.md +2 -0
- package/dist/cases/range-switch.md +2 -0
- package/dist/cases/rename.md +2 -0
- package/dist/cases/reply-feedback.md +2 -0
- package/dist/cases/reply-sources.md +2 -0
- package/dist/cases/route-loading.md +2 -0
- package/dist/cases/scope-picker.md +2 -0
- package/dist/cases/section-index.md +2 -0
- package/dist/cases/session-expired/in-place.d.ts +1 -0
- package/dist/cases/session-expired/in-place.jsx +63 -0
- package/dist/cases/session-expired/redirect.d.ts +1 -0
- package/dist/cases/session-expired/redirect.jsx +62 -0
- package/dist/cases/session-expired.md +204 -0
- package/dist/cases/set-new-password.md +2 -0
- package/dist/cases/settings-page.md +2 -0
- package/dist/cases/settings-save.md +2 -0
- package/dist/cases/side-pane.md +2 -0
- package/dist/cases/sidebar-nav.md +2 -0
- package/dist/cases/sign-up-page.md +3 -0
- package/dist/cases/signup-from-site/plain.d.ts +1 -0
- package/dist/cases/signup-from-site/plain.jsx +125 -0
- package/dist/cases/signup-from-site/with-plan.d.ts +4 -0
- package/dist/cases/signup-from-site/with-plan.jsx +151 -0
- package/dist/cases/signup-from-site.md +351 -0
- package/dist/cases/site-footer.md +2 -0
- package/dist/cases/site-header/links.d.ts +3 -1
- package/dist/cases/site-header/links.jsx +6 -2
- package/dist/cases/site-header.md +11 -3
- package/dist/cases/site-matches-app.md +32 -0
- package/dist/cases/site-search.md +2 -0
- package/dist/cases/slash-command-list.md +2 -0
- package/dist/cases/stat-row.md +2 -0
- package/dist/cases/status-label.md +3 -1
- package/dist/cases/success-feedback.md +2 -0
- package/dist/cases/tabbed-panels.md +2 -0
- package/dist/cases/tag-filter.md +2 -0
- package/dist/cases/task-header.md +2 -0
- package/dist/cases/theme-switcher.md +2 -0
- package/dist/cases/type-to-confirm.md +2 -0
- package/dist/cases/typing-and-status.md +2 -0
- package/dist/cases/unsaved-changes-guard.md +2 -0
- package/dist/cases/upgrade-prompt.md +2 -0
- package/dist/cases/usage-meters.md +2 -0
- package/dist/cases.json +1494 -42
- package/dist/components/checkBox.d.ts +5 -1
- package/dist/components/checkBox.jsx +23 -9
- package/dist/components/diff.d.ts +29 -0
- package/dist/components/diff.jsx +35 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/internal/diff.d.ts +17 -0
- package/dist/internal/diff.js +44 -0
- package/dist/native-mapping.json +9 -2
- package/dist/stories/AgentPermissions.probe.stories.d.ts +7 -0
- package/dist/stories/AgentPermissions.probe.stories.jsx +18 -0
- package/dist/stories/AgentRunFailure.probe.stories.d.ts +6 -0
- package/dist/stories/AgentRunFailure.probe.stories.jsx +12 -0
- package/dist/stories/Cases.generated.stories.d.ts +24 -0
- package/dist/stories/Cases.generated.stories.jsx +48 -0
- package/dist/stories/Checkbox.stories.d.ts +2 -0
- package/dist/stories/Checkbox.stories.jsx +18 -0
- package/dist/stories/Diff.stories.d.ts +9 -0
- package/dist/stories/Diff.stories.jsx +40 -0
- package/dist/stories/ProductDemo.probe.stories.d.ts +6 -0
- package/dist/stories/ProductDemo.probe.stories.jsx +12 -0
- package/dist/stories/SignupFromSite.probe.stories.d.ts +7 -0
- package/dist/stories/SignupFromSite.probe.stories.jsx +17 -0
- package/dist/stories/SiteHeader.probe.stories.d.ts +6 -0
- package/dist/stories/SiteHeader.probe.stories.jsx +13 -0
- package/package.json +1 -1
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
An admin sees who is in the workspace, changes their roles, removes people and invites more.
|
|
4
4
|
|
|
5
|
+
For: an app
|
|
6
|
+
|
|
5
7
|
## Do
|
|
6
8
|
|
|
7
9
|
- Show each member in a row: `UserImage` with `decorative`, the name, the email and the role. The avatar sits beside the same name, so it is hidden from a screen reader.
|
|
@@ -11,6 +13,7 @@ An admin sees who is in the workspace, changes their roles, removes people and i
|
|
|
11
13
|
- Show your own role as text with a 'You' Tag, and give your row no Remove.
|
|
12
14
|
- Confirm 'Remove' in the row, as the case 'Delete confirm' does: the row asks 'Remove Ben Carter?' and shows 'Cancel' and a danger 'Remove'. Then show a toast: 'Ben Carter removed from Acme.'
|
|
13
15
|
- Give each row's 'Remove', and the confirm's 'Cancel' and 'Remove', an `aria-label` that names the person: 'Remove Ben Carter' and 'Cancel removing Ben Carter'.
|
|
16
|
+
- Move focus with the confirm, since the button that had it goes away: to 'Cancel' when the confirm opens, back to the row's button on Cancel, and after a remove or revoke to the next row's button, or the one before it on the last row. With no such row left, focus goes to 'Invite Member'.
|
|
14
17
|
- List pending invites under the members. Each has 'Copy Link', which reads 'Copied' for 2 seconds, and 'Revoke Invite'.
|
|
15
18
|
- Confirm 'Revoke Invite' in the row before it ends the link: the row shows 'Cancel' and a danger 'Revoke'. Then show a toast: 'Invite for sam@partner.example revoked.'
|
|
16
19
|
- Name the invite in each `aria-label`: 'Revoke invite for sam@partner.example' and 'Cancel revoking the invite for sam@partner.example'.
|
|
@@ -58,6 +61,7 @@ import { formatMoney } from 'oneslash-design-system/components/formatNumber';
|
|
|
58
61
|
|
|
59
62
|
type Member = { id: string; name: string; email: string; role: string };
|
|
60
63
|
type Invite = { id: string; email: string; sent: string; link: string };
|
|
64
|
+
type Focusable = HTMLButtonElement | HTMLAnchorElement | null;
|
|
61
65
|
|
|
62
66
|
// A real app reads these from the signed-in person and the plan.
|
|
63
67
|
const youId = 'dana';
|
|
@@ -116,6 +120,12 @@ export default function MembersListRows() {
|
|
|
116
120
|
const copyTimer = useRef<ReturnType<typeof setTimeout>>();
|
|
117
121
|
const mounted = useRef(true);
|
|
118
122
|
const toastIds = useRef<string[]>([]);
|
|
123
|
+
const inviteButton = useRef<Focusable>(null);
|
|
124
|
+
const cancelConfirm = useRef<Focusable>(null);
|
|
125
|
+
// Each row's Remove or Revoke Invite button by row id, so focus can move to one when the button that had it is gone.
|
|
126
|
+
const rowButtons = useRef<Record<string, Focusable>>({});
|
|
127
|
+
// Where focus goes after the next render, once the element it goes to is on screen.
|
|
128
|
+
const focusNext = useRef<() => void>();
|
|
119
129
|
// Gives each new invite its own id, so no two rows share a key.
|
|
120
130
|
const inviteCount = useRef(0);
|
|
121
131
|
|
|
@@ -131,6 +141,12 @@ export default function MembersListRows() {
|
|
|
131
141
|
};
|
|
132
142
|
}, []);
|
|
133
143
|
|
|
144
|
+
useEffect(() => {
|
|
145
|
+
const move = focusNext.current;
|
|
146
|
+
focusNext.current = undefined;
|
|
147
|
+
move?.();
|
|
148
|
+
});
|
|
149
|
+
|
|
134
150
|
// Stands in for the request to the server.
|
|
135
151
|
function later(callback: () => void, ms: number) {
|
|
136
152
|
timers.current.push(setTimeout(callback, ms));
|
|
@@ -157,30 +173,51 @@ export default function MembersListRows() {
|
|
|
157
173
|
}, 900);
|
|
158
174
|
}
|
|
159
175
|
|
|
160
|
-
// Starting a confirm on one row cancels the confirm on any other.
|
|
176
|
+
// Starting a confirm on one row cancels the confirm on any other. It opens in the row, with focus on 'Cancel'.
|
|
161
177
|
function startConfirm(kind: 'member' | 'invite', id: string) {
|
|
162
178
|
setConfirmingMember(kind === 'member' ? id : null);
|
|
163
179
|
setConfirmingInvite(kind === 'invite' ? id : null);
|
|
180
|
+
focusNext.current = () => cancelConfirm.current?.focus();
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// 'Cancel' goes away with the confirm, so focus goes back to the row's button.
|
|
184
|
+
function cancelConfirmOn(id: string) {
|
|
185
|
+
setConfirmingMember(null);
|
|
186
|
+
setConfirmingInvite(null);
|
|
187
|
+
focusNext.current = () => rowButtons.current[id]?.focus();
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// The row is gone: focus goes to the next row's button, or the one before it when it was the last.
|
|
191
|
+
// With no such row left, it goes to 'Invite Member'.
|
|
192
|
+
function focusAfterRemoving(ids: string[], id: string) {
|
|
193
|
+
const at = ids.indexOf(id);
|
|
194
|
+
const neighbor = ids[at + 1] ?? ids[at - 1];
|
|
195
|
+
focusNext.current = () => (neighbor ? rowButtons.current[neighbor] : inviteButton.current)?.focus();
|
|
164
196
|
}
|
|
165
197
|
|
|
166
198
|
function handleRemove(member: Member) {
|
|
167
199
|
if (busyRow) return;
|
|
200
|
+
// Only other people's rows have Remove, in the order they show
|
|
201
|
+
const removable = members.filter((m) => m.id !== youId).map((m) => m.id);
|
|
168
202
|
setBusyRow(member.id);
|
|
169
203
|
later(() => {
|
|
170
204
|
setBusyRow(null);
|
|
171
205
|
setConfirmingMember(null);
|
|
172
206
|
setMembers((list) => list.filter((m) => m.id !== member.id));
|
|
207
|
+
focusAfterRemoving(removable, member.id);
|
|
173
208
|
toastIds.current.push(toast({ type: 'success', message: `${member.name} removed from Acme.` }));
|
|
174
209
|
}, 1200);
|
|
175
210
|
}
|
|
176
211
|
|
|
177
212
|
function handleRevokeInvite(invite: Invite) {
|
|
178
213
|
if (busyRow) return;
|
|
214
|
+
const shown = invites.map((i) => i.id);
|
|
179
215
|
setBusyRow(invite.id);
|
|
180
216
|
later(() => {
|
|
181
217
|
setBusyRow(null);
|
|
182
218
|
setConfirmingInvite(null);
|
|
183
219
|
setInvites((list) => list.filter((i) => i.id !== invite.id));
|
|
220
|
+
focusAfterRemoving(shown, invite.id);
|
|
184
221
|
toastIds.current.push(toast({ type: 'success', message: `Invite for ${invite.email} revoked.` }));
|
|
185
222
|
}, 1200);
|
|
186
223
|
}
|
|
@@ -253,7 +290,7 @@ export default function MembersListRows() {
|
|
|
253
290
|
<Stack gap="small">
|
|
254
291
|
<Cluster justify="between">
|
|
255
292
|
<Heading level={1} size="h5">Members</Heading>
|
|
256
|
-
{canManage && <Button size="small" type="primary" state="enabled" label="Invite Member" decoIcon="UserPlus" onClickButton={handleInviteMember} />}
|
|
293
|
+
{canManage && <Button ref={inviteButton} size="small" type="primary" state="enabled" label="Invite Member" decoIcon="UserPlus" onClickButton={handleInviteMember} />}
|
|
257
294
|
</Cluster>
|
|
258
295
|
<Paragraph tone="secondary" size="body2" measure="none">{seatsUsed} of {seatLimit} seats used on the Free plan.</Paragraph>
|
|
259
296
|
{!canManage && <Paragraph tone="secondary" size="body2" measure="none">Only admins can change this.</Paragraph>}
|
|
@@ -302,11 +339,11 @@ export default function MembersListRows() {
|
|
|
302
339
|
confirmingMember === m.id ? (
|
|
303
340
|
<Cluster gap="small">
|
|
304
341
|
<Paragraph size="body2" measure="none">Remove {m.name}?</Paragraph>
|
|
305
|
-
<Button size="small" type="tertiary" state={busyRow === m.id ? 'disabled' : 'enabled'} label="Cancel" aria-label={`Cancel removing ${m.name}`} onClickButton={() =>
|
|
342
|
+
<Button ref={cancelConfirm} size="small" type="tertiary" state={busyRow === m.id ? 'disabled' : 'enabled'} label="Cancel" aria-label={`Cancel removing ${m.name}`} onClickButton={() => cancelConfirmOn(m.id)} />
|
|
306
343
|
<Button size="small" type="primary" color="danger" state="enabled" label="Remove" aria-label={`Remove ${m.name}`} loading={busyRow === m.id} onClickButton={() => handleRemove(m)} />
|
|
307
344
|
</Cluster>
|
|
308
345
|
) : (
|
|
309
|
-
<Button size="small" type="tertiary" state={busyRow ? 'disabled' : 'enabled'} label="Remove" aria-label={`Remove ${m.name}`} onClickButton={() => startConfirm('member', m.id)} />
|
|
346
|
+
<Button ref={(el) => { rowButtons.current[m.id] = el; }} size="small" type="tertiary" state={busyRow ? 'disabled' : 'enabled'} label="Remove" aria-label={`Remove ${m.name}`} onClickButton={() => startConfirm('member', m.id)} />
|
|
310
347
|
)
|
|
311
348
|
)}
|
|
312
349
|
</TableCell>
|
|
@@ -332,14 +369,14 @@ export default function MembersListRows() {
|
|
|
332
369
|
{confirmingInvite === i.id ? (
|
|
333
370
|
<Cluster gap="small">
|
|
334
371
|
<Paragraph size="body2" measure="none">Revoke this invite?</Paragraph>
|
|
335
|
-
<Button size="small" type="tertiary" state={busyRow === i.id ? 'disabled' : 'enabled'} label="Cancel" aria-label={`Cancel revoking the invite for ${i.email}`} onClickButton={() =>
|
|
372
|
+
<Button ref={cancelConfirm} size="small" type="tertiary" state={busyRow === i.id ? 'disabled' : 'enabled'} label="Cancel" aria-label={`Cancel revoking the invite for ${i.email}`} onClickButton={() => cancelConfirmOn(i.id)} />
|
|
336
373
|
<Button size="small" type="primary" color="danger" state="enabled" label="Revoke" aria-label={`Revoke invite for ${i.email}`} loading={busyRow === i.id} onClickButton={() => handleRevokeInvite(i)} />
|
|
337
374
|
</Cluster>
|
|
338
375
|
) : (
|
|
339
376
|
<Stack gap="small">
|
|
340
377
|
<Cluster gap="small">
|
|
341
378
|
<Button size="small" type="tertiary" state={busyRow ? 'disabled' : 'enabled'} label={copiedInvite === i.id ? 'Copied' : 'Copy Link'} aria-label={`${copiedInvite === i.id ? 'Copied' : 'Copy Link'} for ${i.email}`} onClickButton={() => handleCopy(i)} />
|
|
342
|
-
<Button size="small" type="tertiary" state={busyRow ? 'disabled' : 'enabled'} label="Revoke Invite" aria-label={`Revoke invite for ${i.email}`} onClickButton={() => startConfirm('invite', i.id)} />
|
|
379
|
+
<Button ref={(el) => { rowButtons.current[i.id] = el; }} size="small" type="tertiary" state={busyRow ? 'disabled' : 'enabled'} label="Revoke Invite" aria-label={`Revoke invite for ${i.email}`} onClickButton={() => startConfirm('invite', i.id)} />
|
|
343
380
|
</Cluster>
|
|
344
381
|
{copyBlocked === i.id && <Paragraph tone="secondary" size="caption" measure="none">Copying is blocked here. Select the link and copy it: {i.link}</Paragraph>}
|
|
345
382
|
</Stack>
|
|
@@ -420,6 +457,7 @@ import { formatMoney } from 'oneslash-design-system/components/formatNumber';
|
|
|
420
457
|
|
|
421
458
|
type Member = { id: string; name: string; email: string; role: string };
|
|
422
459
|
type Invite = { id: string; email: string; sent: string; link: string };
|
|
460
|
+
type Focusable = HTMLButtonElement | HTMLAnchorElement | null;
|
|
423
461
|
|
|
424
462
|
// A real app reads these from the signed-in person and the plan.
|
|
425
463
|
const youId = 'dana';
|
|
@@ -485,6 +523,12 @@ export default function MembersListTable() {
|
|
|
485
523
|
const copyTimer = useRef<ReturnType<typeof setTimeout>>();
|
|
486
524
|
const mounted = useRef(true);
|
|
487
525
|
const toastIds = useRef<string[]>([]);
|
|
526
|
+
const inviteButton = useRef<Focusable>(null);
|
|
527
|
+
const cancelConfirm = useRef<Focusable>(null);
|
|
528
|
+
// Each row's Remove or Revoke Invite button by row id, so focus can move to one when the button that had it is gone.
|
|
529
|
+
const rowButtons = useRef<Record<string, Focusable>>({});
|
|
530
|
+
// Where focus goes after the next render, once the element it goes to is on screen.
|
|
531
|
+
const focusNext = useRef<() => void>();
|
|
488
532
|
// Gives each new invite its own id, so no two rows share a key.
|
|
489
533
|
const inviteCount = useRef(0);
|
|
490
534
|
|
|
@@ -500,6 +544,12 @@ export default function MembersListTable() {
|
|
|
500
544
|
};
|
|
501
545
|
}, []);
|
|
502
546
|
|
|
547
|
+
useEffect(() => {
|
|
548
|
+
const move = focusNext.current;
|
|
549
|
+
focusNext.current = undefined;
|
|
550
|
+
move?.();
|
|
551
|
+
});
|
|
552
|
+
|
|
503
553
|
// Stands in for the request to the server.
|
|
504
554
|
function later(callback: () => void, ms: number) {
|
|
505
555
|
timers.current.push(setTimeout(callback, ms));
|
|
@@ -553,30 +603,51 @@ export default function MembersListTable() {
|
|
|
553
603
|
}, 900);
|
|
554
604
|
}
|
|
555
605
|
|
|
556
|
-
// Starting a confirm on one row cancels the confirm on any other.
|
|
606
|
+
// Starting a confirm on one row cancels the confirm on any other. It opens in the row, with focus on 'Cancel'.
|
|
557
607
|
function startConfirm(kind: 'member' | 'invite', id: string) {
|
|
558
608
|
setConfirmingMember(kind === 'member' ? id : null);
|
|
559
609
|
setConfirmingInvite(kind === 'invite' ? id : null);
|
|
610
|
+
focusNext.current = () => cancelConfirm.current?.focus();
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
// 'Cancel' goes away with the confirm, so focus goes back to the row's button.
|
|
614
|
+
function cancelConfirmOn(id: string) {
|
|
615
|
+
setConfirmingMember(null);
|
|
616
|
+
setConfirmingInvite(null);
|
|
617
|
+
focusNext.current = () => rowButtons.current[id]?.focus();
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
// The row is gone: focus goes to the next row's button, or the one before it when it was the last.
|
|
621
|
+
// With no such row left, it goes to 'Invite Member'.
|
|
622
|
+
function focusAfterRemoving(ids: string[], id: string) {
|
|
623
|
+
const at = ids.indexOf(id);
|
|
624
|
+
const neighbor = ids[at + 1] ?? ids[at - 1];
|
|
625
|
+
focusNext.current = () => (neighbor ? rowButtons.current[neighbor] : inviteButton.current)?.focus();
|
|
560
626
|
}
|
|
561
627
|
|
|
562
628
|
function handleRemove(member: Member) {
|
|
563
629
|
if (busyRow) return;
|
|
630
|
+
// Only other people's rows have Remove, in the order they show
|
|
631
|
+
const removable = sorted.filter((m) => m.id !== youId).map((m) => m.id);
|
|
564
632
|
setBusyRow(member.id);
|
|
565
633
|
later(() => {
|
|
566
634
|
setBusyRow(null);
|
|
567
635
|
setConfirmingMember(null);
|
|
568
636
|
setMembers((list) => list.filter((m) => m.id !== member.id));
|
|
637
|
+
focusAfterRemoving(removable, member.id);
|
|
569
638
|
toastIds.current.push(toast({ type: 'success', message: `${member.name} removed from Acme.` }));
|
|
570
639
|
}, 1200);
|
|
571
640
|
}
|
|
572
641
|
|
|
573
642
|
function handleRevokeInvite(invite: Invite) {
|
|
574
643
|
if (busyRow) return;
|
|
644
|
+
const shown = invites.map((i) => i.id);
|
|
575
645
|
setBusyRow(invite.id);
|
|
576
646
|
later(() => {
|
|
577
647
|
setBusyRow(null);
|
|
578
648
|
setConfirmingInvite(null);
|
|
579
649
|
setInvites((list) => list.filter((i) => i.id !== invite.id));
|
|
650
|
+
focusAfterRemoving(shown, invite.id);
|
|
580
651
|
toastIds.current.push(toast({ type: 'success', message: `Invite for ${invite.email} revoked.` }));
|
|
581
652
|
}, 1200);
|
|
582
653
|
}
|
|
@@ -649,7 +720,7 @@ export default function MembersListTable() {
|
|
|
649
720
|
<Stack gap="small">
|
|
650
721
|
<Cluster justify="between">
|
|
651
722
|
<Heading level={1} size="h5">Members</Heading>
|
|
652
|
-
{canManage && <Button size="small" type="primary" state="enabled" label="Invite Member" decoIcon="UserPlus" onClickButton={handleInviteMember} />}
|
|
723
|
+
{canManage && <Button ref={inviteButton} size="small" type="primary" state="enabled" label="Invite Member" decoIcon="UserPlus" onClickButton={handleInviteMember} />}
|
|
653
724
|
</Cluster>
|
|
654
725
|
<Paragraph tone="secondary" size="body2" measure="none">{seatsUsed} of {seatLimit} seats used on the Free plan.</Paragraph>
|
|
655
726
|
{!canManage && <Paragraph tone="secondary" size="body2" measure="none">Only admins can change this.</Paragraph>}
|
|
@@ -705,11 +776,11 @@ export default function MembersListTable() {
|
|
|
705
776
|
confirmingMember === m.id ? (
|
|
706
777
|
<Cluster gap="small">
|
|
707
778
|
<Paragraph size="body2" measure="none">Remove {m.name}?</Paragraph>
|
|
708
|
-
<Button size="small" type="tertiary" state={busyRow === m.id ? 'disabled' : 'enabled'} label="Cancel" aria-label={`Cancel removing ${m.name}`} onClickButton={() =>
|
|
779
|
+
<Button ref={cancelConfirm} size="small" type="tertiary" state={busyRow === m.id ? 'disabled' : 'enabled'} label="Cancel" aria-label={`Cancel removing ${m.name}`} onClickButton={() => cancelConfirmOn(m.id)} />
|
|
709
780
|
<Button size="small" type="primary" color="danger" state="enabled" label="Remove" aria-label={`Remove ${m.name}`} loading={busyRow === m.id} onClickButton={() => handleRemove(m)} />
|
|
710
781
|
</Cluster>
|
|
711
782
|
) : (
|
|
712
|
-
<Button size="small" type="tertiary" state={busyRow ? 'disabled' : 'enabled'} label="Remove" aria-label={`Remove ${m.name}`} onClickButton={() => startConfirm('member', m.id)} />
|
|
783
|
+
<Button ref={(el) => { rowButtons.current[m.id] = el; }} size="small" type="tertiary" state={busyRow ? 'disabled' : 'enabled'} label="Remove" aria-label={`Remove ${m.name}`} onClickButton={() => startConfirm('member', m.id)} />
|
|
713
784
|
)
|
|
714
785
|
)}
|
|
715
786
|
</TableCell>
|
|
@@ -735,14 +806,14 @@ export default function MembersListTable() {
|
|
|
735
806
|
{confirmingInvite === i.id ? (
|
|
736
807
|
<Cluster gap="small">
|
|
737
808
|
<Paragraph size="body2" measure="none">Revoke this invite?</Paragraph>
|
|
738
|
-
<Button size="small" type="tertiary" state={busyRow === i.id ? 'disabled' : 'enabled'} label="Cancel" aria-label={`Cancel revoking the invite for ${i.email}`} onClickButton={() =>
|
|
809
|
+
<Button ref={cancelConfirm} size="small" type="tertiary" state={busyRow === i.id ? 'disabled' : 'enabled'} label="Cancel" aria-label={`Cancel revoking the invite for ${i.email}`} onClickButton={() => cancelConfirmOn(i.id)} />
|
|
739
810
|
<Button size="small" type="primary" color="danger" state="enabled" label="Revoke" aria-label={`Revoke invite for ${i.email}`} loading={busyRow === i.id} onClickButton={() => handleRevokeInvite(i)} />
|
|
740
811
|
</Cluster>
|
|
741
812
|
) : (
|
|
742
813
|
<Stack gap="small">
|
|
743
814
|
<Cluster gap="small">
|
|
744
815
|
<Button size="small" type="tertiary" state={busyRow ? 'disabled' : 'enabled'} label={copiedInvite === i.id ? 'Copied' : 'Copy Link'} aria-label={`${copiedInvite === i.id ? 'Copied' : 'Copy Link'} for ${i.email}`} onClickButton={() => handleCopy(i)} />
|
|
745
|
-
<Button size="small" type="tertiary" state={busyRow ? 'disabled' : 'enabled'} label="Revoke Invite" aria-label={`Revoke invite for ${i.email}`} onClickButton={() => startConfirm('invite', i.id)} />
|
|
816
|
+
<Button ref={(el) => { rowButtons.current[i.id] = el; }} size="small" type="tertiary" state={busyRow ? 'disabled' : 'enabled'} label="Revoke Invite" aria-label={`Revoke invite for ${i.email}`} onClickButton={() => startConfirm('invite', i.id)} />
|
|
746
817
|
</Cluster>
|
|
747
818
|
{copyBlocked === i.id && <Paragraph tone="secondary" size="caption" measure="none">Copying is blocked here. Select the link and copy it: {i.link}</Paragraph>}
|
|
748
819
|
</Stack>
|
|
@@ -81,12 +81,13 @@ export default function MessageComposerWithTools() {
|
|
|
81
81
|
clearTimeout(cancel.current);
|
|
82
82
|
clearInterval(tick.current);
|
|
83
83
|
}; }, []);
|
|
84
|
-
// The run is over: its own row, in the same place and with the same time, now holds the reply or the note.
|
|
85
|
-
function endRun(rowId, text) {
|
|
84
|
+
// The run is over: its own row, in the same place and with the same time, now holds the reply, or the steps and a note.
|
|
85
|
+
function endRun(rowId, text, stopped) {
|
|
86
|
+
if (stopped === void 0) { stopped = false; }
|
|
86
87
|
clearTimeout(runTimer.current);
|
|
87
88
|
clearInterval(tick.current);
|
|
88
89
|
setRun(null);
|
|
89
|
-
setThread(function (rows) { return rows.map(function (m) { return (m.id === rowId ? __assign(__assign({}, m), { text: text, progress: false }) : m); }); });
|
|
90
|
+
setThread(function (rows) { return rows.map(function (m) { return (m.id === rowId ? __assign(__assign({}, m), { text: text, progress: false, stopped: stopped }) : m); }); });
|
|
90
91
|
}
|
|
91
92
|
function addRow(row) {
|
|
92
93
|
setThread(function (rows) { return __spreadArray(__spreadArray([], rows, true), [__assign(__assign({}, row), { id: "m".concat(rows.length + 1) })], false); });
|
|
@@ -121,8 +122,9 @@ export default function MessageComposerWithTools() {
|
|
|
121
122
|
endRun(rowId, 'The email reads well. The pricing link in the second paragraph points to last year\'s page.');
|
|
122
123
|
}, 3000);
|
|
123
124
|
}
|
|
124
|
-
// Stop asks the server to end the run, and shows loading until it has. Only then does the
|
|
125
|
-
// stopped
|
|
125
|
+
// Stop asks the server to end the run, and shows loading until it has. Only then does the row say it
|
|
126
|
+
// stopped: it keeps its steps, the one not done is cancelled, and a line says what was done.
|
|
127
|
+
// Stop is gone, so focus goes to the message box.
|
|
126
128
|
function stop() {
|
|
127
129
|
if (!run || run.stopping)
|
|
128
130
|
return;
|
|
@@ -131,7 +133,7 @@ export default function MessageComposerWithTools() {
|
|
|
131
133
|
// Stands in for the request to the server.
|
|
132
134
|
cancel.current = setTimeout(function () {
|
|
133
135
|
var _a;
|
|
134
|
-
endRun(run.rowId, 'Stopped. Nothing was changed.');
|
|
136
|
+
endRun(run.rowId, 'Stopped after 1 of 2 steps. Nothing was changed.', true);
|
|
135
137
|
(_a = field.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
136
138
|
}, 1200);
|
|
137
139
|
}
|
|
@@ -160,7 +162,15 @@ export default function MessageComposerWithTools() {
|
|
|
160
162
|
</Message>) : (<Message key={m.id} aria-label={m.agent ? "".concat(m.from, ", agent") : m.from} compact={followsOn(thread, i)} avatar={m.agent ? <UserImage userHandle={m.from} icon={Bot} decorative/> : <UserImage userHandle={m.from} decorative/>} name={m.from} meta={m.agent ? agentMeta(m.at) : <TimeStamp createdAt={m.at} dateFormat="absolute" data="time"/>}
|
|
161
163
|
// A sent file opens when its chip is pressed. A real app links to the stored file.
|
|
162
164
|
footer={m.file ? <FileChip name={m.file.name} kind={m.file.kind} meta={m.file.size} href="/files/launch-email.pdf" openInNewTab/> : undefined}>
|
|
163
|
-
{m.
|
|
165
|
+
{m.stopped ? (
|
|
166
|
+
// As in the case 'Agent at work': the steps stay, with the one not done cancelled.
|
|
167
|
+
<Stack gap="medium">
|
|
168
|
+
<StepList aria-label="Acme Agent's steps" steps={[
|
|
169
|
+
{ label: 'Read the thread', status: 'done' },
|
|
170
|
+
{ label: 'Checking the links in the email', status: 'cancelled' },
|
|
171
|
+
]}/>
|
|
172
|
+
<Paragraph measure="none">{m.text}</Paragraph>
|
|
173
|
+
</Stack>) : (m.text && <Paragraph measure="none">{m.text}</Paragraph>)}
|
|
164
174
|
</Message>);
|
|
165
175
|
})}
|
|
166
176
|
</Stack>
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
A person writes a message at the bottom of a thread.
|
|
4
4
|
|
|
5
|
+
For: an app, an agent
|
|
6
|
+
|
|
5
7
|
## Do
|
|
6
8
|
|
|
7
9
|
- Use `Composer` under the thread, with an `aria-label`, since it has no visible label.
|
|
@@ -14,10 +16,10 @@ A person writes a message at the bottom of a thread.
|
|
|
14
16
|
- Pass `onStop` in a conversation with the agent only, so Send becomes Stop.
|
|
15
17
|
- Show the agent's name, its 'Agent' `Tag`, the model line, the seconds so far and a `StepList` on the progress row. The case 'Agent at work' has the full pattern.
|
|
16
18
|
- Show 'Working for 12 seconds' in the progress row's body, above the steps.
|
|
17
|
-
- Show 'Stop' as `loading` until the run has ended. Then
|
|
19
|
+
- Show 'Stop' as `loading` until the run has ended. Then the row keeps its steps and says what was done, as the case 'Agent at work' says.
|
|
18
20
|
- Move focus to the message box when Stop goes away.
|
|
19
21
|
- Announce the progress row politely to screen readers: the app wraps the changing part in a polite live region, since the row has none.
|
|
20
|
-
- Show
|
|
22
|
+
- Show a message that did not send in the thread with its reason under it, as the case 'Message that did not send' says. While the app is offline, a warning Alert sits above the message box.
|
|
21
23
|
- Keep the draft when the person leaves the thread, and show it again when they come back.
|
|
22
24
|
|
|
23
25
|
## Don't
|
|
@@ -143,8 +145,8 @@ const me = 'Dana Lee';
|
|
|
143
145
|
const agentName = 'Acme Agent';
|
|
144
146
|
|
|
145
147
|
type Attachment = { name: string; kind: string; size: string };
|
|
146
|
-
// `progress` marks the agent's row while its run is live. The same row later holds the
|
|
147
|
-
type Row = { id: string; from: string; agent?: boolean; at: Date; text: string; file?: Attachment; progress?: boolean };
|
|
148
|
+
// `progress` marks the agent's row while its run is live. The same row later holds the reply, or the steps and a note.
|
|
149
|
+
type Row = { id: string; from: string; agent?: boolean; at: Date; text: string; file?: Attachment; progress?: boolean; stopped?: boolean };
|
|
148
150
|
|
|
149
151
|
const sampleFile: Attachment = { name: 'Launch email.pdf', kind: 'PDF', size: '240 KB' };
|
|
150
152
|
|
|
@@ -202,12 +204,12 @@ export default function MessageComposerWithTools() {
|
|
|
202
204
|
clearInterval(tick.current);
|
|
203
205
|
}, []);
|
|
204
206
|
|
|
205
|
-
// The run is over: its own row, in the same place and with the same time, now holds the reply or the note.
|
|
206
|
-
function endRun(rowId: string, text: string) {
|
|
207
|
+
// The run is over: its own row, in the same place and with the same time, now holds the reply, or the steps and a note.
|
|
208
|
+
function endRun(rowId: string, text: string, stopped = false) {
|
|
207
209
|
clearTimeout(runTimer.current);
|
|
208
210
|
clearInterval(tick.current);
|
|
209
211
|
setRun(null);
|
|
210
|
-
setThread((rows) => rows.map((m) => (m.id === rowId ? { ...m, text, progress: false } : m)));
|
|
212
|
+
setThread((rows) => rows.map((m) => (m.id === rowId ? { ...m, text, progress: false, stopped } : m)));
|
|
211
213
|
}
|
|
212
214
|
|
|
213
215
|
function addRow(row: Omit<Row, 'id'>) {
|
|
@@ -245,15 +247,16 @@ export default function MessageComposerWithTools() {
|
|
|
245
247
|
}, 3000);
|
|
246
248
|
}
|
|
247
249
|
|
|
248
|
-
// Stop asks the server to end the run, and shows loading until it has. Only then does the
|
|
249
|
-
// stopped
|
|
250
|
+
// Stop asks the server to end the run, and shows loading until it has. Only then does the row say it
|
|
251
|
+
// stopped: it keeps its steps, the one not done is cancelled, and a line says what was done.
|
|
252
|
+
// Stop is gone, so focus goes to the message box.
|
|
250
253
|
function stop() {
|
|
251
254
|
if (!run || run.stopping) return;
|
|
252
255
|
clearTimeout(runTimer.current);
|
|
253
256
|
setRun({ ...run, stopping: true });
|
|
254
257
|
// Stands in for the request to the server.
|
|
255
258
|
cancel.current = setTimeout(() => {
|
|
256
|
-
endRun(run.rowId, 'Stopped. Nothing was changed.');
|
|
259
|
+
endRun(run.rowId, 'Stopped after 1 of 2 steps. Nothing was changed.', true);
|
|
257
260
|
field.current?.focus();
|
|
258
261
|
}, 1200);
|
|
259
262
|
}
|
|
@@ -304,7 +307,21 @@ export default function MessageComposerWithTools() {
|
|
|
304
307
|
// A sent file opens when its chip is pressed. A real app links to the stored file.
|
|
305
308
|
footer={m.file ? <FileChip name={m.file.name} kind={m.file.kind} meta={m.file.size} href="/files/launch-email.pdf" openInNewTab /> : undefined}
|
|
306
309
|
>
|
|
307
|
-
{m.
|
|
310
|
+
{m.stopped ? (
|
|
311
|
+
// As in the case 'Agent at work': the steps stay, with the one not done cancelled.
|
|
312
|
+
<Stack gap="medium">
|
|
313
|
+
<StepList
|
|
314
|
+
aria-label="Acme Agent's steps"
|
|
315
|
+
steps={[
|
|
316
|
+
{ label: 'Read the thread', status: 'done' },
|
|
317
|
+
{ label: 'Checking the links in the email', status: 'cancelled' },
|
|
318
|
+
]}
|
|
319
|
+
/>
|
|
320
|
+
<Paragraph measure="none">{m.text}</Paragraph>
|
|
321
|
+
</Stack>
|
|
322
|
+
) : (
|
|
323
|
+
m.text && <Paragraph measure="none">{m.text}</Paragraph>
|
|
324
|
+
)}
|
|
308
325
|
</Message>
|
|
309
326
|
),
|
|
310
327
|
)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function MessageSendFailureNeedsAPerson(): import("react").JSX.Element;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
14
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
15
|
+
if (ar || !(i in from)) {
|
|
16
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
17
|
+
ar[i] = from[i];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
21
|
+
};
|
|
22
|
+
import { useEffect, useRef, useState } from 'react';
|
|
23
|
+
import Message from '../../components/message';
|
|
24
|
+
import UserImage from '../../components/userImage';
|
|
25
|
+
import TimeStamp from '../../components/timeStamp';
|
|
26
|
+
import Heading from '../../components/heading';
|
|
27
|
+
import Paragraph from '../../components/paragraph';
|
|
28
|
+
import Link from '../../components/link';
|
|
29
|
+
import Button from '../../components/button';
|
|
30
|
+
import Composer from '../../components/composer';
|
|
31
|
+
import { Center, Cluster, Stack } from '../../components/layout';
|
|
32
|
+
// A real app reads this from the session.
|
|
33
|
+
var me = 'Dana Lee';
|
|
34
|
+
// This thread is shared with a Figma file. Dana's access to Figma ran out, so her last reply did not send.
|
|
35
|
+
var firstThread = [
|
|
36
|
+
{ id: 'm1', from: 'Ben Carter', at: new Date('2026-11-16T14:31:00'), text: 'The hero image is too dark on phones.', state: 'sent' },
|
|
37
|
+
{ id: 'm2', from: 'Omar Reyes', at: new Date('2026-11-16T14:35:00'), text: 'I can try a lighter one this afternoon.', state: 'sent' },
|
|
38
|
+
{ id: 'm3', from: me, at: new Date('2026-11-16T14:40:00'), text: 'Yes, try the lighter one and we check it on Monday.', state: 'failed' },
|
|
39
|
+
];
|
|
40
|
+
// Names a message by its first words, for the Buttons under it.
|
|
41
|
+
var firstWords = function (text) { return (text.length > 32 ? "".concat(text.slice(0, 32).trimEnd(), "\u2026") : text); };
|
|
42
|
+
export default function MessageSendFailureNeedsAPerson() {
|
|
43
|
+
var _a = useState(firstThread), thread = _a[0], setThread = _a[1];
|
|
44
|
+
var _b = useState(false), connected = _b[0], setConnected = _b[1];
|
|
45
|
+
var _c = useState(''), text = _c[0], setText = _c[1];
|
|
46
|
+
// Said once, in the polite status line, when a message has gone.
|
|
47
|
+
var _d = useState(''), status = _d[0], setStatus = _d[1];
|
|
48
|
+
var timer = useRef();
|
|
49
|
+
var composer = useRef(null);
|
|
50
|
+
// Each new message gets its own id, so no two rows share one after a discard.
|
|
51
|
+
var nextId = useRef(firstThread.length + 1);
|
|
52
|
+
// Where focus goes after the next render, once the element it goes to is on screen.
|
|
53
|
+
var focusNext = useRef();
|
|
54
|
+
// Stops the request if the example goes away before it ends.
|
|
55
|
+
useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
|
|
56
|
+
useEffect(function () {
|
|
57
|
+
var move = focusNext.current;
|
|
58
|
+
focusNext.current = undefined;
|
|
59
|
+
move === null || move === void 0 ? void 0 : move();
|
|
60
|
+
});
|
|
61
|
+
// The Composer keeps working. Until Figma is reconnected, a new reply cannot send either, and says so.
|
|
62
|
+
function send() {
|
|
63
|
+
var id = "m".concat(nextId.current++);
|
|
64
|
+
setThread(function (rows) { return __spreadArray(__spreadArray([], rows, true), [{ id: id, from: me, at: new Date(), text: text.trim(), state: connected ? 'sent' : 'failed' }], false); });
|
|
65
|
+
setText('');
|
|
66
|
+
}
|
|
67
|
+
// Stands in for a person who reconnected Figma first, so it sends.
|
|
68
|
+
function tryAgain(id) {
|
|
69
|
+
if (thread.some(function (m) { return m.state === 'sending'; }))
|
|
70
|
+
return;
|
|
71
|
+
setThread(function (rows) { return rows.map(function (m) { return (m.id === id ? __assign(__assign({}, m), { state: 'sending' }) : m); }); });
|
|
72
|
+
timer.current = setTimeout(function () {
|
|
73
|
+
setThread(function (rows) { return rows.map(function (m) { return (m.id === id ? __assign(__assign({}, m), { state: 'sent' }) : m); }); });
|
|
74
|
+
setConnected(true);
|
|
75
|
+
setStatus('Message sent.');
|
|
76
|
+
// The line and its Buttons are gone, so focus goes to the message box.
|
|
77
|
+
focusNext.current = function () { var _a; return (_a = composer.current) === null || _a === void 0 ? void 0 : _a.focus(); };
|
|
78
|
+
}, 1200);
|
|
79
|
+
}
|
|
80
|
+
// Takes the message out of the thread. It was never sent, so no one else saw it.
|
|
81
|
+
function discard(id) {
|
|
82
|
+
setThread(function (rows) { return rows.filter(function (m) { return m.id !== id; }); });
|
|
83
|
+
focusNext.current = function () { var _a; return (_a = composer.current) === null || _a === void 0 ? void 0 : _a.focus(); };
|
|
84
|
+
}
|
|
85
|
+
return (<Center width="page">
|
|
86
|
+
<Stack gap="large">
|
|
87
|
+
<Stack gap="small">
|
|
88
|
+
<Heading level={1} size="h5">Homepage hero</Heading>
|
|
89
|
+
<Paragraph tone="secondary" size="body2" measure="none">Replies here also go to the comments on the Figma file.</Paragraph>
|
|
90
|
+
</Stack>
|
|
91
|
+
{/* A real app gives the list that holds the rows role="log". */}
|
|
92
|
+
<Stack gap="small">
|
|
93
|
+
{thread.map(function (m) {
|
|
94
|
+
var notSent = m.state !== 'sent';
|
|
95
|
+
return (<Message key={m.id} aria-label={notSent ? "".concat(m.from, ", not sent") : m.from} avatar={<UserImage userHandle={m.from} decorative/>} name={m.from} meta={<TimeStamp createdAt={m.at} dateFormat="absolute" data="time"/>} footer={notSent ? (<Stack gap="small">
|
|
96
|
+
{/* The reason and its fix. The link goes where the fix is done. */}
|
|
97
|
+
<Paragraph size="body2" tone="secondary" measure="none">
|
|
98
|
+
Not sent. <Link href="/settings/integrations" size="body2">Reconnect Figma</Link>, then send again.
|
|
99
|
+
</Paragraph>
|
|
100
|
+
<Cluster gap="small">
|
|
101
|
+
<Button size="small" type="secondary" state="enabled" label="Try Again" aria-label={"Try again: ".concat(firstWords(m.text))} loading={m.state === 'sending'} onClickButton={function () { return tryAgain(m.id); }}/>
|
|
102
|
+
<Button size="small" type="tertiary" state={m.state === 'sending' ? 'disabled' : 'enabled'} label="Discard" aria-label={"Discard: ".concat(firstWords(m.text))} onClickButton={function () { return discard(m.id); }}/>
|
|
103
|
+
</Cluster>
|
|
104
|
+
</Stack>) : undefined}>
|
|
105
|
+
<Paragraph measure="none">{m.text}</Paragraph>
|
|
106
|
+
</Message>);
|
|
107
|
+
})}
|
|
108
|
+
</Stack>
|
|
109
|
+
<Stack gap="small">
|
|
110
|
+
{/* On the page from the start, so it is heard once when the message goes. */}
|
|
111
|
+
<Paragraph role="status" size="body2" tone="secondary" measure="none">{status}</Paragraph>
|
|
112
|
+
<Composer ref={composer} id="message-send-failure-needs-a-person-message" aria-label="Message" placeholder="Message the team" value={text} onChange={setText} onSubmit={send}/>
|
|
113
|
+
</Stack>
|
|
114
|
+
</Stack>
|
|
115
|
+
</Center>);
|
|
116
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function MessageSendFailureRetrying(): import("react").JSX.Element;
|