@nocobase/app-skills 0.1.0-beta.64 → 0.1.0-beta.65
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 +4 -2
- package/skills/nocobase-app-development/SKILL.md +2 -0
- package/skills/nocobase-app-development/assets/customer-contacts-example/client/pages/customer-contacts/detail.tsx +25 -43
- package/skills/nocobase-app-development/assets/list-edit-example/client/pages/skill-projects/index.tsx +27 -18
- package/skills/nocobase-app-development/assets/list-edit-example/client/pages/skill-projects/locales.ts +2 -0
- package/skills/nocobase-app-development/assets/list-edit-example/tests/client/skill-projects.test.tsx +29 -16
- package/skills/nocobase-app-development/references/database-and-data.md +2 -0
- package/skills/nocobase-app-development/references/frontend/component-selection.md +2 -0
- package/skills/nocobase-app-development/references/frontend/mobile.md +2 -2
- package/skills/nocobase-app-development/references/frontend/references/example/list-page.md +32 -83
- package/skills/nocobase-app-development/references/frontend/references/table.md +41 -7
- package/skills/nocobase-app-development/references/frontend/ui-guidelines.md +3 -2
- package/skills/nocobase-app-development/references/system-settings.md +1 -1
- package/skills/nocobase-app-development/scripts/check-ui-components.mjs +122 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/app-skills",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.65",
|
|
4
4
|
"description": "Agent Skills for developing applications and plugins, upgrading and deploying NocoBase applications.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@playwright/test": "^1.62.1",
|
|
24
24
|
"prettier": "^3.9.6",
|
|
25
|
+
"vitest": "^4.1.10",
|
|
25
26
|
"@nocobase/dev-config": "0.1.0-beta.25"
|
|
26
27
|
},
|
|
27
28
|
"peerDependencies": {
|
|
@@ -39,6 +40,7 @@
|
|
|
39
40
|
"scripts": {
|
|
40
41
|
"format": "prettier . --write",
|
|
41
42
|
"format:check": "prettier . --check",
|
|
42
|
-
"check": "pnpm format:check"
|
|
43
|
+
"check": "pnpm format:check",
|
|
44
|
+
"test": "vitest run"
|
|
43
45
|
}
|
|
44
46
|
}
|
|
@@ -133,6 +133,8 @@ For business lists, reuse the template-provided `DataTable` and companions from
|
|
|
133
133
|
|
|
134
134
|
Every page and overlay you build or change works on a phone in the first delivery, without the user asking: decide its phone layout while designing it and verify it at phone widths before calling it done, following [the phone experience](references/frontend/mobile.md). Shrinking the desktop page, wrapping its toolbar or scrolling an ordinary table sideways does not count; ordinary lists use `DataTable`'s phone cards (`renderCard`) and its `search`, `filters` and `getColumnLabel` toolbar row, and create and edit forms sit in a `FeedbackForm` given `values={form.getValues}` and `savedValues` (the stored record, or the blank values; never the restored draft) inside the route overlay, which asks before discarding any difference on every way out, whatever changed it and with or without a saved draft.
|
|
135
135
|
|
|
136
|
+
**Table row actions are one "⋮" menu (T1.5, Must).** Every table row's actions, a single action included, render through `RowActions` from `#components/row-actions` at the end of the row: the same icon-only "⋮" trigger on every row, in every record state and on every page, business and administration lists alike, with no visible header text over the actions column and no sticky or right-pinned column. The record's state and the viewer's permissions change which items the menu holds, never how the entry looks; no item left means no menu. Never show an action as a text link, an outline button or a row of buttons because it seems frequent or primary: show a named action outside the menu (`exposed`) only when the user asked for it or a confirmed page design shows it, and pin the column only for a wide table whose actions are otherwise out of reach, recording the reason. Details: [section 8 of `table.md`](references/frontend/references/table.md#8-column-definitions-and-row-actions).
|
|
137
|
+
|
|
136
138
|
**Unsaved input is never lost silently (M7.4, Must).** Every create or edit form is a `FeedbackForm` from `#components/feedback-form` with `values={form.getValues}` and `savedValues` (the stored record as the form shows it, or the blank values of a new record; never the restored draft), rendered inside its `RouteDialog`, `RouteDrawer` or covering `RouteChildPage`; a form kept in `useState` instead of React Hook Form passes `values={() => values}` and `savedValues` the same way. That layer then asks "Discard changes?" before Cancel, ×, Esc, the backdrop, browser back and links, and the browser warns before a reload, whenever the form differs from what is saved. Keeping a draft does not replace the question, and neither does working storage: do not swap `FeedbackForm` for a plain `<form>`, do not make `dirty` or a `beforeunload` handler depend on a draft or storage state, do not render `OwnDiscardQuestion` because a draft is kept (it only declares that the file's own guard asks about its unsaved input, as the settings forms do; a guard that only blocks while a save runs asks nothing), and do not test "cancel, reopen, the input is back" as the cancel path. An unknown outcome is not a lock: after a lost response, a 5xx or a timeout, `submission.pending` stays true for the same-key retry, but only `submitting` blocks leaving. Cancel stays enabled, `beforeClose` and any guard of your own read only the save in flight (never `submission.pending`), and the `FeedbackForm`'s `values` and `savedValues` make every way out ask "Discard changes?" as before the save; "Keep editing" keeps the input for the retry, and "Discard" really leaves, with the key left in session storage so reopening offers the same retry. The [component checker](scripts/check-ui-components.mjs) rejects a plain create or edit `<form>`, a `FeedbackForm` without `values` and `savedValues` (React Hook Form or `useState`), a draft-based `dirty`, and an `OwnDiscardQuestion` whose file has no guard reading an unsaved state, and no exception marker waives these findings. Details: [unsaved changes in an overlay](references/frontend/references/overlay.md#25-beforeclose-checks-before-closing).
|
|
137
139
|
|
|
138
140
|
Use [the frontend workflow](references/frontend/ui-workflow.md) selected during feature planning, or select it before a frontend-only change. Routine pages and CRUD using established patterns take the quick workflow; complex interactions and cross-module design decisions take the full workflow with internal design and acceptance reviews. Theme changes use their own verification. Each workflow routes to the relevant [UI guidelines](references/frontend/ui-guidelines.md) and [frontend handbook](references/frontend/frontend-dev.md); none adds a default user approval round.
|
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
useParams,
|
|
14
14
|
} from 'react-router';
|
|
15
15
|
import type { ColumnDef } from '@tanstack/react-table';
|
|
16
|
-
import { MoreHorizontal } from 'lucide-react';
|
|
17
16
|
import { RouteChildPage } from '#components/route-child-page';
|
|
18
17
|
import { BackButton } from '#components/back-button';
|
|
19
18
|
import { PageContainer } from '#components/page-container';
|
|
@@ -22,15 +21,9 @@ import { LongText } from '#components/long-text';
|
|
|
22
21
|
import { DataTable } from '#components/data-table';
|
|
23
22
|
import { RefreshIndicator } from '#components/loading';
|
|
24
23
|
import { RecordLink } from '#components/record-link';
|
|
24
|
+
import { RowActions } from '#components/row-actions';
|
|
25
25
|
import { StatusBadge } from '#components/status-badge';
|
|
26
26
|
import { Button } from '#components/ui/button';
|
|
27
|
-
import {
|
|
28
|
-
DropdownMenu,
|
|
29
|
-
DropdownMenuTrigger,
|
|
30
|
-
DropdownMenuContent,
|
|
31
|
-
DropdownMenuItem,
|
|
32
|
-
DropdownMenuSeparator,
|
|
33
|
-
} from '#components/ui/dropdown-menu';
|
|
34
27
|
import {
|
|
35
28
|
AlertDialog,
|
|
36
29
|
AlertDialogContent,
|
|
@@ -111,39 +104,28 @@ export default function CustomerDetailPage() {
|
|
|
111
104
|
parent.reload();
|
|
112
105
|
},
|
|
113
106
|
};
|
|
114
|
-
// A contact's actions: the table row's menu,
|
|
115
|
-
const contactMenu = (contact: Contact
|
|
116
|
-
<
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
name: contact.name,
|
|
124
|
-
})}
|
|
125
|
-
/>
|
|
126
|
-
}
|
|
127
|
-
>
|
|
128
|
-
<MoreHorizontal />
|
|
129
|
-
</DropdownMenuTrigger>
|
|
130
|
-
<DropdownMenuContent align='end' className='w-auto min-w-40'>
|
|
131
|
-
<DropdownMenuItem
|
|
132
|
-
render={
|
|
107
|
+
// A contact's actions: the table row's "⋮" menu, which DataTable also hands to the contact's phone card.
|
|
108
|
+
const contactMenu = (contact: Contact) => (
|
|
109
|
+
<RowActions
|
|
110
|
+
label={t('customerContacts.actionsFor', { name: contact.name })}
|
|
111
|
+
actions={[
|
|
112
|
+
{
|
|
113
|
+
key: 'edit',
|
|
114
|
+
label: t('customerContacts.edit'),
|
|
115
|
+
render: (
|
|
133
116
|
<Link
|
|
134
117
|
to={{
|
|
135
118
|
pathname: `contacts/${contact.id}/edit`,
|
|
136
119
|
search: location.search,
|
|
137
120
|
}}
|
|
138
121
|
/>
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
onClick={() => {
|
|
122
|
+
),
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
key: 'delete',
|
|
126
|
+
label: t('customerContacts.delete'),
|
|
127
|
+
destructive: true,
|
|
128
|
+
onClick: () => {
|
|
147
129
|
void (async () => {
|
|
148
130
|
if (!lock.acquire()) return;
|
|
149
131
|
try {
|
|
@@ -157,12 +139,10 @@ export default function CustomerDetailPage() {
|
|
|
157
139
|
lock.release();
|
|
158
140
|
}
|
|
159
141
|
})();
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
</DropdownMenuContent>
|
|
165
|
-
</DropdownMenu>
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
]}
|
|
145
|
+
/>
|
|
166
146
|
);
|
|
167
147
|
const columns: ColumnDef<Contact>[] = [
|
|
168
148
|
{
|
|
@@ -193,9 +173,11 @@ export default function CustomerDetailPage() {
|
|
|
193
173
|
? [
|
|
194
174
|
{
|
|
195
175
|
id: 'actions',
|
|
196
|
-
header:
|
|
176
|
+
header: () => (
|
|
177
|
+
<span className='sr-only'>{t('customerContacts.actions')}</span>
|
|
178
|
+
),
|
|
197
179
|
cell: ({ row }: { row: { original: Contact } }) =>
|
|
198
|
-
contactMenu(row.original
|
|
180
|
+
contactMenu(row.original),
|
|
199
181
|
},
|
|
200
182
|
]
|
|
201
183
|
: []),
|
|
@@ -13,6 +13,7 @@ import { projectsScope } from './scopes.js';
|
|
|
13
13
|
import { PageContainer } from '#components/page-container';
|
|
14
14
|
import { PageHeader } from '#components/page-header';
|
|
15
15
|
import { RecordLink } from '#components/record-link';
|
|
16
|
+
import { RowActions } from '#components/row-actions';
|
|
16
17
|
import { Alert, AlertDescription } from '#components/ui/alert';
|
|
17
18
|
import {
|
|
18
19
|
Table,
|
|
@@ -126,22 +127,28 @@ export default function SkillProjectsPage(): ReactElement {
|
|
|
126
127
|
},
|
|
127
128
|
{
|
|
128
129
|
id: 'actions',
|
|
129
|
-
header
|
|
130
|
+
// The actions column keeps a name for screen readers and shows no header text (T1.5).
|
|
131
|
+
header: () => (
|
|
132
|
+
<span className='sr-only'>{t('skillProjects.actions')}</span>
|
|
133
|
+
),
|
|
130
134
|
cell: ({ row }) => (
|
|
131
|
-
<
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
135
|
+
<RowActions
|
|
136
|
+
label={t('skillProjects.actionsFor', { name: row.original.name })}
|
|
137
|
+
actions={[
|
|
138
|
+
{
|
|
139
|
+
key: 'edit',
|
|
140
|
+
label: t('skillProjects.editAction'),
|
|
141
|
+
render: (
|
|
142
|
+
<Link
|
|
143
|
+
to={{
|
|
144
|
+
pathname: `${row.original.id}/edit`,
|
|
145
|
+
search: location.search,
|
|
146
|
+
}}
|
|
147
|
+
/>
|
|
148
|
+
),
|
|
149
|
+
},
|
|
150
|
+
]}
|
|
151
|
+
/>
|
|
145
152
|
),
|
|
146
153
|
},
|
|
147
154
|
],
|
|
@@ -224,7 +231,9 @@ export default function SkillProjectsPage(): ReactElement {
|
|
|
224
231
|
<TableHeader>
|
|
225
232
|
<TableRow>
|
|
226
233
|
<TableHead>{t('skillProjects.name')}</TableHead>
|
|
227
|
-
<TableHead>
|
|
234
|
+
<TableHead>
|
|
235
|
+
<span className='sr-only'>{t('skillProjects.actions')}</span>
|
|
236
|
+
</TableHead>
|
|
228
237
|
</TableRow>
|
|
229
238
|
</TableHeader>
|
|
230
239
|
<TableBody>
|
|
@@ -234,7 +243,7 @@ export default function SkillProjectsPage(): ReactElement {
|
|
|
234
243
|
<Skeleton className='h-4 w-40' />
|
|
235
244
|
</TableCell>
|
|
236
245
|
<TableCell>
|
|
237
|
-
<Skeleton className='
|
|
246
|
+
<Skeleton className='ml-auto size-7' />
|
|
238
247
|
</TableCell>
|
|
239
248
|
</TableRow>
|
|
240
249
|
))}
|
|
@@ -281,7 +290,7 @@ export default function SkillProjectsPage(): ReactElement {
|
|
|
281
290
|
showSelectedCount={false}
|
|
282
291
|
emptyMessage={t('skillProjects.empty')}
|
|
283
292
|
// Phones show one card per project (mobile.md M3): the name opens its detail, and the row's own actions
|
|
284
|
-
// cell (Edit) follows it, so the card offers what the row does.
|
|
293
|
+
// cell (the "⋮" menu with Edit) follows it, so the card offers what the row does.
|
|
285
294
|
renderCard={(row, card) => (
|
|
286
295
|
<div className='flex items-center gap-2 rounded-lg border p-4'>
|
|
287
296
|
<RecordLink
|
|
@@ -30,6 +30,7 @@ export const enUS = {
|
|
|
30
30
|
description: 'Create and rename projects.',
|
|
31
31
|
name: 'Name',
|
|
32
32
|
actions: 'Actions',
|
|
33
|
+
actionsFor: 'Actions for {{name}}',
|
|
33
34
|
detail: 'Project details',
|
|
34
35
|
detailGone:
|
|
35
36
|
'This project no longer exists. Return to Projects to choose another record.',
|
|
@@ -82,6 +83,7 @@ export const zhCN = {
|
|
|
82
83
|
description: '创建项目并修改名称。',
|
|
83
84
|
name: '名称',
|
|
84
85
|
actions: '操作',
|
|
86
|
+
actionsFor: '{{name}} 的操作',
|
|
85
87
|
detail: '项目详情',
|
|
86
88
|
detailGone: '此项目已不存在,请返回项目列表选择其他记录。',
|
|
87
89
|
edit: '编辑项目',
|
|
@@ -50,6 +50,20 @@ const mount = (
|
|
|
50
50
|
const detailRoutes = resolveAppClientContributions([
|
|
51
51
|
{ packageName: namespace, source: 'application', routes: applicationRoutes },
|
|
52
52
|
]).routes;
|
|
53
|
+
// A row's Edit sits in its "⋮" actions menu (T1.5).
|
|
54
|
+
async function openRowEdit(
|
|
55
|
+
user: Pick<typeof userEvent, 'click'>,
|
|
56
|
+
index = 0,
|
|
57
|
+
): Promise<void> {
|
|
58
|
+
// A trigger is ready once it reports its menu closed (.agents/rules/testing.md).
|
|
59
|
+
const triggers = await screen.findAllByRole('button', {
|
|
60
|
+
name: /^Actions for /,
|
|
61
|
+
expanded: false,
|
|
62
|
+
});
|
|
63
|
+
await user.click(triggers[index]!);
|
|
64
|
+
await user.click(await screen.findByRole('menuitem', { name: 'Edit' }));
|
|
65
|
+
}
|
|
66
|
+
|
|
53
67
|
const mountDetail = (fetch: typeof globalThis.fetch) =>
|
|
54
68
|
renderSettingsClient(
|
|
55
69
|
<Routes>
|
|
@@ -96,9 +110,7 @@ it.each(['fast', 'slow'])(
|
|
|
96
110
|
);
|
|
97
111
|
await screen.findByText('Alpha');
|
|
98
112
|
const slot = screen.getByTestId('refresh-slot');
|
|
99
|
-
await userEvent
|
|
100
|
-
screen.getByRole('button', { name: 'Edit', exact: true }),
|
|
101
|
-
);
|
|
113
|
+
await openRowEdit(userEvent);
|
|
102
114
|
await screen.findByRole('textbox', { name: 'Name' });
|
|
103
115
|
vi.useFakeTimers();
|
|
104
116
|
await act(() => vi.advanceTimersByTimeAsync(1000));
|
|
@@ -154,9 +166,7 @@ it('revalidates a corrected name, keeps a rejected draft, and refreshes the list
|
|
|
154
166
|
return { data: current };
|
|
155
167
|
}),
|
|
156
168
|
);
|
|
157
|
-
await user
|
|
158
|
-
await screen.findByRole('button', { name: 'Edit', exact: true }),
|
|
159
|
-
);
|
|
169
|
+
await openRowEdit(user);
|
|
160
170
|
const name = await screen.findByRole('textbox', { name: 'Name' });
|
|
161
171
|
await user.clear(name);
|
|
162
172
|
await user.click(screen.getByRole('button', { name: 'Save', exact: true }));
|
|
@@ -289,9 +299,7 @@ it('keeps the original payload/key after an unknown result, asks before closing
|
|
|
289
299
|
keys.push(request.headers.get('Idempotency-Key'));
|
|
290
300
|
return transport(request);
|
|
291
301
|
}) as typeof fetch);
|
|
292
|
-
await userEvent
|
|
293
|
-
await screen.findByRole('button', { name: 'Edit', exact: true }),
|
|
294
|
-
);
|
|
302
|
+
await openRowEdit(userEvent);
|
|
295
303
|
const name = await screen.findByRole('textbox', { name: 'Name' });
|
|
296
304
|
await userEvent.clear(name);
|
|
297
305
|
await userEvent.type(name, 'Confirmed Alpha');
|
|
@@ -396,11 +404,16 @@ it.each(['cancel', 'save', 'removed', 'lastPageRemoved'])(
|
|
|
396
404
|
screen.getByRole('button', { name: 'Go to next page' }),
|
|
397
405
|
);
|
|
398
406
|
expect(screen.getByText('Page 2 of 2')).toBeVisible();
|
|
399
|
-
const opener =
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
407
|
+
const opener = (
|
|
408
|
+
await screen.findAllByRole('button', {
|
|
409
|
+
name: /^Actions for /,
|
|
410
|
+
expanded: false,
|
|
411
|
+
})
|
|
412
|
+
)[0]!;
|
|
403
413
|
await userEvent.click(opener);
|
|
414
|
+
await userEvent.click(
|
|
415
|
+
await screen.findByRole('menuitem', { name: 'Edit' }),
|
|
416
|
+
);
|
|
404
417
|
const name = await screen.findByRole('textbox', { name: 'Name' });
|
|
405
418
|
if (action === 'save') {
|
|
406
419
|
await userEvent.clear(name);
|
|
@@ -840,7 +853,7 @@ it.each(['Cancel', 'Close', 'Escape', 'backdrop', 'back'] as const)(
|
|
|
840
853
|
},
|
|
841
854
|
);
|
|
842
855
|
await screen.findByText('Alpha');
|
|
843
|
-
await userEvent
|
|
856
|
+
await openRowEdit(userEvent);
|
|
844
857
|
const name = await screen.findByRole('textbox', { name: 'Name' });
|
|
845
858
|
await userEvent.clear(name);
|
|
846
859
|
await userEvent.type(name, 'Renamed Alpha');
|
|
@@ -1037,7 +1050,7 @@ it('shows each project as a card with its detail link and edit action on a phone
|
|
|
1037
1050
|
'href',
|
|
1038
1051
|
expect.stringContaining('/skill-projects/abc/details'),
|
|
1039
1052
|
);
|
|
1040
|
-
await userEvent
|
|
1053
|
+
await openRowEdit(userEvent);
|
|
1041
1054
|
expect(await screen.findByRole('textbox', { name: 'Name' })).toHaveValue(
|
|
1042
1055
|
'Alpha',
|
|
1043
1056
|
);
|
|
@@ -1073,7 +1086,7 @@ it('asks before browser back leaves a dirty edit dialog, as Cancel and Escape do
|
|
|
1073
1086
|
},
|
|
1074
1087
|
);
|
|
1075
1088
|
await screen.findByText('Alpha');
|
|
1076
|
-
await userEvent
|
|
1089
|
+
await openRowEdit(userEvent);
|
|
1077
1090
|
const name = await screen.findByRole('textbox', { name: 'Name' });
|
|
1078
1091
|
await userEvent.type(name, ' draft');
|
|
1079
1092
|
act(() => back());
|
|
@@ -30,6 +30,8 @@ Neither Repository nor Query applies the application's permissions. The route de
|
|
|
30
30
|
|
|
31
31
|
`IdGeneratorProvider` supplies Snowflake IDs when a table needs a sortable identifier not tied to auto-increment. `increments('id')` is fine for ordinary tables.
|
|
32
32
|
|
|
33
|
+
Keep the application's `IdGeneratorProvider` when a plugin contributes an ID implementation. The public `idGeneratorToken` still provides synchronous `generate(): number` and `generateString(): string`. A plugin may bind one `IdGeneratorImplementation` to the original `idGeneratorImplementationToken` from `@nocobase/app-server/id-generator` during registration; its `initialize(): Promise<void>` is awaited by the host ID provider before later providers boot. Resolving the public service during registration does not select an implementation. After every Provider has registered, the first generation call selects and caches the extension or default generator for both methods; later calls do not query the container. Do not generate business IDs during registration. Before initialization, after failure, or after closure, the implementation must reject generation rather than fall back to manual IDs. The plugin owns cleanup and shares sticky initialization with any earlier database preparation hook. Without an extension, the host lazily uses its original manual Snowflake generator. Mode changes require restart; this is not a driver registry or hot-swap protocol.
|
|
34
|
+
|
|
33
35
|
## Verify
|
|
34
36
|
|
|
35
37
|
- Queries return what you expect against a real database, not only in a mocked test.
|
|
@@ -31,6 +31,8 @@ The checker finds native buttons, visible inputs, selects, textareas, dialogs, s
|
|
|
31
31
|
|
|
32
32
|
It also reports a native date interaction: an `<input>` or an imported local shadcn `Input`/`InputGroupInput` (including an alias such as `Input as TextInput` and a namespace such as `UI.Input`) whose `type` is the string `date` or `datetime-local`, written as an attribute string or a string expression, even when passed to a primitive's `render`. Its advice is the application's `DatePicker` ([Dates in `form.md`](references/form.md#dates)); for `datetime-local` it keeps the time with an `Input type='time'` beside it. A `Calendar` in a `Popover`, the official input-style variant, `Input type='time'`, `month` and `week` are not reported, and neither is a component merely named `DatePicker`: review its source for the `Calendar` composition. A `type` computed at runtime (`type={kind}`), passed by spread, or set inside another wrapper is outside the static check and left to the source review.
|
|
33
33
|
|
|
34
|
+
It also checks every table actions column, a column definition with `id: 'actions'` ([T1.5](ui-guidelines.md)): a `header` without `sr-only` is visible header text; `sticky`, `fixed`, `right-0` or `pinned` in the column pins it; and every `Button`, link or `DropdownMenu` the cell renders outside `RowActions`, directly or through a component or function of the same file, is reported with `RowActions` as its replacement, also when it stands beside a `RowActions` menu. A `RowAction`'s `render` (such as `<Link />`) and the buttons of a dialog the action opens are part of the action, not reported. A cell built only from components of other files is not inspected. Showing an action outside the menu goes through `RowActions`' `exposed`, not past the checker; a pinned column of a wide table takes an exception marker naming why its actions are otherwise out of reach.
|
|
35
|
+
|
|
34
36
|
For a necessary native adapter, place a specific `ui-component-exception:` comment on the line immediately before **one** flagged opening element. Explain the unmet behavior and refer to a durable decision when needed. For example, after confirming that the installed component cannot expose the required browser capability:
|
|
35
37
|
|
|
36
38
|
```tsx
|
|
@@ -49,7 +49,7 @@ Boundary: a reference in faithful mode may set its own phone layout; record it i
|
|
|
49
49
|
|
|
50
50
|
## M3 Lists, cards and tables
|
|
51
51
|
|
|
52
|
-
- **M3.1 [Must]** An ordinary business list renders cards on phones: pass `renderCard` to `DataTable` ([phone cards in `table.md`](references/table.md#phone-cards)). The card leads with the record's name or number as its `RecordLink` (T1.3), then its status `Badge` (T1.4), then two or three key fields as short muted text, and ends with the same actions the desktop row offers, in the same "
|
|
52
|
+
- **M3.1 [Must]** An ordinary business list renders cards on phones: pass `renderCard` to `DataTable` ([phone cards in `table.md`](references/table.md#phone-cards)). The card leads with the record's name or number as its `RecordLink` (T1.3), then its status `Badge` (T1.4), then two or three key fields as short muted text, and ends with the same actions the desktop row offers, in the same "⋮" menu (T1.5). `DataTable` does this by default: it hands each card the cell of the row's actions column (`actionsColumnId`, `'actions'` by default) as `renderCard`'s `card.actions`, puts it in the card's top-right corner when the card does not place it, and gives its buttons a 32px tap size, so never write a second, different action control into the card. Everything else is on the detail. A list puts its record actions in rows and cards whenever the user takes them from the list without reading the record first: edit, delete, duplicate, archive, or a status change such as "Mark as done" or "Close". It may leave them out, so a row and its card only open the record, in exactly three cases, and the design (or the quick change's report line) names which: (a) the viewer has no actions on these records; (b) every action needs the record's details first, such as approving or rejecting after reading a request; (c) the list changes records through selection and batch actions, and single-record changes belong with related data on the record's page. Pass: every card has the row's menu with the same items, or the list's recorded case (a), (b) or (c) explains why neither rows nor cards have one (such a list has no actions column, or passes `actionsColumnId={null}`).
|
|
53
53
|
- **M3.2 [Must]** The list keeps its capabilities on phones: sorting through `DataTableSortMenu`, pagination (the shared pagination wraps whole groups, T1.12), the result cap notice (T1.10), all list states (S1–S4), and, when the desktop list has selection, a checkbox in each card, "Select all on this page" above the cards with its partly selected state, and the bulk actions in the toolbar. `DataTable` renders the selection column's header (id `select`, or `selectionColumnId`) above the cards with that visible label as a tap target (the checkbox's own `aria-label` stays its only accessible name, so it is not read twice), so the page's own select-all keeps its permission, disabled and indeterminate states; a card list with checkboxes but no select-all fails M3.2. Select all covers the current page only, and paging or filtering clears the selection as on desktop.
|
|
54
54
|
- **M3.3 [Must]** Card text wraps or clamps (`line-clamp-2`) instead of relying on a hover tooltip; T1.11's hover is a desktop table rule.
|
|
55
55
|
- **M3.4 [Must] Exceptions with a reason**: keep a table on phones, scrolling sideways inside its own bordered container, only when the rows are meant to be compared across columns: a matrix, a price or permission grid, a financial statement, a timetable. Freeze the first column when the table is wider than the screen, and record the reason in the design. A list in a dashboard card (T5.3) with one or two columns stays a table when it fits at 375px.
|
|
@@ -94,7 +94,7 @@ Boundary: a list with a single filter passes it as `filters` too, so its phone r
|
|
|
94
94
|
|
|
95
95
|
## M8 Touch, accessibility and feedback
|
|
96
96
|
|
|
97
|
-
- **M8.1 [Must]** Every tap target is at least 24×24px with no other target within 24px of its center (WCAG 2.5.8), and controls a phone user taps often (a card's "
|
|
97
|
+
- **M8.1 [Must]** Every tap target is at least 24×24px with no other target within 24px of its center (WCAG 2.5.8), and controls a phone user taps often (a card's "⋮" menu, toolbar buttons, checkboxes in cards) use the components' default sizes: `Button` `size='default'` or `size='icon'` (32px), not `xs`, `icon-xs` or `icon-sm`, with `gap-2` between neighbours. A bare icon or a text link inside a sentence is not a target for a main action. Row and card menus are reachable without hover.
|
|
98
98
|
- **M8.2 [Must]** Nothing essential depends on hover, double-click, right-click, a precise pointer or dragging: tooltips repeat information shown elsewhere or are reachable by tap and focus; drag-and-drop has a menu or button alternative (move up/down, "Move to…").
|
|
99
99
|
- **M8.3 [Must]** Gestures do not fight the page: a sideways-scrolling row or canvas does not trap vertical page scrolling, and no custom swipe handler replaces the browser's back gesture.
|
|
100
100
|
- **M8.4 [Must]** States look right on a phone: loading, empty, no results, denied, session expired, failed, refresh failed and submitting fit the card list or form without overflow, and toasts do not cover the primary action for long.
|
|
@@ -6,11 +6,11 @@ Part of the [projects worked example](../example.md). For the runnable, continuo
|
|
|
6
6
|
|
|
7
7
|
**Add first**: `yes n | pnpm exec shadcn add alert empty input-group select skeleton table`, then format the files it creates ([how](../shadcn.md#1-what-the-template-ships-and-how-to-add-the-rest)), and reuse the template's shipped `DataTable` in `client/components/data-table/` with its supported `@tanstack/react-table` v8 dependency ([section 1 of `table.md`](../table.md#1-choosing-a-table-component)).
|
|
8
8
|
|
|
9
|
-
**On phones**: `DataTable` hands `ProjectCard` the row's own actions cell (`
|
|
9
|
+
**On phones**: `DataTable` hands `ProjectCard` the row's own actions cell (its `RowActions` "⋮" menu) as `card.actions`, and the card ends with it (M3.1 in [the phone experience](../../mobile.md)); keep it when adapting this page, and do not add a different action control to the card. Leave it out only together with the row's menu, for one of the three cases M3.1 names. The search box, the filter and the sort sit on one row through `DataTable`'s `search`, `filters` and `getColumnLabel` (M4.1); never lay them out yourself in the `toolbar`.
|
|
10
10
|
|
|
11
11
|
**Links to**: the [create dialog](create-dialog.md), the [detail drawer](detail-drawer.md) and the [edit dialog](edit-dialog.md), which a row's menu opens alone, are its child routes. Without a detail view, render the name as plain text: a link to a route that does not exist lands on the home page.
|
|
12
12
|
|
|
13
|
-
**Without detail and delete** (a list with only a create dialog), remove: the `actions` column
|
|
13
|
+
**Without detail and delete** (a list with only a create dialog), remove: the `actions` column and the `actions` slot of `ProjectCard`, the `deletion` state, `ProjectDeleteDialog` at the end, `focusSearchAfterReloadRef` with its effect, and `afterDelete`, `onSaved` and `onNotFound`, which leaves `outletContext` as `{ reload }`, `ProjectsOutletContext` in `types.ts` with only `reload` and no `ProjectEditOutletContext`; render the name as plain text.
|
|
14
14
|
|
|
15
15
|
Use the application's existing authorization hook to resolve create permission before rendering the page-level action. Put the standard create action only in the page header, including for a successful empty query; never wire it through the empty state's `emptyAction`. Let `DataTable` render each built-in state with its matching icon and one short line, and keep clear, retry and sign-in actions in the existing toolbar or authentication flow. Follow [shared list feedback](../list-feedback.md) for the state and request contract.
|
|
16
16
|
|
|
@@ -24,13 +24,7 @@ import { listStateShowsData, resolveListState } from '@nocobase/app-client';
|
|
|
24
24
|
import { useCan } from '@nocobase/app-plugin-authorization/client';
|
|
25
25
|
import { useLocale, useTranslation } from '@nocobase/i18n/client';
|
|
26
26
|
import type { ColumnDef } from '@tanstack/react-table';
|
|
27
|
-
import {
|
|
28
|
-
MoreHorizontalIcon,
|
|
29
|
-
PencilIcon,
|
|
30
|
-
PlusIcon,
|
|
31
|
-
SearchIcon,
|
|
32
|
-
Trash2Icon,
|
|
33
|
-
} from 'lucide-react';
|
|
27
|
+
import { PlusIcon, SearchIcon } from 'lucide-react';
|
|
34
28
|
import {
|
|
35
29
|
type ReactElement,
|
|
36
30
|
type ReactNode,
|
|
@@ -52,15 +46,8 @@ import { useListLocation } from '#hooks/use-list-location';
|
|
|
52
46
|
import { useTableUrlState } from '#hooks/use-table-url-state';
|
|
53
47
|
import { PageContainer } from '#components/page-container';
|
|
54
48
|
import { PageHeader } from '#components/page-header';
|
|
49
|
+
import { RowActions } from '#components/row-actions';
|
|
55
50
|
import { Button } from '#components/ui/button';
|
|
56
|
-
import {
|
|
57
|
-
DropdownMenu,
|
|
58
|
-
DropdownMenuContent,
|
|
59
|
-
DropdownMenuGroup,
|
|
60
|
-
DropdownMenuItem,
|
|
61
|
-
DropdownMenuSeparator,
|
|
62
|
-
DropdownMenuTrigger,
|
|
63
|
-
} from '#components/ui/dropdown-menu';
|
|
64
51
|
import {
|
|
65
52
|
InputGroup,
|
|
66
53
|
InputGroupAddon,
|
|
@@ -290,14 +277,34 @@ export default function ProjectsPage(): ReactElement {
|
|
|
290
277
|
header: () => (
|
|
291
278
|
<span className='sr-only'>{t('projects.actions.label')}</span>
|
|
292
279
|
),
|
|
280
|
+
// One "⋮" menu at the end of the row, the same on every page (T1.5); DataTable hands it to the phone card.
|
|
293
281
|
cell: ({ row }) => (
|
|
294
|
-
<
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
282
|
+
<RowActions
|
|
283
|
+
label={t('projects.actions.more', { name: row.original.name })}
|
|
284
|
+
actions={[
|
|
285
|
+
{
|
|
286
|
+
// Edit is the list's own child route, edit/:projectId: the item is a link, and the dialog opens
|
|
287
|
+
// alone over the list.
|
|
288
|
+
key: 'edit',
|
|
289
|
+
label: t('projects.actions.edit'),
|
|
290
|
+
render: (
|
|
291
|
+
<Link
|
|
292
|
+
to={{
|
|
293
|
+
pathname: `edit/${encodeURIComponent(row.original.id)}`,
|
|
294
|
+
search: location.search,
|
|
295
|
+
}}
|
|
296
|
+
/>
|
|
297
|
+
),
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
key: 'delete',
|
|
301
|
+
label: t('projects.actions.delete'),
|
|
302
|
+
destructive: true,
|
|
303
|
+
onClick: () =>
|
|
304
|
+
setDeletion({ open: true, project: row.original }),
|
|
305
|
+
},
|
|
306
|
+
]}
|
|
307
|
+
/>
|
|
301
308
|
),
|
|
302
309
|
},
|
|
303
310
|
],
|
|
@@ -378,7 +385,7 @@ export default function ProjectsPage(): ReactElement {
|
|
|
378
385
|
) : null}
|
|
379
386
|
</div>
|
|
380
387
|
)}
|
|
381
|
-
// `card.actions` is the row's actions cell (
|
|
388
|
+
// `card.actions` is the row's actions cell (its RowActions menu), which the card ends with.
|
|
382
389
|
renderCard={(row, card) => (
|
|
383
390
|
<ProjectCard
|
|
384
391
|
project={row.original}
|
|
@@ -442,64 +449,6 @@ function RefreshIndicator(): ReactElement | null {
|
|
|
442
449
|
return visible ? <Spinner className='text-muted-foreground' /> : null;
|
|
443
450
|
}
|
|
444
451
|
|
|
445
|
-
/** A project's actions: the row's menu on desktop and the card's on a phone, where it is a full-size tap target. */
|
|
446
|
-
function ProjectRowMenu({
|
|
447
|
-
project,
|
|
448
|
-
search,
|
|
449
|
-
onDelete,
|
|
450
|
-
size = 'icon-sm',
|
|
451
|
-
}: {
|
|
452
|
-
readonly project: Project;
|
|
453
|
-
readonly search: string;
|
|
454
|
-
readonly onDelete: (project: Project) => void;
|
|
455
|
-
readonly size?: 'icon-sm' | 'icon';
|
|
456
|
-
}): ReactElement {
|
|
457
|
-
const { t } = useTranslation();
|
|
458
|
-
return (
|
|
459
|
-
<DropdownMenu>
|
|
460
|
-
<DropdownMenuTrigger
|
|
461
|
-
render={
|
|
462
|
-
<Button
|
|
463
|
-
variant='ghost'
|
|
464
|
-
size={size}
|
|
465
|
-
aria-label={t('projects.actions.more', { name: project.name })}
|
|
466
|
-
/>
|
|
467
|
-
}
|
|
468
|
-
>
|
|
469
|
-
<MoreHorizontalIcon />
|
|
470
|
-
</DropdownMenuTrigger>
|
|
471
|
-
<DropdownMenuContent align='end' className='w-auto min-w-40'>
|
|
472
|
-
<DropdownMenuGroup>
|
|
473
|
-
{/* Edit is the list's own child route, edit/:projectId: the menu item is a link, and the dialog opens alone over the list. */}
|
|
474
|
-
<DropdownMenuItem
|
|
475
|
-
render={
|
|
476
|
-
<Link
|
|
477
|
-
to={{
|
|
478
|
-
pathname: `edit/${encodeURIComponent(project.id)}`,
|
|
479
|
-
search,
|
|
480
|
-
}}
|
|
481
|
-
/>
|
|
482
|
-
}
|
|
483
|
-
>
|
|
484
|
-
<PencilIcon />
|
|
485
|
-
{t('projects.actions.edit')}
|
|
486
|
-
</DropdownMenuItem>
|
|
487
|
-
</DropdownMenuGroup>
|
|
488
|
-
<DropdownMenuSeparator />
|
|
489
|
-
<DropdownMenuGroup>
|
|
490
|
-
<DropdownMenuItem
|
|
491
|
-
variant='destructive'
|
|
492
|
-
onClick={() => onDelete(project)}
|
|
493
|
-
>
|
|
494
|
-
<Trash2Icon />
|
|
495
|
-
{t('projects.actions.delete')}
|
|
496
|
-
</DropdownMenuItem>
|
|
497
|
-
</DropdownMenuGroup>
|
|
498
|
-
</DropdownMenuContent>
|
|
499
|
-
</DropdownMenu>
|
|
500
|
-
);
|
|
501
|
-
}
|
|
502
|
-
|
|
503
452
|
/**
|
|
504
453
|
* One project on a phone (M3.1 in mobile.md): the name, which opens the same detail drawer as the table's link, and
|
|
505
454
|
* the status first, then the owner and the last update, and the menu. Other fields are in the detail.
|
|
@@ -108,9 +108,9 @@ An ordinary business list shows one card per record below the `md` breakpoint (g
|
|
|
108
108
|
/>
|
|
109
109
|
```
|
|
110
110
|
|
|
111
|
-
- The card is `rounded-lg border p-4`: the record's name link first (T1.3) with its status `Badge` beside it (T1.4), then two or three key fields as a small label–value list, and the row's "
|
|
111
|
+
- The card is `rounded-lg border p-4`: the record's name link first (T1.3) with its status `Badge` beside it (T1.4), then two or three key fields as a small label–value list, and the row's "⋮" menu (`card.actions`) at the end. The complete card is `ProjectCard` in [`example/list-page.md`](example/list-page.md). Do not repeat every column; the detail holds the rest.
|
|
112
112
|
- With `getColumnLabel`, phone cards get an icon "Sort" menu on the search row (`DataTableSortMenu`), offering every sortable column in both directions under the translated names the headers show, and driving the same sorting state as the headers. Spread `useTableUrlState` into `DataTable`, as above: it passes `sortableColumns`, so only the URL's `sortColumns` are sortable, in the headers and the menu (M4.4). A controlled `onSortingChange` writes the URL and resets the page as a header click does. A dot on the icon marks an applied sort; from `md` up the headers sort and the menu is gone. Render `DataTableSortMenu` yourself only for a list outside `DataTable`.
|
|
113
|
-
- The card's menu repeats the row's actions (M3.1), and `DataTable` provides it: `renderCard` receives the cell of the actions column (id `actions`, or `actionsColumnId`) as `card.actions`, already at a 32px tap size. Place it in the card's layout (`ProjectCard` in the example puts it after the name); a card that leaves it out still gets it in its top-right corner. Never write a second, different action control into the card, such as an inline Edit button beside a row's "
|
|
113
|
+
- The card's menu repeats the row's actions (M3.1), and `DataTable` provides it: `renderCard` receives the cell of the actions column (id `actions`, or `actionsColumnId`) as `card.actions`, already at a 32px tap size. Place it in the card's layout (`ProjectCard` in the example puts it after the name); a card that leaves it out still gets it in its top-right corner. Never write a second, different action control into the card, such as an inline Edit button beside a row's "⋮" menu. A list without row actions names its case (a), (b) or (c) of M3.1 in the design or report; the customer list of the [executable relation and batch example](executable-relation-batch.md) is case (c).
|
|
114
114
|
- With selection, render a `Checkbox` in the card with the same `aria-label` as the selection column, from `row.getIsSelected()` and `row.toggleSelected`; bulk actions stay in `toolbar`. Give the selection column the id `select` (or pass its id as `selectionColumnId`): `DataTable` then renders its header, the page's select-all checkbox with its indeterminate state, above the cards with the visible label "Select all on this page", which is also a tap target for it. The checkbox keeps its own `aria-label` ("Select all on this page"), which is its whole accessible name there: the visible text is hidden from assistive technology so the name is not read twice (M3.2).
|
|
115
115
|
- Keep a table on phones only for rows compared across columns (M3.4): omit `renderCard`, and the table scrolls sideways inside its own frame.
|
|
116
116
|
|
|
@@ -204,11 +204,45 @@ The shared component provides accessible English and Chinese text. A business-sp
|
|
|
204
204
|
|
|
205
205
|
- A `Badge` or other styled content goes in a `Popover` that opens on hover (`openOnHover delay={0}` on the trigger) instead: the tooltip surface is inverted, so a badge on it is unreadable.
|
|
206
206
|
- `truncate` shows the ellipsis only on a block element. On a flex element such as `Badge` it clips without one, and the centered text loses both ends, so put the text in a `<span className='truncate'>` inside the badge and give the badge `min-w-0 shrink`. Do not use `line-clamp` in a cell: it needs text that wraps, which the cell prevents, so it only clips.
|
|
207
|
-
- **Put row actions in
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
207
|
+
- **Put row actions in the row's "⋮" menu with `RowActions`** (guideline T1.5). `#components/row-actions` ships with both templates; it renders the same trigger, menu, ordering and empty case on every page, so do not compose a `DropdownMenu`, buttons or links in the actions cell yourself:
|
|
208
|
+
|
|
209
|
+
```tsx
|
|
210
|
+
{
|
|
211
|
+
id: 'actions',
|
|
212
|
+
enableHiding: false,
|
|
213
|
+
// No visible header text; the name stays for screen readers.
|
|
214
|
+
header: () => <span className='sr-only'>{t('projects.actions.label')}</span>,
|
|
215
|
+
cell: ({ row }) => (
|
|
216
|
+
<RowActions
|
|
217
|
+
label={t('projects.actions.more', { name: row.original.name })}
|
|
218
|
+
actions={[
|
|
219
|
+
canUpdate && {
|
|
220
|
+
key: 'edit',
|
|
221
|
+
label: t('projects.actions.edit'),
|
|
222
|
+
render: <Link to={{ pathname: `edit/${encodeURIComponent(row.original.id)}`, search: location.search }} />,
|
|
223
|
+
},
|
|
224
|
+
canDelete && {
|
|
225
|
+
key: 'delete',
|
|
226
|
+
label: t('projects.actions.delete'),
|
|
227
|
+
destructive: true,
|
|
228
|
+
onClick: () => setDeletion({ open: true, project: row.original }),
|
|
229
|
+
},
|
|
230
|
+
]}
|
|
231
|
+
/>
|
|
232
|
+
),
|
|
233
|
+
}
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
- `label` is the trigger's `aria-label` and names the record ("Actions for Apollo", "Apollo 的操作"); a button that opens a menu needs no tooltip (guideline A1).
|
|
237
|
+
- `actions` is the stable order of the items. Leave out an item the viewer may not do (`canX && { … }`); when none is left, `RowActions` renders nothing, so no empty menu or trigger appears. A state-dependent item (Start for a stopped instance, Open for an installed module, Enable for a disabled account) is chosen in this array: the entry looks the same in every state. Use `disabled` only for an item that is temporarily unavailable, such as while it runs.
|
|
238
|
+
- "Edit" is a child route, so its item renders as a link through `render`: `edit/:projectId` is the list's own edit route, so the dialog opens alone over the list and closing returns to it; the drawer's "Edit" uses the route stacked on the drawer instead ([section 2.1 of `overlay.md`](overlay.md#21-declare-the-child-routes)). An external link uses `render={<a href={url} target='_blank' rel='noreferrer' />}`.
|
|
239
|
+
- An item that does something on the server (Install, Start, Disable, Revoke sessions) opens its confirmation when it has consequences, shows its progress in that dialog or in the record's status, and ends in a result toast or an error, as it would from a button; the menu itself closes at once. Keep the existing permission checks, confirmations and feedback when moving such actions into the menu.
|
|
240
|
+
- `destructive: true` items ("Delete") come last, after a separator, in the destructive style, and open the delete confirmation.
|
|
241
|
+
- Items are verbs only ("Edit", "Delete"); the row they are in determines the object (guideline C3). The menu items carry no icons, so every page's menu reads the same.
|
|
242
|
+
- Clicks on the trigger and the items do not reach the row, so a row with `onRowClick` neither navigates nor toggles selection when its menu is used.
|
|
243
|
+
- The column has no visible header text, no fixed width and no `sticky`, `fixed` or right pinning: the trigger keeps it narrow, and it scrolls with the table. Pin it only for a wide table whose actions would otherwise be out of reach after scrolling sideways, and record why.
|
|
244
|
+
- `exposed={['start']}` shows the named actions as ghost buttons before the "⋮", the same on every row, while the rest stay in the menu. Use it only when the user asked for that action outside the menu or a confirmed page design shows it; never because the action is frequent or "primary".
|
|
245
|
+
|
|
212
246
|
- The delete confirmation dialog is `ProjectDeleteDialog`, driven by `deletion` state as [section 4 of `overlay.md`](overlay.md#4-delete-confirmation-alertdialog) describes; after a successful delete, refresh the list and move focus to the search box (`deletedFocusRef`).
|
|
213
247
|
|
|
214
248
|
### Selection and bulk actions
|
|
@@ -58,7 +58,7 @@ Structure, top to bottom: PageHeader (primary action "New X") → toolbar (searc
|
|
|
58
58
|
- **T1.2 [Must]** Filter controls show their current value; while a search or filter is applied, show "Clear filters".
|
|
59
59
|
- **T1.3 [Must]** The first column is the record's name or number; when there is a detail view, clicking it opens the detail view. Use the template’s `RecordLink` for record names and identifiers: foreground text with medium weight, no permanent underline, underline on hover, and underline plus a visible focus outline for keyboard navigation. Preserve native link behavior; action buttons and menu items keep their own styling.
|
|
60
60
|
- **T1.4 [Must]** Enumerated values such as status and type are shown as text in a Badge; color is only an aid, and values must never be distinguished by color alone.
|
|
61
|
-
- **T1.5 [Must]**
|
|
61
|
+
- **T1.5 [Must]** Every table row's actions sit in one menu at the end of the row: render them with `RowActions` from `#components/row-actions`, which draws the same icon-only ghost "⋮" button (`EllipsisVerticalIcon`, `size='icon-sm'`, right-aligned, labelled "Actions for <name>") on every row of every page and opens a `DropdownMenu`. This holds for a single action too, for every state of a record (a stopped and a running instance, an installed and an available module, an enabled and a disabled account), and for administration lists (users, roles, sessions) as much as business lists; the record's state changes which items the menu holds, never how the entry looks. Do not render actions as text links, outline buttons or a row of buttons, and do not mix them with a "More" text button. Items are verbs in a stable order (C3); destructive items come last, after a separator, in the destructive style, and are confirmed with an AlertDialog (I2). Leave out what the viewer may not do, and render no menu when nothing remains; hiding an item is not a permission check, and the server still enforces it (I7). The actions column has no visible header text (`header: () => <span className='sr-only'>…</span>` keeps its name for screen readers), stays as narrow as the trigger, and scrolls with the table: it is not `sticky`, `fixed` or pinned to the right. Open a record's details from its name (T1.3), not from a "View" item or a column of its own. **Exceptions need a recorded basis, never the model's judgement**: show a named action outside the menu only when the user asked for it or a confirmed page design specifies it, by passing its key in `RowActions`' `exposed` (a ghost `size='sm'` button before the "⋮", the same on every row; everything else stays in the menu). How often an action is used, its being the "main" action, an approval or to-do list, or a different action name are not reasons. A wide table that scrolls sideways may pin its actions column only when the actions would otherwise be out of reach, with the reason recorded in the design or report. Which lists have row actions, and when a list may leave them out, is M3.1 in [the phone experience](mobile.md): `DataTable` ends each phone card with the same menu.
|
|
62
62
|
- **T1.6 [Must]** Dates and times are formatted for the current language; numbers and amounts are right-aligned, with thousands separators.
|
|
63
63
|
- **T1.7 [Should]** Search and filter conditions are written to the URL, so they survive a refresh and going back.
|
|
64
64
|
- **T1.8 [Must]** Columns of dates and times (created, updated, due) and of numbers (amounts, quantities, counts) are sortable by default, and so is the name column when it sorts in the current language's order (pinyin for Chinese). Statuses, types, tags, people, long text and yes/no values are not, unless the business asks for it and the order means something (a priority by its rank, not alphabetically). The default order is by last update time, newest first, and a sorted column shows its direction in the header.
|
|
@@ -158,7 +158,7 @@ Do not show raw backend error messages (untranslated exception messages, stack t
|
|
|
158
158
|
|
|
159
159
|
**I12 [Must] Select popups fit their options**: the shadcn `SelectContent` defaults to its trigger's width and keeps every option on one line, so a long option is cut off. Every `SelectContent` therefore gets `className='w-auto max-w-[min(var(--container-sm),var(--available-width))] min-w-(--anchor-width) [&_[data-slot=select-item]>:first-child]:whitespace-normal'`: at least as wide as its trigger, growing with its options up to `max-w-sm` or the space beside it, with a long option wrapping onto another line. Never truncate an option's text inside the popup; the trigger may still end the selected value in an ellipsis. Keep the class on the call site rather than in a wrapper component, and add positioning props such as `align='end'` beside it when the trigger sits at the end of a row.
|
|
160
160
|
|
|
161
|
-
**I13 [Must] Menus on icon triggers size to their items**: the shadcn `DropdownMenuContent` defaults to its trigger's width, so the menu of an icon button (a row's "
|
|
161
|
+
**I13 [Must] Menus on icon triggers size to their items**: the shadcn `DropdownMenuContent` defaults to its trigger's width, so the menu of an icon button (a row's "⋮", a card's "More") is as narrow as the icon and wraps every item. Every `DropdownMenuContent` whose trigger is an icon button, or any trigger narrower than its items, gets `className='w-auto min-w-40'`: as wide as its longest item, and never narrower than `min-w-40`. Keep the class on the call site rather than in a wrapper component, beside positioning props such as `align='end'`; `RowActions` (T1.5) already sets both on a row's menu. A menu whose trigger is at least as wide as its items, such as a labelled button, keeps the default.
|
|
162
162
|
|
|
163
163
|
**I14 [Must] Long text shows in part, by where it sits**: a description, an introduction, a note or a comment never ends in an ellipsis mid-sentence, and never pushes a narrow column longer than its neighbours. Where there is room, such as the description under a page's title or a comment in a timeline, show up to five lines and unfold the rest in place on a click (`LongText`). In a narrow column, such as a record's particulars beside its page or a card, show up to three muted lines and open the whole text in a pop-up beside it (`LongTextPreview`), so the column keeps its height. The last line fades out, and a text that fits is shown plainly, with nothing to click. Both come from the UI Library item `@nocobase/long-text` ([`references/ui-library.md`](references/ui-library.md)). A table cell or a list item's one-line summary keeps `truncate` or `line-clamp-1`, where the row opens the record.
|
|
164
164
|
|
|
@@ -216,6 +216,7 @@ The design review and the acceptance review both go through this checklist item
|
|
|
216
216
|
- [ ] Navigation is consistent: entries in one group all carry an icon or none does, a group's own icon does not repeat its first child's, and a count beside an entry is only what waits on the viewer (`page.md` §6, L8)
|
|
217
217
|
- [ ] All states are covered: loading, empty, no results, load failed, submitting, a block the user may not see; whether a failure offers a retry follows S4 (S1–S7); affected transitions follow S7
|
|
218
218
|
- [ ] Default list states show one concise line with the matching icon and no inline actions; custom empty content remains supported, while create, clear, retry and sign-in recovery stay in their existing permission-gated page or toolbar actions (L7, S1–S4)
|
|
219
|
+
- [ ] Row actions: every row's actions are in one `RowActions` "⋮" menu at the end of the row, a single action included and in every record state; no text links, outline buttons or rows of buttons; the actions column has no visible header text and is not sticky or pinned; destructive items last after a separator; no empty menu; any action shown outside the menu, or a pinned column, cites the user's request or confirmed design (T1.5)
|
|
219
220
|
- [ ] List: search placeholder, filters and clearing them, first column, enum Badges, row actions, formatting, date and number columns sortable, every built-in feedback state in S1–S4, result cap notice, a cut-off cell ending in an ellipsis with its full content on hover, cards on phones (T1.1–T1.6, T1.8–T1.13)
|
|
220
221
|
- [ ] Detail view: drawer or page, record name and grouped actions, opens by URL, label–value layout with "—" for empty values (T2.1–T2.4)
|
|
221
222
|
- [ ] Form: container, labels and required marks, validation timing, button order and copy, submitting, failure, success, loading the latest data before editing (T3.1–T3.8)
|
|
@@ -16,7 +16,7 @@ For each applicable capability, identify its owner, persistence, authorized read
|
|
|
16
16
|
|
|
17
17
|
Reconcile only missing pieces using stable route, group, field and resource keys. Preserve existing configuration, schemas, administrator grants, references and history. A later feature adds its own missing settings without resetting previous settings. Explicit API-only scope or a request to omit an interface still takes precedence.
|
|
18
18
|
|
|
19
|
-
The prepared Users list uses plain user names and one Edit entry for basic information and role assignments in a single `RouteDrawer`; do not add a separate details entry or stack an edit dialog above it.
|
|
19
|
+
The prepared Users list uses plain user names and one Edit entry for basic information and role assignments in a single `RouteDrawer`; do not add a separate details entry or stack an edit dialog above it. The user name opens Edit; the row's other account actions, Disable (Enable for a disabled account) and Revoke sessions, and any action the application adds such as Reset password or Delete, sit in the row's one `RowActions` "⋮" menu ([T1.5](frontend/ui-guidelines.md)), never as buttons on the row. Gate every action by its own permission, keep each action's confirmation and result feedback, put Delete last after a separator, and render no menu when no action remains. Roles use a searchable single/multiple-selection dropdown rather than a long switch list. The editor has one Save: submit profile fields and changed role scopes atomically through `UsersClient.update`; never simulate this with sequential writes or provide competing Save buttons. Role-only managers can edit assignments while profile fields stay read-only; protected options and role-removal confirmation remain enforced. New-user creation stays a dialog and uses the same role picker. Preserve route and permission IDs; legacy detail URLs redirect to Edit. Resolve close/cancel destinations from the actual route hierarchy and preserve the list query, including when mounted at `/users` instead of `/settings/users`. Test both mounts, direct/legacy entry, combined saves, failed-save draft retention, unsaved-change guards and focus restoration.
|
|
20
20
|
|
|
21
21
|
## Surface missing initialization prerequisites
|
|
22
22
|
|
|
@@ -638,6 +638,127 @@ export function inspectSource(ts, text, file, root) {
|
|
|
638
638
|
while (node.parent && node.parent !== source) node = node.parent;
|
|
639
639
|
return node;
|
|
640
640
|
}
|
|
641
|
+
// A table's actions column (ui-guidelines.md T1.5): one RowActions "⋮" menu, no visible header text, not pinned.
|
|
642
|
+
// What its cell renders is read from the column and the units of this file it names; a cell built only from
|
|
643
|
+
// components of other files is left alone.
|
|
644
|
+
function inspectActionColumns() {
|
|
645
|
+
// The cell and every unit of this file it reaches by name, such as a UserActions component or a menu function.
|
|
646
|
+
const reachedRoots = (cell) => {
|
|
647
|
+
const roots = [cell];
|
|
648
|
+
const seen = new Set();
|
|
649
|
+
for (let index = 0; index < roots.length; index += 1)
|
|
650
|
+
(function find(node) {
|
|
651
|
+
if (ts.isIdentifier(node) && units.has(node.text)) {
|
|
652
|
+
const unit = units.get(node.text);
|
|
653
|
+
if (!seen.has(unit) && !roots.includes(unit)) {
|
|
654
|
+
seen.add(unit);
|
|
655
|
+
roots.push(unit);
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
ts.forEachChild(node, find);
|
|
659
|
+
})(roots[index]);
|
|
660
|
+
return roots;
|
|
661
|
+
};
|
|
662
|
+
const tagName = (element) => {
|
|
663
|
+
const tag = ts.isJsxElement(element)
|
|
664
|
+
? element.openingElement.tagName
|
|
665
|
+
: element.tagName;
|
|
666
|
+
return ts.isPropertyAccessExpression(tag)
|
|
667
|
+
? tag.name.text
|
|
668
|
+
: tag.getText(source);
|
|
669
|
+
};
|
|
670
|
+
const actionControl = /^(Button|DropdownMenu\w*|Link|a)$/;
|
|
671
|
+
// Overlays a row action opens (its confirmation, a dialog) hold their own buttons.
|
|
672
|
+
const overlay = /(Dialog|Drawer|Sheet|Popover)/;
|
|
673
|
+
// A control is part of RowActions when it sits in one of its props, or is the `render` of a RowAction object
|
|
674
|
+
// (`{ key, label, render: <Link … /> }`), wherever that object is built.
|
|
675
|
+
const insideRowActions = (node, root) => {
|
|
676
|
+
for (let current = node.parent; current; current = current.parent) {
|
|
677
|
+
if (
|
|
678
|
+
ts.isPropertyAssignment(current) &&
|
|
679
|
+
ts.isIdentifier(current.name) &&
|
|
680
|
+
current.name.text === 'render' &&
|
|
681
|
+
current.initializer
|
|
682
|
+
) {
|
|
683
|
+
let value = current.initializer;
|
|
684
|
+
while (ts.isParenthesizedExpression(value)) value = value.expression;
|
|
685
|
+
if (
|
|
686
|
+
value === node ||
|
|
687
|
+
value.getStart(source) === node.getStart(source)
|
|
688
|
+
)
|
|
689
|
+
return true;
|
|
690
|
+
}
|
|
691
|
+
if (
|
|
692
|
+
ts.isJsxAttribute(current) &&
|
|
693
|
+
tagName(current.parent.parent) === 'RowActions'
|
|
694
|
+
)
|
|
695
|
+
return true;
|
|
696
|
+
if (
|
|
697
|
+
(ts.isJsxElement(current) || ts.isJsxSelfClosingElement(current)) &&
|
|
698
|
+
overlay.test(tagName(current))
|
|
699
|
+
)
|
|
700
|
+
return true;
|
|
701
|
+
if (current === root) break;
|
|
702
|
+
}
|
|
703
|
+
return false;
|
|
704
|
+
};
|
|
705
|
+
const strayControls = (cell) => {
|
|
706
|
+
const found = [];
|
|
707
|
+
for (const root of reachedRoots(cell))
|
|
708
|
+
(function find(node) {
|
|
709
|
+
if (
|
|
710
|
+
(ts.isJsxSelfClosingElement(node) || ts.isJsxElement(node)) &&
|
|
711
|
+
actionControl.test(tagName(node)) &&
|
|
712
|
+
!insideRowActions(node, root)
|
|
713
|
+
)
|
|
714
|
+
found.push(node);
|
|
715
|
+
else ts.forEachChild(node, find);
|
|
716
|
+
})(root);
|
|
717
|
+
return found;
|
|
718
|
+
};
|
|
719
|
+
(function find(node) {
|
|
720
|
+
if (ts.isObjectLiteralExpression(node)) {
|
|
721
|
+
const property = (name) =>
|
|
722
|
+
node.properties.find(
|
|
723
|
+
(item) =>
|
|
724
|
+
ts.isPropertyAssignment(item) &&
|
|
725
|
+
(ts.isIdentifier(item.name) || ts.isStringLiteral(item.name)) &&
|
|
726
|
+
item.name.text === name,
|
|
727
|
+
);
|
|
728
|
+
const id = property('id');
|
|
729
|
+
const cell = property('cell');
|
|
730
|
+
if (
|
|
731
|
+
id &&
|
|
732
|
+
ts.isStringLiteralLike(id.initializer) &&
|
|
733
|
+
id.initializer.text === 'actions' &&
|
|
734
|
+
cell
|
|
735
|
+
) {
|
|
736
|
+
const header = property('header');
|
|
737
|
+
if (header && !/\bsr-only\b/.test(header.initializer.getText(source)))
|
|
738
|
+
report(
|
|
739
|
+
header,
|
|
740
|
+
'actions column',
|
|
741
|
+
"no visible header text: header: () => <span className='sr-only'>{t('…actions')}</span> (T1.5)",
|
|
742
|
+
);
|
|
743
|
+
if (/\b(sticky|fixed|right-0|pinned)\b/.test(node.getText(source)))
|
|
744
|
+
report(
|
|
745
|
+
id,
|
|
746
|
+
'actions column',
|
|
747
|
+
'a column that scrolls with the table; pin it only for a wide table whose actions are otherwise out of reach, with the reason in a ui-component-exception marker (T1.5)',
|
|
748
|
+
);
|
|
749
|
+
// Every control the cell renders outside RowActions is reported, also beside a RowActions menu: an action
|
|
750
|
+
// shown outside the menu goes through its `exposed` prop.
|
|
751
|
+
for (const control of strayControls(cell.initializer))
|
|
752
|
+
report(
|
|
753
|
+
control,
|
|
754
|
+
'actions column',
|
|
755
|
+
"RowActions (#components/row-actions): the row's actions in one ⋮ menu, a single action included; show an action outside it only through exposed, for an action the user or a confirmed design names (T1.5)",
|
|
756
|
+
);
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
ts.forEachChild(node, find);
|
|
760
|
+
})(source);
|
|
761
|
+
}
|
|
641
762
|
const units = new Map();
|
|
642
763
|
for (const statement of source.statements) {
|
|
643
764
|
if (
|
|
@@ -740,6 +861,7 @@ export function inspectSource(ts, text, file, root) {
|
|
|
740
861
|
(downward && reach(unit, (from) => renders.get(from) ?? []))
|
|
741
862
|
);
|
|
742
863
|
}
|
|
864
|
+
inspectActionColumns();
|
|
743
865
|
visit(source);
|
|
744
866
|
for (const exception of exceptions.values()) {
|
|
745
867
|
if (!exception.used)
|