From 86380b2ba57ac7d62eedba1a7c71a5269a4e4dd4 Mon Sep 17 00:00:00 2001 From: Junyi Date: Wed, 9 Apr 2025 21:43:15 +0800 Subject: [PATCH] refactor(plugin-workflow-delay): support to use variable for duration (#6621) --- .../src/client/DelayInstruction.tsx | 80 +++++++---------- .../src/locale/zh-CN.json | 1 + .../src/server/DelayInstruction.ts | 5 +- .../src/server/__tests__/instruction.test.ts | 49 ++++++++++- .../20250403223032-add-duration-unit.test.ts | 86 +++++++++++++++++++ .../20250403223032-add-duration-unit.ts | 54 ++++++++++++ 6 files changed, 221 insertions(+), 54 deletions(-) create mode 100644 packages/plugins/@nocobase/plugin-workflow-delay/src/server/__tests__/migrations/20250403223032-add-duration-unit.test.ts create mode 100644 packages/plugins/@nocobase/plugin-workflow-delay/src/server/migrations/20250403223032-add-duration-unit.ts diff --git a/packages/plugins/@nocobase/plugin-workflow-delay/src/client/DelayInstruction.tsx b/packages/plugins/@nocobase/plugin-workflow-delay/src/client/DelayInstruction.tsx index 81935fa347..0f66b56457 100644 --- a/packages/plugins/@nocobase/plugin-workflow-delay/src/client/DelayInstruction.tsx +++ b/packages/plugins/@nocobase/plugin-workflow-delay/src/client/DelayInstruction.tsx @@ -8,11 +8,10 @@ */ import React from 'react'; -import { InputNumber, Select } from 'antd'; +import { Space } from 'antd'; import { HourglassOutlined } from '@ant-design/icons'; -import { css, useCompile } from '@nocobase/client'; -import { Instruction, JOB_STATUS } from '@nocobase/plugin-workflow/client'; +import { Instruction, JOB_STATUS, WorkflowVariableInput } from '@nocobase/plugin-workflow/client'; import { NAMESPACE } from '../locale'; @@ -24,47 +23,6 @@ const UnitOptions = [ { value: 604800_000, label: `{{t('Weeks', { ns: "workflow" })}}` }, ]; -function getNumberOption(v) { - return UnitOptions.slice() - .reverse() - .find((item) => !(v % item.value)); -} - -function Duration({ value = 60000, onChange }) { - const compile = useCompile(); - const option = getNumberOption(value); - const quantity = Math.round(value / option.value); - - return ( -
- onChange(Math.round(v * option.value))} - className="auto-width" - /> -