@@ -256,46 +256,50 @@ const ImportMirabufPanel: React.FC<PanelPropsImpl> = ({ panelId }) => {
256
256
// Generate Item cards for cached robots.
257
257
const cachedRobotElements = useMemo (
258
258
( ) =>
259
- cachedRobots . sort ( ( a , b ) => a . name ?. localeCompare ( b . name ?? "" ) ?? - 1 ) . map ( info =>
260
- ItemCard ( {
261
- name : info . name || info . cacheKey || "Unnamed Robot" ,
262
- id : info . id ,
263
- primaryButtonNode : SynthesisIcons . AddLarge ,
264
- primaryOnClick : ( ) => {
265
- console . log ( `Selecting cached robot: ${ info . cacheKey } ` )
266
- selectCache ( info , MiraType . ROBOT )
267
- } ,
268
- secondaryOnClick : ( ) => {
269
- console . log ( `Deleting cache of: ${ info . cacheKey } ` )
270
- MirabufCachingService . Remove ( info . cacheKey , info . id , MiraType . ROBOT )
271
-
272
- setCachedRobots ( GetCacheInfo ( MiraType . ROBOT ) )
273
- } ,
274
- } )
275
- ) ,
259
+ cachedRobots
260
+ . sort ( ( a , b ) => a . name ?. localeCompare ( b . name ?? "" ) ?? - 1 )
261
+ . map ( info =>
262
+ ItemCard ( {
263
+ name : info . name || info . cacheKey || "Unnamed Robot" ,
264
+ id : info . id ,
265
+ primaryButtonNode : SynthesisIcons . AddLarge ,
266
+ primaryOnClick : ( ) => {
267
+ console . log ( `Selecting cached robot: ${ info . cacheKey } ` )
268
+ selectCache ( info , MiraType . ROBOT )
269
+ } ,
270
+ secondaryOnClick : ( ) => {
271
+ console . log ( `Deleting cache of: ${ info . cacheKey } ` )
272
+ MirabufCachingService . Remove ( info . cacheKey , info . id , MiraType . ROBOT )
273
+
274
+ setCachedRobots ( GetCacheInfo ( MiraType . ROBOT ) )
275
+ } ,
276
+ } )
277
+ ) ,
276
278
[ cachedRobots , selectCache , setCachedRobots ]
277
279
)
278
280
279
281
// Generate Item cards for cached fields.
280
282
const cachedFieldElements = useMemo (
281
283
( ) =>
282
- cachedFields . sort ( ( a , b ) => a . name ?. localeCompare ( b . name ?? "" ) ?? - 1 ) . map ( info =>
283
- ItemCard ( {
284
- name : info . name || info . cacheKey || "Unnamed Field" ,
285
- id : info . id ,
286
- primaryButtonNode : SynthesisIcons . AddLarge ,
287
- primaryOnClick : ( ) => {
288
- console . log ( `Selecting cached field: ${ info . cacheKey } ` )
289
- selectCache ( info , MiraType . FIELD )
290
- } ,
291
- secondaryOnClick : ( ) => {
292
- console . log ( `Deleting cache of: ${ info . cacheKey } ` )
293
- MirabufCachingService . Remove ( info . cacheKey , info . id , MiraType . FIELD )
294
-
295
- setCachedFields ( GetCacheInfo ( MiraType . FIELD ) )
296
- } ,
297
- } )
298
- ) ,
284
+ cachedFields
285
+ . sort ( ( a , b ) => a . name ?. localeCompare ( b . name ?? "" ) ?? - 1 )
286
+ . map ( info =>
287
+ ItemCard ( {
288
+ name : info . name || info . cacheKey || "Unnamed Field" ,
289
+ id : info . id ,
290
+ primaryButtonNode : SynthesisIcons . AddLarge ,
291
+ primaryOnClick : ( ) => {
292
+ console . log ( `Selecting cached field: ${ info . cacheKey } ` )
293
+ selectCache ( info , MiraType . FIELD )
294
+ } ,
295
+ secondaryOnClick : ( ) => {
296
+ console . log ( `Deleting cache of: ${ info . cacheKey } ` )
297
+ MirabufCachingService . Remove ( info . cacheKey , info . id , MiraType . FIELD )
298
+
299
+ setCachedFields ( GetCacheInfo ( MiraType . FIELD ) )
300
+ } ,
301
+ } )
302
+ ) ,
299
303
[ cachedFields , selectCache , setCachedFields ]
300
304
)
301
305
@@ -304,51 +308,57 @@ const ImportMirabufPanel: React.FC<PanelPropsImpl> = ({ panelId }) => {
304
308
const remoteRobots = manifest ?. robots . filter (
305
309
path => ! cachedRobots . some ( info => info . cacheKey . includes ( path . src ) )
306
310
)
307
- return remoteRobots ?. sort ( ( a , b ) => a . displayName . localeCompare ( b . displayName ) ) . map ( path =>
308
- ItemCard ( {
309
- name : path . displayName ,
310
- id : path . src ,
311
- primaryButtonNode : SynthesisIcons . DownloadLarge ,
312
- primaryOnClick : ( ) => {
313
- console . log ( `Selecting remote: ${ path } ` )
314
- selectRemote ( path , MiraType . ROBOT )
315
- } ,
316
- } )
317
- )
311
+ return remoteRobots
312
+ ?. sort ( ( a , b ) => a . displayName . localeCompare ( b . displayName ) )
313
+ . map ( path =>
314
+ ItemCard ( {
315
+ name : path . displayName ,
316
+ id : path . src ,
317
+ primaryButtonNode : SynthesisIcons . DownloadLarge ,
318
+ primaryOnClick : ( ) => {
319
+ console . log ( `Selecting remote: ${ path } ` )
320
+ selectRemote ( path , MiraType . ROBOT )
321
+ } ,
322
+ } )
323
+ )
318
324
} , [ manifest ?. robots , cachedRobots , selectRemote ] )
319
325
320
326
// Generate Item cards for remote fields.
321
327
const remoteFieldElements = useMemo ( ( ) => {
322
328
const remoteFields = manifest ?. fields . filter (
323
329
path => ! cachedFields . some ( info => info . cacheKey . includes ( path . src ) )
324
330
)
325
- return remoteFields ?. sort ( ( a , b ) => a . displayName . localeCompare ( b . displayName ) ) . map ( path =>
326
- ItemCard ( {
327
- name : path . displayName ,
328
- id : path . src ,
329
- primaryButtonNode : SynthesisIcons . DownloadLarge ,
330
- primaryOnClick : ( ) => {
331
- console . log ( `Selecting remote: ${ path } ` )
332
- selectRemote ( path , MiraType . FIELD )
333
- } ,
334
- } )
335
- )
336
- } , [ manifest ?. fields , cachedFields , selectRemote ] )
337
-
338
- // Generate Item cards for APS robots and fields.
339
- const hubElements = useMemo (
340
- ( ) =>
341
- files ?. sort ( ( a , b ) => a . attributes . displayName ! . localeCompare ( b . attributes . displayName ! ) ) . map ( file =>
331
+ return remoteFields
332
+ ?. sort ( ( a , b ) => a . displayName . localeCompare ( b . displayName ) )
333
+ . map ( path =>
342
334
ItemCard ( {
343
- name : ` ${ file . attributes . displayName ! . replace ( ".mira" , "" ) } ${ file . attributes . versionNumber != undefined ? ` (v ${ file . attributes . versionNumber } )` : '' } ` ,
344
- id : file . id ,
335
+ name : path . displayName ,
336
+ id : path . src ,
345
337
primaryButtonNode : SynthesisIcons . DownloadLarge ,
346
338
primaryOnClick : ( ) => {
347
- console . debug ( file . raw )
348
- selectAPS ( file , viewType )
339
+ console . log ( `Selecting remote: ${ path } ` )
340
+ selectRemote ( path , MiraType . FIELD )
349
341
} ,
350
342
} )
351
- ) ,
343
+ )
344
+ } , [ manifest ?. fields , cachedFields , selectRemote ] )
345
+
346
+ // Generate Item cards for APS robots and fields.
347
+ const hubElements = useMemo (
348
+ ( ) =>
349
+ files
350
+ ?. sort ( ( a , b ) => a . attributes . displayName ! . localeCompare ( b . attributes . displayName ! ) )
351
+ . map ( file =>
352
+ ItemCard ( {
353
+ name : `${ file . attributes . displayName ! . replace ( ".mira" , "" ) } ${ file . attributes . versionNumber != undefined ? ` (v${ file . attributes . versionNumber } )` : "" } ` ,
354
+ id : file . id ,
355
+ primaryButtonNode : SynthesisIcons . DownloadLarge ,
356
+ primaryOnClick : ( ) => {
357
+ console . debug ( file . raw )
358
+ selectAPS ( file , viewType )
359
+ } ,
360
+ } )
361
+ ) ,
352
362
[ files , selectAPS , viewType ]
353
363
)
354
364
0 commit comments