Set statuses on workflows (#6792)

Add listener to keep status on workflows up to date:
- version draft => statuses should contain draft
- version active => statuses should contain active
- version deactivated => if no version active, statuses should contain
deactivated

Renaming also the endpoints because it was not reflecting the full
behaviour.

Finally, adding a new status Archived for versions. Will be used when a
version is deactivated, but is not the last published version anymore.
It means this version cannot be re-activated.
This commit is contained in:
Thomas Trompette
2024-08-30 18:06:04 +02:00
committed by GitHub
parent f7c99ddc7a
commit a3ea0acd1a
15 changed files with 1010 additions and 92 deletions

View File

@ -28,9 +28,10 @@ export enum WorkflowVersionStatus {
DRAFT = 'DRAFT',
ACTIVE = 'ACTIVE',
DEACTIVATED = 'DEACTIVATED',
ARCHIVED = 'ARCHIVED',
}
export const WorkflowVersionStatusOptions = [
const WorkflowVersionStatusOptions = [
{
value: WorkflowVersionStatus.DRAFT,
label: 'Draft',
@ -47,7 +48,13 @@ export const WorkflowVersionStatusOptions = [
value: WorkflowVersionStatus.DEACTIVATED,
label: 'Deactivated',
position: 2,
color: 'gray',
color: 'red',
},
{
value: WorkflowVersionStatus.ARCHIVED,
label: 'Archived',
position: 3,
color: 'grey',
},
];

View File

@ -18,11 +18,34 @@ import { STANDARD_OBJECT_IDS } from 'src/engine/workspace-manager/workspace-sync
import { FavoriteWorkspaceEntity } from 'src/modules/favorite/standard-objects/favorite.workspace-entity';
import { WorkflowEventListenerWorkspaceEntity } from 'src/modules/workflow/common/standard-objects/workflow-event-listener.workspace-entity';
import { WorkflowRunWorkspaceEntity } from 'src/modules/workflow/common/standard-objects/workflow-run.workspace-entity';
import {
WorkflowVersionStatus,
WorkflowVersionStatusOptions,
WorkflowVersionWorkspaceEntity,
} from 'src/modules/workflow/common/standard-objects/workflow-version.workspace-entity';
import { WorkflowVersionWorkspaceEntity } from 'src/modules/workflow/common/standard-objects/workflow-version.workspace-entity';
export enum WorkflowStatus {
DRAFT = 'DRAFT',
ACTIVE = 'ACTIVE',
DEACTIVATED = 'DEACTIVATED',
}
const WorkflowStatusOptions = [
{
value: WorkflowStatus.DRAFT,
label: 'Draft',
position: 0,
color: 'yellow',
},
{
value: WorkflowStatus.ACTIVE,
label: 'Active',
position: 1,
color: 'green',
},
{
value: WorkflowStatus.DEACTIVATED,
label: 'Deactivated',
position: 2,
color: 'grey',
},
];
@WorkspaceEntity({
standardId: STANDARD_OBJECT_IDS.workflow,
@ -61,10 +84,10 @@ export class WorkflowWorkspaceEntity extends BaseWorkspaceEntity {
type: FieldMetadataType.MULTI_SELECT,
label: 'Statuses',
description: 'The current statuses of the workflow versions',
options: WorkflowVersionStatusOptions,
options: WorkflowStatusOptions,
})
@WorkspaceIsNullable()
statuses: WorkflowVersionStatus[] | null;
statuses: WorkflowStatus[] | null;
@WorkspaceField({
standardId: WORKFLOW_STANDARD_FIELD_IDS.position,