@estiva-app/ui 0.97.0 → 0.98.1
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/ConversationCard.d.ts +24 -6
- package/dist/ConversationCard.d.ts.map +1 -1
- package/dist/ConversationLayout.d.ts +18 -6
- package/dist/ConversationLayout.d.ts.map +1 -1
- package/dist/ConversationMenu.d.ts +14 -5
- package/dist/ConversationMenu.d.ts.map +1 -1
- package/dist/ReactionHorizon.d.ts +3 -1
- package/dist/ReactionHorizon.d.ts.map +1 -1
- package/dist/Thread.d.ts +9 -2
- package/dist/Thread.d.ts.map +1 -1
- package/dist/index.js +159 -68
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
- package/registry.json +140 -18
- package/src/ConversationCard.mdx +4 -2
- package/src/ConversationCard.states.test.tsx +25 -5
- package/src/ConversationCard.stories.tsx +3 -3
- package/src/ConversationCard.test.tsx +44 -4
- package/src/ConversationCard.tsx +69 -36
- package/src/ConversationLayout.mdx +12 -0
- package/src/ConversationLayout.stories.tsx +47 -0
- package/src/ConversationLayout.test.tsx +100 -0
- package/src/ConversationLayout.tsx +98 -20
- package/src/ConversationMenu.mdx +5 -2
- package/src/ConversationMenu.stories.tsx +19 -1
- package/src/ConversationMenu.test.tsx +17 -4
- package/src/ConversationMenu.tsx +37 -16
- package/src/ReactionHorizon.mdx +1 -0
- package/src/ReactionHorizon.test.tsx +23 -0
- package/src/ReactionHorizon.tsx +4 -2
- package/src/Thread.mdx +2 -0
- package/src/Thread.test.tsx +17 -0
- package/src/Thread.tsx +32 -8
- package/src/linkedFrom.test.tsx +18 -0
- package/src/linkedFrom.ts +2 -2
- package/stories/Choosing.mdx +1 -1
package/src/ConversationMenu.mdx
CHANGED
|
@@ -5,14 +5,17 @@ import * as Stories from './ConversationMenu.stories'
|
|
|
5
5
|
|
|
6
6
|
# ConversationMenu
|
|
7
7
|
|
|
8
|
-
The ⋯ menu of a comment or a reply: Resolve or Reopen
|
|
8
|
+
The ⋯ menu of a comment or a reply: Resolve or Reopen and the app's own rows; then Edit on your own; then Delete on your own, apart.
|
|
9
9
|
|
|
10
10
|
<Canvas of={Stories.Yours} />
|
|
11
11
|
|
|
12
12
|
## When
|
|
13
13
|
|
|
14
14
|
- Inside **ConversationCard** and **ReplyCard**, which draw it for you.
|
|
15
|
-
- Its `children` are the app's own rows.
|
|
15
|
+
- Its `children` are the app's own rows, after Resolve; `after`, its rows after Edit.
|
|
16
|
+
- In the app's own words: `label` heads the first rows, `resolveHint` stands beside Resolve, `editLabel` is Edit's word. Peek's menu reads as it did with them (Katerina, 1 November).
|
|
17
|
+
|
|
18
|
+
<Canvas of={Stories.InAnAppsWords} />
|
|
16
19
|
|
|
17
20
|
<Canvas of={Stories.Theirs} />
|
|
18
21
|
|
|
@@ -13,7 +13,7 @@ const meta = {
|
|
|
13
13
|
component: ConversationMenu,
|
|
14
14
|
parameters: { layout: 'padded' },
|
|
15
15
|
args: { trigger: <Button variant="outlined">Open the menu</Button> },
|
|
16
|
-
argTypes: { trigger: { control: false }, children: { control: false } },
|
|
16
|
+
argTypes: { trigger: { control: false }, children: { control: false }, after: { control: false } },
|
|
17
17
|
decorators: [(Story) => <div className="flex min-h-[220px] items-start pl-[200px] pt-2">{Story()}</div>],
|
|
18
18
|
play: async ({ canvasElement }) => {
|
|
19
19
|
await userEvent.click(within(canvasElement).getByRole('button', { name: 'Open the menu' }))
|
|
@@ -40,3 +40,21 @@ export const MoreRows: Story = {
|
|
|
40
40
|
name: 'More rows',
|
|
41
41
|
args: { onResolve: () => {}, onEdit: () => {}, onDelete: () => {}, children: <MenuItem label="Item one" onClick={() => {}} /> },
|
|
42
42
|
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* In an app's own words, as Peek's menu reads (Katerina, 1 November): a heading over the first rows, the key that
|
|
46
|
+
* resolves from its box beside Resolve, its word for Edit, and a row of its own after Edit. Delete stays apart.
|
|
47
|
+
*/
|
|
48
|
+
export const InAnAppsWords: Story = {
|
|
49
|
+
name: "In an app's words",
|
|
50
|
+
args: {
|
|
51
|
+
label: 'Heading',
|
|
52
|
+
resolveHint: '->',
|
|
53
|
+
onResolve: () => {},
|
|
54
|
+
onEdit: () => {},
|
|
55
|
+
editLabel: 'Edit message',
|
|
56
|
+
after: <MenuItem label="Item two" onClick={() => {}} />,
|
|
57
|
+
onDelete: () => {},
|
|
58
|
+
children: <MenuItem label="Item one" onClick={() => {}} />,
|
|
59
|
+
},
|
|
60
|
+
}
|
|
@@ -15,7 +15,7 @@ async function open() {
|
|
|
15
15
|
const names = () => screen.getAllByRole('menuitem').map((row) => row.textContent)
|
|
16
16
|
|
|
17
17
|
describe('ConversationMenu', () => {
|
|
18
|
-
it('offers Resolve
|
|
18
|
+
it('offers Resolve and the app’s rows, then Edit, then Delete apart: three groups', async () => {
|
|
19
19
|
const onResolve = vi.fn()
|
|
20
20
|
render(
|
|
21
21
|
<ConversationMenu onResolve={onResolve} onEdit={() => {}} onDelete={() => {}}>
|
|
@@ -24,7 +24,7 @@ describe('ConversationMenu', () => {
|
|
|
24
24
|
)
|
|
25
25
|
await open()
|
|
26
26
|
expect(names()).toEqual(['Resolve', 'Open work', 'Edit', 'Delete'])
|
|
27
|
-
expect(screen.getAllByRole('separator').length).toBe(
|
|
27
|
+
expect(screen.getAllByRole('separator').length).toBe(2)
|
|
28
28
|
fireEvent.click(screen.getByRole('menuitem', { name: 'Resolve' }))
|
|
29
29
|
expect(onResolve).toHaveBeenCalledOnce()
|
|
30
30
|
})
|
|
@@ -38,10 +38,23 @@ describe('ConversationMenu', () => {
|
|
|
38
38
|
expect(onReopen).toHaveBeenCalledOnce()
|
|
39
39
|
})
|
|
40
40
|
|
|
41
|
-
it('offers Edit and Delete only when given,
|
|
41
|
+
it('offers Edit and Delete only when given, Delete apart, and no line before the first group', async () => {
|
|
42
42
|
render(<ConversationMenu onEdit={() => {}} onDelete={() => {}} />)
|
|
43
43
|
await open()
|
|
44
44
|
expect(names()).toEqual(['Edit', 'Delete'])
|
|
45
|
-
expect(screen.
|
|
45
|
+
expect(screen.getAllByRole('separator').length).toBe(1)
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
it('reads as Peek’s did, with Peek’s words passed in: a heading, the Resolve hint, "Edit message", "View details" (Katerina, 1 November)', async () => {
|
|
49
|
+
render(
|
|
50
|
+
<ConversationMenu label="Utilities" resolveHint="->" onResolve={() => {}} onEdit={() => {}} editLabel="Edit message" after={<MenuItem label="View details" onClick={() => {}} />} onDelete={() => {}}>
|
|
51
|
+
<MenuItem label="Open work" onClick={() => {}} />
|
|
52
|
+
</ConversationMenu>,
|
|
53
|
+
)
|
|
54
|
+
await open()
|
|
55
|
+
expect(names().map((n) => n?.replace('->', '').trim())).toEqual(['Resolve', 'Open work', 'Edit message', 'View details', 'Delete'])
|
|
56
|
+
expect(screen.getByText('Utilities')).toBeTruthy()
|
|
57
|
+
expect(screen.getByText('->')).toBeTruthy()
|
|
58
|
+
expect(screen.getAllByRole('separator').length).toBe(2)
|
|
46
59
|
})
|
|
47
60
|
})
|
package/src/ConversationMenu.tsx
CHANGED
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
import type { ReactElement, ReactNode } from 'react'
|
|
2
2
|
import { IconCircleCheck, IconCircleDashed, IconDotsVertical } from '@tabler/icons-react'
|
|
3
3
|
import { IconButton } from './IconButton'
|
|
4
|
-
import { Menu, MenuItem, MenuSeparator } from './Menu'
|
|
4
|
+
import { Menu, MenuItem, MenuSection, MenuSeparator } from './Menu'
|
|
5
5
|
|
|
6
6
|
export interface ConversationMenuProps {
|
|
7
7
|
/** Resolved: the menu offers Reopen in place of Resolve. */
|
|
8
8
|
resolved?: boolean
|
|
9
9
|
onResolve?: () => void
|
|
10
10
|
onReopen?: () => void
|
|
11
|
-
/**
|
|
11
|
+
/** Beside Resolve, how the app's box resolves too, as its key hint: Peek's "->". */
|
|
12
|
+
resolveHint?: string
|
|
13
|
+
/** The app's own rows, after Resolve: `MenuItem`s. */
|
|
12
14
|
children?: ReactNode
|
|
15
|
+
/** A heading over Resolve and the app's rows, in the app's words: Peek's "Utilities". */
|
|
16
|
+
label?: string
|
|
13
17
|
/** Offered on your own only. */
|
|
14
18
|
onEdit?: () => void
|
|
19
|
+
/** Edit's words: "Edit" by default; Peek's "Edit message". */
|
|
20
|
+
editLabel?: string
|
|
21
|
+
/** The app's own rows after Edit, before Delete: Peek's "View details". */
|
|
22
|
+
after?: ReactNode
|
|
15
23
|
/** Offered on your own only; the card asks before it deletes. */
|
|
16
24
|
onDelete?: () => void
|
|
17
25
|
open?: boolean
|
|
@@ -21,12 +29,30 @@ export interface ConversationMenuProps {
|
|
|
21
29
|
}
|
|
22
30
|
|
|
23
31
|
/**
|
|
24
|
-
* The ⋯ menu of a comment or a reply: Resolve or Reopen and the app's
|
|
25
|
-
* A card offers it only when it has a
|
|
26
|
-
* Peek's, moved with the conversation; its
|
|
32
|
+
* The ⋯ menu of a comment or a reply, in up to three groups: Resolve or Reopen and the app's rows; Edit on your own
|
|
33
|
+
* and the app's rows after it; Delete on your own, apart, as it is destructive. A card offers it only when it has a
|
|
34
|
+
* row to show. Peek's, moved with the conversation; what is Peek's own (its heading, its hint, its words, its rows)
|
|
35
|
+
* Peek passes in, so its menu reads as it did (Katerina, 1 November).
|
|
27
36
|
*/
|
|
28
|
-
export function ConversationMenu({ resolved = false, onResolve, onReopen, children, onEdit, onDelete, open, onOpenChange, trigger }: ConversationMenuProps) {
|
|
37
|
+
export function ConversationMenu({ resolved = false, onResolve, onReopen, resolveHint, children, label, onEdit, editLabel = 'Edit', after, onDelete, open, onOpenChange, trigger }: ConversationMenuProps) {
|
|
29
38
|
const resolves = resolved ? onReopen : onResolve
|
|
39
|
+
const first = (resolves || children) && (
|
|
40
|
+
<>
|
|
41
|
+
{resolves &&
|
|
42
|
+
(resolved ? (
|
|
43
|
+
<MenuItem leading={<IconCircleDashed size={16} stroke={1.5} className="text-text-secondary" />} label="Reopen" onClick={onReopen} />
|
|
44
|
+
) : (
|
|
45
|
+
<MenuItem leading={<IconCircleCheck size={16} stroke={1.5} className="text-text-secondary" />} label="Resolve" shortcut={resolveHint} onClick={onResolve} />
|
|
46
|
+
))}
|
|
47
|
+
{children}
|
|
48
|
+
</>
|
|
49
|
+
)
|
|
50
|
+
const middle = (onEdit || after) && (
|
|
51
|
+
<>
|
|
52
|
+
{onEdit && <MenuItem label={editLabel} onClick={onEdit} />}
|
|
53
|
+
{after}
|
|
54
|
+
</>
|
|
55
|
+
)
|
|
30
56
|
return (
|
|
31
57
|
<Menu
|
|
32
58
|
trigger={
|
|
@@ -41,16 +67,11 @@ export function ConversationMenu({ resolved = false, onResolve, onReopen, childr
|
|
|
41
67
|
onOpenChange={onOpenChange}
|
|
42
68
|
className="w-[244px]"
|
|
43
69
|
>
|
|
44
|
-
{
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
))}
|
|
50
|
-
{children}
|
|
51
|
-
{/* Edit and Delete are one group, as in Peek; the line only between two groups that are both there. */}
|
|
52
|
-
{(resolves || children) && (onEdit || onDelete) && <MenuSeparator />}
|
|
53
|
-
{onEdit && <MenuItem label="Edit" onClick={onEdit} />}
|
|
70
|
+
{first && (label ? <MenuSection label={label}>{first}</MenuSection> : first)}
|
|
71
|
+
{/* A line only between two groups that are both there. */}
|
|
72
|
+
{first && middle && <MenuSeparator />}
|
|
73
|
+
{middle}
|
|
74
|
+
{onDelete && (first || middle) && <MenuSeparator />}
|
|
54
75
|
{onDelete && <MenuItem label="Delete" destructive onClick={onDelete} />}
|
|
55
76
|
</Menu>
|
|
56
77
|
)
|
package/src/ReactionHorizon.mdx
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { afterEach, describe, expect, it } from 'vitest'
|
|
3
|
+
import { cleanup, render, screen } from '@testing-library/react'
|
|
4
|
+
import { ReactionHorizon } from './ReactionHorizon'
|
|
5
|
+
|
|
6
|
+
afterEach(cleanup)
|
|
7
|
+
|
|
8
|
+
describe('ReactionHorizon', () => {
|
|
9
|
+
it('says how far back reactions are read, in the kit’s words', () => {
|
|
10
|
+
render(<ReactionHorizon limit={100} omitted={3} />)
|
|
11
|
+
expect(screen.getByText(/the latest 100 comments and replies here\. 3 older ones were not checked\./)).toBeTruthy()
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
it('in the app’s own noun: Peek’s messages', () => {
|
|
15
|
+
render(<ReactionHorizon limit={100} omitted={1} noun="messages" />)
|
|
16
|
+
expect(screen.getByText(/the latest 100 messages and replies here\. 1 older one was not checked\./)).toBeTruthy()
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
it('draws nothing when every one was checked and the read was whole', () => {
|
|
20
|
+
const { container } = render(<ReactionHorizon limit={100} omitted={0} />)
|
|
21
|
+
expect(container.textContent).toBe('')
|
|
22
|
+
})
|
|
23
|
+
})
|
package/src/ReactionHorizon.tsx
CHANGED
|
@@ -5,19 +5,21 @@ export interface ReactionHorizonProps {
|
|
|
5
5
|
omitted: number
|
|
6
6
|
/** Some reactions may be missing: the read was cut short. */
|
|
7
7
|
cut?: boolean
|
|
8
|
+
/** What the app calls what is said, in the plural: "messages" in Peek. Default "comments". */
|
|
9
|
+
noun?: string
|
|
8
10
|
}
|
|
9
11
|
|
|
10
12
|
/**
|
|
11
13
|
* The line that says reactions are read only so far back, and how many older comments were not checked. Nothing is
|
|
12
14
|
* drawn when every one was. Peek's, moved with the conversation.
|
|
13
15
|
*/
|
|
14
|
-
export function ReactionHorizon({ limit, omitted, cut = false }: ReactionHorizonProps) {
|
|
16
|
+
export function ReactionHorizon({ limit, omitted, cut = false, noun = 'comments' }: ReactionHorizonProps) {
|
|
15
17
|
if (omitted <= 0 && !cut) return null
|
|
16
18
|
return (
|
|
17
19
|
<p className="text-caption text-text-muted">
|
|
18
20
|
{omitted > 0 && (
|
|
19
21
|
<>
|
|
20
|
-
Reactions are shown for the latest {limit}
|
|
22
|
+
Reactions are shown for the latest {limit} {noun} and replies here. {omitted} older {omitted === 1 ? 'one was' : 'ones were'} not checked.
|
|
21
23
|
</>
|
|
22
24
|
)}
|
|
23
25
|
{omitted > 0 && cut && ' '}
|
package/src/Thread.mdx
CHANGED
|
@@ -39,6 +39,8 @@ import { ReplyCard, Thread } from '@estiva-app/ui'
|
|
|
39
39
|
|
|
40
40
|
- Its replies are yours to put in time order. Who resolved it is said on the comment, not among them.
|
|
41
41
|
- Still reading: `loading`. Nobody replied yet: nothing in `children`.
|
|
42
|
+
- An app whose empty thread said nothing keeps its silence with `empty={null}`; `closeLabel` names Close in its words for a screen reader.
|
|
43
|
+
- `start.id` is put on the pinned comment as `data-thread-start`, for a link that names the comment, as ConversationLayout's comments carry `data-conversation-item`.
|
|
42
44
|
|
|
43
45
|
## What it owns
|
|
44
46
|
|
package/src/Thread.test.tsx
CHANGED
|
@@ -37,6 +37,23 @@ describe('Thread, beside (the right column)', () => {
|
|
|
37
37
|
expect(onClose).toHaveBeenCalledOnce()
|
|
38
38
|
})
|
|
39
39
|
|
|
40
|
+
it('says nothing in an empty thread when the app asks for silence (empty={null})', () => {
|
|
41
|
+
render(<Thread start={START} empty={null} />)
|
|
42
|
+
expect(screen.queryByText('No replies yet.')).toBeNull()
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
it('carries the comment’s id on the pinned comment, for a link that names it', () => {
|
|
46
|
+
const { container } = render(<Thread start={{ ...START, id: 'c1' }} />)
|
|
47
|
+
expect(container.querySelector('[data-thread-start="c1"]')?.textContent).toContain('The comment it answers')
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
it('names Close in the app’s words for a screen reader, its tooltip still "Close"', () => {
|
|
51
|
+
const onClose = vi.fn()
|
|
52
|
+
render(<Thread start={START} onClose={onClose} closeLabel="Close thread" />)
|
|
53
|
+
fireEvent.click(screen.getByRole('button', { name: 'Close thread' }))
|
|
54
|
+
expect(onClose).toHaveBeenCalledOnce()
|
|
55
|
+
})
|
|
56
|
+
|
|
40
57
|
it('says why no reply can be written in place of the box', () => {
|
|
41
58
|
render(<Thread start={START} box={<p>The box</p>} notice={<p>This file is archived.</p>} />)
|
|
42
59
|
expect(screen.getByText('This file is archived.')).toBeTruthy()
|
package/src/Thread.tsx
CHANGED
|
@@ -12,7 +12,10 @@ import { useContext } from 'react'
|
|
|
12
12
|
import { caretOnOpen, LineByLayout } from './threadCard'
|
|
13
13
|
|
|
14
14
|
/** The comment a thread answers, pinned at the top of its column. */
|
|
15
|
-
export
|
|
15
|
+
export interface ThreadStart extends PinnedCommentProps {
|
|
16
|
+
/** Its id, on the pinned comment as `data-thread-start`, as each comment of a ConversationLayout carries `data-conversation-item`: what an app scrolls to when a link names the comment. */
|
|
17
|
+
id?: string
|
|
18
|
+
}
|
|
16
19
|
|
|
17
20
|
export interface ThreadProps {
|
|
18
21
|
/** `beside`: in the right column, beside the comments, under its own header. `under`: open under its comment, in a one-column conversation: its replies hang from a line, quiet, and the box is under them; ConversationLayout makes the comment and its thread one card. */
|
|
@@ -33,6 +36,10 @@ export interface ThreadProps {
|
|
|
33
36
|
actions?: ReactNode
|
|
34
37
|
/** Closes the column. */
|
|
35
38
|
onClose?: () => void
|
|
39
|
+
/** Close's name for a screen reader, in the app's words ("Close thread"). Its tooltip still says "Close". */
|
|
40
|
+
closeLabel?: string
|
|
41
|
+
/** Beside: what an empty thread says, words or the app's own `EmptyState`. `null`: nothing, for an app whose thread stood empty and silent. Under its comment an empty thread is only its box. */
|
|
42
|
+
empty?: ReactNode
|
|
36
43
|
/** The column's name. */
|
|
37
44
|
title?: ReactNode
|
|
38
45
|
/** The column's scrolling box, for opening at the newest reply. */
|
|
@@ -44,9 +51,9 @@ export interface ThreadProps {
|
|
|
44
51
|
/** Whether there are replies: an app's `replies.map(…)` with none is an empty list, which is not nothing to React but is to the reader. */
|
|
45
52
|
const anyIn = (children: ReactNode) => Children.toArray(children).length > 0
|
|
46
53
|
|
|
47
|
-
function Replies({ children, loading }: { children?: ReactNode; loading: boolean }) {
|
|
54
|
+
function Replies({ children, loading, empty }: { children?: ReactNode; loading: boolean; empty: ReactNode }) {
|
|
48
55
|
if (loading) return <SkeletonConversation />
|
|
49
|
-
if (!anyIn(children)) return <EmptyState scope="section" message=
|
|
56
|
+
if (!anyIn(children)) return typeof empty === 'string' ? <EmptyState scope="section" message={empty} /> : <>{empty}</>
|
|
50
57
|
return <>{children}</>
|
|
51
58
|
}
|
|
52
59
|
|
|
@@ -56,7 +63,22 @@ function Replies({ children, loading }: { children?: ReactNode; loading: boolean
|
|
|
56
63
|
* column: Ship's and Leaf's), the replies hung from a line, quiet, and the box under them, all one card with the
|
|
57
64
|
* comment (Ship's way). Peek's replies column, moved with the conversation.
|
|
58
65
|
*/
|
|
59
|
-
export function Thread({
|
|
66
|
+
export function Thread({
|
|
67
|
+
place = 'beside',
|
|
68
|
+
start,
|
|
69
|
+
children,
|
|
70
|
+
loading = false,
|
|
71
|
+
resolved = false,
|
|
72
|
+
box,
|
|
73
|
+
notice,
|
|
74
|
+
actions,
|
|
75
|
+
onClose,
|
|
76
|
+
closeLabel = 'Close',
|
|
77
|
+
empty = 'No replies yet.',
|
|
78
|
+
title = 'Replies',
|
|
79
|
+
bodyRef,
|
|
80
|
+
className,
|
|
81
|
+
}: ThreadProps) {
|
|
60
82
|
const foot = notice ?? box
|
|
61
83
|
// In a ConversationLayout the layout draws the line, from the comment's face to the last reply, as one bar.
|
|
62
84
|
const layoutLine = useContext(LineByLayout)
|
|
@@ -89,7 +111,7 @@ export function Thread({ place = 'beside', start, children, loading = false, res
|
|
|
89
111
|
{resolved && <Chip type="success" label="Resolved" />}
|
|
90
112
|
{actions}
|
|
91
113
|
{onClose && (
|
|
92
|
-
<IconButton tooltip="Close" aria-label=
|
|
114
|
+
<IconButton tooltip="Close" aria-label={closeLabel} onClick={onClose}>
|
|
93
115
|
<IconX size={16} stroke={1.5} />
|
|
94
116
|
</IconButton>
|
|
95
117
|
)}
|
|
@@ -98,14 +120,16 @@ export function Thread({ place = 'beside', start, children, loading = false, res
|
|
|
98
120
|
footer={foot && <div className="p-3">{foot}</div>}
|
|
99
121
|
>
|
|
100
122
|
{start && (
|
|
101
|
-
<div className="px-4 pb-2 pt-4">
|
|
102
|
-
<PinnedComment {
|
|
123
|
+
<div className="px-4 pb-2 pt-4" data-thread-start={start.id}>
|
|
124
|
+
<PinnedComment author={start.author} time={start.time} words={start.words} deleted={start.deleted} />
|
|
103
125
|
</div>
|
|
104
126
|
)}
|
|
105
127
|
<Divider look="section" label="Replies" className="px-4 py-2" />
|
|
106
128
|
<div className="flex flex-col gap-2 px-4 pb-4">
|
|
107
129
|
<caretOnOpen.Provider value={0}>
|
|
108
|
-
<Replies loading={loading}
|
|
130
|
+
<Replies loading={loading} empty={empty}>
|
|
131
|
+
{children}
|
|
132
|
+
</Replies>
|
|
109
133
|
</caretOnOpen.Provider>
|
|
110
134
|
</div>
|
|
111
135
|
</Panel>
|
package/src/linkedFrom.test.tsx
CHANGED
|
@@ -134,6 +134,17 @@ describe('a card built from interop’s projection', () => {
|
|
|
134
134
|
expect(onAct).toHaveBeenCalledWith('set-lead', OTHER)
|
|
135
135
|
})
|
|
136
136
|
|
|
137
|
+
it('draws an agent picked as the lead as the robot, in the picker and its list', async () => {
|
|
138
|
+
const user = userEvent.setup()
|
|
139
|
+
const agent = { ...PEOPLE, [OWNER]: { displayName: 'Claude (steered by Person two)', bot: true } }
|
|
140
|
+
render(<LinkCard link={linkStateFrom({ ...GROUP, people: agent }, UNREAD, options({ onAct: vi.fn(), directory: agent }))} />)
|
|
141
|
+
const robot = 'svg path[d^="M13.5 2C13.5 2.44425"]'
|
|
142
|
+
const lead = screen.getByRole('combobox', { name: 'Lead' })
|
|
143
|
+
expect(lead.querySelectorAll(robot).length).toBe(1)
|
|
144
|
+
await user.click(lead)
|
|
145
|
+
expect((await screen.findByRole('option', { name: /Claude/ })).querySelectorAll(robot).length).toBe(1)
|
|
146
|
+
})
|
|
147
|
+
|
|
137
148
|
it('shows an archived file’s status and lead as words, even to a reader who could change them', () => {
|
|
138
149
|
render(<LinkCard link={linkStateFrom({ ...GROUP, archived: { by: OWNER, at: 1 } }, UNREAD, options({ onAct: vi.fn() }))} />)
|
|
139
150
|
expect(screen.queryByRole('combobox')).toBeNull()
|
|
@@ -187,6 +198,13 @@ describe('when it changed, and who made it', () => {
|
|
|
187
198
|
expect(screen.getByText('Updated 2h ago')).toBeTruthy()
|
|
188
199
|
})
|
|
189
200
|
|
|
201
|
+
it('draws an agent who made it as the robot, from its profile (Katerina, 1 November)', () => {
|
|
202
|
+
const card = render(<LinkCard link={linkStateFrom(PAGE, UNREAD, options({ directory: { ...PEOPLE, [OTHER]: { displayName: 'Claude (steered by Person one)', bot: true } } }))} />)
|
|
203
|
+
// A person named so would be "C"; the agent is the robot instead.
|
|
204
|
+
expect(within(card.container).queryByText('C')).toBeNull()
|
|
205
|
+
expect(card.container.querySelectorAll('svg path[d^="M13.5 2C13.5 2.44425"]').length).toBe(1)
|
|
206
|
+
})
|
|
207
|
+
|
|
190
208
|
it('leaves the person to the owner picker on a file that has one', () => {
|
|
191
209
|
const card = render(<LinkCard link={linkStateFrom({ ...GROUP, children: [] }, UNREAD, options())} />)
|
|
192
210
|
expect(within(card.container).queryByText('PT')).toBeNull()
|
package/src/linkedFrom.ts
CHANGED
|
@@ -227,7 +227,7 @@ function ownerOf(object: LinkedSource, options: Pick<LinkedFromOptions, 'directo
|
|
|
227
227
|
{ value: '', label: 'Unassigned' },
|
|
228
228
|
...Object.entries(known)
|
|
229
229
|
// The em dash for an unnameable person, never the key (FEE-1).
|
|
230
|
-
.map(([pubkey, profile]) => ({ value: pubkey, label: profile.displayName ?? '—', picture: profile.picture }))
|
|
230
|
+
.map(([pubkey, profile]) => ({ value: pubkey, label: profile.displayName ?? '—', picture: profile.picture, ...(profile.bot ? { bot: true } : {}) }))
|
|
231
231
|
.sort((a, b) => a.label.localeCompare(b.label)),
|
|
232
232
|
],
|
|
233
233
|
...(onAct ? { onChange: (value: string) => onAct(action.id, value) } : {}),
|
|
@@ -255,7 +255,7 @@ function authorOf(object: LinkedSource, directory: LinkedFromOptions['directory'
|
|
|
255
255
|
if (!pubkey || !/^[0-9a-f]{64}$/.test(pubkey)) return undefined
|
|
256
256
|
const profile = object.people?.[pubkey] ?? directory?.[pubkey]
|
|
257
257
|
if (!profile?.displayName) return undefined
|
|
258
|
-
return { name: profile.displayName, ...(profile.picture ? { picture: profile.picture } : {}) }
|
|
258
|
+
return { name: profile.displayName, ...(profile.picture ? { picture: profile.picture } : {}), ...(profile.bot ? { bot: true } : {}) }
|
|
259
259
|
}
|
|
260
260
|
|
|
261
261
|
/** The file a reference names, as the kit's chip, row and card draw it. */
|
package/stories/Choosing.mdx
CHANGED
|
@@ -95,7 +95,7 @@ The same conversation in every app; only its colours are each app's.
|
|
|
95
95
|
| One reply in a thread | **ReplyCard** — a comment's pieces, without replies of its own or Resolve |
|
|
96
96
|
| A comment's replies and the box to write one | **Thread** — in the right column under its header, or under its comment |
|
|
97
97
|
| The way into a thread | **RepliesRow** — faces, "2 replies", the last time and "1 new" |
|
|
98
|
-
| Resolving, with a note | **ResolveDialog**; the comment then says who resolved it and the note
|
|
98
|
+
| Resolving, with a note | **ResolveDialog**; the comment then says who resolved it and the note: **ConversationCard** `resolved` |
|
|
99
99
|
| The words a comment on a part is about | **QuotedLine** — above its name, and what changed since |
|
|
100
100
|
| The comment a thread answers, at the top of its replies column | **PinnedComment** — Thread draws it from its `start` |
|
|
101
101
|
| The strip on a pointed-at comment, and its ⋯ menu | **ConversationActions** and **ConversationMenu** — the cards draw both |
|