Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set statuses on workflows #60

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ export class WorkflowTriggerResolver {
) {}

@Mutation(() => Boolean)
async enableWorkflowTrigger(
async activateWorkflowVersion(
@Args('workflowVersionId') workflowVersionId: string,
) {
return await this.workflowTriggerWorkspaceService.enableWorkflowTrigger(
return await this.workflowTriggerWorkspaceService.activateWorkflowVersion(
workflowVersionId,
);
}

@Mutation(() => Boolean)
async disableWorkflowTrigger(
async deactivateWorkflowVersion(
@Args('workflowVersionId') workflowVersionId: string,
) {
return await this.workflowTriggerWorkspaceService.disableWorkflowTrigger(
return await this.workflowTriggerWorkspaceService.deactivateWorkflowVersion(
workflowVersionId,
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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',
},
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,36 @@ import { WorkflowEventListenerWorkspaceEntity } from 'src/modules/workflow/commo
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';

export enum WorkflowStatus {
DRAFT = 'DRAFT',
ACTIVE = 'ACTIVE',
DEACTIVATED = 'DEACTIVATED',
}

const WorkflowStatusOptions = [
{
value: WorkflowVersionStatus.DRAFT,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: WorkflowVersionStatus is used here instead of WorkflowStatus

Suggested change
value: WorkflowVersionStatus.DRAFT,
value: WorkflowStatus.DRAFT,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Using WorkflowVersionStatus.DRAFT instead of WorkflowStatus.DRAFT will cause type mismatch errors

Suggested change
value: WorkflowVersionStatus.DRAFT,
value: WorkflowStatus.DRAFT,

label: 'Draft',
position: 0,
color: 'yellow',
},
{
value: WorkflowVersionStatus.ACTIVE,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: WorkflowVersionStatus is used here instead of WorkflowStatus

Suggested change
value: WorkflowVersionStatus.ACTIVE,
value: WorkflowStatus.ACTIVE,

label: 'Active',
position: 1,
color: 'green',
},
{
value: WorkflowVersionStatus.DEACTIVATED,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: WorkflowVersionStatus is used here instead of WorkflowStatus

Suggested change
value: WorkflowVersionStatus.DEACTIVATED,
value: WorkflowStatus.DEACTIVATED,

label: 'Deactivated',
position: 2,
color: 'grey',
},
];

@WorkspaceEntity({
standardId: STANDARD_OBJECT_IDS.workflow,
namePlural: 'workflows',
Expand Down Expand Up @@ -61,10 +87,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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ export class WorkflowCommonWorkspaceService {
},
});

return this.getValidWorkflowVersionOrFail(workflowVersion);
}

async getValidWorkflowVersionOrFail(
workflowVersion: WorkflowVersionWorkspaceEntity | null,
): Promise<
Omit<WorkflowVersionWorkspaceEntity, 'trigger'> & {
trigger: WorkflowTrigger;
}
> {
if (!workflowVersion) {
throw new WorkflowTriggerException(
'Workflow version not found',
Expand Down
Loading