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:
parent
09dfd3804e
commit
16498dcbde
@ -456,7 +456,10 @@ export const CollectionFieldset = observer(({ value, onChange }: any) => {
|
|||||||
{Object.keys(value).length < fields.length
|
{Object.keys(value).length < fields.length
|
||||||
? (
|
? (
|
||||||
<Dropdown overlay={
|
<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
|
{fields
|
||||||
.filter(field => !(field.name in value))
|
.filter(field => !(field.name in value))
|
||||||
.map(field => (
|
.map(field => (
|
||||||
|
@ -60,6 +60,21 @@ export default {
|
|||||||
name: 'executions',
|
name: 'executions',
|
||||||
target: 'executions',
|
target: 'executions',
|
||||||
title: '触发执行'
|
title: '触发执行'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'boolean',
|
||||||
|
name: 'executed',
|
||||||
|
defaultValue: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'hasMany',
|
||||||
|
name: 'revisions',
|
||||||
|
target: 'workflows',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'belongsTo',
|
||||||
|
name: 'current',
|
||||||
|
target: 'workflows'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
} as CollectionOptions;
|
} as CollectionOptions;
|
||||||
|
@ -12,7 +12,7 @@ export default {
|
|||||||
const options = execution.getParsedValue(params);
|
const options = execution.getParsedValue(params);
|
||||||
const result = await repo.create({
|
const result = await repo.create({
|
||||||
...options,
|
...options,
|
||||||
transaction: execution.transaction
|
transaction: execution.tx
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -12,7 +12,7 @@ export default {
|
|||||||
const options = execution.getParsedValue(params);
|
const options = execution.getParsedValue(params);
|
||||||
const result = await repo.destroy({
|
const result = await repo.destroy({
|
||||||
...options,
|
...options,
|
||||||
transaction: execution.transaction
|
transaction: execution.tx
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -83,7 +83,7 @@ export default {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (job.status === JOB_STATUS.PENDING) {
|
if (job.status === JOB_STATUS.PENDING) {
|
||||||
await job.save({ transaction: execution.transaction });
|
await job.save({ transaction: execution.tx });
|
||||||
return execution.end(this, job);
|
return execution.end(this, job);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ export default {
|
|||||||
const options = execution.getParsedValue(params);
|
const options = execution.getParsedValue(params);
|
||||||
const result = await (multiple ? repo.find : repo.findOne).call(repo, {
|
const result = await (multiple ? repo.find : repo.findOne).call(repo, {
|
||||||
...options,
|
...options,
|
||||||
transaction: execution.transaction
|
transaction: execution.tx
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -13,7 +13,7 @@ export default {
|
|||||||
const options = execution.getParsedValue(params);
|
const options = execution.getParsedValue(params);
|
||||||
const result = await repo.update({
|
const result = await repo.update({
|
||||||
...options,
|
...options,
|
||||||
transaction: execution.transaction
|
transaction: execution.tx
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -21,6 +21,7 @@ export default class ExecutionModel extends Model {
|
|||||||
declare status: number;
|
declare status: number;
|
||||||
// NOTE: this duplicated column is for transaction in preparing cycle from workflow
|
// NOTE: this duplicated column is for transaction in preparing cycle from workflow
|
||||||
declare useTransaction: boolean;
|
declare useTransaction: boolean;
|
||||||
|
declare transaction: string;
|
||||||
|
|
||||||
declare createdAt: Date;
|
declare createdAt: Date;
|
||||||
declare updatedAt: Date;
|
declare updatedAt: Date;
|
||||||
@ -32,7 +33,8 @@ export default class ExecutionModel extends Model {
|
|||||||
declare getJobs: HasManyGetAssociationsMixin<JobModel>;
|
declare getJobs: HasManyGetAssociationsMixin<JobModel>;
|
||||||
|
|
||||||
options: ExecutionOptions;
|
options: ExecutionOptions;
|
||||||
transaction: Transaction;
|
|
||||||
|
tx: Transaction;
|
||||||
|
|
||||||
nodes: Array<FlowNodeModel> = [];
|
nodes: Array<FlowNodeModel> = [];
|
||||||
nodesMap = new Map<number, FlowNodeModel>();
|
nodesMap = new Map<number, FlowNodeModel>();
|
||||||
@ -98,7 +100,7 @@ export default class ExecutionModel extends Model {
|
|||||||
async prepare(options, commit = false) {
|
async prepare(options, commit = false) {
|
||||||
this.options = options || {};
|
this.options = options || {};
|
||||||
const transaction = await this.getTransaction();
|
const transaction = await this.getTransaction();
|
||||||
this.transaction = transaction;
|
this.tx = transaction;
|
||||||
|
|
||||||
if (!this.workflow) {
|
if (!this.workflow) {
|
||||||
this.workflow = await this.getWorkflow({ transaction });
|
this.workflow = await this.getWorkflow({ transaction });
|
||||||
@ -146,8 +148,8 @@ export default class ExecutionModel extends Model {
|
|||||||
|
|
||||||
private async commit() {
|
private async commit() {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
if (this.transaction && (!this.options.transaction || this.options.transaction.finished)) {
|
if (this.tx && (!this.options.transaction || this.options.transaction.finished)) {
|
||||||
await this.transaction.commit();
|
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
|
// TODO(optimize): many checking of resuming or new could be improved
|
||||||
// could be implemented separately in exec() / resume()
|
// could be implemented separately in exec() / resume()
|
||||||
if (job instanceof Model) {
|
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 {
|
} else {
|
||||||
const upstreamId = prevJob instanceof Model ? prevJob.get('id') : null;
|
const upstreamId = prevJob instanceof Model ? prevJob.get('id') : null;
|
||||||
savedJob = await this.saveJob({
|
savedJob = await this.saveJob({
|
||||||
@ -230,7 +232,7 @@ export default class ExecutionModel extends Model {
|
|||||||
|
|
||||||
async exit(job: JobModel | null) {
|
async exit(job: JobModel | null) {
|
||||||
const status = job ? ExecutionModel.StatusMap[job.status] : EXECUTION_STATUS.RESOLVED;
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,7 +245,7 @@ export default class ExecutionModel extends Model {
|
|||||||
...payload,
|
...payload,
|
||||||
executionId: this.id,
|
executionId: this.id,
|
||||||
},
|
},
|
||||||
{ transaction: this.transaction },
|
{ transaction: this.tx },
|
||||||
)) as unknown as [JobModel, boolean | null];
|
)) as unknown as [JobModel, boolean | null];
|
||||||
this.jobsMap.set(job.id, job);
|
this.jobsMap.set(job.id, job);
|
||||||
this.jobsMapByNodeId[job.nodeId] = job.result;
|
this.jobsMapByNodeId[job.nodeId] = job.result;
|
||||||
|
Loading…
Reference in New Issue
Block a user