22 @license
33 Copyright (c) 2015-2026 Lablup Inc. All rights reserved.
44 */
5+ import { ImportRepoFormCreateVFolderMutation } from '../__generated__/ImportRepoFormCreateVFolderMutation.graphql' ;
56import { useSuspendedBackendaiClient } from '../hooks' ;
67import { useSetBAINotification } from '../hooks/useBAINotification' ;
78import {
@@ -20,13 +21,27 @@ import {
2021} from 'antd' ;
2122import {
2223 BAIButton ,
24+ toLocalId ,
2325 useBAILogger ,
2426 useErrorMessageResolver ,
2527 useGetAvailableFolderName ,
28+ useMutationWithPromise ,
2629} from 'backend.ai-ui' ;
2730import { FolderInput } from 'lucide-react' ;
2831import { useRef } from 'react' ;
2932import { useTranslation } from 'react-i18next' ;
33+ import { graphql } from 'react-relay' ;
34+
35+ const IMPORT_REPO_FORM_CREATE_VFOLDER_MUTATION = graphql `
36+ mutation ImportRepoFormCreateVFolderMutation($input: CreateVFolderV2Input!) {
37+ createVfolderV2(input: $input) {
38+ vfolder {
39+ id
40+ ...BAINodeNotificationItemFragment @alias(as: "notificationFrgmt")
41+ }
42+ }
43+ }
44+ ` ;
3045
3146type URLType = 'github' | 'gitlab' ;
3247
@@ -104,6 +119,11 @@ const ImportRepoForm: React.FC<ImportFromURLFormProps> = ({
104119 const { startSessionWithDefault, upsertSessionNotification } =
105120 useStartSession ( ) ;
106121
122+ const commitCreateMutation =
123+ useMutationWithPromise < ImportRepoFormCreateVFolderMutation > (
124+ IMPORT_REPO_FORM_CREATE_VFOLDER_MUTATION ,
125+ ) ;
126+
107127 const prepareGitHubArchive = async ( inputUrl : string ) => {
108128 const sanitizedUrl = inputUrl . trim ( ) . replace ( / \. g i t $ / , '' ) ;
109129 let parsedUrl : URL ;
@@ -217,25 +237,27 @@ const ImportRepoForm: React.FC<ImportFromURLFormProps> = ({
217237 repoInfo . repoName || 'imported-from-repo' ,
218238 ) ;
219239
220- // create virtual folder
221- const vfolderInfo = await baiClient . vfolder . create (
222- folderName ,
223- values . storageHost ,
224- '' , // group
225- values . vfolder_usage_mode ?? 'general' , // usage mode
226- 'rw' , // permission
227- ) ;
240+ // Create the virtual folder via the V2 mutation; its payload already
241+ // includes the rich folder-card fragment, so the notification can be
242+ // driven directly without a separate `vfolder_node` lookup.
243+ const { createVfolderV2 } = await commitCreateMutation ( {
244+ input : {
245+ name : folderName ,
246+ host : values . storageHost ,
247+ cloneable : false ,
248+ usageMode : values . vfolder_usage_mode ?? 'general' ,
249+ permission : 'rw' ,
250+ projectId : null ,
251+ } ,
252+ } ) ;
253+ const vfolder = createVfolderV2 . vfolder ;
254+ const vfolderLocalId = toLocalId ( vfolder . id ) ;
228255
229256 upsertNotification ( {
230- key : `folder-create-success-${ vfolderInfo . id } ` ,
257+ key : `folder-create-success-${ vfolderLocalId } ` ,
231258 icon : 'folder' ,
232- message : `${ vfolderInfo . name } : ${ t ( 'data.folders.FolderCreated' ) } ` ,
233- toText : t ( 'data.folders.OpenAFolder' ) ,
234- to : {
235- search : new URLSearchParams ( {
236- folder : vfolderInfo . id ,
237- } ) . toString ( ) ,
238- } ,
259+ node : vfolder . notificationFrgmt ?? null ,
260+ description : t ( 'data.folders.FolderCreated' ) ,
239261 open : true ,
240262 duration : 0 ,
241263 } ) ;
@@ -254,7 +276,7 @@ const ImportRepoForm: React.FC<ImportFromURLFormProps> = ({
254276 ) ,
255277 enabled : true ,
256278 } ,
257- mount_ids : [ vfolderInfo . id ] ,
279+ mount_ids : [ vfolderLocalId ] ,
258280 } ;
259281
260282 const results = await startSessionWithDefault ( launcherValue ) ;
0 commit comments