@estiva-app/ui 0.103.0 → 0.104.2
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/MoveDialog.d.ts +12 -1
- package/dist/MoveDialog.d.ts.map +1 -1
- package/dist/ResolveDialog.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +337 -329
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
- package/registry.json +8 -2
- package/src/MoveDialog.mdx +6 -0
- package/src/MoveDialog.stories.tsx +13 -0
- package/src/MoveDialog.test.tsx +40 -1
- package/src/MoveDialog.tsx +19 -1
- package/src/ResolveDialog.test.tsx +11 -0
- package/src/ResolveDialog.tsx +5 -2
- package/src/gates/gates.test.ts +13 -1
- package/src/index.ts +1 -1
package/package.json
CHANGED
package/registry.json
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
"kind": "package",
|
|
5
5
|
"repo": "estiva-ui",
|
|
6
6
|
"package": "@estiva-app/ui",
|
|
7
|
-
"packageVersion": "0.
|
|
7
|
+
"packageVersion": "0.104.2",
|
|
8
8
|
"exports": 245,
|
|
9
|
-
"typeExports":
|
|
9
|
+
"typeExports": 254,
|
|
10
10
|
"files": null
|
|
11
11
|
},
|
|
12
12
|
"storybook": {
|
|
@@ -7230,6 +7230,12 @@
|
|
|
7230
7230
|
"required": false,
|
|
7231
7231
|
"note": "Said when no Folder is offered. \"There is no other folder it can be moved to.\" when absent."
|
|
7232
7232
|
},
|
|
7233
|
+
{
|
|
7234
|
+
"name": "check",
|
|
7235
|
+
"takes": "MoveCheck",
|
|
7236
|
+
"required": false,
|
|
7237
|
+
"note": "A box under the choice, asked only where `label` names it; its answer comes back as `checked`."
|
|
7238
|
+
},
|
|
7233
7239
|
{
|
|
7234
7240
|
"name": "onMove",
|
|
7235
7241
|
"takes": "a handler",
|
package/src/MoveDialog.mdx
CHANGED
|
@@ -65,6 +65,12 @@ import { MoveDialog } from '@estiva-app/ui'
|
|
|
65
65
|
- Pass only the Folders a move can land in: filter `folders` before, by your
|
|
66
66
|
app's own rules (a Folder that cannot take it). A move your app refuses when
|
|
67
67
|
it is made is answered with `false`, said why, and the dialog stays.
|
|
68
|
+
- `check` adds one box under the choice that only some Folders ask:
|
|
69
|
+
`label(folder)` gives its words there, or `undefined` to leave it out;
|
|
70
|
+
`checked` ticks it at open. `onMove` then gets `checked`, only when the box
|
|
71
|
+
was shown for the Folder picked.
|
|
72
|
+
|
|
73
|
+
<Canvas of={MoveDialogStories.WithABox} />
|
|
68
74
|
|
|
69
75
|
<Canvas of={MoveDialogStories.FolderUnreadable} />
|
|
70
76
|
|
|
@@ -120,6 +120,19 @@ export const ListedTwice: Story = {
|
|
|
120
120
|
},
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
+
/** A box only some Folders ask, ticked as it opened: here Steer asks it and Estiva HQ does not. The story picks Steer. */
|
|
124
|
+
export const WithABox: Story = {
|
|
125
|
+
name: 'With a box',
|
|
126
|
+
args: {
|
|
127
|
+
title: 'Folders: navigation for the whole suite',
|
|
128
|
+
from: '',
|
|
129
|
+
places: undefined,
|
|
130
|
+
placesIn: undefined,
|
|
131
|
+
check: { label: (folder: string) => (folder === 'steer' ? 'Label' : undefined), checked: true },
|
|
132
|
+
},
|
|
133
|
+
play: pickSteer,
|
|
134
|
+
}
|
|
135
|
+
|
|
123
136
|
/** Moving: the button says so, and everything waits for the answer. */
|
|
124
137
|
export const Moving: Story = {
|
|
125
138
|
args: { onMove: () => new Promise<boolean>(() => {}) },
|
package/src/MoveDialog.test.tsx
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import { afterEach, describe, expect, it, vi } from 'vitest'
|
|
9
9
|
import { cleanup, render, screen, waitFor } from '@testing-library/react'
|
|
10
10
|
import userEvent from '@testing-library/user-event'
|
|
11
|
-
import { MoveDialog, type MoveDialogProps, type MovePlace } from './MoveDialog'
|
|
11
|
+
import { MoveDialog, type MoveChoice, type MoveDialogProps, type MovePlace } from './MoveDialog'
|
|
12
12
|
|
|
13
13
|
afterEach(cleanup)
|
|
14
14
|
|
|
@@ -231,6 +231,45 @@ describe('MoveDialog, a file not listed in exactly one Folder (`from` empty; Shi
|
|
|
231
231
|
expect(onMove).toHaveBeenLastCalledWith({ folder: 'steer' })
|
|
232
232
|
})
|
|
233
233
|
|
|
234
|
+
it('asks the box only for the Folders that name it, ticked as it opened, and says what it answered', async () => {
|
|
235
|
+
const onMove = vi.fn(async () => true)
|
|
236
|
+
const check = { label: (folder: string) => (folder === 'steer' ? 'Keep it a space in Steer' : undefined), checked: true }
|
|
237
|
+
render(<Fixture {...flat} folders={[HQ, STEER, THIRD]} check={check} onMove={onMove} />)
|
|
238
|
+
await pick('Folder', 'Third')
|
|
239
|
+
expect(screen.queryByRole('checkbox')).toBeNull()
|
|
240
|
+
await pick('Folder', 'Steer')
|
|
241
|
+
const box = screen.getByRole('checkbox', { name: 'Keep it a space in Steer' })
|
|
242
|
+
expect(box.getAttribute('aria-checked')).toBe('true')
|
|
243
|
+
await userEvent.click(box)
|
|
244
|
+
await userEvent.click(screen.getByRole('button', { name: 'Move' }))
|
|
245
|
+
await waitFor(() => expect(onMove).toHaveBeenCalledWith({ folder: 'steer', checked: false }))
|
|
246
|
+
})
|
|
247
|
+
|
|
248
|
+
it('a Folder that does not ask the box moves with no answer for it, even after another Folder showed it ticked', async () => {
|
|
249
|
+
const onMove = vi.fn(async (_choice: MoveChoice) => true)
|
|
250
|
+
const check = { label: (folder: string) => (folder === 'steer' ? 'Keep it a space in Steer' : undefined), checked: true }
|
|
251
|
+
render(<Fixture {...flat} folders={[HQ, STEER, THIRD]} check={check} onMove={onMove} />)
|
|
252
|
+
await pick('Folder', 'Steer')
|
|
253
|
+
expect(screen.getByRole('checkbox', { name: 'Keep it a space in Steer' }).getAttribute('aria-checked')).toBe('true')
|
|
254
|
+
await pick('Folder', 'Third')
|
|
255
|
+
expect(screen.queryByRole('checkbox')).toBeNull()
|
|
256
|
+
await userEvent.click(screen.getByRole('button', { name: 'Move' }))
|
|
257
|
+
await waitFor(() => expect(onMove).toHaveBeenCalledTimes(1))
|
|
258
|
+
expect(onMove.mock.calls[0][0]).toEqual({ folder: 'third' })
|
|
259
|
+
expect(onMove.mock.calls[0][0]).not.toHaveProperty('checked')
|
|
260
|
+
})
|
|
261
|
+
|
|
262
|
+
it('a file that nests sends the box’s answer with the place it goes under', async () => {
|
|
263
|
+
const onMove = vi.fn(async () => true)
|
|
264
|
+
const check = { label: (folder: string) => (folder === 'steer' ? 'Keep it a space in Steer' : undefined), checked: true }
|
|
265
|
+
render(<Fixture startAtTop placesIn={vi.fn(async () => [TOP])} check={check} onMove={onMove} />)
|
|
266
|
+
await pick('Folder', 'Steer')
|
|
267
|
+
expect(screen.getByRole('checkbox', { name: 'Keep it a space in Steer' }).getAttribute('aria-checked')).toBe('true')
|
|
268
|
+
await waitFor(() => expect((screen.getByRole('button', { name: 'Move' }) as HTMLButtonElement).disabled).toBe(false))
|
|
269
|
+
await userEvent.click(screen.getByRole('button', { name: 'Move' }))
|
|
270
|
+
await waitFor(() => expect(onMove).toHaveBeenCalledWith({ folder: 'steer', parent: '', checked: true }))
|
|
271
|
+
})
|
|
272
|
+
|
|
234
273
|
it('listed in one again (`from` named), the one it is in is held back once more', async () => {
|
|
235
274
|
const { rerender } = render(<Fixture {...flat} folders={[HQ, STEER, THIRD]} />)
|
|
236
275
|
rerender(<Fixture {...flat} from="hq" folders={[HQ, STEER, THIRD]} />)
|
package/src/MoveDialog.tsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useEffect, useRef, useState } from 'react'
|
|
2
|
+
import { Checkbox } from './Checkbox'
|
|
2
3
|
import { EmptyState } from './EmptyState'
|
|
3
4
|
import { Field } from './Field'
|
|
4
5
|
import { FormDialog } from './FormDialog'
|
|
@@ -24,6 +25,16 @@ export interface MovePlace {
|
|
|
24
25
|
export interface MoveChoice {
|
|
25
26
|
folder: string
|
|
26
27
|
parent?: string
|
|
28
|
+
/** Whether `check`'s box was ticked; only when it was shown for the Folder picked. */
|
|
29
|
+
checked?: boolean
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** A box under the choice that only some Folders offer, such as "Keep it a space in <team>" where the person may mark one. */
|
|
33
|
+
export interface MoveCheck {
|
|
34
|
+
/** The box's words for a Folder, or `undefined` to leave it out there. */
|
|
35
|
+
label: (folder: string) => string | undefined
|
|
36
|
+
/** Ticked when the dialog opens. */
|
|
37
|
+
checked: boolean
|
|
27
38
|
}
|
|
28
39
|
|
|
29
40
|
/**
|
|
@@ -67,6 +78,8 @@ export interface MoveDialogProps {
|
|
|
67
78
|
folderLabel?: string
|
|
68
79
|
/** Said when no Folder is offered. "There is no other folder it can be moved to." when absent. */
|
|
69
80
|
noFolder?: string
|
|
81
|
+
/** A box under the choice, asked only where `label` names it; its answer comes back as `checked`. */
|
|
82
|
+
check?: MoveCheck
|
|
70
83
|
/** Answer `false` to keep the dialog open (you have said why); anything else closes it. */
|
|
71
84
|
onMove: (choice: MoveChoice) => Promise<boolean | void> | boolean | void
|
|
72
85
|
onClose: () => void
|
|
@@ -85,9 +98,11 @@ export function MoveDialog({
|
|
|
85
98
|
heading = 'Move',
|
|
86
99
|
folderLabel = 'Folder',
|
|
87
100
|
noFolder = 'There is no other folder it can be moved to.',
|
|
101
|
+
check,
|
|
88
102
|
onMove,
|
|
89
103
|
onClose,
|
|
90
104
|
}: MoveDialogProps) {
|
|
105
|
+
const [ticked, setTicked] = useState(check?.checked ?? false)
|
|
91
106
|
const nests = !!placesIn
|
|
92
107
|
// Moving a file that nests under nothing into the Folder it is in would do nothing, so that one is not offered.
|
|
93
108
|
const destinations = folders && (nests ? folders : folders.filter((folder) => folder.id !== from))
|
|
@@ -130,6 +145,8 @@ export function MoveDialog({
|
|
|
130
145
|
const valueOf = (place: MovePlace) => place.id || TOP
|
|
131
146
|
const parent = picked ?? (startAtTop && targets[0] && !targets[0].id ? TOP : undefined)
|
|
132
147
|
const ready = !!folder && (!nests || !!parent)
|
|
148
|
+
const checkLabel = folder ? check?.label(folder) : undefined
|
|
149
|
+
const asked = checkLabel === undefined ? {} : { checked: ticked }
|
|
133
150
|
|
|
134
151
|
return (
|
|
135
152
|
<FormDialog
|
|
@@ -137,7 +154,7 @@ export function MoveDialog({
|
|
|
137
154
|
submitLabel="Move"
|
|
138
155
|
busyLabel="Moving…"
|
|
139
156
|
ready={ready}
|
|
140
|
-
onSubmit={() => onMove(nests ? { folder, parent: parent === TOP ? '' : parent } : { folder })}
|
|
157
|
+
onSubmit={() => onMove({ ...(nests ? { folder, parent: parent === TOP ? '' : parent } : { folder }), ...asked })}
|
|
141
158
|
onClose={onClose}
|
|
142
159
|
>
|
|
143
160
|
{destinations?.length === 0 ? (
|
|
@@ -179,6 +196,7 @@ export function MoveDialog({
|
|
|
179
196
|
/>
|
|
180
197
|
</Field>
|
|
181
198
|
))}
|
|
199
|
+
{checkLabel !== undefined && <Checkbox checked={ticked} onChange={setTicked} label={checkLabel} />}
|
|
182
200
|
</>
|
|
183
201
|
)}
|
|
184
202
|
</FormDialog>
|
|
@@ -71,4 +71,15 @@ describe('ResolveDialog', () => {
|
|
|
71
71
|
render(<ResolveDialog onResolve={() => false} onCancel={() => {}} refused="The file is archived" />)
|
|
72
72
|
expect(screen.getByText(/The file is archived/)).toBeTruthy()
|
|
73
73
|
})
|
|
74
|
+
|
|
75
|
+
// Found in Leaf's adoption (3 November): the refusal marked the note invalid, and the form then sent nothing.
|
|
76
|
+
it('after a refusal, Resolve tries again, with the note as written', async () => {
|
|
77
|
+
const user = userEvent.setup()
|
|
78
|
+
const onResolve = vi.fn(() => false)
|
|
79
|
+
render(<ResolveDialog onResolve={onResolve} onCancel={() => {}} refused="The relay is busy. Try again." />)
|
|
80
|
+
await user.type(screen.getByRole('textbox'), 'Done')
|
|
81
|
+
await user.click(screen.getByRole('button', { name: 'Resolve' }))
|
|
82
|
+
await vi.waitFor(() => expect(onResolve).toHaveBeenCalledWith('Done'))
|
|
83
|
+
expect(screen.getByRole('alert').textContent).toBe('The relay is busy. Try again.')
|
|
84
|
+
})
|
|
74
85
|
})
|
package/src/ResolveDialog.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useState } from 'react'
|
|
2
|
-
import { Field } from './Field'
|
|
2
|
+
import { Field, FieldLine } from './Field'
|
|
3
3
|
import { FormDialog } from './FormDialog'
|
|
4
4
|
import { Textarea } from './Textarea'
|
|
5
5
|
|
|
@@ -22,8 +22,11 @@ export function ResolveDialog({ onResolve, onCancel, refused }: ResolveDialogPro
|
|
|
22
22
|
return (
|
|
23
23
|
// Outlined at rest and green on hover in Signal, the kit's `resolve` look.
|
|
24
24
|
<FormDialog title="Resolve" submitLabel="Resolve" submitVariant="resolve" onSubmit={() => onResolve(note)} onClose={onCancel}>
|
|
25
|
-
<Field label="Resolution message (optional)"
|
|
25
|
+
<Field label="Resolution message (optional)">
|
|
26
|
+
{/* The refusal in the error line's place, 6px under the note, without marking the note invalid: an invalid field
|
|
27
|
+
stops the form, and Resolve could not try again (found in Leaf's adoption, 3 November). */}
|
|
26
28
|
<Textarea autoFocus value={note} onChange={(e) => setNote(e.target.value)} placeholder="Summarize the outcome or decision..." className="h-[109px]" />
|
|
29
|
+
{refused && <FieldLine tone="error">{refused}</FieldLine>}
|
|
27
30
|
</Field>
|
|
28
31
|
</FormDialog>
|
|
29
32
|
)
|
package/src/gates/gates.test.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'nod
|
|
|
3
3
|
import { join } from 'node:path'
|
|
4
4
|
import { pathToFileURL } from 'node:url'
|
|
5
5
|
import { ESLint, type Linter } from 'eslint'
|
|
6
|
-
import { afterAll, describe, expect, it } from 'vitest'
|
|
6
|
+
import { afterAll, beforeAll, describe, expect, it } from 'vitest'
|
|
7
7
|
import { appChecks } from './app-checks'
|
|
8
8
|
import { countCommitted, hookRuns, skippedFolders, skipsListed } from './ci'
|
|
9
9
|
import { writeGateCount } from './count'
|
|
@@ -354,6 +354,18 @@ describe('runHook', () => {
|
|
|
354
354
|
})
|
|
355
355
|
|
|
356
356
|
describe('gates:status', () => {
|
|
357
|
+
// The made apps sit inside this repository, so status read it as theirs and fetched its origin, once or twice a test:
|
|
358
|
+
// on the release machine that took up to 20 s and the tests ran out of time (v0.104.1, 3 November). Git stops looking
|
|
359
|
+
// at `node_modules`, so an app is no repository unless a test makes it one.
|
|
360
|
+
const ceiling = process.env.GIT_CEILING_DIRECTORIES
|
|
361
|
+
beforeAll(() => {
|
|
362
|
+
process.env.GIT_CEILING_DIRECTORIES = join(root, 'node_modules')
|
|
363
|
+
})
|
|
364
|
+
afterAll(() => {
|
|
365
|
+
if (ceiling === undefined) delete process.env.GIT_CEILING_DIRECTORIES
|
|
366
|
+
else process.env.GIT_CEILING_DIRECTORIES = ceiling
|
|
367
|
+
})
|
|
368
|
+
|
|
357
369
|
it('reads a CI job by its id, a committed hook, and a script', () => {
|
|
358
370
|
const dir = app('status-helpers', {
|
|
359
371
|
'.github/workflows/deploy.yml': 'jobs:\n check:\n steps:\n - run: npm test\n gate:\n steps:\n # - run: npm run lint:rules\n - run: npm run lint:rules\n',
|
package/src/index.ts
CHANGED
|
@@ -15,7 +15,7 @@ export { AttachmentCard, type AttachmentCardProps, type AttachmentCardState } fr
|
|
|
15
15
|
export { Avatar, hueFor, initialsFor, type AvatarProps } from './Avatar'
|
|
16
16
|
export { AvatarGroup, type AvatarGroupMember, type AvatarGroupProps } from './AvatarGroup'
|
|
17
17
|
export { MembersPill, type MembersPillProps } from './MembersPill'
|
|
18
|
-
export { MoveDialog, type MoveChoice, type MoveDialogProps, type MoveFolder, type MovePlace } from './MoveDialog'
|
|
18
|
+
export { MoveDialog, type MoveCheck, type MoveChoice, type MoveDialogProps, type MoveFolder, type MovePlace } from './MoveDialog'
|
|
19
19
|
export { MembersDialog, type MembersDialogCandidate, type MembersDialogMember, type MembersDialogProps, type MembersDialogSelfAction } from './MembersDialog'
|
|
20
20
|
export { Banner, type BannerProps, type BannerTone } from './Banner'
|
|
21
21
|
export { BlockHandle, blockAtY, type BlockHandleProps, type BlockHandleEditing, type HandleBlock } from './BlockHandle'
|