Skip to content
Merged

Dev #66

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/flow-approval-presenter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @coding-flow/flow-approval-presenter

## 0.2.13

### Patch Changes

- 版本升级至 0.2.13(配合 flow-design 拒绝脚本 key 存储修复发布,本包无功能变更)

## 0.2.11

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/flow-approval-presenter/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@coding-flow/flow-approval-presenter",
"version": "0.2.11",
"version": "0.2.13",
"description": "flow-engine approval presenter framework ",
"type": "module",
"sideEffects": [
Expand Down
6 changes: 6 additions & 0 deletions packages/flow-core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @coding-flow/flow-core

## 0.2.13

### Patch Changes

- 版本升级至 0.2.13(配合 flow-design 拒绝脚本 key 存储修复发布,本包无功能变更)

## 0.2.11

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/flow-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@coding-flow/flow-core",
"version": "0.2.11",
"version": "0.2.13",
"description": "flow-engine core lib framework ",
"type": "module",
"sideEffects": [
Expand Down
6 changes: 6 additions & 0 deletions packages/flow-design/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @coding-flow/flow-design

## 0.2.13

### Patch Changes

- 修复拒绝动作的脚本存储:动作 script 字段保存脚本 key,脚本正文由脚本接口按 key 加载与保存,兼容历史内联脚本(codingapi/flow-engine#235)

## 0.2.11

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/flow-design/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@coding-flow/flow-design",
"version": "0.2.11",
"version": "0.2.13",
"description": "flow-engine design components ",
"type": "module",
"sideEffects": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const VIEW_KEY = 'ActionRejectViewPlugin';
export interface ActionRejectViewPlugin {
// 当前节点id
nodeId:string;
// 当前的脚本
// 当前的脚本正文(由脚本key加载,兼容历史内联脚本)
value?: string;
// 脚本更改回掉
onChange?: (value: string) => void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,29 @@ import React from "react";
import {ActionFormProps} from "@/script-components/typings";
import {Col, Form, Row} from "antd";
import {ActionRejectView} from "@/plugins/view/action-reject-view";
import {GroovyScriptLoader, GroovyScriptLoaderContent} from "@/script-components/components/groovy-script-loader";
import {ActionRejectScriptUtils} from "@/script-components/services/action-reject";

/**
* 按节点id创建脚本加载器的内容组件。
* <p>
* 使用工厂返回稳定的组件类型,避免父组件每次渲染都生成新的组件类型导致下拉框重新挂载。
*/
const createRejectScriptContent = (nodeId: string): React.FC<GroovyScriptLoaderContent> => {
const RejectScriptContent: React.FC<GroovyScriptLoaderContent> = (contentProps) => (
<ActionRejectView
nodeId={nodeId}
value={contentProps.value}
onChange={contentProps.onChange}
/>
);
return RejectScriptContent;
};

export const RejectActionForm:React.FC<ActionFormProps> = (props)=>{
export const RejectActionForm: React.FC<ActionFormProps> = (props) => {

const script = Form.useWatch("script", props.form) as string | undefined;
const content = React.useMemo(() => createRejectScriptContent(props.nodeId), [props.nodeId]);

return (
<Row>
Expand All @@ -16,9 +35,18 @@ export const RejectActionForm:React.FC<ActionFormProps> = (props)=>{
label={"拒绝策略"}
help={"配置拒绝时跳转的节点"}
>
<ActionRejectView
nodeId={props.nodeId}
/>
{ActionRejectScriptUtils.isInlineScript(script) ? (
// 兼容历史数据:脚本字段中保存的是脚本正文,直接按正文回显;
// 保存流程时后端会将其归一化为脚本key
<ActionRejectView
nodeId={props.nodeId}
/>
) : (
// 脚本字段保存脚本key,脚本正文由脚本接口按key加载与保存
<GroovyScriptLoader
content={content}
/>
)}
</Form.Item>
</Col>
</Row>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,19 @@ export class ActionRejectScriptUtils {
}


/**
* 判断脚本字段中存放的是脚本正文而非脚本key。
* <p>
* 旧版设计器会把脚本正文直接写入动作的 script 字段,后端在保存流程时会将其
* 归一化为脚本key;此处用于兼容此类历史数据的回显与编辑。
*/
public static isInlineScript(value?: string) {
if (!value) {
return false;
}
return value.includes('def run') || value.includes('\n') || value.includes('\r');
}

public static getType(script?: string) {
if (script) {
const meta = GroovyScriptConvertorUtil.getScriptMeta(script);
Expand Down
21 changes: 21 additions & 0 deletions packages/flow-design/tests/script/action_reject.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import {describe, expect, it} from '@rstest/core';
import {ActionRejectScriptUtils} from '@/script-components/services/action-reject';

describe('ActionRejectScriptUtils', () => {
it('生成的拒绝脚本应包含可回显的脚本元数据', () => {
const script = ActionRejectScriptUtils.update({label: '发起节点', value: 'start-node'});

expect(script).toContain('def run');
expect(ActionRejectScriptUtils.getType(script)).toBe('start-node');
});

it('应识别脚本字段中存放的是正文而非脚本key(兼容历史数据)', () => {
const script = ActionRejectScriptUtils.update({label: '终止流程', value: 'TERMINATE'});

// 设计器写入的脚本正文需要被识别为内联脚本,避免被当成脚本key提交
expect(ActionRejectScriptUtils.isInlineScript(script)).toBe(true);
// 后端正常保存的脚本key不包含换行与def run
expect(ActionRejectScriptUtils.isInlineScript('script-20261030-abcdef')).toBe(false);
expect(ActionRejectScriptUtils.isInlineScript(undefined)).toBe(false);
});
});
6 changes: 6 additions & 0 deletions packages/flow-icons/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @coding-flow/flow-icons

## 0.2.13

### Patch Changes

- 版本升级至 0.2.13(配合 flow-design 拒绝脚本 key 存储修复发布,本包无功能变更)

## 0.2.11

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/flow-icons/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@coding-flow/flow-icons",
"version": "0.2.11",
"version": "0.2.13",
"description": "flow-engine icons ",
"type": "module",
"sideEffects": [
Expand Down
6 changes: 6 additions & 0 deletions packages/flow-mobile/flow-mobile-approval/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @coding-flow/flow-mobile-approval

## 0.2.13

### Patch Changes

- 版本升级至 0.2.13(配合 flow-design 拒绝脚本 key 存储修复发布,本包无功能变更)

## 0.2.11

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/flow-mobile/flow-mobile-approval/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@coding-flow/flow-mobile-approval",
"version": "0.2.11",
"version": "0.2.13",
"description": "flow-engine pc mobile approval components",
"type": "module",
"sideEffects": [
Expand Down
6 changes: 6 additions & 0 deletions packages/flow-mobile/flow-mobile-form/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @coding-flow/flow-mobile-form

## 0.2.13

### Patch Changes

- 版本升级至 0.2.13(配合 flow-design 拒绝脚本 key 存储修复发布,本包无功能变更)

## 0.2.11

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/flow-mobile/flow-mobile-form/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@coding-flow/flow-mobile-form",
"version": "0.2.11",
"version": "0.2.13",
"description": "flow-engine mobile form engine",
"type": "module",
"sideEffects": [
Expand Down
6 changes: 6 additions & 0 deletions packages/flow-mobile/flow-mobile-ui/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @coding-flow/flow-mobile-ui

## 0.2.13

### Patch Changes

- 版本升级至 0.2.13(配合 flow-design 拒绝脚本 key 存储修复发布,本包无功能变更)

## 0.2.11

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/flow-mobile/flow-mobile-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@coding-flow/flow-mobile-ui",
"version": "0.2.11",
"version": "0.2.13",
"description": "flow-engine mobile ui components",
"type": "module",
"sideEffects": [
Expand Down
6 changes: 6 additions & 0 deletions packages/flow-pc/flow-pc-approval/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @coding-flow/flow-pc-approval

## 0.2.13

### Patch Changes

- 版本升级至 0.2.13(配合 flow-design 拒绝脚本 key 存储修复发布,本包无功能变更)

## 0.2.11

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/flow-pc/flow-pc-approval/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@coding-flow/flow-pc-approval",
"version": "0.2.11",
"version": "0.2.13",
"description": "flow-engine pc form approval components",
"type": "module",
"sideEffects": [
Expand Down
6 changes: 6 additions & 0 deletions packages/flow-pc/flow-pc-form/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @coding-flow/flow-pc-form

## 0.2.13

### Patch Changes

- 版本升级至 0.2.13(配合 flow-design 拒绝脚本 key 存储修复发布,本包无功能变更)

## 0.2.11

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/flow-pc/flow-pc-form/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@coding-flow/flow-pc-form",
"version": "0.2.11",
"version": "0.2.13",
"description": "flow-engine pc form engine",
"type": "module",
"sideEffects": [
Expand Down
6 changes: 6 additions & 0 deletions packages/flow-pc/flow-pc-ui/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @coding-flow/flow-pc-ui

## 0.2.13

### Patch Changes

- 版本升级至 0.2.13(配合 flow-design 拒绝脚本 key 存储修复发布,本包无功能变更)

## 0.2.11

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/flow-pc/flow-pc-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@coding-flow/flow-pc-ui",
"version": "0.2.11",
"version": "0.2.13",
"description": "flow-engine pc ui components",
"type": "module",
"sideEffects": [
Expand Down
6 changes: 6 additions & 0 deletions packages/flow-types/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @coding-flow/flow-types

## 0.2.13

### Patch Changes

- 版本升级至 0.2.13(配合 flow-design 拒绝脚本 key 存储修复发布,本包无功能变更)

## 0.2.11

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/flow-types/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@coding-flow/flow-types",
"version": "0.2.11",
"version": "0.2.13",
"description": "flow-engine types",
"type": "module",
"sideEffects": [
Expand Down
Loading