Skip to content

Commit

Permalink
Pick settings from multiplying architecture at init for the catalog
Browse files Browse the repository at this point in the history
url

part of KaotoIO#1204

Signed-off-by: Aurélien Pupier <apupier@redhat.com>
  • Loading branch information
apupier committed Jul 4, 2024
1 parent 5a8598c commit d9986e8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
4 changes: 1 addition & 3 deletions packages/ui/src/multiplying-architecture/KaotoEditorApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,19 @@ import { SourceCodeProvider } from '../providers/source-code.provider';
import { KaotoBridge } from './KaotoBridge';
import { KaotoEditor } from './KaotoEditor';
import { KaotoEditorChannelApi } from './KaotoEditorChannelApi';
import { CatalogSchemaLoader } from '../utils';

export class KaotoEditorApp implements Editor {
private readonly editorRef: RefObject<EditorApi>;
private readonly catalogUrl: string;
af_isReact = true;
af_componentId = 'kaoto-editor';
af_componentTitle = 'Kaoto Editor';

constructor(
private readonly envelopeContext: KogitoEditorEnvelopeContextType<KaotoEditorChannelApi>,
private readonly initArgs: EditorInitArgs,
private readonly catalogUrl: string,
) {
this.editorRef = createRef<EditorApi>();
this.catalogUrl = `${this.initArgs.resourcesPathPrefix}${CatalogSchemaLoader.DEFAULT_CATALOG_PATH.replace('.', '')}`;
}

async getElementPosition() {
Expand Down
12 changes: 10 additions & 2 deletions packages/ui/src/multiplying-architecture/KaotoEditorFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,20 @@ import {
KogitoEditorEnvelopeContextType,
} from '@kie-tools-core/editor/dist/api';
import { KaotoEditorChannelApi } from './KaotoEditorChannelApi';
import { CatalogSchemaLoader, isDefined } from '../utils';

export class KaotoEditorFactory implements EditorFactory<Editor, KaotoEditorChannelApi> {
public createEditor(
public async createEditor(
envelopeContext: KogitoEditorEnvelopeContextType<KaotoEditorChannelApi>,
initArgs: EditorInitArgs,
): Promise<Editor> {
return Promise.resolve(new KaotoEditorApp(envelopeContext, initArgs));
let catalogUrl;
const catalogUrlFromChannelApi = await envelopeContext.channelApi.requests.getCatalogURL();
if (isDefined(catalogUrlFromChannelApi)) {
catalogUrl = catalogUrlFromChannelApi;
} else {
catalogUrl = `${initArgs.resourcesPathPrefix}${CatalogSchemaLoader.DEFAULT_CATALOG_PATH.replace('.', '')}`;
}
return Promise.resolve(new KaotoEditorApp(envelopeContext, initArgs, catalogUrl));
}
}

0 comments on commit d9986e8

Please sign in to comment.