@@ -16,6 +16,7 @@ import { getVMById, listVMs } from "../api/deploy/vms";
1616
1717import {
1818 NotificationRead as Notification ,
19+ ResourceMigrationRead ,
1920 TeamRead as Team ,
2021 ZoneRead as Zone ,
2122} from "@kthcloud/go-deploy-types/types/v2/body/index" ;
@@ -26,6 +27,7 @@ import {
2627} from "@kthcloud/go-deploy-types/types/v2/body" ;
2728import { listGpuGroups } from "../api/deploy/gpuGroups" ;
2829import { listGpuLeases } from "../api/deploy/gpuLeases" ;
30+ import { listMigrations } from "../api/deploy/resourceMigrations" ;
2931
3032type ResourceContextType = {
3133 rows : Resource [ ] ;
@@ -50,6 +52,8 @@ type ResourceContextType = {
5052 setGpuGroups : ( gpuGroups : GpuGroupRead [ ] ) => void ;
5153 gpuLeases : GpuLeaseRead [ ] ;
5254 setGpuLeases : ( gpuLeases : GpuLeaseRead [ ] ) => void ;
55+ resourceMigrations : ResourceMigrationRead [ ] ;
56+ setResourceMigrations : ( resourceMigrations : ResourceMigrationRead [ ] ) => void ;
5357 queueJob : ( job : Job ) => void ;
5458 beginFastLoad : ( ) => void ;
5559 initialLoad : boolean ;
@@ -83,6 +87,8 @@ const initialState: ResourceContextType = {
8387 setGpuGroups : ( ) => { } ,
8488 gpuLeases : new Array < GpuLeaseRead > ( ) ,
8589 setGpuLeases : ( ) => { } ,
90+ resourceMigrations : new Array < ResourceMigrationRead > ( ) ,
91+ setResourceMigrations : ( ) => { } ,
8692 queueJob : ( ) => { } ,
8793 initialLoad : false ,
8894 setInitialLoad : ( ) => { } ,
@@ -118,6 +124,9 @@ export const ResourceContextProvider = ({
118124 const [ zones , setZones ] = useState < Zone [ ] > ( [ ] ) ;
119125 const [ gpuGroups , setGpuGroups ] = useState < GpuGroupRead [ ] > ( [ ] ) ;
120126 const [ gpuLeases , setGpuLeases ] = useState < GpuLeaseRead [ ] > ( [ ] ) ;
127+ const [ resourceMigrations , setResourceMigrations ] = useState <
128+ ResourceMigrationRead [ ]
129+ > ( [ ] ) ;
121130
122131 // Loading and connection error handler
123132 const [ initialLoad , setInitialLoad ] = useState < boolean > ( false ) ;
@@ -244,6 +253,20 @@ export const ResourceContextProvider = ({
244253 }
245254 } ;
246255
256+ const loadResourceMigrations = async ( ) => {
257+ if ( ! ( initialized && keycloak . authenticated && keycloak . token ) ) return ;
258+ try {
259+ const migrations = await listMigrations ( keycloak . token ) ;
260+ setResourceMigrations ( migrations ) ;
261+ } catch ( error : any ) {
262+ errorHandler ( error ) . forEach ( ( e ) =>
263+ enqueueSnackbar ( "Error fetching migrations: " + e , {
264+ variant : "error" ,
265+ } )
266+ ) ;
267+ }
268+ } ;
269+
247270 const loadNotifications = async ( ) => {
248271 if ( ! ( initialized && keycloak . authenticated && keycloak . token ) ) return ;
249272 try {
@@ -368,6 +391,7 @@ export const ResourceContextProvider = ({
368391 loadZones ( ) ;
369392 loadGpuGroups ( ) ;
370393 loadGpuLeases ( ) ;
394+ loadResourceMigrations ( ) ;
371395
372396 // eslint-disable-next-line
373397 } , [ user ] ) ;
@@ -416,6 +440,8 @@ export const ResourceContextProvider = ({
416440 setGpuGroups,
417441 gpuLeases,
418442 setGpuLeases,
443+ resourceMigrations,
444+ setResourceMigrations,
419445 queueJob,
420446 beginFastLoad,
421447 initialLoad,
0 commit comments