1
1
import React , { useEffect , useState } from 'react' ;
2
2
import AddIcon from '@mui/icons-material/Add' ;
3
3
import { createDockerDesktopClient } from '@docker/extension-api-client' ;
4
- import { Stack , Typography , Button , ButtonGroup , Grid , debounce , Card , CardContent , IconButton , Alert , DialogTitle , Dialog , DialogContent , FormControlLabel , Checkbox } from '@mui/material' ;
4
+ import { Stack , Typography , Button , ButtonGroup , Grid , debounce , Card , CardContent , IconButton , Alert , DialogTitle , Dialog , DialogContent , FormControlLabel , Checkbox , CircularProgress , Paper } from '@mui/material' ;
5
5
import { CatalogItem , CatalogItemCard , CatalogItemWithName } from './components/PromptCard' ;
6
6
import { parse , stringify } from 'yaml' ;
7
7
import { Ref } from './Refs' ;
8
8
import { RegistrySyncStatus } from './components/RegistrySyncStatus' ;
9
9
import { getRegistry } from './Registry' ;
10
10
import { ClaudeConfigSyncStatus , setNeverShowAgain } from './components/ClaudeConfigSyncStatus' ;
11
11
import { FolderOpenRounded , } from '@mui/icons-material' ;
12
+ import { ExecResult } from '@docker/extension-api-client-types/dist/v0' ;
12
13
13
14
const NEVER_SHOW_AGAIN_KEY = 'registry-sync-never-show-again' ;
14
15
@@ -24,6 +25,7 @@ export function App() {
24
25
const [ registryItems , setRegistryItems ] = useState < { [ key : string ] : { ref : string } } > ( { } ) ;
25
26
const [ showReloadModal , setShowReloadModal ] = useState ( false ) ;
26
27
const [ hasConfig , setHasConfig ] = useState ( false ) ;
28
+ const [ imagesLoadingResults , setImagesLoadingResults ] = useState < ExecResult | null > ( null ) ;
27
29
28
30
const loadCatalog = async ( showNotification = true ) => {
29
31
const cachedCatalog = localStorage . getItem ( 'catalog' ) ;
@@ -108,8 +110,24 @@ export function App() {
108
110
109
111
}
110
112
113
+ const startImagesLoading = async ( ) => {
114
+ setImagesLoadingResults ( null ) ;
115
+ try {
116
+ const result = await client . docker . cli . exec ( 'pull' , [ 'vonwig/function_write_files:latest' ] )
117
+ setImagesLoadingResults ( result ) ;
118
+ }
119
+ catch ( error ) {
120
+ console . error ( error )
121
+ if ( error ) {
122
+ setImagesLoadingResults ( error as ExecResult )
123
+ }
124
+
125
+ }
126
+ }
127
+
111
128
useEffect ( ( ) => {
112
129
loadCatalog ( ) ;
130
+ startImagesLoading ( ) ;
113
131
loadRegistry ( ) ;
114
132
const interval = setInterval ( ( ) => {
115
133
loadCatalog ( false ) ;
@@ -124,9 +142,22 @@ export function App() {
124
142
catalogItems . some ( ( c ) => c . name === i )
125
143
)
126
144
145
+ if ( ! imagesLoadingResults || imagesLoadingResults . stderr ) {
146
+ return < Paper sx = { { padding : 2 , height : '90vh' , display : 'flex' , flexDirection : 'column' , justifyContent : 'center' , alignItems : 'center' } } >
147
+ { ! imagesLoadingResults && < CircularProgress sx = { { marginBottom : 2 } } /> }
148
+ { ! imagesLoadingResults && < Typography > Loading images...</ Typography > }
149
+ { imagesLoadingResults && < Alert sx = { { fontSize : '1.5em' } } action = { < Button variant = 'outlined' color = 'secondary' onClick = { ( ) => startImagesLoading ( ) } > Retry</ Button > } title = "Error loading images" severity = "error" > { imagesLoadingResults . stderr } </ Alert > }
150
+ < Typography > { imagesLoadingResults ?. stdout } </ Typography >
151
+ </ Paper >
152
+ }
153
+
154
+
155
+
156
+
127
157
return (
128
158
< div >
129
159
< Dialog open = { showReloadModal } onClose = { ( ) => setShowReloadModal ( false ) } >
160
+
130
161
< DialogTitle > Registry Updated</ DialogTitle >
131
162
< DialogContent >
132
163
< Typography sx = { { marginBottom : 2 } } >
@@ -144,7 +175,6 @@ export function App() {
144
175
145
176
< Stack direction = "column" spacing = { 1 } >
146
177
< div >
147
-
148
178
< ButtonGroup >
149
179
< Button onClick = { ( ) => loadCatalog ( true ) } > Refresh catalog</ Button >
150
180
< Button onClick = { loadRegistry } > Refresh registry</ Button >
@@ -188,8 +218,7 @@ export function App() {
188
218
</ Grid >
189
219
</ Grid >
190
220
</ Stack >
191
-
192
-
193
221
</ div >
194
222
)
223
+
195
224
}
0 commit comments