mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 07:25:15 +00:00
Merge branch 'main' into fix/association-appends
This commit is contained in:
commit
c4bfd13a68
@ -14,7 +14,7 @@
|
|||||||
"@nocobase/resourcer": "0.9.3-alpha.1",
|
"@nocobase/resourcer": "0.9.3-alpha.1",
|
||||||
"@nocobase/server": "0.9.3-alpha.1",
|
"@nocobase/server": "0.9.3-alpha.1",
|
||||||
"@nocobase/utils": "0.9.3-alpha.1",
|
"@nocobase/utils": "0.9.3-alpha.1",
|
||||||
"antd": "4.22.8",
|
"antd": "^4.24.8",
|
||||||
"axios": "^0.27.2",
|
"axios": "^0.27.2",
|
||||||
"classnames": "^2.3.1",
|
"classnames": "^2.3.1",
|
||||||
"cron-parser": "4.4.0",
|
"cron-parser": "4.4.0",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { Link, useHistory } from 'react-router-dom';
|
import { Link, useHistory } from 'react-router-dom';
|
||||||
import { Dropdown, Menu, Button, Tag, Switch, message, Breadcrumb } from 'antd';
|
import { Dropdown, Button, Tag, Switch, message, Breadcrumb, Modal } from 'antd';
|
||||||
import { DownOutlined, RightOutlined, EllipsisOutlined } from '@ant-design/icons';
|
import { DownOutlined, RightOutlined, EllipsisOutlined } from '@ant-design/icons';
|
||||||
import { cx } from '@emotion/css';
|
import { cx } from '@emotion/css';
|
||||||
import classnames from 'classnames';
|
import classnames from 'classnames';
|
||||||
@ -95,6 +95,24 @@ export function WorkflowCanvas() {
|
|||||||
history.push(`${revision.id}`);
|
history.push(`${revision.id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function onDelete() {
|
||||||
|
const content = workflow.current
|
||||||
|
? lang('Delete a main version will cause all other revisions to be deleted too.')
|
||||||
|
: '';
|
||||||
|
Modal.confirm({
|
||||||
|
title: t('Are you sure you want to delete it?'),
|
||||||
|
content,
|
||||||
|
async onOk() {
|
||||||
|
await resource.destroy({
|
||||||
|
filterByTk: workflow.id,
|
||||||
|
});
|
||||||
|
message.success(t('Operation succeeded'));
|
||||||
|
|
||||||
|
history.push(workflow.current ? '..' : `${revisions.find((item) => item.current)?.id}`);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
async function onMenuCommand({ key }) {
|
async function onMenuCommand({ key }) {
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case 'history':
|
case 'history':
|
||||||
@ -102,6 +120,8 @@ export function WorkflowCanvas() {
|
|||||||
return;
|
return;
|
||||||
case 'revision':
|
case 'revision':
|
||||||
return onRevision();
|
return onRevision();
|
||||||
|
case 'delete':
|
||||||
|
return onDelete();
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -134,31 +154,29 @@ export function WorkflowCanvas() {
|
|||||||
<div className="workflow-versions">
|
<div className="workflow-versions">
|
||||||
<Dropdown
|
<Dropdown
|
||||||
trigger={['click']}
|
trigger={['click']}
|
||||||
overlay={
|
menu={{
|
||||||
<Menu
|
onClick: onSwitchVersion,
|
||||||
onClick={onSwitchVersion}
|
defaultSelectedKeys: [`${workflow.id}`],
|
||||||
defaultSelectedKeys={[`${workflow.id}`]}
|
className: cx(workflowVersionDropdownClass),
|
||||||
className={cx(workflowVersionDropdownClass)}
|
items: revisions
|
||||||
items={revisions
|
.sort((a, b) => b.id - a.id)
|
||||||
.sort((a, b) => b.id - a.id)
|
.map((item, index) => ({
|
||||||
.map((item, index) => ({
|
key: `${item.id}`,
|
||||||
key: `${item.id}`,
|
icon: item.current ? <RightOutlined /> : null,
|
||||||
icon: item.current ? <RightOutlined /> : null,
|
label: (
|
||||||
label: (
|
<span
|
||||||
<span
|
className={classnames({
|
||||||
className={classnames({
|
executed: item.executed,
|
||||||
executed: item.executed,
|
unexecuted: !item.executed,
|
||||||
unexecuted: !item.executed,
|
enabled: item.enabled,
|
||||||
enabled: item.enabled,
|
})}
|
||||||
})}
|
>
|
||||||
>
|
<strong>{`#${item.id}`}</strong>
|
||||||
<strong>{`#${item.id}`}</strong>
|
<time>{new Date(item.createdAt).toLocaleString()}</time>
|
||||||
<time>{new Date(item.createdAt).toLocaleString()}</time>
|
</span>
|
||||||
</span>
|
),
|
||||||
),
|
})),
|
||||||
}))}
|
}}
|
||||||
/>
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
<Button type="text">
|
<Button type="text">
|
||||||
<label>{lang('Version')}</label>
|
<label>{lang('Version')}</label>
|
||||||
@ -174,15 +192,14 @@ export function WorkflowCanvas() {
|
|||||||
unCheckedChildren={lang('Off')}
|
unCheckedChildren={lang('Off')}
|
||||||
/>
|
/>
|
||||||
<Dropdown
|
<Dropdown
|
||||||
overlay={
|
menu={{
|
||||||
<Menu
|
items: [
|
||||||
items={[
|
{ key: 'history', label: lang('Execution history'), disabled: !workflow.allExecuted },
|
||||||
{ key: 'history', label: lang('Execution history'), disabled: !workflow.allExecuted },
|
{ key: 'revision', label: lang('Copy to new version'), disabled: !revisionable },
|
||||||
{ key: 'revision', label: lang('Copy to new version'), disabled: !revisionable },
|
{ key: 'delete', label: t('Delete') },
|
||||||
]}
|
],
|
||||||
onClick={onMenuCommand}
|
onClick: onMenuCommand,
|
||||||
/>
|
}}
|
||||||
}
|
|
||||||
>
|
>
|
||||||
<Button type="text" icon={<EllipsisOutlined />} />
|
<Button type="text" icon={<EllipsisOutlined />} />
|
||||||
</Dropdown>
|
</Dropdown>
|
||||||
|
@ -9,6 +9,7 @@ export default {
|
|||||||
Version: '版本',
|
Version: '版本',
|
||||||
'Copy to new version': '复制到新版本',
|
'Copy to new version': '复制到新版本',
|
||||||
Duplicate: '复制',
|
Duplicate: '复制',
|
||||||
|
'Delete a main version will cause all other revisions to be deleted too.': '删除主版本将导致其他版本一并被删除。',
|
||||||
Loading: '加载中',
|
Loading: '加载中',
|
||||||
'Load failed': '加载失败',
|
'Load failed': '加载失败',
|
||||||
Trigger: '触发器',
|
Trigger: '触发器',
|
||||||
|
@ -253,26 +253,14 @@ export default class WorkflowPlugin extends Plugin {
|
|||||||
const executed = await workflow.countExecutions({ transaction });
|
const executed = await workflow.countExecutions({ transaction });
|
||||||
|
|
||||||
// NOTE: not to trigger afterUpdate hook here
|
// NOTE: not to trigger afterUpdate hook here
|
||||||
await workflow.update({ executed }, { transaction, hooks: false });
|
await workflow.increment('executed', { transaction });
|
||||||
|
|
||||||
const allExecuted = await (<typeof ExecutionModel>execution.constructor).count({
|
await (<typeof WorkflowModel>workflow.constructor).increment('allExecuted', {
|
||||||
where: {
|
where: {
|
||||||
key: workflow.key,
|
key: workflow.key,
|
||||||
},
|
},
|
||||||
transaction,
|
transaction,
|
||||||
});
|
});
|
||||||
await (<typeof WorkflowModel>workflow.constructor).update(
|
|
||||||
{
|
|
||||||
allExecuted,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
where: {
|
|
||||||
key: workflow.key,
|
|
||||||
},
|
|
||||||
individualHooks: true,
|
|
||||||
transaction,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
execution.workflow = workflow;
|
execution.workflow = workflow;
|
||||||
|
|
||||||
|
@ -74,6 +74,7 @@ export default function () {
|
|||||||
sourceKey: 'key',
|
sourceKey: 'key',
|
||||||
// NOTE: no constraints needed here because tricky self-referencing
|
// NOTE: no constraints needed here because tricky self-referencing
|
||||||
constraints: false,
|
constraints: false,
|
||||||
|
onDelete: 'NO ACTION',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
// NOTE: use unique index for avoiding deadlock in mysql when setCurrent
|
// NOTE: use unique index for avoiding deadlock in mysql when setCurrent
|
||||||
|
Loading…
Reference in New Issue
Block a user