@@ -15,14 +15,10 @@ import {
1515 isYamlLibraryConfiguration ,
1616} from "@/components/shared/GitHubLibrary/types" ;
1717import {
18- fetchAndStoreComponentLibrary ,
18+ COMPONENT_LIBRARY_URL ,
1919 hydrateComponentReference ,
2020} from "@/services/componentService" ;
21- import type {
22- ComponentFolder ,
23- ComponentLibrary ,
24- SearchResult ,
25- } from "@/types/componentLibrary" ;
21+ import type { ComponentFolder , SearchResult } from "@/types/componentLibrary" ;
2622import type {
2723 ComponentReference ,
2824 HydratedComponentReference ,
@@ -69,7 +65,6 @@ type AvailableComponentLibraries =
6965 | string ;
7066
7167type ComponentLibraryContextType = {
72- componentLibrary : ComponentLibrary | undefined ;
7368 userComponentsFolder : ComponentFolder | undefined ;
7469 usedComponentsFolder : ComponentFolder ;
7570 isLoading : boolean ;
@@ -136,6 +131,10 @@ function useComponentLibraryRegistry() {
136131 /**
137132 * In future we will have other library types, including "standard_library", "favorite_components", "used_components", etc.
138133 */
134+ [
135+ "standard_components" ,
136+ new YamlFileLibrary ( "Standard library" , COMPONENT_LIBRARY_URL ) ,
137+ ] ,
139138 ] ) ,
140139 [ queryClient ] ,
141140 ) ;
@@ -187,7 +186,6 @@ export const ComponentLibraryProvider = ({
187186 const { getComponentLibraryObject, existingComponentLibraries } =
188187 useComponentLibraryRegistry ( ) ;
189188
190- const [ componentLibrary , setComponentLibrary ] = useState < ComponentLibrary > ( ) ;
191189 const [ userComponentsFolder , setUserComponentsFolder ] =
192190 useState < ComponentFolder > ( ) ;
193191
@@ -196,17 +194,6 @@ export const ComponentLibraryProvider = ({
196194 const [ newComponent , setNewComponent ] =
197195 useState < HydratedComponentReference | null > ( null ) ;
198196
199- // Fetch main component library
200- const {
201- data : rawComponentLibrary ,
202- isLoading : isLibraryLoading ,
203- error : libraryError ,
204- refetch : refetchLibrary ,
205- } = useQuery ( {
206- queryKey : [ "componentLibrary" ] ,
207- queryFn : fetchAndStoreComponentLibrary ,
208- } ) ;
209-
210197 // Fetch user components
211198 const {
212199 data : rawUserComponentsFolder ,
@@ -227,14 +214,6 @@ export const ComponentLibraryProvider = ({
227214 ) ;
228215
229216 // Methods
230- const refreshComponentLibrary = useCallback ( async ( ) => {
231- const { data : updatedLibrary } = await refetchLibrary ( ) ;
232-
233- if ( updatedLibrary ) {
234- setComponentLibrary ( updatedLibrary ) ;
235- }
236- } , [ refetchLibrary ] ) ;
237-
238217 const refreshUserComponents = useCallback ( async ( ) => {
239218 const { data : updatedUserComponents } = await refetchUserComponents ( ) ;
240219
@@ -273,15 +252,7 @@ export const ComponentLibraryProvider = ({
273252 } ,
274253 } ;
275254
276- if ( componentLibrary ) {
277- const uniqueComponents = filterToUniqueByDigest (
278- flattenFolders ( componentLibrary ) ,
279- ) ;
280-
281- result . components . standard = uniqueComponents . filter (
282- ( c ) => c . spec && componentMatchesSearch ( c . spec , search , filters ) ,
283- ) ;
284- }
255+ // classic search is not supported for now
285256
286257 if ( userComponentsFolder ) {
287258 const uniqueComponents = filterToUniqueByDigest (
@@ -303,13 +274,13 @@ export const ComponentLibraryProvider = ({
303274
304275 return result ;
305276 } ,
306- [ componentLibrary , userComponentsFolder , usedComponentsFolder ] ,
277+ [ userComponentsFolder , usedComponentsFolder ] ,
307278 ) ;
308279
309280 const internalAddComponentToLibrary = useCallback (
310281 async ( hydratedComponent : HydratedComponentReference ) => {
311282 await importComponent ( hydratedComponent ) ;
312- await refreshComponentLibrary ( ) ;
283+
313284 await refreshUserComponents ( ) ;
314285 setNewComponent ( null ) ;
315286 setExistingComponent ( null ) ;
@@ -322,7 +293,7 @@ export const ComponentLibraryProvider = ({
322293 } ) ,
323294 ) ;
324295 } ,
325- [ refreshComponentLibrary , refreshUserComponents , importComponent ] ,
296+ [ refreshUserComponents , importComponent ] ,
326297 ) ;
327298
328299 const handleImportComponent = useCallback (
@@ -341,12 +312,7 @@ export const ComponentLibraryProvider = ({
341312 console . error ( "Error importing component:" , error ) ;
342313 }
343314 } ,
344- [
345- newComponent ,
346- refreshComponentLibrary ,
347- refreshUserComponents ,
348- importComponent ,
349- ] ,
315+ [ newComponent , refreshUserComponents , importComponent ] ,
350316 ) ;
351317
352318 const addToComponentLibraryWithDuplicateCheck = useCallback (
@@ -376,12 +342,7 @@ export const ComponentLibraryProvider = ({
376342 console . error ( "Error adding component to library:" , error ) ;
377343 }
378344 } ,
379- [
380- userComponentsFolder ,
381- refreshComponentLibrary ,
382- refreshUserComponents ,
383- importComponent ,
384- ] ,
345+ [ userComponentsFolder , refreshUserComponents , importComponent ] ,
385346 ) ;
386347
387348 const addToComponentLibrary = useCallback (
@@ -420,7 +381,6 @@ export const ComponentLibraryProvider = ({
420381 USER_COMPONENTS_LIST_NAME ,
421382 component . name ,
422383 ) . then ( async ( ) => {
423- await refreshComponentLibrary ( ) ;
424384 await refreshUserComponents ( ) ;
425385 } ) ;
426386 } else {
@@ -432,7 +392,7 @@ export const ComponentLibraryProvider = ({
432392 console . error ( "Error deleting component:" , error ) ;
433393 }
434394 } ,
435- [ refreshComponentLibrary , refreshUserComponents ] ,
395+ [ refreshUserComponents ] ,
436396 ) ;
437397
438398 const handleCloseDuplicationDialog = useCallback ( ( ) => {
@@ -451,14 +411,6 @@ export const ComponentLibraryProvider = ({
451411 [ currentSearchFilter , searchComponentLibrary ] ,
452412 ) ;
453413
454- useEffect ( ( ) => {
455- if ( ! rawComponentLibrary ) {
456- setComponentLibrary ( undefined ) ;
457- return ;
458- }
459- setComponentLibrary ( rawComponentLibrary ) ;
460- } , [ rawComponentLibrary ] ) ;
461-
462414 useEffect ( ( ) => {
463415 if ( ! rawUserComponentsFolder ) {
464416 setUserComponentsFolder ( undefined ) ;
@@ -476,12 +428,11 @@ export const ComponentLibraryProvider = ({
476428 [ ] ,
477429 ) ;
478430
479- const isLoading = isLibraryLoading || isUserComponentsLoading ;
480- const error = libraryError || userComponentsError ;
431+ const isLoading = isUserComponentsLoading ;
432+ const error = userComponentsError ;
481433
482434 const value = useMemo (
483435 ( ) => ( {
484- componentLibrary,
485436 userComponentsFolder,
486437 usedComponentsFolder,
487438 isLoading,
@@ -495,7 +446,6 @@ export const ComponentLibraryProvider = ({
495446 checkIfUserComponent,
496447 } ) ,
497448 [
498- componentLibrary ,
499449 userComponentsFolder ,
500450 usedComponentsFolder ,
501451 isLoading ,
0 commit comments