Skip to content

Commit

Permalink
chore(ui): Remove direct catalog usage
Browse files Browse the repository at this point in the history
Currently, we're using the catalog at runtime by:

```
import catalogIndex from '@kaoto-next/camel-catalog/index.json?url';
```

While it works, the problem with this approach is that we're tying
the @kaoto-next/camel-catalog dependency at runtime.

The change is to leverage the vite build step in which the catalog
is copied to the `assets` folder.

```
    fetch(`.${DEFAULT_CATALOG_PATH}/index.json`)
```

Relates to: #131
  • Loading branch information
lordrip committed Sep 27, 2023
1 parent 1453212 commit 5f5aba0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
"lint:fix": "yarn eslint \"src/**/*.{ts,tsx}\" --fix"
},
"dependencies": {
"@kaoto-next/camel-catalog": "workspace:*",
"@kaoto-next/uniforms-patternfly": "workspace:*",
"@patternfly/patternfly": "^5.0.0",
"@patternfly/react-code-editor": "^5.0.0",
Expand Down Expand Up @@ -65,6 +64,7 @@
"@babel/preset-env": "^7.21.5",
"@babel/preset-react": "^7.18.6",
"@babel/preset-typescript": "^7.21.5",
"@kaoto-next/camel-catalog": "workspace:*",
"@testing-library/dom": "^9.3.0",
"@testing-library/jest-dom": "^6.0.0",
"@testing-library/react": "^14.0.0",
Expand Down
3 changes: 1 addition & 2 deletions packages/ui/src/providers/catalog-schema-loader.provider.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import catalogIndex from '@kaoto-next/camel-catalog/index.json?url';
import { FunctionComponent, PropsWithChildren, createContext, useEffect, useState } from 'react';
import { CamelSchemasProcessor, DEFAULT_CATALOG_PATH } from '../camel-utils';
import { CamelCatalogIndex, CatalogEntry, CatalogKind, ComponentsCatalog, Schema } from '../models';
Expand All @@ -15,7 +14,7 @@ export const CatalogSchemaLoaderProvider: FunctionComponent<PropsWithChildren> =
const [isLoading, setIsLoading] = useState(true);

useEffect(() => {
fetch(catalogIndex)
fetch(`.${DEFAULT_CATALOG_PATH}/index.json`)
.then((response) => response.json())
.then((catalogIndex: CamelCatalogIndex) => {
const camelComponentsFiles = fetchFile(catalogIndex.catalogs.components.file);
Expand Down

0 comments on commit 5f5aba0

Please sign in to comment.