Fix(plugin workflow): fix transaction of execution (#364)

* fix(plugin-workflow): fix values dropdown height

* fix(plugin-workflow): fix duplicated property name
This commit is contained in:
Junyi 2022-05-06 13:55:36 +08:00 committed by GitHub
parent 09dfd3804e
commit 16498dcbde
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 33 additions and 13 deletions

View File

@ -456,7 +456,10 @@ export const CollectionFieldset = observer(({ value, onChange }: any) => {
{Object.keys(value).length < fields.length
? (
<Dropdown overlay={
<Menu onClick={({ key }) => onChange({ ...value, [key]: null })}>
<Menu onClick={({ key }) => onChange({ ...value, [key]: null })} className={css`
max-height: 300px;
overflow-y: auto;
`}>
{fields
.filter(field => !(field.name in value))
.map(field => (

View File

@ -60,6 +60,21 @@ export default {
name: 'executions',
target: 'executions',
title: '触发执行'
},
{
type: 'boolean',
name: 'executed',
defaultValue: false
},
{
type: 'hasMany',
name: 'revisions',
target: 'workflows',
},
{
type: 'belongsTo',
name: 'current',
target: 'workflows'
}
]
} as CollectionOptions;

View File

@ -12,7 +12,7 @@ export default {
const options = execution.getParsedValue(params);
const result = await repo.create({
...options,
transaction: execution.transaction
transaction: execution.tx
});
return {

View File

@ -12,7 +12,7 @@ export default {
const options = execution.getParsedValue(params);
const result = await repo.destroy({
...options,
transaction: execution.transaction
transaction: execution.tx
});
return {

View File

@ -83,7 +83,7 @@ export default {
});
if (job.status === JOB_STATUS.PENDING) {
await job.save({ transaction: execution.transaction });
await job.save({ transaction: execution.tx });
return execution.end(this, job);
}

View File

@ -13,7 +13,7 @@ export default {
const options = execution.getParsedValue(params);
const result = await (multiple ? repo.find : repo.findOne).call(repo, {
...options,
transaction: execution.transaction
transaction: execution.tx
});
return {

View File

@ -13,7 +13,7 @@ export default {
const options = execution.getParsedValue(params);
const result = await repo.update({
...options,
transaction: execution.transaction
transaction: execution.tx
});
return {

View File

@ -21,6 +21,7 @@ export default class ExecutionModel extends Model {
declare status: number;
// NOTE: this duplicated column is for transaction in preparing cycle from workflow
declare useTransaction: boolean;
declare transaction: string;
declare createdAt: Date;
declare updatedAt: Date;
@ -32,7 +33,8 @@ export default class ExecutionModel extends Model {
declare getJobs: HasManyGetAssociationsMixin<JobModel>;
options: ExecutionOptions;
transaction: Transaction;
tx: Transaction;
nodes: Array<FlowNodeModel> = [];
nodesMap = new Map<number, FlowNodeModel>();
@ -98,7 +100,7 @@ export default class ExecutionModel extends Model {
async prepare(options, commit = false) {
this.options = options || {};
const transaction = await this.getTransaction();
this.transaction = transaction;
this.tx = transaction;
if (!this.workflow) {
this.workflow = await this.getWorkflow({ transaction });
@ -146,8 +148,8 @@ export default class ExecutionModel extends Model {
private async commit() {
// @ts-ignore
if (this.transaction && (!this.options.transaction || this.options.transaction.finished)) {
await this.transaction.commit();
if (this.tx && (!this.options.transaction || this.options.transaction.finished)) {
await this.tx.commit();
}
}
@ -178,7 +180,7 @@ export default class ExecutionModel extends Model {
// TODO(optimize): many checking of resuming or new could be improved
// could be implemented separately in exec() / resume()
if (job instanceof Model) {
savedJob = (await job.save({ transaction: this.transaction })) as unknown as JobModel;
savedJob = (await job.save({ transaction: this.tx })) as unknown as JobModel;
} else {
const upstreamId = prevJob instanceof Model ? prevJob.get('id') : null;
savedJob = await this.saveJob({
@ -230,7 +232,7 @@ export default class ExecutionModel extends Model {
async exit(job: JobModel | null) {
const status = job ? ExecutionModel.StatusMap[job.status] : EXECUTION_STATUS.RESOLVED;
await this.update({ status }, { transaction: this.transaction });
await this.update({ status }, { transaction: this.tx });
return null;
}
@ -243,7 +245,7 @@ export default class ExecutionModel extends Model {
...payload,
executionId: this.id,
},
{ transaction: this.transaction },
{ transaction: this.tx },
)) as unknown as [JobModel, boolean | null];
this.jobsMap.set(job.id, job);
this.jobsMapByNodeId[job.nodeId] = job.result;