feat: a trash for tickets

Deleting a ticket now sends it to the trash, for whoever opened it or an
admin: it disappears from boards, searches and statistics, cannot change,
and comes back from the ticket page or the trash page for 30 days. After
that it is deleted for good with the usual cascade.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-08 18:47:30 +02:00
parent 71b807b94b
commit bec39da46d
49 changed files with 1671 additions and 9 deletions

View File

@@ -309,6 +309,13 @@ export class IssueDto {
})
rank!: string;
@ApiProperty({ type: [ChecklistItemDto] }) checklist!: ChecklistItemDto[];
@ApiProperty({
type: String,
nullable: true,
format: 'date-time',
description: 'In the trash since then; null when it is not',
})
trashedAt!: string | null;
@ApiProperty({
type: [DevLinkDto],
description: 'Commits, branches and pull requests that mention it',

View File

@@ -311,6 +311,47 @@ export class IssuesController {
);
}
@Delete('issues/:issue')
@ISSUE
@ApiOperation({
summary: 'Move the ticket to the trash',
description:
'Whoever opened it, or an owner/admin. Hidden everywhere; restore it within 30 days or it is deleted for good.',
})
@ApiOkResponse({ type: CommandResultDto })
@ApiCommandErrors()
async trash(@CurrentUser() me: User, @Param('issue') issue: string) {
return this.issues.trash(me.id, await this.refs.issueId(me.id, issue));
}
@Post('issues/:issue/restore')
@HttpCode(200)
@ISSUE
@ApiOperation({ summary: 'Bring the ticket back from the trash' })
@ApiOkResponse({ type: CommandResultDto })
@ApiCommandErrors()
async restore(@CurrentUser() me: User, @Param('issue') issue: string) {
return this.issues.restore(me.id, await this.refs.issueId(me.id, issue));
}
@Get('projects/:project/trash')
@ApiOptionalPireonAuth()
@PROJECT
@ApiOperation({ summary: "The project's tickets in the trash, newest first" })
@ApiOkResponse({ type: [IssueDto] })
@ApiReadErrors()
async trashed(
@CurrentUser() me: User | undefined,
@Param('project') project: string,
) {
return this.refs.issueDtos(
await this.issues.trashed(
viewerOf(me),
await this.refs.projectId(viewerOf(me), project),
),
);
}
@Post('issues/bulk')
@HttpCode(200)
@ApiOperation({