From a3fba58c797cdd6563d4485eac11fcc257ed5850 Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Mon, 2 Feb 2026 21:46:12 -0800 Subject: [PATCH] refactor: move cancellable states to module-level constant (#8570) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary Moves static data outside the `useJobActions` composable to module-level. ## Changes - **What**: Extracted `cancellableStates` array to a module-level `CANCELLABLE_STATES` constant. The `cancelAction` object remains inside the composable because it depends on `t()` for i18n reactivity. ## Review Focus This is a pure refactor with no behavior change - the constant is now allocated once per module instead of per-composable-call. Fixes #7946 ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-8570-refactor-move-cancellable-states-to-module-level-constant-2fc6d73d3650814fa1fefa172f7ace2f) by [Unito](https://www.unito.io) ## Summary by CodeRabbit * **Chores** * Internal code refactoring to improve maintainability of job cancellation logic. --- src/composables/queue/useJobActions.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/composables/queue/useJobActions.ts b/src/composables/queue/useJobActions.ts index d350503d9..4e664c4c1 100644 --- a/src/composables/queue/useJobActions.ts +++ b/src/composables/queue/useJobActions.ts @@ -13,6 +13,8 @@ export type JobAction = { variant: 'destructive' | 'secondary' | 'textonly' } +const CANCELLABLE_STATES: JobState[] = ['pending', 'initialization', 'running'] + export function useJobActions( job: MaybeRefOrGetter ) { @@ -26,8 +28,6 @@ export function useJobActions( variant: 'destructive' } - const cancellableStates: JobState[] = ['pending', 'initialization', 'running'] - const jobRef = computed(() => toValue(job) ?? null) const canCancelJob = computed(() => { @@ -38,7 +38,7 @@ export function useJobActions( return ( currentJob.showClear !== false && - cancellableStates.includes(currentJob.state) + CANCELLABLE_STATES.includes(currentJob.state) ) })