From a4103f44e5c394e57d7c015acd10c170190e66cd Mon Sep 17 00:00:00 2001 From: axeleron007 Date: Thu, 16 Sep 2021 18:56:24 +0300 Subject: [PATCH] Test Panel functionality fixed. --- .../elsa-workflows-studio/src/components.d.ts | 3 +- ...elsa-workflow-definition-editor-screen.tsx | 9 +-- .../elsa-workflow-test-panel.tsx | 71 +++++++------------ 3 files changed, 30 insertions(+), 53 deletions(-) diff --git a/src/designer/elsa-workflows-studio/src/components.d.ts b/src/designer/elsa-workflows-studio/src/components.d.ts index 09480ddb1..0477b3163 100644 --- a/src/designer/elsa-workflows-studio/src/components.d.ts +++ b/src/designer/elsa-workflows-studio/src/components.d.ts @@ -329,9 +329,9 @@ export namespace Components { } interface ElsaWorkflowTestPanel { "culture": string; - "selectTestActivity": (activityId?: string) => Promise; "serverUrl": string; "workflowDefinition": WorkflowDefinition; + "workflowTestActivityId": string; } } declare global { @@ -1048,6 +1048,7 @@ declare namespace LocalJSX { "culture"?: string; "serverUrl"?: string; "workflowDefinition"?: WorkflowDefinition; + "workflowTestActivityId"?: string; } interface IntrinsicElements { "elsa-activity-editor-modal": ElsaActivityEditorModal; 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 cda184df0..fd7ff7e05 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 @@ -64,8 +64,6 @@ export class ElsaWorkflowDefinitionEditorScreen { i18next: i18n; el: HTMLElement; designer: HTMLElsaDesignerTreeElement; - testPanel: HTMLElsaWorkflowTestPanelElement; - flyoutPanel: HTMLElsaFlyoutPanelElement; @Method() async getServerUrl(): Promise { @@ -385,13 +383,11 @@ export class ElsaWorkflowDefinitionEditorScreen { async onActivitySelected(e: CustomEvent) { this.selectedActivityId = e.detail.activityId; - await this.testPanel.selectTestActivity(this.selectedActivityId); } async onActivityDeselected(e: CustomEvent) { if (this.selectedActivityId == e.detail.activityId) this.selectedActivityId = null; - await this.testPanel.selectTestActivity(null); } onConnectionContextMenuButtonClicked(e: CustomEvent) { @@ -625,7 +621,7 @@ export class ElsaWorkflowDefinitionEditorScreen { private renderPanel() { return ( - this.flyoutPanel = el}> + General Test - this.testPanel = el} + diff --git a/src/designer/elsa-workflows-studio/src/components/screens/workflow-definition-editor/elsa-workflow-test-panel/elsa-workflow-test-panel.tsx b/src/designer/elsa-workflows-studio/src/components/screens/workflow-definition-editor/elsa-workflow-test-panel/elsa-workflow-test-panel.tsx index b9d5bca67..3acd3d243 100644 --- a/src/designer/elsa-workflows-studio/src/components/screens/workflow-definition-editor/elsa-workflow-test-panel/elsa-workflow-test-panel.tsx +++ b/src/designer/elsa-workflows-studio/src/components/screens/workflow-definition-editor/elsa-workflow-test-panel/elsa-workflow-test-panel.tsx @@ -22,35 +22,29 @@ interface Tab { export class ElsaWorkflowTestPanel { @Prop() workflowDefinition: WorkflowDefinition; + @Prop() workflowTestActivityId: string; @Prop() culture: string; @Prop() serverUrl: string; - @State() publishedVersion: number; @State() hubConnection: HubConnection; @State() workflowTestActivityMessages: Array = []; i18next: i18n; - signalRConnectionId: string; - el: HTMLElement; - tabs: Array = []; - testActivity: WorkflowTestActivityMessage; - - @Method() - async selectTestActivity(activityId?: string) { - const message = this.workflowTestActivityMessages.find(x => x.activityId == activityId) - const messageInternal = !!message ? message : null; - this.selectTestActivityMessageInternal(messageInternal); - this.render(); - } + signalRConnectionId: string; + message: WorkflowTestActivityMessage; @Watch('workflowDefinition') async workflowDefinitionChangedHandler(newWorkflow: WorkflowDefinition, oldWorkflow: WorkflowDefinition) { - if (newWorkflow.version !== oldWorkflow.version || newWorkflow.isPublished !== oldWorkflow.isPublished || newWorkflow.isLatest !== oldWorkflow.isLatest) - await this.loadPublishedVersion(); } + @Watch('workflowTestActivityId') + async workflowTestActivityMessageChangedHandler(newMessage: string, oldMessage: string) { + const message = this.workflowTestActivityMessages.find(x => x.activityId == newMessage); + debugger; + this.message = !!message ? message : null; + } + async componentWillLoad() { this.i18next = await loadTranslations(this.culture, resources); - await this.loadPublishedVersion(); this.connectMessageHub(); } @@ -76,6 +70,7 @@ export class ElsaWorkflowTestPanel { } async onExecuteWorkflowClick() { + this.message = null; this.workflowTestActivityMessages = []; eventBus.emit(EventTypes.TestActivityMessageReceived, this, null); const elsaClient = this.createClient(); @@ -90,19 +85,15 @@ export class ElsaWorkflowTestPanel { } async onUseAsSchemaClick() { - const value = this.testActivity.data["Inbound Request"]; + const value = this.message.data["Inbound Request"]; const request: WorkflowTestUpdateRequest = { - activityId: this.testActivity.activityId, + activityId: this.message.activityId, jsonSchema: JSON.stringify(convert(value), null, 4) }; eventBus.emit(EventTypes.ActivityJsonSchemaUpdated, this, request); } - selectTestActivityMessageInternal(message?: WorkflowTestActivityMessage) { - this.testActivity = message; - } - render() { const t = (x, params?) => this.i18next.t(x, params); @@ -121,10 +112,10 @@ export class ElsaWorkflowTestPanel { renderActivityTestMessage() { -debugger - const {testActivity} = this; - if (testActivity == undefined) + const {message} = this; + + if (message == undefined || !message) return const t = (x, params?) => this.i18next.t(x, params); @@ -132,14 +123,14 @@ debugger const wellKnownDataKeys = {State: true, Input: null, Outcomes: true, Exception: true}; let dataKey = null; - for (const key in testActivity.data) { - if (!testActivity.data.hasOwnProperty(key)) + for (const key in message.data) { + if (!message.data.hasOwnProperty(key)) continue; if (!!wellKnownDataKeys[key]) continue; - const value = testActivity.data[key]; + const value = message.data[key]; if (!value && value != 0) continue; @@ -165,11 +156,11 @@ debugger
{'Correlation Id'}
-
{testActivity.correlationId}
+
{message.correlationId}
{t('Status')}
-
{testActivity.status}
+
{message.status}
{collection.map(filteredData, (v, k) => (
@@ -195,20 +186,20 @@ debugger renderActivityTestError() { - const {testActivity} = this; + const {message} = this; - if (testActivity == undefined) + if (message == undefined || !message) return const t = (x, params?) => this.i18next.t(x, params); - if (!testActivity.error) + if (!message.error) return; return (
{t('Error')}
-
{testActivity.error}
+
{message.error}
); } @@ -216,18 +207,6 @@ debugger createClient() { return createElsaClient(this.serverUrl); } - - async loadPublishedVersion() { - const elsaClient = this.createClient(); - const {workflowDefinition} = this; - - const publishedWorkflowDefinitions = await elsaClient.workflowDefinitionsApi.getMany([workflowDefinition.definitionId], {isPublished: true}); - const publishedDefinition: WorkflowDefinitionSummary = workflowDefinition.isPublished ? workflowDefinition : publishedWorkflowDefinitions.find(x => x.definitionId == workflowDefinition.definitionId); - - if (publishedDefinition) { - this.publishedVersion = publishedDefinition.version; - } - } } Tunnel.injectProps(ElsaWorkflowTestPanel, ['serverUrl', 'culture']); \ No newline at end of file