Skip to content

TaskView is a self-hosted project and task management platform focused on clarity, ownership, and control. TaskView is built for teams that want a transparent, self-hosted alternative to SaaS task managers.

fix: confirm closing

Nikolai Giman6f8e01b44608
diff --git a/api/src/tv-modules/sprints/SprintsManager.ts b/api/src/tv-modules/sprints/SprintsManager.ts
index 58e14c8..37c0a10 100644
--- a/api/src/tv-modules/sprints/SprintsManager.ts
+++ b/api/src/tv-modules/sprints/SprintsManager.ts
@@ -172,9 +172,9 @@ export class SprintsManager {
async deleteSprint(sprintId: number): Promise<SprintResult<true>> {
const sprint = await this.repository.getById(sprintId);
if (!sprint) return fail('not_found');
- if (sprint.status !== 'draft' && sprint.status !== 'planned') {
- return fail('conflict', 'only draft or planned sprints can be deleted; close active sprints first');
- }
+ // A sprint of any status can be deleted (including completed) — useful for
+ // cleaning up an accidentally closed sprint. The DB FK sets tasks.sprint_id
+ // to NULL (tasks return to the backlog) and cascades outcomes/retros/capacity.
const deleted = await this.repository.delete(sprintId);
if (!deleted) return fail('invalid_state');
eventBus.emit('sprint.deleted', { sprintId, goalId: sprint.goalId, initiatorId: this.initiatorId });
diff --git a/taskview-packages/taskview-api/src/api/__tests__/sprints.test.ts b/taskview-packages/taskview-api/src/api/__tests__/sprints.test.ts
index 0be8f05..4fd4d4d 100644
--- a/taskview-packages/taskview-api/src/api/__tests__/sprints.test.ts
+++ b/taskview-packages/taskview-api/src/api/__tests__/sprints.test.ts
@@ -206,12 +206,15 @@ describe('Sprints', () => {
expect(conflict).toBeFalsy()
})
- it('rejects deleting an active sprint', async () => {
+ it('deletes a sprint of any status, including active', async () => {
const id = await createPlanned()
await $api.sprints.activate(id)
- const result = await $api.sprints.remove(id).catch(() => null)
- expect(result).toBeFalsy()
+ const result = await $api.sprints.remove(id).catch(console.error)
+ expect(result).toBe(true)
+
+ const gone = await $api.sprints.getById(id).catch(() => null)
+ expect(gone).toBeNull()
})
it('pauses and resumes an active sprint', async () => {
@@ -277,7 +280,7 @@ describe('Sprints', () => {
expect(result).toBeFalsy()
})
- it('treats a completed sprint as read-only and undeletable', async () => {
+ it('treats a completed sprint as read-only but still deletable', async () => {
const id = await createPlanned()
await $api.sprints.activate(id)
await $api.sprints.startReview(id)
@@ -286,8 +289,12 @@ describe('Sprints', () => {
const update = await $api.sprints.update({ sprintId: id, name: 'nope' }).catch(() => null)
expect(update).toBeFalsy()
- const remove = await $api.sprints.remove(id).catch(() => null)
- expect(remove).toBeFalsy()
+ // A completed sprint can be deleted (e.g. to undo an accidental close).
+ const remove = await $api.sprints.remove(id).catch(console.error)
+ expect(remove).toBe(true)
+
+ const gone = await $api.sprints.getById(id).catch(() => null)
+ expect(gone).toBeNull()
})
})
diff --git a/web/src/components/features/sprints/parts/SprintReviewDialog.vue b/web/src/components/features/sprints/parts/SprintReviewDialog.vue
index 04ef737..8141613 100644
--- a/web/src/components/features/sprints/parts/SprintReviewDialog.vue
+++ b/web/src/components/features/sprints/parts/SprintReviewDialog.vue
@@ -25,6 +25,14 @@
{{ t('sprints.review.hint') }}
</p>
+ <UAlert
+ icon="i-lucide-triangle-alert"
+ color="warning"
+ variant="subtle"
+ :title="t('sprints.review.warningTitle')"
+ :description="t('sprints.review.warning')"
+ />
+
<p
v-if="!tasks.length"
class="py-4 text-center text-sm text-dimmed"
@@ -109,7 +117,43 @@
:label="t('sprints.actions.close')"
color="primary"
:loading="loading"
- @click="submit"
+ @click="confirmOpen = true"
+ />
+ </div>
+ </template>
+ </UCard>
+ </template>
+ </UModal>
+
+ <UModal
+ v-model:open="confirmOpen"
+ :fullscreen="isMobile"
+ >
+ <template #content>
+ <UCard>
+ <template #header>
+ <h3 class="font-semibold">
+ {{ t('sprints.review.confirmTitle') }}
+ </h3>
+ </template>
+
+ <p class="text-sm text-muted">
+ {{ t('sprints.review.confirmMessage') }}
+ </p>
+
+ <template #footer>
+ <div class="flex justify-end gap-2">
+ <UButton
+ :label="t('common.no')"
+ color="neutral"
+ variant="ghost"
+ @click="confirmOpen = false"
+ />
+ <UButton
+ :label="t('common.yes')"
+ color="primary"
+ :loading="loading"
+ @click="performClose"
/>
</div>
</template>
@@ -149,6 +193,7 @@ const { formatPoints, toNumber, unitLabel } = useSprintFormat()
const unit = computed(() => goalsStore.goalMap.get(props.sprint.goalId)?.estimateUnit ?? 'points')
const loading = ref(false)
+const confirmOpen = ref(false)
const goalAchieved = ref(false)
const outcomes = ref<Record<number, SprintOutcome>>({})
// Target sprint per carried-over task. The BACKLOG sentinel (0) means "no sprint"
@@ -193,7 +238,7 @@ watch(open, (value) => {
}
})
-async function submit() {
+async function performClose() {
loading.value = true
try {
// Lifecycle is active -> review -> completed. If review hasn't been started
@@ -230,6 +275,9 @@ async function submit() {
}
} finally {
loading.value = false
+ // The confirm step is consumed either way: on success both dialogs close,
+ // on failure the toast is shown and the user stays in the review dialog.
+ confirmOpen.value = false
}
}
</script>
diff --git a/web/src/locales/en.ts b/web/src/locales/en.ts
index afcf4d0..d1bcac2 100644
--- a/web/src/locales/en.ts
+++ b/web/src/locales/en.ts
@@ -880,6 +880,10 @@ export default {
goalAchieved: 'Sprint goal achieved',
carryTo: 'Carry over to',
backlogOption: 'Backlog',
+ warningTitle: 'This finalizes the sprint',
+ warning: 'Once closed, the sprint is marked completed and counts toward velocity. Unfinished tasks are carried over or dropped per the choices below.',
+ confirmTitle: 'Close this sprint?',
+ confirmMessage: 'The sprint will be marked completed and its tasks moved according to the chosen outcomes. Continue?',
},
outcomes: {
accepted: 'Accepted',
diff --git a/web/src/locales/ru.ts b/web/src/locales/ru.ts
index f58146a..9900b08 100644
--- a/web/src/locales/ru.ts
+++ b/web/src/locales/ru.ts
@@ -813,6 +813,10 @@ export default {
goalAchieved: 'Цель спринта достигнута',
carryTo: 'Перенести в',
backlogOption: 'Бэклог',
+ warningTitle: 'Это завершает спринт',
+ warning: 'После закрытия спринт станет завершённым и попадёт в velocity. Незавершённые задачи будут перенесены или убраны согласно выбору ниже.',
+ confirmTitle: 'Закрыть этот спринт?',
+ confirmMessage: 'Спринт станет завершённым, а его задачи будут перемещены согласно выбранным исходам. Продолжить?',
},
outcomes: {
accepted: 'Принято',
diff --git a/web/src/pages/user/sprints.vue b/web/src/pages/user/sprints.vue
index 5c5ce01..914176b 100644
--- a/web/src/pages/user/sprints.vue
+++ b/web/src/pages/user/sprints.vue
@@ -135,20 +135,22 @@
</div>
<div class="flex items-center gap-2">
<span class="text-sm text-dimmed">{{ formatRange(sprint) }}</span>
- <template v-if="canManage && (sprint.status === 'draft' || sprint.status === 'planned')">
- <UButton
- icon="i-lucide-play"
- :label="t('sprints.actions.activate')"
- size="xs"
- @click.stop="activate(sprint)"
- />
- <UButton
- icon="i-lucide-pencil"
- color="neutral"
- variant="ghost"
- size="xs"
- @click.stop="openEdit(sprint)"
- />
+ <template v-if="canManage">
+ <template v-if="sprint.status === 'draft' || sprint.status === 'planned'">
+ <UButton
+ icon="i-lucide-play"
+ :label="t('sprints.actions.activate')"
+ size="xs"
+ @click.stop="activate(sprint)"
+ />
+ <UButton
+ icon="i-lucide-pencil"
+ color="neutral"
+ variant="ghost"
+ size="xs"
+ @click.stop="openEdit(sprint)"
+ />
+ </template>
<UButton
icon="i-lucide-trash-2"
color="error"