Skip to content

Commit 640331d

Browse files
committed
fix(FR-2820): lift row actions to ProjectPage and clean up selection on success
1 parent 60171f3 commit 640331d

47 files changed

Lines changed: 1325 additions & 274 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/backend.ai-ui/src/components/fragments/BAIProjectBulkEditModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ const BAIProjectBulkEditModal = ({
8282
showIcon
8383
ghostInfoBg={false}
8484
title={t(
85-
'comp:BAIProjectBulkEditModal.FollowingFoldersWillBeUpdated',
85+
'comp:BAIProjectBulkEditModal.FollowingProjectsWillBeUpdated',
8686
)}
8787
description={
8888
<ul

packages/backend.ai-ui/src/components/fragments/BAIProjectTable.stories.tsx

Lines changed: 52 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ const meta: Meta<typeof BAIProjectTable> = {
4646
| \`projectFragment\` | \`BAIProjectTableFragment$key\` | - | GraphQL fragment reference (required) |
4747
| \`onChangeOrder\` | \`(order: ProjectSorterValue \\| null) => void\` | - | Callback when sort order changes |
4848
| \`onClickProjectEditButton\` | \`(project: Project) => void\` | - | Callback when edit button is clicked (required) |
49-
| \`updateFetchKey\` | \`() => void\` | - | Callback to trigger data refetch |
49+
| \`onClickDeactivateProject\` | \`(project: Project) => Promise<void>\` | - | Async callback when deactivate is confirmed (required) |
50+
| \`onClickRestoreProject\` | \`(project: Project) => Promise<void>\` | - | Async callback when restore is confirmed (required) |
51+
| \`onClickPurgeProject\` | \`(project: Project) => void\` | - | Callback when purge is clicked (required) |
5052
5153
## Pre-configured Columns
5254
- **Name**: Project name (sortable)
@@ -93,11 +95,25 @@ For other props (loading, pagination, etc.), refer to [BAITable](?path=/docs/tab
9395
type: { summary: '(project: Project) => void' },
9496
},
9597
},
96-
updateFetchKey: {
97-
action: 'fetch-triggered',
98-
description: 'Callback to trigger data refetch',
98+
onClickDeactivateProject: {
99+
action: 'deactivate-confirmed',
100+
description: 'Async callback when deactivate is confirmed',
99101
table: {
100-
type: { summary: '() => void' },
102+
type: { summary: '(project: Project) => Promise<void>' },
103+
},
104+
},
105+
onClickRestoreProject: {
106+
action: 'restore-confirmed',
107+
description: 'Async callback when restore is confirmed',
108+
table: {
109+
type: { summary: '(project: Project) => Promise<void>' },
110+
},
111+
},
112+
onClickPurgeProject: {
113+
action: 'purge-clicked',
114+
description: 'Callback when purge is clicked',
115+
table: {
116+
type: { summary: '(project: Project) => void' },
101117
},
102118
},
103119
},
@@ -126,19 +142,28 @@ For other props (loading, pagination, etc.), refer to [BAITable](?path=/docs/tab
126142
export default meta;
127143
type Story = StoryObj<typeof BAIProjectTable>;
128144

129-
interface QueryResolverProps extends Pick<
130-
React.ComponentProps<typeof BAIProjectTable>,
131-
| 'onClickProjectEditButton'
132-
| 'onChangeOrder'
133-
| 'updateFetchKey'
134-
| 'loading'
135-
| 'order'
145+
interface QueryResolverProps extends Partial<
146+
Pick<
147+
React.ComponentProps<typeof BAIProjectTable>,
148+
| 'onClickProjectEditButton'
149+
| 'onClickDeactivateProject'
150+
| 'onClickRestoreProject'
151+
| 'onClickPurgeProject'
152+
| 'onChangeOrder'
153+
| 'loading'
154+
| 'order'
155+
>
136156
> {}
137157

158+
const noop = () => {};
159+
const asyncNoop = async () => {};
160+
138161
const QueryResolver: React.FC<QueryResolverProps> = ({
139-
onClickProjectEditButton,
140-
onChangeOrder,
141-
updateFetchKey,
162+
onClickProjectEditButton = noop,
163+
onClickDeactivateProject = asyncNoop,
164+
onClickRestoreProject = asyncNoop,
165+
onClickPurgeProject = noop,
166+
onChangeOrder = noop,
142167
loading,
143168
order,
144169
}) => {
@@ -170,8 +195,10 @@ const QueryResolver: React.FC<QueryResolverProps> = ({
170195
<BAIProjectTable
171196
projectFragment={projectNodes}
172197
onClickProjectEditButton={onClickProjectEditButton}
198+
onClickDeactivateProject={onClickDeactivateProject}
199+
onClickRestoreProject={onClickRestoreProject}
200+
onClickPurgeProject={onClickPurgeProject}
173201
onChangeOrder={onChangeOrder}
174-
updateFetchKey={updateFetchKey}
175202
loading={loading}
176203
order={order}
177204
pagination={{
@@ -315,7 +342,6 @@ export const DifferentTypes: Story = {
315342
<QueryResolver
316343
onClickProjectEditButton={() => {}}
317344
onChangeOrder={() => {}}
318-
updateFetchKey={() => {}}
319345
/>
320346
</RelayResolver>
321347
),
@@ -374,7 +400,6 @@ export const ActiveInactiveStates: Story = {
374400
<QueryResolver
375401
onClickProjectEditButton={() => {}}
376402
onChangeOrder={() => {}}
377-
updateFetchKey={() => {}}
378403
/>
379404
</RelayResolver>
380405
),
@@ -437,7 +462,6 @@ export const WithSorting: Story = {
437462
order={order}
438463
onChangeOrder={(newOrder) => setOrder(newOrder)}
439464
onClickProjectEditButton={() => {}}
440-
updateFetchKey={() => {}}
441465
/>
442466
</RelayResolver>
443467
</div>
@@ -477,7 +501,6 @@ export const Loading: Story = {
477501
loading={true}
478502
onClickProjectEditButton={() => {}}
479503
onChangeOrder={() => {}}
480-
updateFetchKey={() => {}}
481504
/>
482505
</RelayResolver>
483506
),
@@ -510,7 +533,6 @@ export const Empty: Story = {
510533
<QueryResolver
511534
onClickProjectEditButton={() => {}}
512535
onChangeOrder={() => {}}
513-
updateFetchKey={() => {}}
514536
/>
515537
</RelayResolver>
516538
),
@@ -580,7 +602,6 @@ export const VariousResourceAllocations: Story = {
580602
<QueryResolver
581603
onClickProjectEditButton={() => {}}
582604
onChangeOrder={() => {}}
583-
updateFetchKey={() => {}}
584605
/>
585606
</RelayResolver>
586607
),
@@ -693,11 +714,19 @@ export const RealWorldExample: Story = {
693714
onClickProjectEditButton={(project) =>
694715
addAction(`Edit: ${project.name}`)
695716
}
717+
onClickDeactivateProject={async (project) => {
718+
addAction(`Deactivate: ${project.name}`);
719+
}}
720+
onClickRestoreProject={async (project) => {
721+
addAction(`Restore: ${project.name}`);
722+
}}
723+
onClickPurgeProject={(project) =>
724+
addAction(`Purge: ${project.name}`)
725+
}
696726
onChangeOrder={(newOrder) => {
697727
setOrder(newOrder);
698728
addAction(`Sort: ${newOrder || 'default'}`);
699729
}}
700-
updateFetchKey={() => addAction('Refetch data')}
701730
/>
702731
</RelayResolver>
703732
</div>

0 commit comments

Comments
 (0)