From 9f8a8db96afb6efb440d8f12bd302c17f28d2f4e Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Mon, 1 Nov 2021 21:03:52 +0100 Subject: [PATCH] Add custom attributes field to activity descriptor --- .../Elsa.Client/Models/ActivityDescriptor.cs | 5 +++-- .../Metadata/ActivityDescriptor.cs | 2 ++ .../elsa-designer-tree/elsa-designer-tree.tsx | 15 ++++++++------- .../elsa-activity-editor-modal.tsx | 3 ++- .../elsa-workflows-studio/src/models/domain.ts | 3 ++- 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/clients/Elsa.Client/Models/ActivityDescriptor.cs b/src/clients/Elsa.Client/Models/ActivityDescriptor.cs index 847299874..2c9088a5d 100644 --- a/src/clients/Elsa.Client/Models/ActivityDescriptor.cs +++ b/src/clients/Elsa.Client/Models/ActivityDescriptor.cs @@ -1,3 +1,4 @@ +using System; using System.Runtime.Serialization; namespace Elsa.Client.Models @@ -10,7 +11,7 @@ namespace Elsa.Client.Models [DataMember(Order = 3)] public string? Description { get; set; } [DataMember(Order = 4)] public string Category { get; set; } = default!; [DataMember(Order = 5)] public ActivityTraits Traits { get; set; } - [DataMember(Order = 6)] public string[] Outcomes { get; set; } = new string[0]; - [DataMember(Order = 7)] public ActivityPropertyDescriptor[] Properties { get; set; } = new ActivityPropertyDescriptor[0]; + [DataMember(Order = 6)] public string[] Outcomes { get; set; } = Array.Empty(); + [DataMember(Order = 7)] public ActivityPropertyDescriptor[] Properties { get; set; } = Array.Empty(); } } \ No newline at end of file diff --git a/src/core/Elsa.Abstractions/Metadata/ActivityDescriptor.cs b/src/core/Elsa.Abstractions/Metadata/ActivityDescriptor.cs index 7735d440b..f57e9e11f 100644 --- a/src/core/Elsa.Abstractions/Metadata/ActivityDescriptor.cs +++ b/src/core/Elsa.Abstractions/Metadata/ActivityDescriptor.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; namespace Elsa.Metadata { @@ -31,5 +32,6 @@ namespace Elsa.Metadata public ActivityInputDescriptor[] InputProperties { get; set; } public ActivityOutputDescriptor[] OutputProperties { get; set; } + public IDictionary CustomAttributes { get; set; } = new Dictionary(); } } \ No newline at end of file diff --git a/src/designer/elsa-workflows-studio/src/components/designers/tree/elsa-designer-tree/elsa-designer-tree.tsx b/src/designer/elsa-workflows-studio/src/components/designers/tree/elsa-designer-tree/elsa-designer-tree.tsx index 32239350f..bb09b02fb 100644 --- a/src/designer/elsa-workflows-studio/src/components/designers/tree/elsa-designer-tree/elsa-designer-tree.tsx +++ b/src/designer/elsa-workflows-studio/src/components/designers/tree/elsa-designer-tree/elsa-designer-tree.tsx @@ -116,7 +116,7 @@ export class ElsaWorkflowDesigner { this.ignoreCopyPasteActivities = true; this.activityContextMenuTestState = state; this.activityContextMenuButtonTestClicked.emit(state); - } + } @Watch('model') handleModelChanged(newValue: WorkflowModel) { @@ -149,7 +149,7 @@ export class ElsaWorkflowDesigner { @Watch('activityContextTestMenu') handleActivityContextMenuTestChanged(newValue: ActivityContextMenuState) { this.activityContextMenuTestState = newValue; - } + } @Listen('keydown', {target: 'window'}) async handleKeyDown(event: KeyboardEvent) { @@ -329,7 +329,8 @@ export class ElsaWorkflowDesigner { traits: ActivityTraits.Action, description: `(Not Found) ${activityModel.description}`, category: 'Not Found', - browsable: false + browsable: false, + customAttributes: {} }; } @@ -705,7 +706,7 @@ export class ElsaWorkflowDesigner { d3.select(node.elem).select('svg').classed('elsa-text-green-400', true).classed('elsa-text-gray-400', false).classed('hover:elsa-text-blue-500', false); return; } - + if (this.mode !== WorkflowDesignerMode.Test) await this.showActivityPicker(); }) .on("mouseover", e => { @@ -893,7 +894,7 @@ export class ElsaWorkflowDesigner { `; } - renderActivityBody(displayContext: ActivityDesignDisplayContext) { + renderActivityBody(displayContext: ActivityDesignDisplayContext) { return ( `
@@ -914,7 +915,7 @@ export class ElsaWorkflowDesigner { render() { return ( (this.el = el)}> - {this.mode == WorkflowDesignerMode.Test ? + {this.mode == WorkflowDesignerMode.Test ?
@@ -923,7 +924,7 @@ export class ElsaWorkflowDesigner {
: undefined - } + } (this.svg = el)} id="svg" style={{ height: 'calc(100vh - 64px)', width: '100%', diff --git a/src/designer/elsa-workflows-studio/src/components/screens/workflow-definition-editor/elsa-activity-editor-modal/elsa-activity-editor-modal.tsx b/src/designer/elsa-workflows-studio/src/components/screens/workflow-definition-editor/elsa-activity-editor-modal/elsa-activity-editor-modal.tsx index fb6000a7c..bfdea796c 100644 --- a/src/designer/elsa-workflows-studio/src/components/screens/workflow-definition-editor/elsa-activity-editor-modal/elsa-activity-editor-modal.tsx +++ b/src/designer/elsa-workflows-studio/src/components/screens/workflow-definition-editor/elsa-activity-editor-modal/elsa-activity-editor-modal.tsx @@ -89,7 +89,8 @@ export class ElsaActivityEditorModal { browsable: false, inputProperties: [], outputProperties: [], - description: '' + description: '', + customAttributes: {} }; const propertyCategories = activityDescriptor.inputProperties.filter(x => x.category).map(x => x.category).distinct(); const defaultProperties = activityDescriptor.inputProperties.filter(x => !x.category || x.category.length == 0); diff --git a/src/designer/elsa-workflows-studio/src/models/domain.ts b/src/designer/elsa-workflows-studio/src/models/domain.ts index bb1905359..2bf116cec 100644 --- a/src/designer/elsa-workflows-studio/src/models/domain.ts +++ b/src/designer/elsa-workflows-studio/src/models/domain.ts @@ -265,6 +265,7 @@ export interface ActivityDescriptor { browsable: boolean; inputProperties: Array; outputProperties: Array; + customAttributes: any; } export interface ActivityPropertyDescriptor { @@ -351,4 +352,4 @@ export const getVersionOptionsString = (versionOptions?: VersionOptions) => { : versionOptions.isLatestOrPublished ? 'LatestOrPublished' : versionOptions.version.toString(); -}; \ No newline at end of file +};