tachybase_todo/packages/plugins/@nocobase/plugin-workflow-sql/src/client/SQLInstruction.tsx
Junyi d691e4c7e6
feat(plugin-workflow): support multiple data source in workflow (#3739)
* feat(plugin-workflow): support multiple data source in workflow

* fix(plugin-workflow): fix test cases

* test(plugin-workflow-sql): debug test case

* fix(plugin-workflow): fix collection trigger creation without config

* test(plugin-workflow-sql): debug test case

* fix: workflow e2e test

* chore(ci): disable console intercept in vitest

* chore(ci): disable console intercept in vitest

* chore(ci): disable console intercept in vitest

* chore(ci): disable console intercept in vitest

* test(plugin-workflow-sql): debug test case

* test: approval e2e

* fix: remove pro-plugins from packages

* refactor(plugin-workflow): support pass collection from props to CollectionBlockInitializer

* test(plugin-workflow): add test case

* fix(plugin-workflow): disable modification of executed workflow

* fix: e2ePageObjectModel

* fix: load data source when data source load failed (#3793)

* chore: console.log

* fix(subTable): fix sorting rule setting (#3795)

* fix: through collection support search (#3800)

* fix(client): visible -> useVisible

* fix(client): fix action designer error occured in custom form (#3801)

* fix(client): fix action designer error occured in custom form

* fix(client): fix from the source

* chore(module): remove submodule

* fix(plugin-workflow): fix client cycling import

* fix(plugin-workflow): fix collection event name

* fix(plugin-workflow): fix undefined ref

---------

Co-authored-by: hongboji <j414562100@qq.com>
Co-authored-by: ChengLei Shao <chareice@live.com>
Co-authored-by: Zeke Zhang <958414905@qq.com>
Co-authored-by: katherinehhh <shunai.tang@hand-china.com>
Co-authored-by: chenos <chenlinxh@gmail.com>
2024-03-25 14:46:22 +08:00

69 lines
1.9 KiB
TypeScript

import { css } from '@nocobase/client';
import { Instruction, WorkflowVariableRawTextArea, defaultFieldNames } from '@nocobase/plugin-workflow/client';
import React from 'react';
import { Trans } from 'react-i18next';
import { NAMESPACE } from '../locale';
export default class extends Instruction {
title = `{{t("SQL action", { ns: "${NAMESPACE}" })}}`;
type = 'sql';
group = 'collection';
description = `{{t("Execute a SQL statement in database.", { ns: "${NAMESPACE}" })}}`;
fieldset = {
dataSource: {
type: 'string',
required: true,
title: `{{t("Data source")}}`,
description: `{{t("Select a data source to execute SQL.", { ns: "${NAMESPACE}" })}}`,
'x-decorator': 'FormItem',
'x-component': 'DataSourceSelect',
'x-component-props': {
className: 'auto-width',
filter(item) {
return item.options.isDBInstance;
},
},
default: 'main',
},
sql: {
type: 'string',
required: true,
title: 'SQL',
description: '{{sqlDescription()}}',
'x-decorator': 'FormItem',
'x-component': 'WorkflowVariableRawTextArea',
'x-component-props': {
rows: 20,
className: css`
font-size: 80%;
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
`,
},
},
};
scope = {
sqlDescription() {
return (
<Trans ns={NAMESPACE}>
{'SQL query result could be used through '}
<a href="https://docs-cn.nocobase.com/handbook/workflow-json-query" target="_blank" rel="noreferrer">
{'JSON query node'}
</a>
{' (Commercial plugin).'}
</Trans>
);
},
};
components = {
WorkflowVariableRawTextArea,
};
useVariables({ key, title }, { types, fieldNames = defaultFieldNames }) {
return {
[fieldNames.value]: key,
[fieldNames.label]: title,
};
}
}