@estiva-app/ui 0.104.3 → 0.106.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/dist/AttachmentCard.d.ts.map +1 -1
- package/dist/CommentBox.d.ts +10 -6
- package/dist/CommentBox.d.ts.map +1 -1
- package/dist/ConversationCard.d.ts +4 -3
- package/dist/ConversationCard.d.ts.map +1 -1
- package/dist/MoveDialog.d.ts +2 -2
- package/dist/MoveDialog.d.ts.map +1 -1
- package/dist/ReactionRow.d.ts +12 -2
- package/dist/ReactionRow.d.ts.map +1 -1
- package/dist/conversation.examples.d.ts +28 -2
- package/dist/conversation.examples.d.ts.map +1 -1
- package/dist/editor.js +163 -23
- package/dist/editor.js.map +4 -4
- package/dist/index.js +105 -11
- package/dist/index.js.map +4 -4
- package/package.json +3 -3
- package/registry.json +8 -20
- package/src/ArchiveDialog.mdx +2 -2
- package/src/ArchiveDialog.stories.tsx +5 -5
- package/src/AttachmentCard.tsx +4 -1
- package/src/CommentBox.mdx +5 -2
- package/src/CommentBox.stories.tsx +57 -25
- package/src/CommentBox.test.tsx +72 -12
- package/src/CommentBox.tsx +59 -23
- package/src/ConversationCard.mdx +2 -0
- package/src/ConversationCard.stories.tsx +30 -6
- package/src/ConversationCard.test.tsx +63 -1
- package/src/ConversationCard.tsx +39 -7
- package/src/FormDialog.mdx +3 -3
- package/src/FormDialog.stories.tsx +5 -5
- package/src/MoveDialog.mdx +16 -16
- package/src/MoveDialog.stories.tsx +22 -22
- package/src/MoveDialog.test.tsx +58 -48
- package/src/MoveDialog.tsx +8 -7
- package/src/ReactionRow.tsx +8 -2
- package/src/conversation.examples.tsx +36 -7
|
@@ -12,8 +12,8 @@ const PROJECT: MovePlace = { id: '30850:a:folders', path: ['Folders: navigation
|
|
|
12
12
|
const BRIEF: MovePlace = { id: '30840:a:brief', path: ['Folders: navigation for the whole suite', 'Brief'] }
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
* Moving a file to another
|
|
16
|
-
* its own
|
|
15
|
+
* Moving a file to another team, under another file, or both. The places in
|
|
16
|
+
* its own team are the caller's, read before it opens; another team's are
|
|
17
17
|
* read when it is picked.
|
|
18
18
|
*/
|
|
19
19
|
const meta = {
|
|
@@ -42,34 +42,34 @@ type Story = StoryObj<typeof meta>
|
|
|
42
42
|
|
|
43
43
|
const pickSteer = async ({ canvasElement }: { canvasElement: HTMLElement }) => {
|
|
44
44
|
const page = within(canvasElement.ownerDocument.body)
|
|
45
|
-
await userEvent.click(page.getByRole('combobox', { name: '
|
|
45
|
+
await userEvent.click(page.getByRole('combobox', { name: 'Team' }))
|
|
46
46
|
await userEvent.click(await page.findByRole('option', { name: 'Steer' }))
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
/** A file that may sit under any other: its own
|
|
49
|
+
/** A file that may sit under any other: its own team first, at the top, with every other place there. */
|
|
50
50
|
export const Topic: Story = {}
|
|
51
51
|
|
|
52
|
-
/** A file that nests under nothing: only the
|
|
52
|
+
/** A file that nests under nothing: only the team is asked, and not the one it is in. Move waits for a pick. */
|
|
53
53
|
export const Project: Story = {
|
|
54
54
|
args: { title: 'Folders: navigation for the whole suite', places: undefined, placesIn: undefined },
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
/** Nowhere to go in its own
|
|
57
|
+
/** Nowhere to go in its own team: one holding only this file and what is under it. */
|
|
58
58
|
export const NowhereHere: Story = {
|
|
59
59
|
name: 'Nowhere here',
|
|
60
60
|
args: { places: [] },
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
/** Another
|
|
63
|
+
/** Another team could not be read: the section's empty line, with Try again. */
|
|
64
64
|
export const FolderUnreadable: Story = {
|
|
65
|
-
name: '
|
|
65
|
+
name: 'Team unreadable',
|
|
66
66
|
args: { places: [], placesIn: (): Promise<readonly MovePlace[]> => Promise.reject(new Error('down')) },
|
|
67
67
|
play: pickSteer,
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
/** Another
|
|
70
|
+
/** Another team, still being read: the second list says so and waits. */
|
|
71
71
|
export const ReadingAFolder: Story = {
|
|
72
|
-
name: 'Reading a
|
|
72
|
+
name: 'Reading a team',
|
|
73
73
|
args: { placesIn: () => new Promise<readonly MovePlace[]>(() => {}) },
|
|
74
74
|
play: pickSteer,
|
|
75
75
|
}
|
|
@@ -80,26 +80,26 @@ export const UnderNone: Story = {
|
|
|
80
80
|
args: { startAtTop: false, topLabel: 'None — under none of these', places: [TOP, PROJECT] },
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
/** The
|
|
83
|
+
/** The teams are still being read: the list says so. */
|
|
84
84
|
export const ReadingFolders: Story = {
|
|
85
85
|
name: 'Reading folders',
|
|
86
86
|
args: { folders: undefined },
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
/** No
|
|
89
|
+
/** No team to offer: said in the dialog's body, and Move stays greyed. */
|
|
90
90
|
export const NoOtherFolder: Story = {
|
|
91
|
-
name: 'No other
|
|
91
|
+
name: 'No other team',
|
|
92
92
|
args: { folders: [FOLDERS[0]], places: undefined, placesIn: undefined },
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
/** Another app's words, opening on the
|
|
95
|
+
/** Another app's words, opening on the team the app chose. */
|
|
96
96
|
export const AnotherAppsWords: Story = {
|
|
97
97
|
name: 'Another app’s words',
|
|
98
98
|
args: {
|
|
99
|
-
heading: 'Move to
|
|
100
|
-
folderLabel: 'Destination
|
|
101
|
-
noFolder: 'There is no other
|
|
102
|
-
description: 'Only the
|
|
99
|
+
heading: 'Move to team',
|
|
100
|
+
folderLabel: 'Destination team',
|
|
101
|
+
noFolder: 'There is no other team it can be moved to.',
|
|
102
|
+
description: 'Only the team it is listed in changes. Its issues and its conversation stay exactly as they are.',
|
|
103
103
|
title: 'Folders: navigation for the whole suite',
|
|
104
104
|
places: undefined,
|
|
105
105
|
placesIn: undefined,
|
|
@@ -108,19 +108,19 @@ export const AnotherAppsWords: Story = {
|
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
/**
|
|
111
|
-
* A file listed in two
|
|
111
|
+
* A file listed in two teams, after a move that half-worked: `from` is empty, so every team is offered, the ones
|
|
112
112
|
* it is in too, since moving into one takes it out of the other; Move again is the retry. Nothing is chosen for the
|
|
113
113
|
* person. The story opens the list.
|
|
114
114
|
*/
|
|
115
115
|
export const ListedTwice: Story = {
|
|
116
|
-
name: 'Listed in two
|
|
116
|
+
name: 'Listed in two teams',
|
|
117
117
|
args: { title: 'Folders: navigation for the whole suite', from: '', places: undefined, placesIn: undefined },
|
|
118
118
|
play: async ({ canvasElement }) => {
|
|
119
|
-
await userEvent.click(within(canvasElement.ownerDocument.body).getByRole('combobox', { name: '
|
|
119
|
+
await userEvent.click(within(canvasElement.ownerDocument.body).getByRole('combobox', { name: 'Team' }))
|
|
120
120
|
},
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
/** A box only some
|
|
123
|
+
/** A box only some teams ask, ticked as it opened: here Steer asks it and Estiva HQ does not. The story picks Steer. */
|
|
124
124
|
export const WithABox: Story = {
|
|
125
125
|
name: 'With a box',
|
|
126
126
|
args: {
|
package/src/MoveDialog.test.tsx
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// @vitest-environment jsdom
|
|
2
2
|
/**
|
|
3
|
-
* Move a file to another
|
|
3
|
+
* Move a file to another team, under another file, or both (FOL-45): Peek's
|
|
4
4
|
* MoveDialog, moved into the kit (C11, 2 November) with Peek's tests, and
|
|
5
|
-
* what Leaf's and Ship's moves need beside them. A
|
|
5
|
+
* what Leaf's and Ship's moves need beside them. A team that could not be
|
|
6
6
|
* read is said as the section's empty line with its Try again (B8).
|
|
7
7
|
*/
|
|
8
8
|
import { afterEach, describe, expect, it, vi } from 'vitest'
|
|
@@ -44,16 +44,16 @@ const pick = async (name: string, option: string) => {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
describe('MoveDialog (FOL-45, Peek’s tests)', () => {
|
|
47
|
-
it('opens on the
|
|
47
|
+
it('opens on the team the file is in, with only real moves there', async () => {
|
|
48
48
|
render(<Fixture places={[BRIEF]} />)
|
|
49
49
|
expect(await optionsOf('Put it under')).toEqual(['Brief'])
|
|
50
50
|
})
|
|
51
51
|
|
|
52
|
-
it('reads another
|
|
52
|
+
it('reads another team when it is picked, and moves to its top by default', async () => {
|
|
53
53
|
const placesIn = vi.fn(async () => [TOP, BRIEF])
|
|
54
54
|
const onMove = vi.fn(async () => true)
|
|
55
55
|
render(<Fixture startAtTop placesIn={placesIn} onMove={onMove} />)
|
|
56
|
-
await pick('
|
|
56
|
+
await pick('Team', 'Steer')
|
|
57
57
|
expect(placesIn).toHaveBeenCalledWith('steer')
|
|
58
58
|
expect(await optionsOf('Put it under')).toEqual(['The top of Steer', 'Brief'])
|
|
59
59
|
await userEvent.keyboard('{Escape}')
|
|
@@ -61,13 +61,13 @@ describe('MoveDialog (FOL-45, Peek’s tests)', () => {
|
|
|
61
61
|
await waitFor(() => expect(onMove).toHaveBeenCalledWith({ folder: 'steer', parent: '' }))
|
|
62
62
|
})
|
|
63
63
|
|
|
64
|
-
it('asks a file that nests under nothing only for the
|
|
64
|
+
it('asks a file that nests under nothing only for the team, never offers the one it is in, and waits for a pick', async () => {
|
|
65
65
|
const onMove = vi.fn(async () => true)
|
|
66
66
|
render(<Fixture places={undefined} placesIn={undefined} onMove={onMove} />)
|
|
67
67
|
expect(screen.queryByRole('combobox', { name: 'Put it under' })).toBeNull()
|
|
68
68
|
// Nothing preselected: a Move pressed straight away would be a move nobody chose.
|
|
69
69
|
expect((screen.getByRole('button', { name: 'Move' }) as HTMLButtonElement).disabled).toBe(true)
|
|
70
|
-
expect(await optionsOf('
|
|
70
|
+
expect(await optionsOf('Team')).toEqual(['Steer'])
|
|
71
71
|
await userEvent.click(await screen.findByRole('option', { name: 'Steer' }))
|
|
72
72
|
await userEvent.click(screen.getByRole('button', { name: 'Move' }))
|
|
73
73
|
await waitFor(() => expect(onMove).toHaveBeenCalledWith({ folder: 'steer' }))
|
|
@@ -76,7 +76,7 @@ describe('MoveDialog (FOL-45, Peek’s tests)', () => {
|
|
|
76
76
|
it('never picks a parent for a file whose parent is one kind: Move waits until the person does', async () => {
|
|
77
77
|
const onMove = vi.fn(async () => true)
|
|
78
78
|
render(<Fixture placesIn={async () => [LIVE]} onMove={onMove} />)
|
|
79
|
-
await pick('
|
|
79
|
+
await pick('Team', 'Steer')
|
|
80
80
|
await screen.findByRole('combobox', { name: 'Put it under' })
|
|
81
81
|
await waitFor(() => expect(screen.getByRole('combobox', { name: 'Put it under' }).hasAttribute('data-disabled')).toBe(false))
|
|
82
82
|
expect((screen.getByRole('button', { name: 'Move' }) as HTMLButtonElement).disabled).toBe(true)
|
|
@@ -85,17 +85,17 @@ describe('MoveDialog (FOL-45, Peek’s tests)', () => {
|
|
|
85
85
|
await waitFor(() => expect(onMove).toHaveBeenCalledWith({ folder: 'steer', parent: LIVE.id }))
|
|
86
86
|
})
|
|
87
87
|
|
|
88
|
-
it('says so when the picked
|
|
88
|
+
it('says so when the picked team has nowhere to put it, and does not move', async () => {
|
|
89
89
|
render(<Fixture placesIn={async () => []} />)
|
|
90
|
-
await pick('
|
|
90
|
+
await pick('Team', 'Steer')
|
|
91
91
|
expect(await screen.findByText('There is nowhere in Steer to put it.')).toBeTruthy()
|
|
92
92
|
expect((screen.getByRole('button', { name: 'Move' }) as HTMLButtonElement).disabled).toBe(true)
|
|
93
93
|
})
|
|
94
94
|
|
|
95
|
-
it('says a
|
|
95
|
+
it('says a team that could not be read, and reads it again on Try again', async () => {
|
|
96
96
|
const placesIn = vi.fn().mockRejectedValueOnce(new Error('down')).mockResolvedValueOnce([TOP])
|
|
97
97
|
render(<Fixture placesIn={placesIn} />)
|
|
98
|
-
await pick('
|
|
98
|
+
await pick('Team', 'Steer')
|
|
99
99
|
expect(await screen.findByText('Steer could not be read.')).toBeTruthy()
|
|
100
100
|
expect((screen.getByRole('button', { name: 'Move' }) as HTMLButtonElement).disabled).toBe(true)
|
|
101
101
|
await userEvent.click(screen.getByRole('button', { name: 'Try again' }))
|
|
@@ -104,9 +104,9 @@ describe('MoveDialog (FOL-45, Peek’s tests)', () => {
|
|
|
104
104
|
})
|
|
105
105
|
|
|
106
106
|
describe('MoveDialog, the kit’s', () => {
|
|
107
|
-
it('says a
|
|
107
|
+
it('says a team that could not be read as the empty line beside it does, with its Try again (B8)', async () => {
|
|
108
108
|
render(<Fixture placesIn={async () => Promise.reject(new Error('down'))} />)
|
|
109
|
-
await pick('
|
|
109
|
+
await pick('Team', 'Steer')
|
|
110
110
|
const line = await screen.findByText('Steer could not be read.')
|
|
111
111
|
const empty = screen.getByText((_, element) => element?.tagName === 'P' && element.textContent === 'Steer could not be read.')
|
|
112
112
|
expect(empty).toBe(line)
|
|
@@ -115,16 +115,16 @@ describe('MoveDialog, the kit’s', () => {
|
|
|
115
115
|
expect(line.nextElementSibling).toBe(screen.getByRole('button', { name: 'Try again' }))
|
|
116
116
|
})
|
|
117
117
|
|
|
118
|
-
it('reads two picks of one
|
|
118
|
+
it('reads two picks of one team once', async () => {
|
|
119
119
|
const placesIn = vi.fn(() => new Promise<MovePlace[]>(() => {}))
|
|
120
120
|
render(<Fixture placesIn={placesIn} />)
|
|
121
|
-
await pick('
|
|
122
|
-
await pick('
|
|
123
|
-
await pick('
|
|
121
|
+
await pick('Team', 'Steer')
|
|
122
|
+
await pick('Team', 'Estiva HQ')
|
|
123
|
+
await pick('Team', 'Steer')
|
|
124
124
|
expect(placesIn).toHaveBeenCalledTimes(1)
|
|
125
125
|
})
|
|
126
126
|
|
|
127
|
-
it('reads the
|
|
127
|
+
it('reads the team it opens on when its places were not handed in', async () => {
|
|
128
128
|
const placesIn = vi.fn(async () => [TOP])
|
|
129
129
|
render(<Fixture places={undefined} placesIn={placesIn} startAtTop />)
|
|
130
130
|
await waitFor(() => expect(placesIn).toHaveBeenCalledWith('hq'))
|
|
@@ -142,41 +142,51 @@ describe('MoveDialog, the kit’s', () => {
|
|
|
142
142
|
expect(await optionsOf('Put it under')).toEqual(['None — under none of these', 'A live project'])
|
|
143
143
|
})
|
|
144
144
|
|
|
145
|
-
it('while the
|
|
145
|
+
it('while the teams are still read, says so in the list, and does not say there is nowhere to go (Leaf’s)', () => {
|
|
146
146
|
render(<Fixture folders={undefined} />)
|
|
147
|
-
expect(screen.queryByText('There is no other
|
|
148
|
-
expect(screen.getByRole('combobox', { name: '
|
|
147
|
+
expect(screen.queryByText('There is no other team it can be moved to.')).toBeNull()
|
|
148
|
+
expect(screen.getByRole('combobox', { name: 'Team' }).textContent).toContain('Reading…')
|
|
149
149
|
})
|
|
150
150
|
|
|
151
|
-
it('
|
|
151
|
+
it('asks the person to pick a team before one is chosen', () => {
|
|
152
|
+
render(<Fixture places={undefined} placesIn={undefined} />)
|
|
153
|
+
expect(screen.getByRole('combobox', { name: 'Team' }).textContent).toContain('Pick a team')
|
|
154
|
+
})
|
|
155
|
+
|
|
156
|
+
it('says “This team” when a team with no name could not be read', async () => {
|
|
157
|
+
render(<Fixture folders={[HQ, { id: 'unnamed', name: '' }]} startIn="unnamed" placesIn={async () => Promise.reject(new Error('down'))} />)
|
|
158
|
+
expect(await screen.findByText('This team could not be read.')).toBeTruthy()
|
|
159
|
+
})
|
|
160
|
+
|
|
161
|
+
it('says there is no other team when none is offered', () => {
|
|
152
162
|
render(<Fixture folders={[HQ]} places={undefined} placesIn={undefined} />)
|
|
153
|
-
expect(screen.getByText('There is no other
|
|
163
|
+
expect(screen.getByText('There is no other team it can be moved to.')).toBeTruthy()
|
|
154
164
|
expect((screen.getByRole('button', { name: 'Move' }) as HTMLButtonElement).disabled).toBe(true)
|
|
155
165
|
})
|
|
156
166
|
|
|
157
|
-
it('takes another app’s words, and opens on the
|
|
167
|
+
it('takes another app’s words, and opens on the team it is given (Ship’s Move to team)', async () => {
|
|
158
168
|
const onMove = vi.fn(async () => true)
|
|
159
169
|
render(
|
|
160
170
|
<Fixture
|
|
161
|
-
heading="Move to
|
|
162
|
-
folderLabel="Destination
|
|
163
|
-
description="Only the
|
|
171
|
+
heading="Move to team"
|
|
172
|
+
folderLabel="Destination team"
|
|
173
|
+
description="Only the team it is listed in changes."
|
|
164
174
|
places={undefined}
|
|
165
175
|
placesIn={undefined}
|
|
166
176
|
startIn="steer"
|
|
167
177
|
onMove={onMove}
|
|
168
178
|
/>,
|
|
169
179
|
)
|
|
170
|
-
expect(screen.getByRole('dialog', { name: 'Move to
|
|
171
|
-
expect(screen.getByText('Only the
|
|
172
|
-
expect(screen.getByRole('combobox', { name: 'Destination
|
|
180
|
+
expect(screen.getByRole('dialog', { name: 'Move to team' })).toBeTruthy()
|
|
181
|
+
expect(screen.getByText('Only the team it is listed in changes.')).toBeTruthy()
|
|
182
|
+
expect(screen.getByRole('combobox', { name: 'Destination team' }).textContent).toContain('Steer')
|
|
173
183
|
await userEvent.click(screen.getByRole('button', { name: 'Move' }))
|
|
174
184
|
await waitFor(() => expect(onMove).toHaveBeenCalledWith({ folder: 'steer' }))
|
|
175
185
|
})
|
|
176
186
|
|
|
177
|
-
it('says no other
|
|
178
|
-
render(<Fixture folders={[HQ]} placesIn={undefined} noFolder="There is no other
|
|
179
|
-
expect(screen.getByText('There is no other
|
|
187
|
+
it('says no other team in the app’s words', () => {
|
|
188
|
+
render(<Fixture folders={[HQ]} placesIn={undefined} noFolder="There is no other team it can be moved to." />)
|
|
189
|
+
expect(screen.getByText('There is no other team it can be moved to.')).toBeTruthy()
|
|
180
190
|
})
|
|
181
191
|
|
|
182
192
|
it('stays open when the move is refused, and closes when it went through', async () => {
|
|
@@ -202,13 +212,13 @@ describe('MoveDialog, the kit’s', () => {
|
|
|
202
212
|
})
|
|
203
213
|
})
|
|
204
214
|
|
|
205
|
-
describe('MoveDialog, a file not listed in exactly one
|
|
215
|
+
describe('MoveDialog, a file not listed in exactly one team (`from` empty; Ship’s move, 2 November)', () => {
|
|
206
216
|
const THIRD = { id: 'third', name: 'Third' }
|
|
207
217
|
const flat = { places: undefined, placesIn: undefined, from: '' }
|
|
208
218
|
|
|
209
|
-
it('holds no
|
|
219
|
+
it('holds no team back: listed in two after a move that half-worked, or in none, every team is offered', async () => {
|
|
210
220
|
render(<Fixture {...flat} folders={[HQ, STEER, THIRD]} />)
|
|
211
|
-
expect(await optionsOf('
|
|
221
|
+
expect(await optionsOf('Team')).toEqual(['Estiva HQ', 'Steer', 'Third'])
|
|
212
222
|
})
|
|
213
223
|
|
|
214
224
|
it('chooses nothing for the person even so: Move waits for a pick, or it opens on startIn', async () => {
|
|
@@ -216,13 +226,13 @@ describe('MoveDialog, a file not listed in exactly one Folder (`from` empty; Shi
|
|
|
216
226
|
expect((screen.getByRole('button', { name: 'Move' }) as HTMLButtonElement).disabled).toBe(true)
|
|
217
227
|
cleanup()
|
|
218
228
|
render(<Fixture {...flat} folders={[HQ, STEER, THIRD]} startIn="third" />)
|
|
219
|
-
expect(screen.getByRole('combobox', { name: '
|
|
229
|
+
expect(screen.getByRole('combobox', { name: 'Team' }).textContent).toContain('Third')
|
|
220
230
|
})
|
|
221
231
|
|
|
222
|
-
it('stays open on a refusal, and Move again is the retry, to the same
|
|
232
|
+
it('stays open on a refusal, and Move again is the retry, to the same team', async () => {
|
|
223
233
|
const onMove = vi.fn(async () => false)
|
|
224
234
|
render(<Fixture {...flat} folders={[HQ, STEER, THIRD]} onMove={onMove} />)
|
|
225
|
-
await pick('
|
|
235
|
+
await pick('Team', 'Steer')
|
|
226
236
|
await userEvent.click(screen.getByRole('button', { name: 'Move' }))
|
|
227
237
|
await waitFor(() => expect(onMove).toHaveBeenCalledTimes(1))
|
|
228
238
|
await waitFor(() => expect((screen.getByRole('button', { name: 'Move' }) as HTMLButtonElement).disabled).toBe(false))
|
|
@@ -231,13 +241,13 @@ describe('MoveDialog, a file not listed in exactly one Folder (`from` empty; Shi
|
|
|
231
241
|
expect(onMove).toHaveBeenLastCalledWith({ folder: 'steer' })
|
|
232
242
|
})
|
|
233
243
|
|
|
234
|
-
it('asks the box only for the
|
|
244
|
+
it('asks the box only for the teams that name it, ticked as it opened, and says what it answered', async () => {
|
|
235
245
|
const onMove = vi.fn(async () => true)
|
|
236
246
|
const check = { label: (folder: string) => (folder === 'steer' ? 'Keep it a space in Steer' : undefined), checked: true }
|
|
237
247
|
render(<Fixture {...flat} folders={[HQ, STEER, THIRD]} check={check} onMove={onMove} />)
|
|
238
|
-
await pick('
|
|
248
|
+
await pick('Team', 'Third')
|
|
239
249
|
expect(screen.queryByRole('checkbox')).toBeNull()
|
|
240
|
-
await pick('
|
|
250
|
+
await pick('Team', 'Steer')
|
|
241
251
|
const box = screen.getByRole('checkbox', { name: 'Keep it a space in Steer' })
|
|
242
252
|
expect(box.getAttribute('aria-checked')).toBe('true')
|
|
243
253
|
await userEvent.click(box)
|
|
@@ -245,13 +255,13 @@ describe('MoveDialog, a file not listed in exactly one Folder (`from` empty; Shi
|
|
|
245
255
|
await waitFor(() => expect(onMove).toHaveBeenCalledWith({ folder: 'steer', checked: false }))
|
|
246
256
|
})
|
|
247
257
|
|
|
248
|
-
it('a
|
|
258
|
+
it('a team that does not ask the box moves with no answer for it, even after another team showed it ticked', async () => {
|
|
249
259
|
const onMove = vi.fn(async (_choice: MoveChoice) => true)
|
|
250
260
|
const check = { label: (folder: string) => (folder === 'steer' ? 'Keep it a space in Steer' : undefined), checked: true }
|
|
251
261
|
render(<Fixture {...flat} folders={[HQ, STEER, THIRD]} check={check} onMove={onMove} />)
|
|
252
|
-
await pick('
|
|
262
|
+
await pick('Team', 'Steer')
|
|
253
263
|
expect(screen.getByRole('checkbox', { name: 'Keep it a space in Steer' }).getAttribute('aria-checked')).toBe('true')
|
|
254
|
-
await pick('
|
|
264
|
+
await pick('Team', 'Third')
|
|
255
265
|
expect(screen.queryByRole('checkbox')).toBeNull()
|
|
256
266
|
await userEvent.click(screen.getByRole('button', { name: 'Move' }))
|
|
257
267
|
await waitFor(() => expect(onMove).toHaveBeenCalledTimes(1))
|
|
@@ -263,7 +273,7 @@ describe('MoveDialog, a file not listed in exactly one Folder (`from` empty; Shi
|
|
|
263
273
|
const onMove = vi.fn(async () => true)
|
|
264
274
|
const check = { label: (folder: string) => (folder === 'steer' ? 'Keep it a space in Steer' : undefined), checked: true }
|
|
265
275
|
render(<Fixture startAtTop placesIn={vi.fn(async () => [TOP])} check={check} onMove={onMove} />)
|
|
266
|
-
await pick('
|
|
276
|
+
await pick('Team', 'Steer')
|
|
267
277
|
expect(screen.getByRole('checkbox', { name: 'Keep it a space in Steer' }).getAttribute('aria-checked')).toBe('true')
|
|
268
278
|
await waitFor(() => expect((screen.getByRole('button', { name: 'Move' }) as HTMLButtonElement).disabled).toBe(false))
|
|
269
279
|
await userEvent.click(screen.getByRole('button', { name: 'Move' }))
|
|
@@ -273,6 +283,6 @@ describe('MoveDialog, a file not listed in exactly one Folder (`from` empty; Shi
|
|
|
273
283
|
it('listed in one again (`from` named), the one it is in is held back once more', async () => {
|
|
274
284
|
const { rerender } = render(<Fixture {...flat} folders={[HQ, STEER, THIRD]} />)
|
|
275
285
|
rerender(<Fixture {...flat} from="hq" folders={[HQ, STEER, THIRD]} />)
|
|
276
|
-
expect(await optionsOf('
|
|
286
|
+
expect(await optionsOf('Team')).toEqual(['Steer', 'Third'])
|
|
277
287
|
})
|
|
278
288
|
})
|
package/src/MoveDialog.tsx
CHANGED
|
@@ -74,9 +74,9 @@ export interface MoveDialogProps {
|
|
|
74
74
|
startIn?: string
|
|
75
75
|
/** The dialog's heading. "Move" when absent. */
|
|
76
76
|
heading?: string
|
|
77
|
-
/** The
|
|
77
|
+
/** The team field's label. "Team" when absent. */
|
|
78
78
|
folderLabel?: string
|
|
79
|
-
/** Said when no
|
|
79
|
+
/** Said when no team is offered. "There is no other team it can be moved to." when absent. */
|
|
80
80
|
noFolder?: string
|
|
81
81
|
/** A box under the choice, asked only where `label` names it; its answer comes back as `checked`. */
|
|
82
82
|
check?: MoveCheck
|
|
@@ -96,8 +96,8 @@ export function MoveDialog({
|
|
|
96
96
|
topLabel,
|
|
97
97
|
startIn,
|
|
98
98
|
heading = 'Move',
|
|
99
|
-
folderLabel = '
|
|
100
|
-
noFolder = 'There is no other
|
|
99
|
+
folderLabel = 'Team',
|
|
100
|
+
noFolder = 'There is no other team it can be moved to.',
|
|
101
101
|
check,
|
|
102
102
|
onMove,
|
|
103
103
|
onClose,
|
|
@@ -139,7 +139,8 @@ export function MoveDialog({
|
|
|
139
139
|
setPicked(undefined)
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
-
const
|
|
142
|
+
const chosenName = destinations?.find((candidate) => candidate.id === folder)?.name
|
|
143
|
+
const folderName = chosenName || 'this team'
|
|
143
144
|
const status = nests && folder ? read[folder] : undefined
|
|
144
145
|
const targets = Array.isArray(status) ? (status as readonly MovePlace[]) : []
|
|
145
146
|
const valueOf = (place: MovePlace) => place.id || TOP
|
|
@@ -171,14 +172,14 @@ export function MoveDialog({
|
|
|
171
172
|
value={folder}
|
|
172
173
|
onChange={chooseFolder}
|
|
173
174
|
options={(destinations ?? []).map((candidate) => ({ value: candidate.id, label: candidate.name }))}
|
|
174
|
-
placeholder={destinations ? 'Pick a
|
|
175
|
+
placeholder={destinations ? 'Pick a team' : 'Reading…'}
|
|
175
176
|
ariaLabel={folderLabel}
|
|
176
177
|
/>
|
|
177
178
|
</Field>
|
|
178
179
|
{nests &&
|
|
179
180
|
folder &&
|
|
180
181
|
(status === 'failed' ? (
|
|
181
|
-
<EmptyState scope="section" message={`${
|
|
182
|
+
<EmptyState scope="section" message={`${chosenName || 'This team'} could not be read.`} action={{ label: 'Try again', onClick: () => readPlaces(folder) }} />
|
|
182
183
|
) : Array.isArray(status) && targets.length === 0 ? (
|
|
183
184
|
<EmptyState scope="section" message={`There is nowhere in ${folderName} to put it.`} />
|
|
184
185
|
) : (
|
package/src/ReactionRow.tsx
CHANGED
|
@@ -92,11 +92,17 @@ export interface ReactionRowProps {
|
|
|
92
92
|
nameOf: (id: string) => string
|
|
93
93
|
/** Who is looking: their pills are lit, and "who reacted" says "you". */
|
|
94
94
|
viewer?: string
|
|
95
|
-
/**
|
|
96
|
-
|
|
95
|
+
/**
|
|
96
|
+
* Your reaction on or off. Absent, the row only shows (read-only, signed out). In a `ConversationCard`, answering
|
|
97
|
+
* with what the relay said lets the card say why a refused one did not go through.
|
|
98
|
+
*/
|
|
99
|
+
onToggle?: (emoji: string) => void | Promise<ReactionAnswer | void>
|
|
97
100
|
className?: string
|
|
98
101
|
}
|
|
99
102
|
|
|
103
|
+
/** What the relay said about a reaction; `reason` as it came, said in plain words by the card. */
|
|
104
|
+
export type ReactionAnswer = { accepted: true } | { accepted: false; reason: unknown }
|
|
105
|
+
|
|
100
106
|
export function ReactionRow({ reactions, options, nameOf, viewer, onToggle, className }: ReactionRowProps) {
|
|
101
107
|
const shown = reactions.filter((r) => r.by.length > 0)
|
|
102
108
|
if (shown.length === 0) return null
|
|
@@ -99,25 +99,54 @@ export function WithBlock() {
|
|
|
99
99
|
)
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
+
/**
|
|
103
|
+
* What the relay (or Estiva ID, or the network) says for each cause of a refusal, as an app hands it over raw. The kit
|
|
104
|
+
* says each in `@estiva-app/conversation`'s plain words; a story picks one to show its sentence.
|
|
105
|
+
*/
|
|
106
|
+
export const RELAY_SAYS = {
|
|
107
|
+
'Too long': 'invalid: content exceeds maximum size of 262144 bytes',
|
|
108
|
+
'Deleted, or no longer yours to write beside': 'invalid: edit target not found or not editable by you',
|
|
109
|
+
'No longer a member': 'restricted: not a channel member',
|
|
110
|
+
Archived: 'restricted: channel is archived',
|
|
111
|
+
'Too many at once': 'rate-limited: slow down',
|
|
112
|
+
'Wrong clock': 'invalid: event timestamp too far in the future',
|
|
113
|
+
'Signed out': 'auth-required: authentication required',
|
|
114
|
+
'Anything else': 'error: internal error',
|
|
115
|
+
} as const
|
|
116
|
+
export type RelaySays = keyof typeof RELAY_SAYS
|
|
117
|
+
|
|
118
|
+
/** What the server says when it refuses a file, as protocol's upload hands it over. */
|
|
119
|
+
export const SERVER_SAYS = {
|
|
120
|
+
'Too large': 'upload failed: 413 {"error":"file too large: 11534336 bytes (max 10485760)"}',
|
|
121
|
+
'Not a type it takes': 'upload failed: 415 unsupported content type',
|
|
122
|
+
'Could not be read': 'upload failed: 422 invalid image metadata',
|
|
123
|
+
'Too many at once': 'upload failed: 429 rate limit exceeded',
|
|
124
|
+
'Signed out': 'upload failed: 401 authentication failed',
|
|
125
|
+
'No longer a member': 'upload failed: 403 forbidden',
|
|
126
|
+
'Anything else': 'upload failed: 500 internal error',
|
|
127
|
+
} as const
|
|
128
|
+
export type ServerSays = keyof typeof SERVER_SAYS
|
|
129
|
+
|
|
102
130
|
const saved = (): Promise<SendAnswer> => new Promise((resolve) => setTimeout(() => resolve({ accepted: true }), 400))
|
|
103
|
-
const refused = (): Promise<SendAnswer> => new Promise((resolve) => setTimeout(() => resolve({ accepted: false, reason
|
|
131
|
+
const refused = (reason: string): Promise<SendAnswer> => new Promise((resolve) => setTimeout(() => resolve({ accepted: false, reason }), 600))
|
|
104
132
|
const asBody = (text: string): JSONContent => ({ type: 'doc', content: [{ type: 'paragraph', content: [{ type: 'text', text }] }] })
|
|
105
133
|
|
|
106
|
-
/** The box a comment is edited in: the kit's CommentBox, as an app hands it to the card. */
|
|
107
|
-
export function EditBox({ text, done, refuse
|
|
134
|
+
/** The box a comment is edited in: the kit's CommentBox, as an app hands it to the card. `refuse`: why the relay says no. */
|
|
135
|
+
export function EditBox({ text, done, refuse }: { text: string; done: () => void; refuse?: RelaySays }) {
|
|
136
|
+
const answer = () => (refuse ? refused(RELAY_SAYS[refuse]) : saved())
|
|
108
137
|
return (
|
|
109
138
|
<CommentBox
|
|
110
139
|
people={[]}
|
|
111
140
|
label="Edit"
|
|
112
141
|
placeholder={null}
|
|
113
|
-
send={
|
|
142
|
+
send={answer}
|
|
114
143
|
edit={{
|
|
115
144
|
body: asBody(text),
|
|
116
145
|
onCancel: done,
|
|
117
146
|
onSave: async () => {
|
|
118
|
-
const
|
|
119
|
-
if (
|
|
120
|
-
return
|
|
147
|
+
const said = await answer()
|
|
148
|
+
if (said.accepted) done()
|
|
149
|
+
return said
|
|
121
150
|
},
|
|
122
151
|
}}
|
|
123
152
|
/>
|