@coding-flow/flow-design 0.0.48 → 0.0.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,7 +15,7 @@ const Left = ()=>/*#__PURE__*/ jsx("div", {
15
15
  const SaveAsButton = ()=>{
16
16
  const [visible, setVisible] = react.useState(false);
17
17
  const [form] = Form.useForm();
18
- const { context } = useDesignContext();
18
+ const { context, state } = useDesignContext();
19
19
  react.useEffect(()=>{
20
20
  if (!visible) form.resetFields();
21
21
  }, [
@@ -62,6 +62,7 @@ const SaveAsButton = ()=>{
62
62
  form.submit();
63
63
  },
64
64
  type: "primary",
65
+ loading: state.view.loading,
65
66
  children: "确定"
66
67
  }),
67
68
  /*#__PURE__*/ jsx(Button, {
@@ -93,6 +94,7 @@ const Right = ()=>{
93
94
  /*#__PURE__*/ jsx(Button, {
94
95
  icon: /*#__PURE__*/ jsx(SaveOutlined, {}),
95
96
  type: "primary",
97
+ loading: state.view.loading,
96
98
  onClick: ()=>{
97
99
  context.save().then(()=>{
98
100
  message.success("流程已经保存.");
@@ -1,6 +1,7 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import "react";
3
3
  import { Provider } from "react-redux";
4
+ import { Spin } from "antd";
4
5
  import { DesignPanelContext } from "../context/index.js";
5
6
  import { createDesignContext } from "../hooks/use-design-context.js";
6
7
  import { designStore } from "../store.js";
@@ -8,16 +9,21 @@ import { Header } from "./header.js";
8
9
  import { Footer } from "./footer.js";
9
10
  import { Body } from "./body.js";
10
11
  const DesignPanelLayoutScope = (props)=>{
11
- const { context } = createDesignContext(props);
12
+ const { context, state } = createDesignContext(props);
12
13
  return /*#__PURE__*/ jsx(DesignPanelContext.Provider, {
13
14
  value: context,
14
- children: /*#__PURE__*/ jsxs("div", {
15
- className: props.className,
16
- children: [
17
- /*#__PURE__*/ jsx(Header, {}),
18
- /*#__PURE__*/ jsx(Body, {}),
19
- /*#__PURE__*/ jsx(Footer, {})
20
- ]
15
+ children: /*#__PURE__*/ jsx(Spin, {
16
+ spinning: state.view.loading,
17
+ tip: state.view.loadingText,
18
+ size: "large",
19
+ children: /*#__PURE__*/ jsxs("div", {
20
+ className: props.className,
21
+ children: [
22
+ /*#__PURE__*/ jsx(Header, {}),
23
+ /*#__PURE__*/ jsx(Body, {}),
24
+ /*#__PURE__*/ jsx(Footer, {})
25
+ ]
26
+ })
21
27
  })
22
28
  });
23
29
  };
@@ -25,6 +25,7 @@ export declare class Presenter {
25
25
  addWorkflowSubForm(values: any): void;
26
26
  updateWorkflowFormField(code: string, values: any): void;
27
27
  importWorkflowForm(selectedForm: FlowForm): void;
28
+ private setLoading;
28
29
  save(versionName?: string): Promise<void>;
29
30
  getNodeManager(): NodeManger;
30
31
  createNode(form: string, type: string): Promise<any>;
@@ -110,20 +110,35 @@ class Presenter {
110
110
  };
111
111
  this.updateWorkflowForm(updatedForm);
112
112
  }
113
+ setLoading(loading, loadingText) {
114
+ this.dispatch((prevState)=>({
115
+ ...prevState,
116
+ view: {
117
+ ...prevState.view,
118
+ loading,
119
+ loadingText
120
+ }
121
+ }));
122
+ }
113
123
  async save(versionName) {
114
- const values = this.formActionContext.save();
115
- this.updateWorkflow(values);
116
- const latest = {
117
- ...this.state,
118
- workflow: this.mergeWorkflow(this.state.workflow, values)
119
- };
120
- const convertor = new WorkflowConvertor(latest.workflow);
121
- const apiData = convertor.toApi();
122
- await this.api.save({
123
- ...apiData,
124
- versionName
125
- });
126
- console.log('save latest:', apiData);
124
+ this.setLoading(true, '正在保存...');
125
+ try {
126
+ const values = this.formActionContext.save();
127
+ this.updateWorkflow(values);
128
+ const latest = {
129
+ ...this.state,
130
+ workflow: this.mergeWorkflow(this.state.workflow, values)
131
+ };
132
+ const convertor = new WorkflowConvertor(latest.workflow);
133
+ const apiData = convertor.toApi();
134
+ await this.api.save({
135
+ ...apiData,
136
+ versionName
137
+ });
138
+ console.log('save latest:', apiData);
139
+ } finally{
140
+ this.setLoading(false);
141
+ }
127
142
  }
128
143
  getNodeManager() {
129
144
  return new NodeManger(this.state.workflow.nodes || []);
@@ -152,17 +167,23 @@ class Presenter {
152
167
  this.dispatch(initStateData);
153
168
  }
154
169
  loadDesign(id) {
170
+ this.setLoading(true, '正在加载流程...');
155
171
  this.api.load(id).then((result)=>{
156
172
  const convertor = new WorkflowConvertor(result);
157
173
  const renderData = convertor.toRender();
158
174
  this.updateWorkflow(renderData);
175
+ }).finally(()=>{
176
+ this.setLoading(false);
159
177
  });
160
178
  }
161
179
  createDesign() {
180
+ this.setLoading(true, '正在创建流程...');
162
181
  this.api.create().then((result)=>{
163
182
  const convertor = new WorkflowConvertor(result);
164
183
  const renderData = convertor.toRender();
165
184
  this.updateWorkflow(renderData);
185
+ }).finally(()=>{
186
+ this.setLoading(false);
166
187
  });
167
188
  }
168
189
  }
@@ -33,6 +33,8 @@ export interface FlowNode {
33
33
  export interface State {
34
34
  view: {
35
35
  tabPanel: TabPanelType;
36
+ loading: boolean;
37
+ loadingText?: string;
36
38
  };
37
39
  workflow: Workflow;
38
40
  }
@@ -1,7 +1,8 @@
1
1
  const LayoutHeaderHeight = 50;
2
2
  const initStateData = {
3
3
  view: {
4
- tabPanel: 'base'
4
+ tabPanel: 'base',
5
+ loading: false
5
6
  },
6
7
  workflow: {
7
8
  id: '',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coding-flow/flow-design",
3
- "version": "0.0.48",
3
+ "version": "0.0.51",
4
4
  "description": "flow-engine design components ",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -49,16 +49,16 @@
49
49
  "nanoid": "^5.1.6",
50
50
  "react-redux": "^9.2.0",
51
51
  "styled-components": "^5.3.11",
52
- "@coding-flow/flow-core": "0.0.48",
53
- "@coding-flow/flow-icons": "0.0.48",
54
- "@coding-flow/flow-types": "0.0.48",
55
- "@coding-flow/flow-pc-ui": "0.0.48"
52
+ "@coding-flow/flow-core": "0.0.51",
53
+ "@coding-flow/flow-icons": "0.0.51",
54
+ "@coding-flow/flow-types": "0.0.51",
55
+ "@coding-flow/flow-pc-ui": "0.0.51"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@types/lodash-es": "^4.17.12",
59
59
  "@types/styled-components": "^5.1.36",
60
- "@coding-flow/flow-core": "0.0.48",
61
- "@coding-flow/flow-types": "0.0.48"
60
+ "@coding-flow/flow-core": "0.0.51",
61
+ "@coding-flow/flow-types": "0.0.51"
62
62
  },
63
63
  "scripts": {
64
64
  "build": "rslib build",