Skip to content

Commit 806865e

Browse files
committed
fix(FR-2914): scope deployment add-revision model folder picker to current project
1 parent 908117b commit 806865e

3 files changed

Lines changed: 54 additions & 51 deletions

File tree

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

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ const BAIVFolderSelect: React.FC<BAIVFolderSelectProps> = ({
6060
valuePropName = 'id',
6161
onResolvedNamesChange,
6262
ref,
63+
labelRender: userLabelRender,
6364
...selectProps
6465
}) => {
6566
'use memo';
@@ -288,33 +289,36 @@ const BAIVFolderSelect: React.FC<BAIVFolderSelectProps> = ({
288289
filterOption: false,
289290
}
290291
}
291-
labelRender={({ label, value }) => {
292-
return onClickVFolder ? (
293-
<BAILink onClick={() => onClickVFolder(_.toString(value))}>
294-
{label}
295-
</BAILink>
296-
) : (
297-
<>
298-
{label}
299-
<BAIText type="secondary">
300-
&nbsp; (
301-
<BAIText
302-
ellipsis
303-
type="secondary"
304-
style={{
305-
width: 80,
306-
}}
307-
monospace
308-
>
309-
{valuePropName === 'id'
310-
? toLocalId(_.toString(value))
311-
: _.toString(value)}
292+
labelRender={
293+
userLabelRender ??
294+
(({ label, value }) => {
295+
return onClickVFolder ? (
296+
<BAILink onClick={() => onClickVFolder(_.toString(value))}>
297+
{label}
298+
</BAILink>
299+
) : (
300+
<>
301+
{label}
302+
<BAIText type="secondary">
303+
&nbsp; (
304+
<BAIText
305+
ellipsis
306+
type="secondary"
307+
style={{
308+
width: 80,
309+
}}
310+
monospace
311+
>
312+
{valuePropName === 'id'
313+
? toLocalId(_.toString(value))
314+
: _.toString(value)}
315+
</BAIText>
316+
)
312317
</BAIText>
313-
)
314-
</BAIText>
315-
</>
316-
);
317-
}}
318+
</>
319+
);
320+
})
321+
}
318322
optionRender={({ label, value }) => (
319323
<>
320324
{label}

react/src/components/DeploymentAddRevisionModal.tsx

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {
2121
reverseMapExtraArgs,
2222
} from '../helper/runtimeExtraArgsParser';
2323
import { useBAISettingUserState } from '../hooks/useBAISetting';
24-
import { useModelStoreProject } from '../hooks/useModelStoreProject';
24+
import { useCurrentProjectValue } from '../hooks/useCurrentProject';
2525
import {
2626
buildArgsSchemaKeySet,
2727
buildDefaultsMap,
@@ -71,8 +71,8 @@ import {
7171
BAIFlex,
7272
BAIModal,
7373
BAIModalProps,
74-
BAIProjectVfolderSelect,
7574
BAIRuntimeVariantSelect,
75+
BAIVFolderSelect,
7676
convertToUUID,
7777
safeDecodeUuid,
7878
toLocalId,
@@ -180,10 +180,11 @@ const DeploymentAddRevisionModal: React.FC<DeploymentAddRevisionModalProps> = ({
180180
const { token } = theme.useToken();
181181
const { message } = App.useApp();
182182
const relayEnvironment = useRelayEnvironment();
183-
// The model folder picker scopes to the MODEL_STORE project, not the
184-
// deployment's own project — model cards live in the domain-wide model
185-
// store regardless of which project owns the deployment.
186-
const { id: modelStoreProjectId } = useModelStoreProject();
183+
// The model folder picker scopes to the user's current project so the
184+
// listing matches what the user has access to in the active project
185+
// context, consistent with the rest of the model-deployment UI
186+
// (ServiceLauncherPageContent, ModelCardDeployModal).
187+
const { id: currentProjectId } = useCurrentProjectValue();
187188
const { logger } = useBAILogger();
188189

189190
// Defer `open` so the lazy query only fires once the modal has actually
@@ -263,7 +264,6 @@ const DeploymentAddRevisionModal: React.FC<DeploymentAddRevisionModalProps> = ({
263264
query DeploymentAddRevisionModalQuery($deploymentId: ID!) {
264265
deployment(id: $deploymentId) {
265266
metadata {
266-
projectId
267267
resourceGroupName
268268
}
269269
currentRevision {
@@ -758,9 +758,10 @@ const DeploymentAddRevisionModal: React.FC<DeploymentAddRevisionModalProps> = ({
758758
]),
759759
),
760760
runtimeVariantId: rev.modelRuntimeConfig?.runtimeVariantId ?? undefined,
761-
// BAIProjectVfolderSelect returns the canonical dashed UUID, which
762-
// matches `rev.modelMountConfig.vfolderId` directly. `convertToUUID`
763-
// in the submit is idempotent on already-dashed values.
761+
// BAIVFolderSelect with `valuePropName="row_id"` returns the
762+
// canonical dashed UUID, which matches `rev.modelMountConfig.vfolderId`
763+
// directly. `convertToUUID` in the submit is idempotent on already-
764+
// dashed values.
764765
modelFolderId: rev.modelMountConfig?.vfolderId ?? undefined,
765766
mountDestination: rev.modelMountConfig?.mountDestination ?? '/models',
766767
definitionPath: rev.modelMountConfig?.definitionPath ?? undefined,
@@ -1273,13 +1274,12 @@ const DeploymentAddRevisionModal: React.FC<DeploymentAddRevisionModalProps> = ({
12731274
tooltip={t('deployment.ModelFolderTooltip')}
12741275
rules={[{ required: true }]}
12751276
>
1276-
<BAIProjectVfolderSelect
1277-
projectId={modelStoreProjectId ?? ''}
1278-
disabled={!modelStoreProjectId}
1279-
filter={{
1280-
usageMode: { equals: 'MODEL' },
1281-
status: { equals: 'READY' },
1282-
}}
1277+
<BAIVFolderSelect
1278+
currentProjectId={currentProjectId ?? undefined}
1279+
excludeDeleted
1280+
filter='usage_mode == "model"'
1281+
valuePropName="row_id"
1282+
labelRender={({ label, value }) => label ?? value}
12831283
style={{ width: '100%' }}
12841284
/>
12851285
</Form.Item>
@@ -1332,13 +1332,12 @@ const DeploymentAddRevisionModal: React.FC<DeploymentAddRevisionModalProps> = ({
13321332
tooltip={t('deployment.ModelFolderTooltip')}
13331333
rules={[{ required: true }]}
13341334
>
1335-
<BAIProjectVfolderSelect
1336-
projectId={modelStoreProjectId ?? ''}
1337-
disabled={!modelStoreProjectId}
1338-
filter={{
1339-
usageMode: { equals: 'MODEL' },
1340-
status: { equals: 'READY' },
1341-
}}
1335+
<BAIVFolderSelect
1336+
currentProjectId={currentProjectId ?? undefined}
1337+
excludeDeleted
1338+
filter='usage_mode == "model"'
1339+
valuePropName="row_id"
1340+
labelRender={({ label, value }) => label ?? value}
13421341
style={{ width: '100%' }}
13431342
/>
13441343
</Form.Item>

react/src/components/VFolderNodes.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import VFolderNodeIdenticon from './VFolderNodeIdenticon';
2121
import VFolderPermissionCell from './VFolderPermissionCell';
2222
import { DeleteFilled, DeleteOutlined, UserOutlined } from '@ant-design/icons';
2323
import { useToggle } from 'ahooks';
24-
import { Alert, App, theme, Typography } from 'antd';
24+
import { App, theme, Typography } from 'antd';
2525
import {
2626
filterOutNullAndUndefined,
2727
BAIEndpointsIcon,

0 commit comments

Comments
 (0)