From d9986e86014ef3a6640a3f9cbc1ada333622c49f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Pupier?= Date: Thu, 27 Jun 2024 10:05:43 +0200 Subject: [PATCH] Pick settings from multiplying architecture at init for the catalog url MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit part of #1204 Signed-off-by: Aurélien Pupier --- .../src/multiplying-architecture/KaotoEditorApp.tsx | 4 +--- .../multiplying-architecture/KaotoEditorFactory.ts | 12 ++++++++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/packages/ui/src/multiplying-architecture/KaotoEditorApp.tsx b/packages/ui/src/multiplying-architecture/KaotoEditorApp.tsx index 31c9ad16f..bb981052e 100644 --- a/packages/ui/src/multiplying-architecture/KaotoEditorApp.tsx +++ b/packages/ui/src/multiplying-architecture/KaotoEditorApp.tsx @@ -13,11 +13,9 @@ 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; - private readonly catalogUrl: string; af_isReact = true; af_componentId = 'kaoto-editor'; af_componentTitle = 'Kaoto Editor'; @@ -25,9 +23,9 @@ export class KaotoEditorApp implements Editor { constructor( private readonly envelopeContext: KogitoEditorEnvelopeContextType, private readonly initArgs: EditorInitArgs, + private readonly catalogUrl: string, ) { this.editorRef = createRef(); - this.catalogUrl = `${this.initArgs.resourcesPathPrefix}${CatalogSchemaLoader.DEFAULT_CATALOG_PATH.replace('.', '')}`; } async getElementPosition() { diff --git a/packages/ui/src/multiplying-architecture/KaotoEditorFactory.ts b/packages/ui/src/multiplying-architecture/KaotoEditorFactory.ts index 0b3dec840..7cf754f1e 100644 --- a/packages/ui/src/multiplying-architecture/KaotoEditorFactory.ts +++ b/packages/ui/src/multiplying-architecture/KaotoEditorFactory.ts @@ -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 { - public createEditor( + public async createEditor( envelopeContext: KogitoEditorEnvelopeContextType, initArgs: EditorInitArgs, ): Promise { - 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)); } }