Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(catalog): Add runtime selector #1182

Merged
merged 1 commit into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/camel-catalog/package.json
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we rename the parent folder to camel-catalog-plugin? or not a convention in javscript world to match the folder name with the artifact name?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This folder will be removed after we merged all related PRs 😃

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@kaoto/camel-catalog",
"name": "@kaoto/camel-catalog-plugin",
"version": "2.1.0-dev",
"type": "commonjs",
"description": "Camel Catalog and schemas for Kaoto",
Expand Down
4 changes: 2 additions & 2 deletions packages/catalog-generator/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@kaoto/catalog-generator",
"name": "@kaoto/camel-catalog",
"version": "2.1.0-dev",
"type": "commonjs",
"description": "Camel Catalog and schemas for Kaoto",
Expand All @@ -14,7 +14,7 @@
"./index.json": "./dist/camel-catalog/index.json",
"./types": "./dist/types/index.ts",
"./package.json": "./package.json",
"./*.json": "./dist/*.json"
"./*.json": "./dist/camel-catalog/*.json"
},
"scripts": {
"build": "yarn clean && yarn build:mvn && yarn build:default:catalog && yarn build:ts",
Expand Down
6 changes: 3 additions & 3 deletions packages/ui-tests/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ const config: StorybookConfig = {
docs: {
autodocs: true,
},
// Configures the static asset folder in Storybook
// Requires the camel-catalog build
staticDirs: [{ from: '../../camel-catalog/dist', to: 'camel-catalog' }],
// Configures the static asset folder in> Storybook
// Requires the catalog-generator build
staticDirs: [{ from: '../../catalog-generator/dist/camel-catalog', to: 'camel-catalog' }],
typescript: {
check: false,
checkOptions: {},
Expand Down
17 changes: 10 additions & 7 deletions packages/ui-tests/stories/canvas/Canvas.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
EntitiesProvider,
KameletVisualEntity,
PipeVisualEntity,
RuntimeProvider,
SchemasLoaderProvider,
SourceCodeProvider,
VisibleFLowsContextResult,
Expand Down Expand Up @@ -48,13 +49,15 @@ const emptyPipeEntity = new PipeVisualEntity(emptyPipeJson);
const ContextDecorator = (Story: StoryFn) => (
<SourceCodeProvider>
<EntitiesProvider>
<SchemasLoaderProvider catalogUrl={CatalogSchemaLoader.DEFAULT_CATALOG_PATH}>
<CatalogLoaderProvider catalogUrl={CatalogSchemaLoader.DEFAULT_CATALOG_PATH}>
<CatalogTilesProvider>
<Story />
</CatalogTilesProvider>
</CatalogLoaderProvider>
</SchemasLoaderProvider>
<RuntimeProvider catalogUrl={CatalogSchemaLoader.DEFAULT_CATALOG_PATH}>
<SchemasLoaderProvider>
<CatalogLoaderProvider>
<CatalogTilesProvider>
<Story />
</CatalogTilesProvider>
</CatalogLoaderProvider>
</SchemasLoaderProvider>
</RuntimeProvider>
</EntitiesProvider>
</SourceCodeProvider>
);
Expand Down
21 changes: 12 additions & 9 deletions packages/ui-tests/stories/canvas/ContextToolbar.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
CatalogTilesProvider,
ContextToolbar,
EntitiesProvider,
RuntimeProvider,
SchemasLoaderProvider,
SourceCodeApiContext,
SourceCodeProvider,
Expand All @@ -20,15 +21,17 @@ const EntitiesContextDecorator = (Story: StoryFn) => {
return (
<SourceCodeProvider>
<EntitiesProvider>
<SchemasLoaderProvider catalogUrl={CatalogSchemaLoader.DEFAULT_CATALOG_PATH}>
<CatalogLoaderProvider catalogUrl={CatalogSchemaLoader.DEFAULT_CATALOG_PATH}>
<CatalogTilesProvider>
<VisibleFlowsProvider>
<Story />
</VisibleFlowsProvider>
</CatalogTilesProvider>
</CatalogLoaderProvider>
</SchemasLoaderProvider>
<RuntimeProvider catalogUrl={CatalogSchemaLoader.DEFAULT_CATALOG_PATH}>
<SchemasLoaderProvider>
<CatalogLoaderProvider>
<CatalogTilesProvider>
<VisibleFlowsProvider>
<Story />
</VisibleFlowsProvider>
</CatalogTilesProvider>
</CatalogLoaderProvider>
</SchemasLoaderProvider>
</RuntimeProvider>
</EntitiesProvider>
</SourceCodeProvider>
);
Expand Down
20 changes: 14 additions & 6 deletions packages/ui-tests/stories/canvas/NewBeanModal.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
import { Meta, StoryFn } from '@storybook/react';
import { CatalogLoaderProvider, CatalogSchemaLoader, SchemasLoaderProvider, NewBeanModal } from '@kaoto/kaoto/testing';
import {
CatalogLoaderProvider,
CatalogSchemaLoader,
SchemasLoaderProvider,
NewBeanModal,
RuntimeProvider,
} from '@kaoto/kaoto/testing';

export default {
title: 'Canvas/NewBeanModal',
component: NewBeanModal,
decorators: [
(Story: StoryFn) => (
<SchemasLoaderProvider catalogUrl={CatalogSchemaLoader.DEFAULT_CATALOG_PATH}>
<CatalogLoaderProvider catalogUrl={CatalogSchemaLoader.DEFAULT_CATALOG_PATH}>
<Story />
</CatalogLoaderProvider>
</SchemasLoaderProvider>
<RuntimeProvider catalogUrl={CatalogSchemaLoader.DEFAULT_CATALOG_PATH}>
<SchemasLoaderProvider>
<CatalogLoaderProvider>
<Story />
</CatalogLoaderProvider>
</SchemasLoaderProvider>
</RuntimeProvider>
),
],
} as Meta<typeof NewBeanModal>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { DataFormatEditor, MetadataEditor } from '@kaoto/kaoto';
import {
CanvasNode,
CatalogLoaderProvider,
CatalogSchemaLoader,
IVisualizationNode,
KaotoSchemaDefinition,
RuntimeProvider,
SchemasLoaderProvider,
VisualComponentSchema,
} from '@kaoto/kaoto/testing';
import { Meta, StoryFn } from '@storybook/react';
import { CanvasNode } from './../canvas.models';

const visualComponentSchema: VisualComponentSchema = {
title: 'My Node',
Expand Down Expand Up @@ -37,11 +38,13 @@ const mockNode: CanvasNode = {
};

const EntitiesContextDecorator = (Story: StoryFn) => (
<SchemasLoaderProvider catalogUrl={CatalogSchemaLoader.DEFAULT_CATALOG_PATH}>
<CatalogLoaderProvider catalogUrl={CatalogSchemaLoader.DEFAULT_CATALOG_PATH}>
<Story />
</CatalogLoaderProvider>
</SchemasLoaderProvider>
<RuntimeProvider catalogUrl={CatalogSchemaLoader.DEFAULT_CATALOG_PATH}>
<SchemasLoaderProvider>
<CatalogLoaderProvider>
<Story />
</CatalogLoaderProvider>
</SchemasLoaderProvider>
</RuntimeProvider>
);

export default {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { MetadataEditor, StepExpressionEditor } from '@kaoto/kaoto';
import {
CanvasNode,
CatalogLoaderProvider,
CatalogSchemaLoader,
IVisualizationNode,
KaotoSchemaDefinition,
MetadataEditor,
RuntimeProvider,
SchemasLoaderProvider,
StepExpressionEditor,
VisualComponentSchema,
} from '@kaoto/kaoto/testing';
import { Meta, StoryFn } from '@storybook/react';
import { CanvasNode } from './../canvas.models';

const visualComponentSchema: VisualComponentSchema = {
title: 'My Node',
Expand Down Expand Up @@ -36,11 +38,13 @@ const mockNode: CanvasNode = {
};

const EntitiesContextDecorator = (Story: StoryFn) => (
<SchemasLoaderProvider catalogUrl={CatalogSchemaLoader.DEFAULT_CATALOG_PATH}>
<CatalogLoaderProvider catalogUrl={CatalogSchemaLoader.DEFAULT_CATALOG_PATH}>
<Story />
</CatalogLoaderProvider>
</SchemasLoaderProvider>
<RuntimeProvider catalogUrl={CatalogSchemaLoader.DEFAULT_CATALOG_PATH}>
<SchemasLoaderProvider>
<CatalogLoaderProvider>
<Story />
</CatalogLoaderProvider>
</SchemasLoaderProvider>
</RuntimeProvider>
);

export default {
Expand Down
12 changes: 9 additions & 3 deletions packages/ui/scripts/copy-camel-catalog-files.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
import { copyFileSync, existsSync, mkdirSync } from 'node:fs';
import { resolve, join, basename } from 'node:path';
import { basename, dirname, relative, resolve } from 'node:path';

/**
* Copy the built Kaoto Camel Catalog files into the assets/camel-catalog folder
*/
async function copyCamelCatalogFiles(destinationFolder) {
const { getCamelCatalogFiles } = await import('./get-camel-catalog-files.js');
const camelCatalogFiles = getCamelCatalogFiles();
const { basePath, files: camelCatalogFiles } = getCamelCatalogFiles();

camelCatalogFiles.forEach((file) => {
const dest = resolve(join(destinationFolder, basename(file)));
const relativePath = relative(basePath, file);
const destDir = resolve(destinationFolder, dirname(relativePath));

if (!existsSync(destDir)) {
mkdirSync(destDir, { recursive: true });
}

const dest = resolve(destDir, basename(file));
console.info('\t', `Copying '${file}' to '${dest}'`);

copyFileSync(file, dest);
Expand Down
27 changes: 21 additions & 6 deletions packages/ui/scripts/get-camel-catalog-files.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { readdirSync } from 'node:fs';
import { readdirSync, existsSync, statSync } from 'node:fs';
import { createRequire } from 'node:module';
import { dirname, join } from 'node:path';
import { normalizePath } from 'vite';
Expand Down Expand Up @@ -38,10 +38,25 @@ export const getCamelCatalogFiles = () => {
throw new Error(message.join('\n\n'));
}

/** List all the JSON files in the Camel Catalog folder */
const jsonFiles = readdirSync(camelCatalogPath)
.filter((file) => file.endsWith('.json'))
.map((file) => normalizePath(join(camelCatalogPath, file)));
/** Recursively list all the JSON files in the Camel Catalog folder and subfolders */
const jsonFiles = [];
getFilesRecursively(camelCatalogPath, jsonFiles);

return jsonFiles;
return { basePath: camelCatalogPath, files: jsonFiles.filter((file) => file.endsWith('.json')) };
};

function getFilesRecursively(source, files) {
const exists = existsSync(source);
const stats = exists && statSync(source);
const isDirectory = exists && stats.isDirectory();

if (isDirectory) {
const directoryFiles = readdirSync(source);

for (const file of directoryFiles) {
getFilesRecursively(join(source, file), files);
}
} else {
files.push(source);
}
}
35 changes: 20 additions & 15 deletions packages/ui/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
import { Outlet } from 'react-router-dom';
import { Shell } from './layout/Shell';
import { CatalogTilesProvider } from './providers/catalog-tiles.provider';
import { CatalogLoaderProvider } from './providers/catalog.provider';
import { EntitiesProvider } from './providers/entities.provider';
import { SchemasLoaderProvider } from './providers/schemas.provider';
import { SourceCodeProvider } from './providers/source-code.provider';
import {
CatalogLoaderProvider,
CatalogTilesProvider,
EntitiesProvider,
RuntimeProvider,
SchemasLoaderProvider,
SourceCodeProvider,
VisibleFlowsProvider,
} from './providers';
import { CatalogSchemaLoader } from './utils/catalog-schema-loader';
import { VisibleFlowsProvider } from './providers';

function App() {
return (
<SourceCodeProvider>
<EntitiesProvider>
<Shell>
<SchemasLoaderProvider catalogUrl={CatalogSchemaLoader.DEFAULT_CATALOG_PATH}>
<CatalogLoaderProvider catalogUrl={CatalogSchemaLoader.DEFAULT_CATALOG_PATH}>
<CatalogTilesProvider>
<VisibleFlowsProvider>
<Outlet />
</VisibleFlowsProvider>
</CatalogTilesProvider>
</CatalogLoaderProvider>
</SchemasLoaderProvider>
<RuntimeProvider catalogUrl={CatalogSchemaLoader.DEFAULT_CATALOG_PATH}>
<SchemasLoaderProvider>
<CatalogLoaderProvider>
<CatalogTilesProvider>
<VisibleFlowsProvider>
<Outlet />
</VisibleFlowsProvider>
</CatalogTilesProvider>
</CatalogLoaderProvider>
</SchemasLoaderProvider>
</RuntimeProvider>
</Shell>
</EntitiesProvider>
</SourceCodeProvider>
Expand Down
1 change: 1 addition & 0 deletions packages/ui/src/assets/quarkus-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
61 changes: 61 additions & 0 deletions packages/ui/src/assets/redhat-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions packages/ui/src/assets/springboot-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading