Implement New Workflow
This commit is contained in:
parent
a7f72b25af
commit
1e5cf372e9
|
|
@ -20,6 +20,7 @@ import { PagerData } from "./components/shared/pager/pager";
|
|||
import { PanelPosition, PanelStateChangedArgs } from "./components/designer/panel/models";
|
||||
import { WorkflowUpdatedArgs } from "./components/designer/workflow-editor/workflow-editor";
|
||||
import { ActivityDriverRegistry } from "./services";
|
||||
import { Flowchart } from "./components/activities/flowchart/models";
|
||||
import { WorkflowPropsUpdatedArgs } from "./components/designer/workflow-properties-editor/workflow-properties-editor";
|
||||
import { PublishClickedArgs } from "./components/toolbar/workflow-publish-button/workflow-publish-button";
|
||||
export namespace Components {
|
||||
|
|
@ -170,6 +171,7 @@ export namespace Components {
|
|||
"importWorkflow": (workflow: WorkflowDefinition, workflowInstance?: WorkflowInstance) => Promise<void>;
|
||||
"importWorkflowMetadata": (workflow: WorkflowDefinition) => Promise<void>;
|
||||
"monacoLibPath": string;
|
||||
"newWorkflow": () => Promise<void>;
|
||||
"registerActivityDrivers": (register: (registry: ActivityDriverRegistry) => void) => Promise<void>;
|
||||
}
|
||||
interface ElsaWorkflowInstanceBrowser {
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import {ActivityDriverRegistry, EventBus} from '../../../services';
|
|||
import {WorkflowPropsUpdatedArgs} from "../workflow-properties-editor/workflow-properties-editor";
|
||||
import {MonacoEditorSettings} from "../../../services/monaco-editor-settings";
|
||||
import {PluginRegistry} from "../../../services/plugin-registry";
|
||||
import {Flowchart} from "../../activities/flowchart/models";
|
||||
|
||||
export interface WorkflowUpdatedArgs {
|
||||
workflow: WorkflowDefinition;
|
||||
|
|
@ -138,6 +139,31 @@ export class WorkflowEditor {
|
|||
this.workflowDefinition = workflow;
|
||||
}
|
||||
|
||||
@Method()
|
||||
public async newWorkflow() {
|
||||
const flowchart = {
|
||||
typeName: 'Elsa.Flowchart',
|
||||
activities: [],
|
||||
connections: [],
|
||||
id: uuid(),
|
||||
metadata: {},
|
||||
applicationProperties: {},
|
||||
variables: []
|
||||
} as Flowchart;
|
||||
|
||||
const workflowDefinition: WorkflowDefinition = {
|
||||
root: flowchart,
|
||||
id: uuid(),
|
||||
definitionId: uuid(),
|
||||
version: 1,
|
||||
isLatest: true,
|
||||
isPublished: false,
|
||||
materializerName: 'Json'
|
||||
}
|
||||
|
||||
await this.importWorkflow(workflowDefinition);
|
||||
}
|
||||
|
||||
public render() {
|
||||
const tunnelState: WorkflowDesignerState = {
|
||||
workflow: this.workflowDefinition,
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import {WorkflowUpdatedArgs} from '../../designer/workflow-editor/workflow-edito
|
|||
import {PublishClickedArgs} from "../../toolbar/workflow-publish-button/workflow-publish-button";
|
||||
import {MonacoEditorSettings} from "../../../services/monaco-editor-settings";
|
||||
import {downloadFromBlob, getVersionOptionsString} from "../../../utils";
|
||||
import {uuid} from "@antv/x6/lib/util/string/uuid";
|
||||
|
||||
@Component({
|
||||
tag: 'elsa-studio'
|
||||
|
|
@ -106,13 +107,7 @@ export class Studio {
|
|||
if (!workflowEditorElement)
|
||||
return;
|
||||
|
||||
const request: SaveWorkflowDefinitionRequest = {
|
||||
definitionId: "",
|
||||
publish: false
|
||||
};
|
||||
|
||||
const updatedWorkflow = await this.elsaClient.workflowDefinitions.post(request);
|
||||
await this.workflowEditorElement.importWorkflowMetadata(updatedWorkflow);
|
||||
await this.workflowEditorElement.newWorkflow();
|
||||
}
|
||||
|
||||
@Listen('exportClicked')
|
||||
|
|
|
|||
Loading…
Reference in a new issue