@@ -15,19 +15,30 @@ import {
1515} from 'antd' ;
1616import {
1717 BAIButton ,
18+ toGlobalId ,
1819 useBAILogger ,
1920 useErrorMessageResolver ,
2021 useGetAvailableFolderName ,
2122} from 'backend.ai-ui' ;
2223import { FolderInput } from 'lucide-react' ;
2324import { useRef } from 'react' ;
2425import { useTranslation } from 'react-i18next' ;
26+ import { fetchQuery , graphql , useRelayEnvironment } from 'react-relay' ;
27+ import { ImportRepoFormVFolderNotificationQuery } from 'src/__generated__/ImportRepoFormVFolderNotificationQuery.graphql' ;
2528import { useSetBAINotification } from 'src/hooks/useBAINotification' ;
2629import {
2730 StartSessionWithDefaultValue ,
2831 useStartSession ,
2932} from 'src/hooks/useStartSession' ;
3033
34+ const IMPORT_REPO_FORM_VFOLDER_NOTIFICATION_QUERY = graphql `
35+ query ImportRepoFormVFolderNotificationQuery($id: String!) {
36+ vfolder_node(id: $id) {
37+ ...BAINodeNotificationItemFragment @alias(as: "notificationFrgmt")
38+ }
39+ }
40+ ` ;
41+
3142type URLType = 'github' | 'gitlab' ;
3243
3344type VFolderUsageModeForImport = 'general' | 'model' ;
@@ -94,6 +105,7 @@ const ImportRepoForm: React.FC<ImportFromURLFormProps> = ({
94105 const formRef = useRef < FormInstance < ImportFromURLFormValues > | null > ( null ) ;
95106 const baiClient = useSuspendedBackendaiClient ( ) ;
96107 const { upsertNotification } = useSetBAINotification ( ) ;
108+ const relayEnv = useRelayEnvironment ( ) ;
97109 const app = App . useApp ( ) ;
98110 const { getErrorMessage } = useErrorMessageResolver ( ) ;
99111
@@ -226,16 +238,25 @@ const ImportRepoForm: React.FC<ImportFromURLFormProps> = ({
226238 'rw' , // permission
227239 ) ;
228240
241+ // REST `/folders` does not return a Relay fragment, so query the new
242+ // VirtualFolderNode by id to drive the rich folder-card notification
243+ // (BAINodeNotificationItem). Falls back gracefully — if the node is
244+ // unreachable, the notification still opens but without the folder-link
245+ // header; the import session creation flow continues regardless.
246+ const notificationData =
247+ await fetchQuery < ImportRepoFormVFolderNotificationQuery > (
248+ relayEnv ,
249+ IMPORT_REPO_FORM_VFOLDER_NOTIFICATION_QUERY ,
250+ { id : toGlobalId ( 'VirtualFolderNode' , vfolderInfo . id ) } ,
251+ )
252+ . toPromise ( )
253+ . catch ( ( ) => null ) ;
254+
229255 upsertNotification ( {
230256 key : `folder-create-success-${ vfolderInfo . id } ` ,
231257 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- } ,
258+ node : notificationData ?. vfolder_node ?. notificationFrgmt ?? undefined ,
259+ description : t ( 'data.folders.FolderCreated' ) ,
239260 open : true ,
240261 duration : 0 ,
241262 } ) ;
0 commit comments