From 2c9b7eb17f3cc514d0fdd8b9c18e864dc5f8e1ea Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Fri, 17 Sep 2021 13:02:33 +0200 Subject: [PATCH] BREAKING: Make Elsa Studio service bus async --- .../elsa-workflows-studio/package.json | 2 +- .../elsa-studio-root/elsa-studio-root.tsx | 8 +-- .../elsa-expression-editor.tsx | 4 +- .../elsa-script-property.tsx | 4 +- ...sa-workflow-blueprint-properties-panel.tsx | 2 +- .../elsa-workflow-blueprint-side-panel.tsx | 2 +- .../elsa-workflow-blueprint-viewer-screen.tsx | 4 +- ...elsa-workflow-definition-editor-screen.tsx | 28 +++++----- .../elsa-workflow-properties-panel.tsx | 2 +- .../elsa-workflow-settings-modal.tsx | 2 +- .../elsa-workflow-definitions-list-screen.tsx | 6 +- .../elsa-workflow-instance-list-screen.tsx | 56 ++++++++++--------- .../elsa-workflow-instance-journal.tsx | 2 +- .../elsa-workflow-instance-viewer-screen.tsx | 6 +- .../elsa-workflow-registry-list-screen.tsx | 6 +- .../src/models/services.ts | 8 +-- .../plugins/workflow-settings-plugin.tsx | 8 +-- .../services/elsa-client.ts | 16 +++--- .../src/services/elsa-client.ts | 10 ++-- .../src/utils/select-list-items.ts | 6 +- 20 files changed, 92 insertions(+), 90 deletions(-) diff --git a/src/designer/elsa-workflows-studio/package.json b/src/designer/elsa-workflows-studio/package.json index bf6a42920..79d682c2a 100644 --- a/src/designer/elsa-workflows-studio/package.json +++ b/src/designer/elsa-workflows-studio/package.json @@ -1,6 +1,6 @@ { "name": "@elsa-workflows/elsa-workflows-studio", - "version": "2.2.5", + "version": "2.2.7", "description": "Elsa Workflow Studio is a collection of web components to manage Elsa workflows stored on an Elsa Workflows server.", "repository": { "type": "git", diff --git a/src/designer/elsa-workflows-studio/src/components/dashboard/pages/elsa-studio-root/elsa-studio-root.tsx b/src/designer/elsa-workflows-studio/src/components/dashboard/pages/elsa-studio-root/elsa-studio-root.tsx index a1575a20f..ea7421902 100644 --- a/src/designer/elsa-workflows-studio/src/components/dashboard/pages/elsa-studio-root/elsa-studio-root.tsx +++ b/src/designer/elsa-workflows-studio/src/components/dashboard/pages/elsa-studio-root/elsa-studio-root.tsx @@ -52,9 +52,9 @@ export class ElsaStudioRoot { eventBus.detach(EventTypes.HideToastNotification, this.onHideToastNotification); } - componentWillLoad() { - const elsaClientFactory: () => ElsaClient = () => createElsaClient(this.serverUrl); - const httpClientFactory: () => AxiosInstance = () => createHttpClient(this.serverUrl); + async componentWillLoad() { + const elsaClientFactory: () => Promise = () => createElsaClient(this.serverUrl); + const httpClientFactory: () => Promise = () => createHttpClient(this.serverUrl); const elsaStudio: ElsaStudio = { serverUrl: this.serverUrl, @@ -65,7 +65,7 @@ export class ElsaStudioRoot { propertyDisplayManager, activityIconProvider, confirmDialogService, - toastNotificationService, + toastNotificationService, elsaClientFactory, httpClientFactory, getOrCreateProperty: getOrCreateProperty, diff --git a/src/designer/elsa-workflows-studio/src/components/editors/elsa-expression-editor/elsa-expression-editor.tsx b/src/designer/elsa-workflows-studio/src/components/editors/elsa-expression-editor/elsa-expression-editor.tsx index b82586200..92be9b53c 100644 --- a/src/designer/elsa-workflows-studio/src/components/editors/elsa-expression-editor/elsa-expression-editor.tsx +++ b/src/designer/elsa-workflows-studio/src/components/editors/elsa-expression-editor/elsa-expression-editor.tsx @@ -1,5 +1,5 @@ import {Component, EventEmitter, h, Host, Method, Prop, State, Watch, Event} from '@stencil/core'; -import {createElsaClient} from "../../../services/elsa-client"; +import {createElsaClient} from "../../../services"; import Tunnel from '../../../data/workflow-editor'; import {MonacoValueChangedArgs} from "../../controls/elsa-monaco/elsa-monaco"; @@ -37,7 +37,7 @@ export class ElsaExpressionEditor { } async componentDidLoad() { - const elsaClient = createElsaClient(this.serverUrl); + const elsaClient = await createElsaClient(this.serverUrl); const libSource = await elsaClient.scriptingApi.getJavaScriptTypeDefinitions(this.workflowDefinitionId, this.context); const libUri = 'defaultLib:lib.es6.d.ts'; await this.monacoEditor.addJavaScriptLib(libSource, libUri); diff --git a/src/designer/elsa-workflows-studio/src/components/editors/properties/elsa-script-property/elsa-script-property.tsx b/src/designer/elsa-workflows-studio/src/components/editors/properties/elsa-script-property/elsa-script-property.tsx index e34977d1f..b80dd0556 100644 --- a/src/designer/elsa-workflows-studio/src/components/editors/properties/elsa-script-property/elsa-script-property.tsx +++ b/src/designer/elsa-workflows-studio/src/components/editors/properties/elsa-script-property/elsa-script-property.tsx @@ -1,6 +1,6 @@ import {Component, h, Prop, State} from '@stencil/core'; import {ActivityDefinitionProperty, ActivityPropertyDescriptor} from "../../../../models"; -import {createElsaClient} from "../../../../services/elsa-client"; +import {createElsaClient} from "../../../../services"; import Tunnel from '../../../../data/workflow-editor'; import {MonacoValueChangedArgs} from "../../../controls/elsa-monaco/elsa-monaco"; @@ -26,7 +26,7 @@ export class ElsaScriptProperty { } async componentDidLoad() { - const elsaClient = createElsaClient(this.serverUrl); + const elsaClient = await createElsaClient(this.serverUrl); const libSource = await elsaClient.scriptingApi.getJavaScriptTypeDefinitions(this.workflowDefinitionId, this.context); const libUri = 'defaultLib:lib.es6.d.ts'; await this.monacoEditor.addJavaScriptLib(libSource, libUri); diff --git a/src/designer/elsa-workflows-studio/src/components/screens/workflow-blueprint-viewer/elsa-workflow-blueprint-properties-panel/elsa-workflow-blueprint-properties-panel.tsx b/src/designer/elsa-workflows-studio/src/components/screens/workflow-blueprint-viewer/elsa-workflow-blueprint-properties-panel/elsa-workflow-blueprint-properties-panel.tsx index 2714e4b7a..d3d5ff1e5 100644 --- a/src/designer/elsa-workflows-studio/src/components/screens/workflow-blueprint-viewer/elsa-workflow-blueprint-properties-panel/elsa-workflow-blueprint-properties-panel.tsx +++ b/src/designer/elsa-workflows-studio/src/components/screens/workflow-blueprint-viewer/elsa-workflow-blueprint-properties-panel/elsa-workflow-blueprint-properties-panel.tsx @@ -125,7 +125,7 @@ export class ElsaWorkflowBlueprintPropertiesPanel { } async loadPublishedVersion() { - const elsaClient = this.createClient(); + const elsaClient = await this.createClient(); const {workflowBlueprint} = this; const publishedWorkflowDefinitions = await elsaClient.workflowDefinitionsApi.getMany([workflowBlueprint.id], {isPublished: true}); diff --git a/src/designer/elsa-workflows-studio/src/components/screens/workflow-blueprint-viewer/elsa-workflow-blueprint-side-panel/elsa-workflow-blueprint-side-panel.tsx b/src/designer/elsa-workflows-studio/src/components/screens/workflow-blueprint-viewer/elsa-workflow-blueprint-side-panel/elsa-workflow-blueprint-side-panel.tsx index 4075d34bd..4025fd93c 100644 --- a/src/designer/elsa-workflows-studio/src/components/screens/workflow-blueprint-viewer/elsa-workflow-blueprint-side-panel/elsa-workflow-blueprint-side-panel.tsx +++ b/src/designer/elsa-workflows-studio/src/components/screens/workflow-blueprint-viewer/elsa-workflow-blueprint-side-panel/elsa-workflow-blueprint-side-panel.tsx @@ -35,7 +35,7 @@ export class ElsaWorkflowBlueprintSidePanel { } async loadWorkflowBlueprint(workflowId = this.workflowId) { - const elsaClient = this.createClient(); + const elsaClient = await this.createClient(); this.workflowBlueprint = await elsaClient.workflowRegistryApi.get(workflowId, {isLatest: true}); } diff --git a/src/designer/elsa-workflows-studio/src/components/screens/workflow-blueprint-viewer/elsa-workflow-blueprint-viewer-screen/elsa-workflow-blueprint-viewer-screen.tsx b/src/designer/elsa-workflows-studio/src/components/screens/workflow-blueprint-viewer/elsa-workflow-blueprint-viewer-screen/elsa-workflow-blueprint-viewer-screen.tsx index 6c152e6b5..26af2860f 100644 --- a/src/designer/elsa-workflows-studio/src/components/screens/workflow-blueprint-viewer/elsa-workflow-blueprint-viewer-screen/elsa-workflow-blueprint-viewer-screen.tsx +++ b/src/designer/elsa-workflows-studio/src/components/screens/workflow-blueprint-viewer/elsa-workflow-blueprint-viewer-screen/elsa-workflow-blueprint-viewer-screen.tsx @@ -56,7 +56,7 @@ export class ElsaWorkflowBlueprintViewerScreen { propertyStorageProviders: {} }; - const client = createElsaClient(this.serverUrl); + const client = await createElsaClient(this.serverUrl); if (workflowDefinitionId && workflowDefinitionId.length > 0) { try { @@ -88,7 +88,7 @@ export class ElsaWorkflowBlueprintViewerScreen { } async loadActivityDescriptors() { - const client = createElsaClient(this.serverUrl); + const client = await createElsaClient(this.serverUrl); state.activityDescriptors = await client.activitiesApi.list(); } diff --git a/src/designer/elsa-workflows-studio/src/components/screens/workflow-definition-editor/elsa-workflow-definition-editor-screen/elsa-workflow-definition-editor-screen.tsx b/src/designer/elsa-workflows-studio/src/components/screens/workflow-definition-editor/elsa-workflow-definition-editor-screen/elsa-workflow-definition-editor-screen.tsx index f77a6848e..317ab198a 100644 --- a/src/designer/elsa-workflows-studio/src/components/screens/workflow-definition-editor/elsa-workflow-definition-editor-screen/elsa-workflow-definition-editor-screen.tsx +++ b/src/designer/elsa-workflows-studio/src/components/screens/workflow-definition-editor/elsa-workflow-definition-editor-screen/elsa-workflow-definition-editor-screen.tsx @@ -76,7 +76,7 @@ export class ElsaWorkflowDefinitionEditorScreen { @Method() async exportWorkflow() { - const client = createElsaClient(this.serverUrl); + const client = await createElsaClient(this.serverUrl); const workflowDefinition = this.workflowDefinition; const versionOptions: VersionOptions = {version: workflowDefinition.version}; const response = await client.workflowDefinitionsApi.export(workflowDefinition.definitionId, versionOptions); @@ -85,7 +85,7 @@ export class ElsaWorkflowDefinitionEditorScreen { @Method() async importWorkflow(file: File) { - const client = createElsaClient(this.serverUrl); + const client = await createElsaClient(this.serverUrl); this.importing = true; this.imported = false; @@ -99,7 +99,7 @@ export class ElsaWorkflowDefinitionEditorScreen { this.importing = false; this.imported = true; setTimeout(() => this.imported = false, 500); - eventBus.emit(EventTypes.WorkflowImported, this, this.workflowDefinition); + await eventBus.emit(EventTypes.WorkflowImported, this, this.workflowDefinition); } catch (e) { console.error(e); this.importing = false; @@ -114,7 +114,7 @@ export class ElsaWorkflowDefinitionEditorScreen { const workflowDefinitionId = newValue; let workflowDefinition: WorkflowDefinition = ElsaWorkflowDefinitionEditorScreen.createWorkflowDefinition(); workflowDefinition.definitionId = workflowDefinitionId; - const client = createElsaClient(this.serverUrl); + const client = await createElsaClient(this.serverUrl); if (workflowDefinitionId && workflowDefinitionId.length > 0) { try { @@ -171,12 +171,12 @@ export class ElsaWorkflowDefinitionEditorScreen { t = (key: string) => this.i18next.t(key); async loadActivityDescriptors() { - const client = createElsaClient(this.serverUrl); + const client = await createElsaClient(this.serverUrl); state.activityDescriptors = await client.activitiesApi.list(); } async loadWorkflowStorageDescriptors() { - const client = createElsaClient(this.serverUrl); + const client = await createElsaClient(this.serverUrl); state.workflowStorageDescriptors = await client.workflowStorageProvidersApi.list(); } @@ -189,14 +189,14 @@ export class ElsaWorkflowDefinitionEditorScreen { this.publishing = true; await this.saveWorkflow(true); this.publishing = false; - eventBus.emit(EventTypes.WorkflowPublished, this, this.workflowDefinition); + await eventBus.emit(EventTypes.WorkflowPublished, this, this.workflowDefinition); } async unPublishWorkflow() { this.unPublishing = true; await this.unpublishWorkflow(); this.unPublishing = false; - eventBus.emit(EventTypes.WorkflowRetracted, this, this.workflowDefinition); + await eventBus.emit(EventTypes.WorkflowRetracted, this, this.workflowDefinition); } async saveWorkflow(publish?: boolean) { @@ -209,7 +209,7 @@ export class ElsaWorkflowDefinitionEditorScreen { workflowModel = workflowModel || this.workflowModel; - const client = createElsaClient(this.serverUrl); + const client = await createElsaClient(this.serverUrl); let workflowDefinition = this.workflowDefinition; const isNew = typeof workflowDefinition.definitionId === 'undefined' && typeof this.workflowDefinitionId === 'undefined'; @@ -273,7 +273,7 @@ export class ElsaWorkflowDefinitionEditorScreen { } async unpublishWorkflow() { - const client = createElsaClient(this.serverUrl); + const client = await createElsaClient(this.serverUrl); const workflowDefinitionId = this.workflowDefinition.definitionId; this.unPublishing = true; @@ -336,8 +336,8 @@ export class ElsaWorkflowDefinitionEditorScreen { this.connectionContextMenuState = state; } - onShowWorkflowSettingsClick() { - eventBus.emit(EventTypes.ShowWorkflowSettings); + async onShowWorkflowSettingsClick() { + await eventBus.emit(EventTypes.ShowWorkflowSettings); } async onPublishClicked() { @@ -360,7 +360,7 @@ export class ElsaWorkflowDefinitionEditorScreen { e.preventDefault(); await this.designer.removeActivity(this.activityContextMenuState.activity); this.handleContextMenuChange({x: 0, y: 0, shown: false, activity: null}); - eventBus.emit(EventTypes.HideModalDialog); + await eventBus.emit(EventTypes.HideModalDialog); } async onEditActivityClick(e: Event) { @@ -372,7 +372,7 @@ export class ElsaWorkflowDefinitionEditorScreen { async onPasteActivityClick(e: Event) { e.preventDefault(); let activityModel = this.connectionContextMenuState.activity; - eventBus.emit(EventTypes.PasteActivity, this, activityModel); + await eventBus.emit(EventTypes.PasteActivity, this, activityModel); this.handleConnectionContextMenuChange({x: 0, y: 0, shown: false, activity: null}); } diff --git a/src/designer/elsa-workflows-studio/src/components/screens/workflow-definition-editor/elsa-workflow-properties-panel/elsa-workflow-properties-panel.tsx b/src/designer/elsa-workflows-studio/src/components/screens/workflow-definition-editor/elsa-workflow-properties-panel/elsa-workflow-properties-panel.tsx index fe8efe1b0..8f0975344 100644 --- a/src/designer/elsa-workflows-studio/src/components/screens/workflow-definition-editor/elsa-workflow-properties-panel/elsa-workflow-properties-panel.tsx +++ b/src/designer/elsa-workflows-studio/src/components/screens/workflow-definition-editor/elsa-workflow-properties-panel/elsa-workflow-properties-panel.tsx @@ -77,7 +77,7 @@ export class ElsaWorkflowPropertiesPanel { } async loadPublishedVersion() { - const elsaClient = this.createClient(); + const elsaClient = await this.createClient(); const {workflowDefinition} = this; const publishedWorkflowDefinitions = await elsaClient.workflowDefinitionsApi.getMany([workflowDefinition.definitionId], {isPublished: true}); diff --git a/src/designer/elsa-workflows-studio/src/components/screens/workflow-definition-editor/elsa-workflow-settings-modal/elsa-workflow-settings-modal.tsx b/src/designer/elsa-workflows-studio/src/components/screens/workflow-definition-editor/elsa-workflow-settings-modal/elsa-workflow-settings-modal.tsx index aa3a04a58..4db5ab455 100644 --- a/src/designer/elsa-workflows-studio/src/components/screens/workflow-definition-editor/elsa-workflow-settings-modal/elsa-workflow-settings-modal.tsx +++ b/src/designer/elsa-workflows-studio/src/components/screens/workflow-definition-editor/elsa-workflow-settings-modal/elsa-workflow-settings-modal.tsx @@ -44,7 +44,7 @@ export class ElsaWorkflowDefinitionSettingsModal { async componentWillLoad() { this.handleWorkflowDefinitionChanged(this.workflowDefinition); - const client = createElsaClient(this.serverUrl); + const client = await createElsaClient(this.serverUrl); this.workflowChannels = await client.workflowChannelsApi.list(); } diff --git a/src/designer/elsa-workflows-studio/src/components/screens/workflow-definition-list/elsa-workflow-definitions-screen/elsa-workflow-definitions-list-screen.tsx b/src/designer/elsa-workflows-studio/src/components/screens/workflow-definition-list/elsa-workflow-definitions-screen/elsa-workflow-definitions-list-screen.tsx index 458c5df4b..771785b42 100644 --- a/src/designer/elsa-workflows-studio/src/components/screens/workflow-definition-list/elsa-workflow-definitions-screen/elsa-workflow-definitions-list-screen.tsx +++ b/src/designer/elsa-workflows-studio/src/components/screens/workflow-definition-list/elsa-workflow-definitions-screen/elsa-workflow-definitions-list-screen.tsx @@ -35,13 +35,13 @@ export class ElsaWorkflowDefinitionsListScreen { if (!result) return; - const elsaClient = this.createClient(); + const elsaClient = await this.createClient(); await elsaClient.workflowDefinitionsApi.delete(workflowDefinition.definitionId); await this.loadWorkflowDefinitions(); } async loadWorkflowDefinitions() { - const elsaClient = this.createClient(); + const elsaClient = await this.createClient(); const page = 0; const pageSize = 50; const latestVersionOptions: VersionOptions = {isLatest: true}; @@ -153,4 +153,4 @@ export class ElsaWorkflowDefinitionsListScreen { } } -Tunnel.injectProps(ElsaWorkflowDefinitionsListScreen, ['serverUrl', 'culture', 'basePath']); \ No newline at end of file +Tunnel.injectProps(ElsaWorkflowDefinitionsListScreen, ['serverUrl', 'culture', 'basePath']); diff --git a/src/designer/elsa-workflows-studio/src/components/screens/workflow-instance-list/elsa-workflow-instance-list-screen/elsa-workflow-instance-list-screen.tsx b/src/designer/elsa-workflows-studio/src/components/screens/workflow-instance-list/elsa-workflow-instance-list-screen/elsa-workflow-instance-list-screen.tsx index 87e6b619a..0831e6eaa 100644 --- a/src/designer/elsa-workflows-studio/src/components/screens/workflow-instance-list/elsa-workflow-instance-list-screen/elsa-workflow-instance-list-screen.tsx +++ b/src/designer/elsa-workflows-studio/src/components/screens/workflow-instance-list/elsa-workflow-instance-list-screen/elsa-workflow-instance-list-screen.tsx @@ -51,7 +51,7 @@ export class ElsaWorkflowInstanceListScreen { @State() currentSearchTerm?: string; i18next: i18n; - + async componentWillLoad() { this.i18next = await loadTranslations(this.culture, resources); @@ -73,7 +73,7 @@ export class ElsaWorkflowInstanceListScreen { name: 'Delete', }]; - eventBus.emit(EventTypes.WorkflowInstanceBulkActionsLoading, this, {sender: this, bulkActions}); + await eventBus.emit(EventTypes.WorkflowInstanceBulkActionsLoading, this, {sender: this, bulkActions}); this.bulkActions = bulkActions; } @@ -104,8 +104,8 @@ export class ElsaWorkflowInstanceListScreen { @Watch("currentPageSize") async handlePageSizeChanged(value: number) { this.currentPageSize = value; - this.currentPageSize = isNaN(this.currentPageSize) ? ElsaWorkflowInstanceListScreen.DEFAULT_PAGE_SIZE : this.currentPageSize; - this.currentPageSize = Math.max(Math.min(this.currentPageSize, ElsaWorkflowInstanceListScreen.MAX_PAGE_SIZE), ElsaWorkflowInstanceListScreen.MIN_PAGE_SIZE); + this.currentPageSize = isNaN(this.currentPageSize) ? ElsaWorkflowInstanceListScreen.DEFAULT_PAGE_SIZE : this.currentPageSize; + this.currentPageSize = Math.max(Math.min(this.currentPageSize, ElsaWorkflowInstanceListScreen.MAX_PAGE_SIZE), ElsaWorkflowInstanceListScreen.MIN_PAGE_SIZE); await this.loadWorkflowInstances(); } @@ -124,30 +124,30 @@ export class ElsaWorkflowInstanceListScreen { this.selectedWorkflowStatus = query.status; this.selectedOrderByState = query.orderBy ?? OrderBy.Started; this.currentPage = !!query.page ? parseInt(query.page) : 0; - this.currentPage = isNaN(this.currentPage) ? ElsaWorkflowInstanceListScreen.START_PAGE : this.currentPage; + this.currentPage = isNaN(this.currentPage) ? ElsaWorkflowInstanceListScreen.START_PAGE : this.currentPage; this.currentPageSize = !!query.pageSize ? parseInt(query.pageSize) : ElsaWorkflowInstanceListScreen.DEFAULT_PAGE_SIZE; - this.currentPageSize = isNaN(this.currentPageSize) ? ElsaWorkflowInstanceListScreen.DEFAULT_PAGE_SIZE : this.currentPageSize; - this.currentPageSize = Math.max(Math.min(this.currentPageSize, ElsaWorkflowInstanceListScreen.MAX_PAGE_SIZE), ElsaWorkflowInstanceListScreen.MIN_PAGE_SIZE); + this.currentPageSize = isNaN(this.currentPageSize) ? ElsaWorkflowInstanceListScreen.DEFAULT_PAGE_SIZE : this.currentPageSize; + this.currentPageSize = Math.max(Math.min(this.currentPageSize, ElsaWorkflowInstanceListScreen.MAX_PAGE_SIZE), ElsaWorkflowInstanceListScreen.MIN_PAGE_SIZE); } async loadWorkflowBlueprints() { - const elsaClient = this.createClient(); + const elsaClient = await this.createClient(); const versionOptions: VersionOptions = {allVersions: true}; const workflowBlueprintPagedList = await elsaClient.workflowRegistryApi.list(null, null, versionOptions); this.workflowBlueprints = workflowBlueprintPagedList.items; } async loadWorkflowInstances() { - this.currentPage = isNaN(this.currentPage) ? ElsaWorkflowInstanceListScreen.START_PAGE : this.currentPage; - this.currentPage = Math.max(this.currentPage, ElsaWorkflowInstanceListScreen.START_PAGE); - this.currentPageSize = isNaN(this.currentPageSize) ? ElsaWorkflowInstanceListScreen.DEFAULT_PAGE_SIZE : this.currentPageSize; - const elsaClient = this.createClient(); + this.currentPage = isNaN(this.currentPage) ? ElsaWorkflowInstanceListScreen.START_PAGE : this.currentPage; + this.currentPage = Math.max(this.currentPage, ElsaWorkflowInstanceListScreen.START_PAGE); + this.currentPageSize = isNaN(this.currentPageSize) ? ElsaWorkflowInstanceListScreen.DEFAULT_PAGE_SIZE : this.currentPageSize; + const elsaClient = await this.createClient(); this.workflowInstances = await elsaClient.workflowInstancesApi.list(this.currentPage, this.currentPageSize, this.selectedWorkflowId, this.selectedWorkflowStatus, this.selectedOrderByState, this.currentSearchTerm); - const maxPage = Math.floor(this.workflowInstances.totalCount / this.currentPageSize); - if (this.currentPage > maxPage) { + const maxPage = Math.floor(this.workflowInstances.totalCount / this.currentPageSize); + if (this.currentPage > maxPage) { this.currentPage = maxPage; this.workflowInstances = await elsaClient.workflowInstancesApi.list(this.currentPage, this.currentPageSize, this.selectedWorkflowId, this.selectedWorkflowStatus, this.selectedOrderByState, this.currentSearchTerm); - } + } } createClient() { @@ -175,11 +175,11 @@ export class ElsaWorkflowInstanceListScreen { filters['page'] = this.currentPage.toString(); var newPageSize = !!pageSize ? pageSize : this.currentPageSize; - newPageSize = Math.max(Math.min(newPageSize, 100), ElsaWorkflowInstanceListScreen.MIN_PAGE_SIZE); + newPageSize = Math.max(Math.min(newPageSize, 100), ElsaWorkflowInstanceListScreen.MIN_PAGE_SIZE); filters['pageSize'] = newPageSize.toString(); - + if (newPageSize != this.currentPageSize) - filters['page'] = Math.floor(this.currentPage * this.currentPageSize / newPageSize).toString(); + filters['page'] = Math.floor(this.currentPage * this.currentPageSize / newPageSize).toString(); const queryString = collection.map(filters, (v, k) => `${k}=${v}`).join('&'); return `/workflow-instances?${queryString}`; @@ -251,7 +251,7 @@ export class ElsaWorkflowInstanceListScreen { if (!result) return; - const elsaClient = this.createClient(); + const elsaClient = await this.createClient(); await elsaClient.workflowInstancesApi.cancel(workflowInstance.id); await this.loadWorkflowInstances(); } @@ -263,7 +263,7 @@ export class ElsaWorkflowInstanceListScreen { if (!result) return; - const elsaClient = this.createClient(); + const elsaClient = await this.createClient(); await elsaClient.workflowInstancesApi.delete(workflowInstance.id); await this.loadWorkflowInstances(); } @@ -275,7 +275,7 @@ export class ElsaWorkflowInstanceListScreen { if (!result) return; - const elsaClient = this.createClient(); + const elsaClient = await this.createClient(); await elsaClient.workflowInstancesApi.bulkCancel({workflowInstanceIds: this.selectedWorkflowInstanceIds}); this.selectedWorkflowInstanceIds = []; await this.loadWorkflowInstances(); @@ -289,7 +289,7 @@ export class ElsaWorkflowInstanceListScreen { if (!result) return; - const elsaClient = this.createClient(); + const elsaClient = await this.createClient(); await elsaClient.workflowInstancesApi.bulkDelete({workflowInstanceIds: this.selectedWorkflowInstanceIds}); this.selectedWorkflowInstanceIds = []; await this.loadWorkflowInstances(); @@ -351,7 +351,8 @@ export class ElsaWorkflowInstanceListScreen { - + ); }; @@ -657,7 +658,7 @@ export class ElsaWorkflowInstanceListScreen { const history = this.history; const items: Array = pageSizes.map(x => { - const text = ""+x; + const text = "" + x; const item: DropdownButtonItem = {text: text, isSelected: x == currentPageSize, value: x}; if (!!history) @@ -667,12 +668,15 @@ export class ElsaWorkflowInstanceListScreen { }); const renderIcon = function () { - return + return }; - return this.handlePageSizeChanged(e.detail.value)}/> + return this.handlePageSizeChanged(e.detail.value)}/> } renderOrderByFilter() { diff --git a/src/designer/elsa-workflows-studio/src/components/screens/workflow-instance-viewer/elsa-workflow-instance-journal/elsa-workflow-instance-journal.tsx b/src/designer/elsa-workflows-studio/src/components/screens/workflow-instance-viewer/elsa-workflow-instance-journal/elsa-workflow-instance-journal.tsx index ec28e8539..82ead214b 100644 --- a/src/designer/elsa-workflows-studio/src/components/screens/workflow-instance-viewer/elsa-workflow-instance-journal/elsa-workflow-instance-journal.tsx +++ b/src/designer/elsa-workflows-studio/src/components/screens/workflow-instance-viewer/elsa-workflow-instance-journal/elsa-workflow-instance-journal.tsx @@ -52,7 +52,7 @@ export class ElsaWorkflowInstanceJournal { @Watch('workflowInstanceId') async workflowInstanceIdChangedHandler(newValue: string) { const workflowInstanceId = newValue; - const client = createElsaClient(this.serverUrl); + const client = await createElsaClient(this.serverUrl); if (workflowInstanceId && workflowInstanceId.length > 0) { try { diff --git a/src/designer/elsa-workflows-studio/src/components/screens/workflow-instance-viewer/elsa-workflow-instance-viewer-screen/elsa-workflow-instance-viewer-screen.tsx b/src/designer/elsa-workflows-studio/src/components/screens/workflow-instance-viewer/elsa-workflow-instance-viewer-screen/elsa-workflow-instance-viewer-screen.tsx index ce4f7733e..39ec97cd8 100644 --- a/src/designer/elsa-workflows-studio/src/components/screens/workflow-instance-viewer/elsa-workflow-instance-viewer-screen/elsa-workflow-instance-viewer-screen.tsx +++ b/src/designer/elsa-workflows-studio/src/components/screens/workflow-instance-viewer/elsa-workflow-instance-viewer-screen/elsa-workflow-instance-viewer-screen.tsx @@ -93,7 +93,7 @@ export class ElsaWorkflowInstanceViewerScreen { propertyStorageProviders: {} }; - const client = createElsaClient(this.serverUrl); + const client = await createElsaClient(this.serverUrl); if (workflowInstanceId && workflowInstanceId.length > 0) { try { @@ -126,7 +126,7 @@ export class ElsaWorkflowInstanceViewerScreen { } async loadActivityDescriptors() { - const client = createElsaClient(this.serverUrl); + const client = await createElsaClient(this.serverUrl); state.activityDescriptors = await client.activitiesApi.list(); } @@ -223,7 +223,7 @@ export class ElsaWorkflowInstanceViewerScreen { return; } - const elsaClient = createElsaClient(this.serverUrl); + const elsaClient = await createElsaClient(this.serverUrl); this.activityStats = await elsaClient.activityStatsApi.get(this.workflowInstanceId, e.detail.activity.activityId); } diff --git a/src/designer/elsa-workflows-studio/src/components/screens/workflow-registry-list/elsa-workflow-registry-list-screen/elsa-workflow-registry-list-screen.tsx b/src/designer/elsa-workflows-studio/src/components/screens/workflow-registry-list/elsa-workflow-registry-list-screen/elsa-workflow-registry-list-screen.tsx index d0879a957..1ebf72e57 100644 --- a/src/designer/elsa-workflows-studio/src/components/screens/workflow-registry-list/elsa-workflow-registry-list-screen/elsa-workflow-registry-list-screen.tsx +++ b/src/designer/elsa-workflows-studio/src/components/screens/workflow-registry-list/elsa-workflow-registry-list-screen/elsa-workflow-registry-list-screen.tsx @@ -31,7 +31,7 @@ export class ElsaWorkflowRegistryListScreen { async componentWillLoad() { await this.loadWorkflowBlueprints(); - eventBus.emit(EventTypes.WorkflowRegistryLoadingColumns, this, this.workflowRegistryColumns); + await eventBus.emit(EventTypes.WorkflowRegistryLoadingColumns, this, this.workflowRegistryColumns); } connectedCallback() { @@ -66,7 +66,7 @@ export class ElsaWorkflowRegistryListScreen { const workflowRegistryUpdating: ConfigureWorkflowRegistryUpdatingContext = { params: [workflowBlueprintId, key, value] }; - eventBus.emit(EventTypes.WorkflowRegistryUpdating, this, workflowRegistryUpdating); + await eventBus.emit(EventTypes.WorkflowRegistryUpdating, this, workflowRegistryUpdating); } async onLoadWorkflowBlueprints() { @@ -74,7 +74,7 @@ export class ElsaWorkflowRegistryListScreen { } async loadWorkflowBlueprints() { - const elsaClient = this.createClient(); + const elsaClient = await this.createClient(); const page = 0; const pageSize = 50; const versionOptions: VersionOptions = {allVersions: true}; diff --git a/src/designer/elsa-workflows-studio/src/models/services.ts b/src/designer/elsa-workflows-studio/src/models/services.ts index 3fcbcbde1..c3c1ddc37 100644 --- a/src/designer/elsa-workflows-studio/src/models/services.ts +++ b/src/designer/elsa-workflows-studio/src/models/services.ts @@ -1,6 +1,6 @@ import {PluginManager, ActivityIconProvider, ConfirmDialogService, PropertyDisplayManager} from "../services"; import {ElsaClient, ToastNotificationService} from "../services"; -import EventBus from "js-event-bus"; +import EventBus from "../services/custom-event-bus"; import {AxiosInstance} from "axios"; import {ActivityDefinitionProperty} from "./domain"; import {ActivityModel} from "./view"; @@ -11,12 +11,12 @@ export interface ElsaStudio { featuresString: string; pluginManager: PluginManager; propertyDisplayManager: PropertyDisplayManager; - elsaClientFactory: () => ElsaClient; - httpClientFactory: () => AxiosInstance; + elsaClientFactory: () => Promise; + httpClientFactory: () => Promise; eventBus: EventBus; activityIconProvider: ActivityIconProvider; confirmDialogService: ConfirmDialogService; toastNotificationService: ToastNotificationService; getOrCreateProperty: (activity: ActivityModel, name: string, defaultExpression?: () => string, defaultSyntax?: () => string) => ActivityDefinitionProperty; htmlToElement: (html: string) => Element; -} \ No newline at end of file +} diff --git a/src/designer/elsa-workflows-studio/src/modules/elsa-workflows-settings/plugins/workflow-settings-plugin.tsx b/src/designer/elsa-workflows-studio/src/modules/elsa-workflows-settings/plugins/workflow-settings-plugin.tsx index feb23af2a..dde607e80 100644 --- a/src/designer/elsa-workflows-studio/src/modules/elsa-workflows-settings/plugins/workflow-settings-plugin.tsx +++ b/src/designer/elsa-workflows-studio/src/modules/elsa-workflows-settings/plugins/workflow-settings-plugin.tsx @@ -1,6 +1,6 @@ import {h} from '@stencil/core'; import {createElsaWorkflowSettingsClient, SaveWorkflowSettingsRequest} from "../services/elsa-client"; -import {eventBus, ElsaPlugin, ElsaClient} from "../../../services"; +import {eventBus, ElsaPlugin} from "../../../services"; import { EventTypes, ConfigureWorkflowRegistryColumnsContext, @@ -10,11 +10,9 @@ import { export class WorkflowSettingsPlugin implements ElsaPlugin { serverUrl: string; - elsaClient: ElsaClient; constructor(elsaStudio: ElsaStudio) { this.serverUrl = elsaStudio.serverUrl; - this.elsaClient = elsaStudio.elsaClientFactory(); eventBus.on(EventTypes.WorkflowRegistryLoadingColumns, this.onLoadingColumns); eventBus.on(EventTypes.WorkflowRegistryUpdating, this.onUpdating); @@ -29,7 +27,7 @@ export class WorkflowSettingsPlugin implements ElsaPlugin { async onUpdating(context: ConfigureWorkflowRegistryUpdatingContext) { - const elsaClient = createElsaWorkflowSettingsClient(this.serverUrl); + const elsaClient = await createElsaWorkflowSettingsClient(this.serverUrl); const workflowSettings = await elsaClient.workflowSettingsApi.list(); const workflowBlueprintSettings = workflowSettings.find(x => x.workflowBlueprintId == context.params[0] && x.key == context.params[1]); @@ -43,6 +41,6 @@ export class WorkflowSettingsPlugin implements ElsaPlugin { }; await elsaClient.workflowSettingsApi.save(request); - eventBus.emit(EventTypes.WorkflowRegistryUpdated, this); + await eventBus.emit(EventTypes.WorkflowRegistryUpdated, this); } } diff --git a/src/designer/elsa-workflows-studio/src/modules/elsa-workflows-settings/services/elsa-client.ts b/src/designer/elsa-workflows-studio/src/modules/elsa-workflows-settings/services/elsa-client.ts index 6aebfe880..53c4dfdd9 100644 --- a/src/designer/elsa-workflows-studio/src/modules/elsa-workflows-settings/services/elsa-client.ts +++ b/src/designer/elsa-workflows-studio/src/modules/elsa-workflows-settings/services/elsa-client.ts @@ -24,37 +24,37 @@ export const createHttpClient = function(baseAddress: string) : AxiosInstance const service = new Service(httpClient); eventBus.emit(EventTypes.HttpClientCreated, this, {service, httpClient}); - + return _httpClient = httpClient; } -export const createElsaWorkflowSettingsClient = function (serverUrl: string): ElsaWorkflowSettingsClient { +export const createElsaWorkflowSettingsClient = async function (serverUrl: string): Promise { if (!!_elsaWorkflowSettingsClient) return _elsaWorkflowSettingsClient; - const httpClient: AxiosInstance = createHttpClient(serverUrl); + const httpClient: AxiosInstance = await createHttpClient(serverUrl); _elsaWorkflowSettingsClient = { workflowSettingsApi: { list: async () => { const response = await httpClient.get>(`v1/workflow-settings`); return response.data; - }, + }, save: async request => { const response = await httpClient.post('v1/workflow-settings', request); return response.data; }, delete: async id => { await httpClient.delete(`v1/workflow-settings/${id}`); - }, - } + }, + } } return _elsaWorkflowSettingsClient; } -export interface ElsaWorkflowSettingsClient { +export interface ElsaWorkflowSettingsClient { workflowSettingsApi: WorkflowSettingsApi; } @@ -72,4 +72,4 @@ export interface SaveWorkflowSettingsRequest { workflowBlueprintId?: string; key?: string; value?: string; -} \ No newline at end of file +} diff --git a/src/designer/elsa-workflows-studio/src/services/elsa-client.ts b/src/designer/elsa-workflows-studio/src/services/elsa-client.ts index 8f24910a8..81cf64520 100644 --- a/src/designer/elsa-workflows-studio/src/services/elsa-client.ts +++ b/src/designer/elsa-workflows-studio/src/services/elsa-client.ts @@ -29,7 +29,7 @@ import { let _httpClient: AxiosInstance = null; let _elsaClient: ElsaClient = null; -export const createHttpClient = function (baseAddress: string): AxiosInstance { +export const createHttpClient = async function (baseAddress: string): Promise { if (!!_httpClient) return _httpClient; @@ -37,22 +37,22 @@ export const createHttpClient = function (baseAddress: string): AxiosInstance { baseURL: baseAddress }; - eventBus.emit(EventTypes.HttpClientConfigCreated, this, {config}); + await eventBus.emit(EventTypes.HttpClientConfigCreated, this, {config}); const httpClient = axios.create(config); const service = new Service(httpClient); - eventBus.emit(EventTypes.HttpClientCreated, this, {service, httpClient}); + await eventBus.emit(EventTypes.HttpClientCreated, this, {service, httpClient}); return _httpClient = httpClient; } -export const createElsaClient = function (serverUrl: string): ElsaClient { +export const createElsaClient = async function (serverUrl: string): Promise { if (!!_elsaClient) return _elsaClient; - const httpClient: AxiosInstance = createHttpClient(serverUrl); + const httpClient: AxiosInstance = await createHttpClient(serverUrl); _elsaClient = { activitiesApi: { diff --git a/src/designer/elsa-workflows-studio/src/utils/select-list-items.ts b/src/designer/elsa-workflows-studio/src/utils/select-list-items.ts index 7b5800301..4ac829329 100644 --- a/src/designer/elsa-workflows-studio/src/utils/select-list-items.ts +++ b/src/designer/elsa-workflows-studio/src/utils/select-list-items.ts @@ -1,8 +1,8 @@ import {ActivityPropertyDescriptor, RuntimeSelectListItemsProviderSettings, SelectListItem} from "../models"; -import {createElsaClient, ElsaClient} from "../services/elsa-client"; +import {createElsaClient, ElsaClient} from "../services"; async function fetchRuntimeItems(serverUrl: string, options: RuntimeSelectListItemsProviderSettings): Promise> { - const elsaClient = createElsaClient(serverUrl); + const elsaClient = await createElsaClient(serverUrl); return await elsaClient.designerApi.runtimeSelectItemsApi.get(options.runtimeSelectListItemsProviderType, options.context || {}); } @@ -17,4 +17,4 @@ export async function getSelectListItems(serverUrl: string, propertyDescriptor: } return items || []; -} \ No newline at end of file +}