Skip to content

No template-level deactivation: templates can only be started or fully deleted #10

Description

@fantasywind

Context

An admin screen needs to take an approval template out of service: no new instances may be started from it, while instances already in flight finish on the workflow snapshot they were submitted with.

Current behaviour

TemplateService exposes activate / deactivate / delete for categories only:

activateApprovalTemplateCategory(id)
deactivateApprovalTemplateCategory(id)
deleteApprovalTemplateCategory(id)

For templates themselves there is no equivalent. ApprovalTemplateEntity has a deletedAt column but no service method sets it, and there is no isActive / status field. listApprovalTemplates({ status }) filters by ApprovalTemplateListStatusEnum (DRAFT / PUBLISHED), which is derived from version state rather than from an explicit lifecycle flag.

Why this matters

The only host-side approximations are both lossy:

  • Archive the published version. Blocks submission, but the version history now reads as if the template were never in service, and re-activating means republishing — which produces a new version number for a change that was purely administrative.
  • Keep a separate "deactivated template" list in the host. Works, but it is a second source of truth for template lifecycle sitting outside the library that owns templates.

Suggested fix

Add an explicit lifecycle flag on the template plus the two service methods:

deactivateApprovalTemplate(id: string): Promise<ApprovalTemplateEntity>;
activateApprovalTemplate(id: string): Promise<ApprovalTemplateEntity>;

with submitApprovalInstance rejecting a deactivated template, and in-flight instances unaffected (they already run from workflowSnapshot).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions