@remit/ui 0.0.216 → 0.0.218
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/calendar-invite-card.render.test.ts +19 -0
- package/src/components/calendar-invite-card.stories.tsx +28 -2
- package/src/components/calendar-invite-card.tsx +11 -3
- package/src/components/calendar-types.ts +3 -1
- package/src/components/intelligence-panel-calendar.stories.tsx +46 -9
package/package.json
CHANGED
|
@@ -103,6 +103,25 @@ describe("CalendarInviteCard", () => {
|
|
|
103
103
|
assert.match(html, /Offer other times/);
|
|
104
104
|
});
|
|
105
105
|
|
|
106
|
+
it("offers Change on every answered card, dismissed included", () => {
|
|
107
|
+
for (const html of [
|
|
108
|
+
render({ rsvp: "accepted" }),
|
|
109
|
+
render({ rsvp: "tentative" }),
|
|
110
|
+
render({ rsvp: "declined" }),
|
|
111
|
+
render({ invite: { ...kickoffInvite, state: "dismissed" } }),
|
|
112
|
+
]) {
|
|
113
|
+
assert.match(html, />Change</);
|
|
114
|
+
assert.doesNotMatch(html, />Add to calendar</);
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it("says a dismissed card was dismissed, and names no reply", () => {
|
|
119
|
+
const html = render({ invite: { ...kickoffInvite, state: "dismissed" } });
|
|
120
|
+
assert.match(html, /You dismissed this/);
|
|
121
|
+
assert.doesNotMatch(html, /On your calendar/);
|
|
122
|
+
assert.doesNotMatch(html, /No reply/);
|
|
123
|
+
});
|
|
124
|
+
|
|
106
125
|
it("gives a thumb targets it can hit", () => {
|
|
107
126
|
assert.match(render({ touch: true }), /min-h-11/);
|
|
108
127
|
assert.doesNotMatch(render(), /min-h-11/);
|
|
@@ -85,6 +85,20 @@ export const Declined: Story = {
|
|
|
85
85
|
args: { ...base, rsvp: "declined", clashes: [] },
|
|
86
86
|
};
|
|
87
87
|
|
|
88
|
+
/** Answered, then the organiser's cancellation was answered into the same event, so this one offers no Change. */
|
|
89
|
+
export const AnsweredThenCancelled: Story = {
|
|
90
|
+
args: { ...base, rsvp: "accepted", clashes: [], onReopen: undefined },
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
/** Dismissed without an answer. Change brings the answers back. */
|
|
94
|
+
export const Dismissed: Story = {
|
|
95
|
+
args: {
|
|
96
|
+
...base,
|
|
97
|
+
invite: { ...kickoffInvite, state: "dismissed" },
|
|
98
|
+
clashes: [],
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
|
|
88
102
|
/** A later message carried a higher SEQUENCE, so this one is not the question. */
|
|
89
103
|
export const OvertakenByANewerRevision: Story = {
|
|
90
104
|
args: { ...base, invite: superseded, onOpenNewer: () => undefined },
|
|
@@ -119,18 +133,30 @@ export const Touch: Story = {
|
|
|
119
133
|
args: { ...base, touch: true },
|
|
120
134
|
};
|
|
121
135
|
|
|
122
|
-
/**
|
|
136
|
+
/**
|
|
137
|
+
* The card answering for real, so the review is a click-through. Every answer,
|
|
138
|
+
* dismissing included, offers Change, which asks again.
|
|
139
|
+
*/
|
|
123
140
|
export const Answering: Story = {
|
|
124
141
|
render: () => {
|
|
125
142
|
const [rsvp, setRsvp] = useState<RsvpState>("noReply");
|
|
143
|
+
const [dismissed, setDismissed] = useState(false);
|
|
126
144
|
return (
|
|
127
145
|
<CalendarInviteCard
|
|
128
146
|
{...base}
|
|
147
|
+
invite={{
|
|
148
|
+
...kickoffInvite,
|
|
149
|
+
state: dismissed ? "dismissed" : "pending",
|
|
150
|
+
}}
|
|
129
151
|
rsvp={rsvp}
|
|
130
152
|
onAdd={() => setRsvp("accepted")}
|
|
131
153
|
onTentative={() => setRsvp("tentative")}
|
|
132
154
|
onDecline={() => setRsvp("declined")}
|
|
133
|
-
|
|
155
|
+
mute={{ sender: "Priya Natarajan", onMute: () => setDismissed(true) }}
|
|
156
|
+
onReopen={() => {
|
|
157
|
+
setRsvp("noReply");
|
|
158
|
+
setDismissed(false);
|
|
159
|
+
}}
|
|
134
160
|
/>
|
|
135
161
|
);
|
|
136
162
|
},
|
|
@@ -99,6 +99,14 @@ const tallyWord: Record<RsvpState, string> = {
|
|
|
99
99
|
noReply: "no reply",
|
|
100
100
|
};
|
|
101
101
|
|
|
102
|
+
const answeredText = (
|
|
103
|
+
state: CalendarInvite["state"],
|
|
104
|
+
rsvp: RsvpState,
|
|
105
|
+
): string => {
|
|
106
|
+
if (state === "dismissed") return "You dismissed this";
|
|
107
|
+
return rsvp === "declined" ? "You declined" : "On your calendar";
|
|
108
|
+
};
|
|
109
|
+
|
|
102
110
|
export function CalendarInviteCard({
|
|
103
111
|
invite,
|
|
104
112
|
whenText,
|
|
@@ -253,7 +261,7 @@ export function CalendarInviteCard({
|
|
|
253
261
|
)}
|
|
254
262
|
|
|
255
263
|
{!stale &&
|
|
256
|
-
(rsvp === "noReply" ? (
|
|
264
|
+
(rsvp === "noReply" && invite.state !== "dismissed" ? (
|
|
257
265
|
<div className="flex flex-col gap-2 border-t border-line pt-3">
|
|
258
266
|
<div className={cn("flex gap-2", touch && "flex-wrap")}>
|
|
259
267
|
<Button
|
|
@@ -317,8 +325,8 @@ export function CalendarInviteCard({
|
|
|
317
325
|
<div className="flex flex-col gap-2 border-t border-line pt-3">
|
|
318
326
|
<div className="flex flex-wrap items-center gap-3">
|
|
319
327
|
<span className="flex items-center gap-1.5 text-sm text-fg">
|
|
320
|
-
{rsvp
|
|
321
|
-
<RsvpBadge rsvp={rsvp} />
|
|
328
|
+
{answeredText(invite.state, rsvp)}
|
|
329
|
+
{invite.state !== "dismissed" && <RsvpBadge rsvp={rsvp} />}
|
|
322
330
|
</span>
|
|
323
331
|
{onReopen && (
|
|
324
332
|
<Button
|
|
@@ -194,11 +194,13 @@ export type CalendarParseMethod = "ics" | "markup" | "pattern";
|
|
|
194
194
|
* Where an invitation stands. `superseded` is a later message carrying a higher
|
|
195
195
|
* SEQUENCE for the same UID. `cancelled` is a METHOD:CANCEL that still needs
|
|
196
196
|
* the reader to act, because nothing leaves the calendar without a person
|
|
197
|
-
* saying so either.
|
|
197
|
+
* saying so either. `dismissed` was waved away without an answer, and can
|
|
198
|
+
* still be taken back.
|
|
198
199
|
*/
|
|
199
200
|
export type CalendarInviteState =
|
|
200
201
|
| "pending"
|
|
201
202
|
| "answered"
|
|
203
|
+
| "dismissed"
|
|
202
204
|
| "superseded"
|
|
203
205
|
| "cancelled";
|
|
204
206
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
2
|
import { type ReactNode, useState } from "react";
|
|
3
|
+
import { expect, userEvent, within } from "storybook/test";
|
|
3
4
|
import type { RsvpState } from "./calendar-types.js";
|
|
4
5
|
import type { IntelligenceCalendarData } from "./intelligence-calendar.js";
|
|
5
6
|
import {
|
|
@@ -67,6 +68,7 @@ function PanelDemo({
|
|
|
67
68
|
calendar.invite?.rsvp ?? "noReply",
|
|
68
69
|
);
|
|
69
70
|
const [removed, setRemoved] = useState(false);
|
|
71
|
+
const [dismissed, setDismissed] = useState(false);
|
|
70
72
|
const [offering, setOffering] = useState(calendar.prose !== undefined);
|
|
71
73
|
const [picked, setPicked] = useState<string[]>([]);
|
|
72
74
|
const [dropped, setDropped] = useState<string[]>([]);
|
|
@@ -84,7 +86,14 @@ function PanelDemo({
|
|
|
84
86
|
...calendar,
|
|
85
87
|
invite:
|
|
86
88
|
calendar.invite && !removed
|
|
87
|
-
? {
|
|
89
|
+
? {
|
|
90
|
+
...calendar.invite,
|
|
91
|
+
invite: dismissed
|
|
92
|
+
? { ...calendar.invite.invite, state: "dismissed" }
|
|
93
|
+
: calendar.invite.invite,
|
|
94
|
+
rsvp,
|
|
95
|
+
sender: sender.sender.name,
|
|
96
|
+
}
|
|
88
97
|
: undefined,
|
|
89
98
|
prose,
|
|
90
99
|
suggestions: calendar.suggestions.filter(
|
|
@@ -110,10 +119,18 @@ function PanelDemo({
|
|
|
110
119
|
onReopenInvite:
|
|
111
120
|
calendar.invite?.invite.state === "cancelled"
|
|
112
121
|
? () => setRemoved(true)
|
|
113
|
-
:
|
|
114
|
-
|
|
122
|
+
: () => {
|
|
123
|
+
setRsvp("noReply");
|
|
124
|
+
setDismissed(false);
|
|
125
|
+
},
|
|
126
|
+
onMuteInvite: () => setDismissed(true),
|
|
115
127
|
onOfferOtherTimes: () => setOffering(true),
|
|
116
128
|
onRemoveInvite: () => setRemoved(true),
|
|
129
|
+
onOpenNewerInvite:
|
|
130
|
+
calendar.invite?.invite.state === "superseded"
|
|
131
|
+
? () =>
|
|
132
|
+
setLastAction("opened the newer revision's conversation")
|
|
133
|
+
: undefined,
|
|
117
134
|
onToggleSlot: (slot) => {
|
|
118
135
|
setPicked((prev) =>
|
|
119
136
|
prev.includes(slot.startTime)
|
|
@@ -314,6 +331,19 @@ export const Declined = rail(KICKOFF, organiserSender, {
|
|
|
314
331
|
},
|
|
315
332
|
});
|
|
316
333
|
|
|
334
|
+
/**
|
|
335
|
+
* Dismissed, or muted, without an answer. The card stays beside the message,
|
|
336
|
+
* and Change brings the answers back.
|
|
337
|
+
*/
|
|
338
|
+
export const Dismissed = rail(KICKOFF, organiserSender, {
|
|
339
|
+
...inviteWithClash,
|
|
340
|
+
invite: inviteWithClash.invite && {
|
|
341
|
+
...inviteWithClash.invite,
|
|
342
|
+
invite: { ...inviteWithClash.invite.invite, state: "dismissed" },
|
|
343
|
+
clashes: [],
|
|
344
|
+
},
|
|
345
|
+
});
|
|
346
|
+
|
|
317
347
|
/**
|
|
318
348
|
* Answered maybe. The event is on the calendar as tentative, and the organiser
|
|
319
349
|
* was not told.
|
|
@@ -374,13 +404,20 @@ export const InviteWithNothingBooked = rail(
|
|
|
374
404
|
* A later message carried a higher SEQUENCE for the same UID. The stale one is
|
|
375
405
|
* dimmed and its buttons are gone: answering a revision that has been replaced
|
|
376
406
|
* puts the wrong hour on the calendar, so the card offers the newer one instead
|
|
377
|
-
* of an answer.
|
|
407
|
+
* of an answer, and pressing it opens the conversation that carries it.
|
|
378
408
|
*/
|
|
379
|
-
export const SupersededInvitation =
|
|
380
|
-
KICKOFF,
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
409
|
+
export const SupersededInvitation: Story = {
|
|
410
|
+
...rail(KICKOFF, organiserSender, supersededInvite),
|
|
411
|
+
play: async ({ canvasElement }) => {
|
|
412
|
+
const canvas = within(canvasElement);
|
|
413
|
+
await userEvent.click(
|
|
414
|
+
canvas.getByRole("button", { name: "Open the newer invitation" }),
|
|
415
|
+
);
|
|
416
|
+
await expect(
|
|
417
|
+
canvas.getByText("Prototype: opened the newer revision's conversation"),
|
|
418
|
+
).toBeVisible();
|
|
419
|
+
},
|
|
420
|
+
};
|
|
384
421
|
|
|
385
422
|
/**
|
|
386
423
|
* METHOD:CANCEL on something already accepted. Reader does not take it off by
|