Refactor activity descriptors state
This commit is contained in:
parent
944c43d1b6
commit
b4bb5de6aa
|
|
@ -5,7 +5,7 @@
|
|||
* It contains typing information for all components that exist in this project.
|
||||
*/
|
||||
import { HTMLStencilElement, JSXBase } from "@stencil/core/internal";
|
||||
import { ActionDefinition, ActionInvokedArgs, Activity, ActivityDescriptor, ActivitySelectedArgs, ContainerSelectedArgs, GraphUpdatedArgs, IntellisenseContext, SelectListItem, TabChangedArgs, TabDefinition, Variable, WorkflowDefinition, WorkflowDefinitionSummary, WorkflowInstance, WorkflowInstanceSummary } from "./models";
|
||||
import { ActionDefinition, ActionInvokedArgs, Activity, ActivitySelectedArgs, ContainerSelectedArgs, GraphUpdatedArgs, IntellisenseContext, SelectListItem, TabChangedArgs, TabDefinition, Variable, WorkflowDefinition, WorkflowDefinitionSummary, WorkflowInstance, WorkflowInstanceSummary } from "./models";
|
||||
import { ActivityUpdatedArgs, DeleteActivityRequestedArgs } from "./components/designer/workflow-definition-editor/activity-properties-editor";
|
||||
import { Button } from "./components/shared/button-group/models";
|
||||
import { ContainerActivityComponent } from "./components/activities/container-activity-component";
|
||||
|
|
@ -32,7 +32,6 @@ export namespace Components {
|
|||
}
|
||||
interface ElsaActivityPropertiesEditor {
|
||||
"activity"?: Activity;
|
||||
"activityDescriptors": Array<ActivityDescriptor>;
|
||||
"hide": () => Promise<void>;
|
||||
"show": () => Promise<void>;
|
||||
"variables": Array<Variable>;
|
||||
|
|
@ -199,7 +198,6 @@ export namespace Components {
|
|||
"show": () => Promise<void>;
|
||||
}
|
||||
interface ElsaWorkflowDefinitionEditor {
|
||||
"activityDescriptors": Array<ActivityDescriptor>;
|
||||
"getCanvas": () => Promise<HTMLElsaCanvasElement>;
|
||||
"getWorkflowDefinition": () => Promise<WorkflowDefinition>;
|
||||
"importWorkflow": (workflowDefinition: WorkflowDefinition) => Promise<void>;
|
||||
|
|
@ -213,7 +211,6 @@ export namespace Components {
|
|||
"graph": Graph;
|
||||
}
|
||||
interface ElsaWorkflowDefinitionEditorToolboxActivities {
|
||||
"activityDescriptors": Array<ActivityDescriptor>;
|
||||
"graph": Graph;
|
||||
}
|
||||
interface ElsaWorkflowDefinitionPropertiesEditor {
|
||||
|
|
@ -232,7 +229,6 @@ export namespace Components {
|
|||
"workflowInstance"?: WorkflowInstance;
|
||||
}
|
||||
interface ElsaWorkflowInstanceViewer {
|
||||
"activityDescriptors": Array<ActivityDescriptor>;
|
||||
"getCanvas": () => Promise<HTMLElsaCanvasElement>;
|
||||
"getWorkflow": () => Promise<WorkflowDefinition>;
|
||||
"importWorkflow": (workflowDefinition: WorkflowDefinition, workflowInstance: WorkflowInstance) => Promise<void>;
|
||||
|
|
@ -603,7 +599,6 @@ declare namespace LocalJSX {
|
|||
}
|
||||
interface ElsaActivityPropertiesEditor {
|
||||
"activity"?: Activity;
|
||||
"activityDescriptors"?: Array<ActivityDescriptor>;
|
||||
"onActivityUpdated"?: (event: CustomEvent<ActivityUpdatedArgs>) => void;
|
||||
"onDeleteActivityRequested"?: (event: CustomEvent<DeleteActivityRequestedArgs>) => void;
|
||||
"variables"?: Array<Variable>;
|
||||
|
|
@ -773,7 +768,6 @@ declare namespace LocalJSX {
|
|||
"onWorkflowDefinitionSelected"?: (event: CustomEvent<WorkflowDefinitionSummary>) => void;
|
||||
}
|
||||
interface ElsaWorkflowDefinitionEditor {
|
||||
"activityDescriptors"?: Array<ActivityDescriptor>;
|
||||
"monacoLibPath"?: string;
|
||||
"onWorkflowUpdated"?: (event: CustomEvent<WorkflowDefinitionUpdatedArgs>) => void;
|
||||
"workflowDefinition"?: WorkflowDefinition;
|
||||
|
|
@ -782,7 +776,6 @@ declare namespace LocalJSX {
|
|||
"graph"?: Graph;
|
||||
}
|
||||
interface ElsaWorkflowDefinitionEditorToolboxActivities {
|
||||
"activityDescriptors"?: Array<ActivityDescriptor>;
|
||||
"graph"?: Graph;
|
||||
}
|
||||
interface ElsaWorkflowDefinitionPropertiesEditor {
|
||||
|
|
@ -797,7 +790,6 @@ declare namespace LocalJSX {
|
|||
"workflowInstance"?: WorkflowInstance;
|
||||
}
|
||||
interface ElsaWorkflowInstanceViewer {
|
||||
"activityDescriptors"?: Array<ActivityDescriptor>;
|
||||
"monacoLibPath"?: string;
|
||||
"workflowDefinition"?: WorkflowDefinition;
|
||||
"workflowInstance"?: WorkflowInstance;
|
||||
|
|
|
|||
|
|
@ -4,13 +4,11 @@ import {ActivityDescriptor, WorkflowDefinition} from "../../models";
|
|||
|
||||
export interface WorkflowDesignerState {
|
||||
workflow: WorkflowDefinition;
|
||||
activityDescriptors: Array<ActivityDescriptor>;
|
||||
}
|
||||
|
||||
export default createProviderConsumer<WorkflowDesignerState>(
|
||||
{
|
||||
workflow: null,
|
||||
activityDescriptors: []
|
||||
},
|
||||
(subscribe, child) => (<context-consumer subscribe={subscribe} renderer={child}/>)
|
||||
);
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import {Container} from "typedi";
|
|||
import {ActivityInputContext} from "../../../services/node-input-driver";
|
||||
import {FormEntry} from "../../shared/forms/form-entry";
|
||||
import {isNullOrWhitespace} from "../../../utils";
|
||||
import descriptorsStore from "../../../data/descriptors-store";
|
||||
|
||||
export interface ActivityUpdatedArgs {
|
||||
activity: Activity;
|
||||
|
|
@ -38,7 +39,6 @@ export class ActivityPropertiesEditor {
|
|||
this.inputDriverRegistry = Container.get(InputDriverRegistry);
|
||||
}
|
||||
|
||||
@Prop() activityDescriptors: Array<ActivityDescriptor> = [];
|
||||
@Prop() activity?: Activity;
|
||||
@Prop() variables: Array<Variable> = [];
|
||||
|
||||
|
|
@ -138,7 +138,7 @@ export class ActivityPropertiesEditor {
|
|||
);
|
||||
}
|
||||
|
||||
private findActivityDescriptor = (): ActivityDescriptor => !!this.activity ? this.activityDescriptors.find(x => x.activityType == this.activity.typeName) : null;
|
||||
private findActivityDescriptor = (): ActivityDescriptor => !!this.activity ? descriptorsStore.activityDescriptors.find(x => x.activityType == this.activity.typeName) : null;
|
||||
private onSelectedTabIndexChanged = (e: CustomEvent<TabChangedArgs>) => this.selectedTabIndex = e.detail.selectedTabIndex
|
||||
|
||||
private onActivityIdChanged = (e: any) => {
|
||||
|
|
@ -277,5 +277,3 @@ export class ActivityPropertiesEditor {
|
|||
</div>
|
||||
};
|
||||
}
|
||||
|
||||
WorkflowEditorTunnel.injectProps(ActivityPropertiesEditor, ['activityDescriptors']);
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import {Container} from 'typedi';
|
|||
import {ActivityDescriptor} from '../../../models';
|
||||
import {ActivityDriverRegistry} from '../../../services';
|
||||
import WorkflowEditorTunnel from '../state';
|
||||
import descriptorsStore from "../../../data/descriptors-store";
|
||||
|
||||
interface ActivityCategoryModel {
|
||||
category: string;
|
||||
|
|
@ -17,7 +18,6 @@ interface ActivityCategoryModel {
|
|||
})
|
||||
export class ToolboxActivities {
|
||||
@Prop() graph: Graph;
|
||||
@Prop({mutable: true}) activityDescriptors: Array<ActivityDescriptor> = [];
|
||||
@State() activityCategoryModels: Array<ActivityCategoryModel> = [];
|
||||
private dnd: Addon.Dnd;
|
||||
private renderedActivities: Map<string, string>;
|
||||
|
|
@ -67,7 +67,7 @@ export class ToolboxActivities {
|
|||
}
|
||||
|
||||
componentDidLoad() {
|
||||
this.handleActivityDescriptorsChanged(this.activityDescriptors);
|
||||
this.handleActivityDescriptorsChanged(descriptorsStore.activityDescriptors);
|
||||
}
|
||||
|
||||
private static onActivityStartDrag(e: DragEvent, activityDescriptor: ActivityDescriptor) {
|
||||
|
|
@ -127,5 +127,3 @@ export class ToolboxActivities {
|
|||
</nav>
|
||||
}
|
||||
}
|
||||
|
||||
WorkflowEditorTunnel.injectProps(ToolboxActivities, ['activityDescriptors']);
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import {MonacoEditorSettings} from "../../../services/monaco-editor-settings";
|
|||
import {Flowchart} from "../../activities/flowchart/models";
|
||||
import {flattenList, walkActivities} from "../../activities/flowchart/activity-walker";
|
||||
import {ActivityPropertyChangedEventArgs, WorkflowDefinitionPropsUpdatedArgs, WorkflowDefinitionUpdatedArgs, WorkflowEditorEventTypes} from "./models";
|
||||
import descriptorsStore from "../../../data/descriptors-store";
|
||||
|
||||
@Component({
|
||||
tag: 'elsa-workflow-definition-editor',
|
||||
|
|
@ -50,7 +51,6 @@ export class WorkflowDefinitionEditor {
|
|||
|
||||
@Prop() workflowDefinition?: WorkflowDefinition;
|
||||
@Prop({attribute: 'monaco-lib-path'}) public monacoLibPath: string;
|
||||
@Prop() activityDescriptors: Array<ActivityDescriptor> = [];
|
||||
@Event() workflowUpdated: EventEmitter<WorkflowDefinitionUpdatedArgs>
|
||||
@State() private workflowDefinitionState: WorkflowDefinition;
|
||||
@State() private selectedActivity?: Activity;
|
||||
|
|
@ -125,7 +125,7 @@ export class WorkflowDefinitionEditor {
|
|||
@Method()
|
||||
public async newWorkflow() {
|
||||
|
||||
const flowchartDescriptor = this.activityDescriptors.find(x => x.activityType == 'Elsa.Flowchart');
|
||||
const flowchartDescriptor = descriptorsStore.activityDescriptors.find(x => x.activityType == 'Elsa.Flowchart');
|
||||
const newName = await this.generateUniqueActivityName(flowchartDescriptor);
|
||||
|
||||
const flowchart = {
|
||||
|
|
@ -168,7 +168,6 @@ export class WorkflowDefinitionEditor {
|
|||
public render() {
|
||||
const tunnelState: WorkflowDesignerState = {
|
||||
workflow: this.workflowDefinitionState,
|
||||
activityDescriptors: this.activityDescriptors,
|
||||
};
|
||||
|
||||
return (
|
||||
|
|
@ -247,7 +246,7 @@ export class WorkflowDefinitionEditor {
|
|||
const activityType = activityDescriptor.activityType;
|
||||
const workflowDefinition = await this.getWorkflowDefinitionInternal();
|
||||
const root = workflowDefinition.root;
|
||||
const activityDescriptors = this.activityDescriptors;
|
||||
const activityDescriptors = descriptorsStore.activityDescriptors;
|
||||
const graph = walkActivities(root, activityDescriptors);
|
||||
const activityNodes = flattenList(graph.children);
|
||||
const activityCount = activityNodes.filter(x => x.activity.typeName == activityType).length;
|
||||
|
|
|
|||
|
|
@ -97,5 +97,3 @@ export class ActivityProperties {
|
|||
</div>
|
||||
};
|
||||
}
|
||||
|
||||
WorkflowEditorTunnel.injectProps(ActivityProperties, ['activityDescriptors']);
|
||||
|
|
|
|||
|
|
@ -154,5 +154,3 @@ export class WorkflowDefinitionPropertiesEditor {
|
|||
|
||||
private onSelectedTabIndexChanged = (e: CustomEvent<TabChangedArgs>) => this.selectedTabIndex = e.detail.selectedTabIndex;
|
||||
}
|
||||
|
||||
WorkflowEditorTunnel.injectProps(WorkflowDefinitionPropertiesEditor, ['activityDescriptors']);
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@ export class WorkflowInstanceViewer {
|
|||
|
||||
@Element() private el: HTMLElsaWorkflowDefinitionEditorElement;
|
||||
@Prop({attribute: 'monaco-lib-path'}) public monacoLibPath: string;
|
||||
@Prop() public activityDescriptors: Array<ActivityDescriptor> = [];
|
||||
@Prop() public workflowDefinition: WorkflowDefinition;
|
||||
@Prop() public workflowInstance: WorkflowInstance;
|
||||
@State() private selectedActivity?: Activity;
|
||||
|
|
@ -128,7 +127,6 @@ export class WorkflowInstanceViewer {
|
|||
|
||||
const tunnelState: WorkflowDesignerState = {
|
||||
workflow: this.workflowDefinition,
|
||||
activityDescriptors: this.activityDescriptors,
|
||||
};
|
||||
|
||||
return (
|
||||
|
|
|
|||
Loading…
Reference in a new issue