feat: archive a project instead of deleting it

The owner archives a finished project (archiveProject, POST
/projects/{project}/archive) and brings it back (unarchive). While
archived it stays readable, managers still read its rules and webhooks,
but no command changes it: contributing and managing checks refuse with
422, votes and public proposals too, and automations do not run. The web
shows a read-only notice on every page of it (with «Desarchivar» for the
owner), hides what edits, marks it on the home page and lists it last.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-15 15:46:22 +02:00
parent e598f76e1c
commit 4acf629106
42 changed files with 1057 additions and 14 deletions

View File

@@ -96,9 +96,12 @@ async function managedProject(
access: WriteAccess,
projectId: string,
actorId: string,
/** Only to read the rules: an archived project still shows them. */
reading = false,
): Promise<Project> {
const project = await access.project(projectId);
project.assertCanManage(actorId);
if (reading) project.assertManages(actorId);
else project.assertCanManage(actorId);
return project;
}
@@ -231,6 +234,7 @@ export class RunAutomationCommandHandler
? await this.access.live(issue.projectId, Project)
: null;
if (!issue || !project) return 'The ticket is gone';
if (project.archivedAt) return 'The project is archived';
const { kind, value } = command.automation.action;
const actor = SYSTEM_ACTOR_ID;
switch (kind) {
@@ -297,7 +301,7 @@ export class GetAutomationsQueryHandler
) {}
async execute(query: GetAutomationsQuery): Promise<Automation[]> {
await managedProject(this.access, query.projectId, query.viewerId);
await managedProject(this.access, query.projectId, query.viewerId, true);
return this.automations.findByProject(query.projectId);
}
}

View File

@@ -0,0 +1,19 @@
import { CommandHandler, ICommandHandler } from '@nestjs/cqrs';
import { ArchiveProjectCommand } from './archive-project.command';
import { CommandResult, ack } from './command-result';
import { WriteAccess } from './write-access';
@CommandHandler(ArchiveProjectCommand)
export class ArchiveProjectCommandHandler
implements ICommandHandler<ArchiveProjectCommand>
{
constructor(private readonly access: WriteAccess) {}
async execute(command: ArchiveProjectCommand): Promise<CommandResult> {
const project = await this.access.project(command.projectId);
if (command.archived) project.archive(command.actorId);
else project.unarchive(command.actorId);
await project.commitAndWait();
return ack(project);
}
}

View File

@@ -0,0 +1,13 @@
import { Command } from '@nestjs/cqrs';
import { CommandResult } from './command-result';
/** The owner archives the project (read-only) or, with `archived` false, brings it back. */
export class ArchiveProjectCommand extends Command<CommandResult> {
constructor(
public readonly actorId: string,
public readonly projectId: string,
public readonly archived: boolean,
) {
super();
}
}

View File

@@ -21,6 +21,7 @@ import { UpdateReleaseCommandHandler } from './update-release.command-handler';
import { PublishReleaseCommandHandler } from './publish-release.command-handler';
import { ArchiveReleaseCommandHandler } from './archive-release.command-handler';
import { DeleteProjectCommandHandler } from './delete-project.command-handler';
import { ArchiveProjectCommandHandler } from './archive-project.command-handler';
import { DeleteIssueCommandHandler } from './delete-issue.command-handler';
import { DeleteReleaseCommandHandler } from './delete-release.command-handler';
import { PurgeCommentCommandHandler } from './purge-comment.command-handler';
@@ -66,6 +67,7 @@ export const COMMAND_HANDLERS = [
PublishReleaseCommandHandler,
ArchiveReleaseCommandHandler,
DeleteProjectCommandHandler,
ArchiveProjectCommandHandler,
// Emitted by sagas only (cascades and reactions to other aggregates).
DeleteIssueCommandHandler,
DeleteReleaseCommandHandler,

View File

@@ -24,6 +24,7 @@ export class VoteIssueCommandHandler
throw new ForbiddenError(
`You are not a member of project ${project.key}`,
);
project.assertNotArchived();
if (issue.trashedAt)
throw new BusinessRuleError(`${issue.key} is in the trash`);
issue.vote(command.actorId, command.on);

View File

@@ -26,6 +26,8 @@ import {
ProjectRole,
ProjectSettingsChangedEvent,
ProjectUpdatedEvent,
ProjectArchivedEvent,
ProjectUnarchivedEvent,
ProjectWorkflow,
ReleaseArchivedEvent,
ReleaseNotesWrittenEvent,
@@ -109,6 +111,10 @@ export function describeEvent(
return `${actor} creó el proyecto ${event.project.key}`;
if (event instanceof ProjectUpdatedEvent)
return `${actor} actualizó el proyecto ${ctx.projectKey}`;
if (event instanceof ProjectArchivedEvent)
return `${actor} archivó el proyecto ${ctx.projectKey}`;
if (event instanceof ProjectUnarchivedEvent)
return `${actor} desarchivó el proyecto ${ctx.projectKey}`;
if (event instanceof ProjectSettingsChangedEvent)
return `${actor} cambió los estados, tipos o áreas del proyecto ${ctx.projectKey}`;
if (event instanceof ProjectMemberAddedEvent) {

View File

@@ -25,6 +25,8 @@ import {
ProjectMemberRemovedEvent,
ProjectMemberRoleChangedEvent,
ProjectUpdatedEvent,
ProjectArchivedEvent,
ProjectUnarchivedEvent,
ReleaseArchivedEvent,
ReleaseNotesWrittenEvent,
IssueSprintChangedEvent,
@@ -57,6 +59,8 @@ import { versionOf } from './read-model-notifier';
@EventsHandler(
ProjectCreatedEvent,
ProjectUpdatedEvent,
ProjectArchivedEvent,
ProjectUnarchivedEvent,
ProjectSettingsChangedEvent,
ProjectMemberAddedEvent,
ProjectMemberRemovedEvent,

View File

@@ -16,6 +16,7 @@ import { ProjectMemberAddedEventHandler } from './project-member-added.event-han
import { ProjectMemberRemovedEventHandler } from './project-member-removed.event-handler';
import { ProjectMemberRoleChangedEventHandler } from './project-member-role-changed.event-handler';
import { ProjectUpdatedEventHandler } from './project-updated.event-handler';
import { ProjectArchivedEventHandler } from './project-archived.event-handler';
import { ReleaseArchivedEventHandler } from './release-archived.event-handler';
import { ReleaseCreatedEventHandler } from './release-created.event-handler';
import { ReleaseShippedEventHandler } from './release-shipped.event-handler';
@@ -63,6 +64,7 @@ export const EVENT_HANDLERS = [
ProjectMemberRemovedEventHandler,
ProjectMemberRoleChangedEventHandler,
ProjectUpdatedEventHandler,
ProjectArchivedEventHandler,
ProjectSettingsChangedEventHandler,
ReleaseArchivedEventHandler,
ReleaseCreatedEventHandler,

View File

@@ -0,0 +1,28 @@
import { EventsHandler, IEventHandler } from '@nestjs/cqrs';
import {
ProjectArchivedEvent,
ProjectUnarchivedEvent,
} from '@task-stream/api/tracker/domain';
import { UpsertMaterializedProjectRepository } from '../ports/upsert-materialized-project.repository';
import { ReadModelNotifier, versionOf } from './read-model-notifier';
@EventsHandler(ProjectArchivedEvent, ProjectUnarchivedEvent)
export class ProjectArchivedEventHandler
implements IEventHandler<ProjectArchivedEvent | ProjectUnarchivedEvent>
{
constructor(
private readonly upsertMaterializedProjectRepository: UpsertMaterializedProjectRepository,
private readonly notifier: ReadModelNotifier,
) {}
async handle(event: ProjectArchivedEvent | ProjectUnarchivedEvent) {
await this.upsertMaterializedProjectRepository.upsert({
id: event.projectId,
archivedAt:
event instanceof ProjectArchivedEvent ? event.occurredAt : null,
updatedAt: event.occurredAt,
version: versionOf(event),
});
await this.notifier.project(event);
}
}

View File

@@ -29,6 +29,7 @@ import { ChangeProjectMemberRoleCommand } from './commands/change-project-member
import { CommandResult } from './commands/command-result';
import { CreateProjectCommand } from './commands/create-project.command';
import { DeleteProjectCommand } from './commands/delete-project.command';
import { ArchiveProjectCommand } from './commands/archive-project.command';
import { RemoveProjectMemberCommand } from './commands/remove-project-member.command';
import { UpdateProjectCommand } from './commands/update-project.command';
import { UpdateProjectSettingsCommand } from './commands/update-project-settings.command';
@@ -75,7 +76,7 @@ export class ProjectsService {
(await this.findProjects.findById(projectIdOrKey)) ??
(await this.findProjects.findByKey(projectIdOrKey.toUpperCase()));
if (!found?.isPublic) throw new NotFoundError('Project', projectIdOrKey);
if (!found.acceptsProposals)
if (!found.acceptsProposals || found.archivedAt)
throw new ForbiddenError(`${found.key} does not take proposals`);
const cleanTitle = title.trim();
@@ -170,7 +171,8 @@ export class ProjectsService {
automations: Automation[];
}> {
const project = await this.access.project(projectId);
project.assertCanManage(actorId);
// Copying only reads it: an archived project makes a fine template.
project.assertManages(actorId);
const automations: Automation[] = await this.queryBus.execute(
new GetAutomationsQuery(actorId, projectId),
);
@@ -241,6 +243,17 @@ export class ProjectsService {
}
/** Statuses, transitions, ticket types and areas (owners and admins). */
/** Archives the project (read-only) or brings it back; its owner only. */
setArchived(
actorId: string,
projectId: string,
archived: boolean,
): Promise<CommandResult> {
return this.commands.execute(
new ArchiveProjectCommand(actorId, projectId, archived),
);
}
updateSettings(
actorId: string,
projectId: string,

View File

@@ -327,9 +327,7 @@ export class GetWebhooksQueryHandler
) {}
async execute(query: GetWebhooksQuery): Promise<WebhookView[]> {
(await this.access.project(query.projectId)).assertCanManage(
query.viewerId,
);
(await this.access.project(query.projectId)).assertManages(query.viewerId);
return (await this.webhooks.findByProject(query.projectId)).map(view);
}
}

View File

@@ -21,6 +21,7 @@ export * from './release-updated.event';
export * from './release-shipped.event';
export * from './release-archived.event';
export * from './project-deleted.event';
export * from './project-archived.event';
export * from './issue-deleted.event';
export * from './release-deleted.event';
export * from './issue-attachment-added.event';

View File

@@ -0,0 +1,18 @@
import { AutowiredEvent } from '@task-stream/api/shared/domain';
import { TrackerEvent } from './tracker.event';
/** The owner archived the project: read-only until it is unarchived. */
@AutowiredEvent
export class ProjectArchivedEvent extends TrackerEvent {
constructor(actorId: string, projectId: string) {
super(actorId, projectId, projectId);
}
}
/** The owner brought an archived project back. */
@AutowiredEvent
export class ProjectUnarchivedEvent extends TrackerEvent {
constructor(actorId: string, projectId: string) {
super(actorId, projectId, projectId);
}
}

View File

@@ -106,4 +106,28 @@ describe('Deleting a project', () => {
).toHaveLength(2);
expect(source.links.map((l) => l.targetIssueId)).toEqual(['o']);
});
it('archives a project read-only, and only its owner brings it back', () => {
const project = newProject();
expect(() => project.archive('admin')).toThrow(ForbiddenError);
project.archive('owner');
expect(project.archivedAt).not.toBeNull();
// Idempotent.
const events = project.getUncommittedEvents().length;
project.archive('owner');
expect(project.getUncommittedEvents()).toHaveLength(events);
// Nothing changes, but who manages it can still read what only they see.
expect(() => project.assertCanContribute('admin')).toThrow(/archivado/);
expect(() => project.updateDetails('owner', { name: 'Otra' })).toThrow(
BusinessRuleError,
);
expect(() => project.assertManages('admin')).not.toThrow();
expect(() => project.unarchive('admin')).toThrow(ForbiddenError);
project.unarchive('owner');
expect(project.archivedAt).toBeNull();
expect(() => project.assertCanContribute('admin')).not.toThrow();
expect(replay(project, Project).rebuilt.archivedAt).toBeNull();
});
});

View File

@@ -4,6 +4,10 @@ import {
VersionedAggregateRoot,
assertThat,
} from '@task-stream/api/shared/domain';
import {
ProjectArchivedEvent,
ProjectUnarchivedEvent,
} from '../events/project-archived.event';
import { ProjectCreatedEvent } from '../events/project-created.event';
import { ProjectDeletedEvent } from '../events/project-deleted.event';
import { ProjectMemberAddedEvent } from '../events/project-member-added.event';
@@ -62,6 +66,8 @@ export class Project extends VersionedAggregateRoot implements ProjectProps {
public updatedAt!: string;
/** Set once deleted: the project can no longer be loaded for commands. */
public deleted = false;
/** Archived since then: read-only until its owner brings it back. */
public archivedAt: string | null = null;
constructor(id: string) {
super();
@@ -96,10 +102,20 @@ export class Project extends VersionedAggregateRoot implements ProjectProps {
if (this.roleOf(userId) === ProjectRole.VIEWER) {
throw new ForbiddenError(`Viewers cannot modify project ${this.key}`);
}
this.assertNotArchived();
}
/** Can manage members, releases and project settings. */
/** Can change members, releases, settings and rules (owners and admins). */
assertCanManage(userId: string): void {
this.assertManages(userId);
this.assertNotArchived();
}
/**
* Is an owner or an admin: enough to read what only they see (rules,
* webhooks…), archived or not. To change anything, assertCanManage.
*/
assertManages(userId: string): void {
const role = this.roleOf(userId);
if (role !== ProjectRole.OWNER && role !== ProjectRole.ADMIN) {
throw new ForbiddenError(
@@ -108,6 +124,36 @@ export class Project extends VersionedAggregateRoot implements ProjectProps {
}
}
/** An archived project only changes back to active (by its owner). */
assertNotArchived(): void {
if (this.archivedAt)
throw new BusinessRuleError(
`${this.key} está archivado: es de solo lectura hasta que su propietario lo desarchive`,
);
}
/**
* Only the owner archives a project: everything stays readable, nothing
* changes until they unarchive it. Idempotent.
*/
archive(actorId: string): void {
if (actorId !== this.ownerId)
throw new ForbiddenError(
`Only the owner can archive project ${this.key}`,
);
if (this.archivedAt) return;
this.apply(new ProjectArchivedEvent(actorId, this.id));
}
unarchive(actorId: string): void {
if (actorId !== this.ownerId)
throw new ForbiddenError(
`Only the owner can unarchive project ${this.key}`,
);
if (!this.archivedAt) return;
this.apply(new ProjectUnarchivedEvent(actorId, this.id));
}
updateDetails(
actorId: string,
changes: {
@@ -249,6 +295,14 @@ export class Project extends VersionedAggregateRoot implements ProjectProps {
this.deleted = true;
}
onProjectArchivedEvent(event: ProjectArchivedEvent): void {
this.archivedAt = event.occurredAt;
}
onProjectUnarchivedEvent(): void {
this.archivedAt = null;
}
onProjectSettingsChangedEvent(event: ProjectSettingsChangedEvent): void {
this.settings = structuredClone(event.settings);
this.updatedAt = event.occurredAt;

View File

@@ -18,6 +18,8 @@ export class ProjectReadModel {
acceptsProposals!: boolean;
owner!: UserRefReadModel;
members!: ProjectMemberReadModel[];
/** Archived since then (read-only); null while active. */
archivedAt!: string | null;
/** Statuses, transitions, ticket types and areas. */
settings!: ProjectSettings;
createdAt!: string;

View File

@@ -66,6 +66,7 @@ function toProject(doc: ProjectDoc): ProjectReadModel {
isPublic: rest.isPublic ?? false,
acceptsProposals: rest.acceptsProposals ?? false,
settings: rest.settings ?? defaultProjectSettings(),
archivedAt: rest.archivedAt ?? null,
};
}

View File

@@ -219,6 +219,27 @@ export class ProjectResolver {
return this.projects.delete(me.id, projectId, confirmKey);
}
@Mutation(() => CommandResultGql, {
description:
'Archive the project (owner only): everything stays readable, nothing changes until it is unarchived',
})
archiveProject(
@CurrentUser() me: User,
@Args('projectId', { type: () => ID }) projectId: string,
) {
return this.projects.setArchived(me.id, projectId, true);
}
@Mutation(() => CommandResultGql, {
description: 'Bring an archived project back (owner only)',
})
unarchiveProject(
@CurrentUser() me: User,
@Args('projectId', { type: () => ID }) projectId: string,
) {
return this.projects.setArchived(me.id, projectId, false);
}
@Mutation(() => CommandResultGql, {
description: 'Add a Pireon user to the project',
})

View File

@@ -137,6 +137,11 @@ export class ProjectGql {
@Field(() => UserRefGql) owner!: UserRefGql;
@Field(() => [ProjectMemberGql]) members!: ProjectMemberGql[];
@Field() createdAt!: string;
@Field(() => String, {
nullable: true,
description: 'Archived since then (read-only); null while active',
})
archivedAt!: string | null;
@Field() updatedAt!: string;
@Field(() => Int) version!: number;
}

View File

@@ -128,6 +128,13 @@ export class ProjectDto {
@ApiProperty({ type: ProjectSettingsDto })
settings!: ProjectSettingsDto;
@ApiProperty({ format: 'date-time' }) createdAt!: string;
@ApiProperty({
type: String,
nullable: true,
format: 'date-time',
description: 'Archived since then (read-only); null while active',
})
archivedAt!: string | null;
@ApiProperty({ format: 'date-time' }) updatedAt!: string;
@ApiProperty({ description: 'Version of the aggregate (event count)' })
version!: number;

View File

@@ -5,6 +5,7 @@ import {
Get,
Param,
Patch,
HttpCode,
Post,
Put,
Query,
@@ -148,6 +149,38 @@ export class ProjectsController {
);
}
@Post(':project/archive')
@HttpCode(200)
@PROJECT
@ApiOperation({
summary: 'Archive a project (owner only)',
description:
'It stays readable (board, tickets, history, statistics); nothing can change until it is unarchived.',
})
@ApiOkResponse({ type: CommandResultDto })
@ApiCommandErrors()
async archive(@CurrentUser() me: User, @Param('project') project: string) {
return this.projects.setArchived(
me.id,
await this.refs.projectId(me.id, project),
true,
);
}
@Post(':project/unarchive')
@HttpCode(200)
@PROJECT
@ApiOperation({ summary: 'Bring an archived project back (owner only)' })
@ApiOkResponse({ type: CommandResultDto })
@ApiCommandErrors()
async unarchive(@CurrentUser() me: User, @Param('project') project: string) {
return this.projects.setArchived(
me.id,
await this.refs.projectId(me.id, project),
false,
);
}
@Put(':project/settings')
@PROJECT
@ApiOperation({

View File

@@ -51,6 +51,7 @@ export const projectPageEvents = eventGroup({
analyticsRequested: type<{ projectId: string; days: number }>(),
burnupRequested: type<{ releaseId: string }>(),
visibilityChangeRequested: type<{ projectId: string; isPublic: boolean }>(),
archiveRequested: type<{ projectId: string; archived: boolean }>(),
proposalsChangeRequested: type<{
projectId: string;
acceptsProposals: boolean;

View File

@@ -162,6 +162,12 @@ export class ProjectFacade {
this.dispatch.visibilityChangeRequested({ projectId, isPublic });
}
/** Archives the project (read-only for everyone) or brings it back. Owner only. */
setArchived(archived: boolean): void {
const projectId = this.projectId();
if (projectId) this.dispatch.archiveRequested({ projectId, archived });
}
/** Take bug reports and ideas from anyone (while public). Owners and admins. */
setAcceptsProposals(acceptsProposals: boolean): void {
const projectId = this.projectId();

View File

@@ -100,11 +100,17 @@ export const ProjectStore = signalStore(
);
return {
myRole,
/** Archived projects are read-only for everyone. */
canManage: computed(
() => myRole() === ProjectRole.OWNER || myRole() === ProjectRole.ADMIN,
() =>
!project()?.archivedAt &&
(myRole() === ProjectRole.OWNER || myRole() === ProjectRole.ADMIN),
),
canContribute: computed(
() => !!myRole() && myRole() !== ProjectRole.VIEWER,
() =>
!project()?.archivedAt &&
!!myRole() &&
myRole() !== ProjectRole.VIEWER,
),
members: computed(() => project()?.members ?? []),
/** Statuses, types and areas of the project, with lookups. */
@@ -433,6 +439,20 @@ export const ProjectStore = signalStore(
),
),
),
events
.on(projectPageEvents.archiveRequested)
.pipe(
mergeMap(({ payload }) =>
runCommand(
projects.setArchived(payload.projectId, payload.archived),
payload.archived
? 'Proyecto archivado: queda en solo lectura'
: 'Proyecto desarchivado',
projectApiEvents.commandSucceeded,
projectApiEvents.commandFailed,
),
),
),
events
.on(projectPageEvents.proposalsChangeRequested)
.pipe(

View File

@@ -39,8 +39,13 @@ export const ProjectsStore = signalStore(
error: null,
}),
withComputed(({ projects }) => ({
/** By name, archived ones last. */
sorted: computed(() =>
[...projects()].sort((a, b) => a.name.localeCompare(b.name)),
[...projects()].sort(
(a, b) =>
Number(!!a.archivedAt) - Number(!!b.archivedAt) ||
a.name.localeCompare(b.name),
),
),
})),
withReducer(

View File

@@ -31,6 +31,8 @@ export interface Project {
owner: UserRef;
members: ProjectMember[];
settings: ProjectSettings;
/** Archived since then (read-only); null while active. */
archivedAt: string | null;
updatedAt: string;
version: number;
}

View File

@@ -71,6 +71,11 @@ export abstract class ProjectsGateway {
projectId: string,
since: string | null,
): Observable<ProjectInsights>;
/** Archives the project (read-only) or brings it back. Owner only. */
abstract setArchived(
projectId: string,
archived: boolean,
): Observable<CommandResult>;
/** Statistics of the last `days` days. */
abstract analytics(
projectId: string,

View File

@@ -17,6 +17,8 @@ import {
ChangeProjectMemberRoleDocument,
CreateProjectDocument,
DeleteProjectDocument,
ArchiveProjectDocument,
UnarchiveProjectDocument,
MyProjectsDocument,
ProjectAnalyticsDocument,
ProjectInsightsDocument,
@@ -102,6 +104,16 @@ export class GraphqlProjectsGateway extends ProjectsGateway {
.pipe(map((d) => toCommandResult(d.updateProject)));
}
setArchived(projectId: string, archived: boolean): Observable<CommandResult> {
return archived
? this.gql
.mutate(ArchiveProjectDocument, { projectId })
.pipe(map((d) => toCommandResult(d.archiveProject)))
: this.gql
.mutate(UnarchiveProjectDocument, { projectId })
.pipe(map((d) => toCommandResult(d.unarchiveProject)));
}
delete(projectId: string, confirmKey: string): Observable<CommandResult> {
return this.gql
.mutate(DeleteProjectDocument, { projectId, confirmKey })

View File

@@ -10,6 +10,7 @@ fragment ProjectFields on Project {
description
isPublic
acceptsProposals
archivedAt
updatedAt
version
owner {

View File

@@ -527,6 +527,7 @@ export type ProjectFieldsFragment = {
description: string | null;
isPublic: boolean;
acceptsProposals: boolean;
archivedAt: string | null;
updatedAt: string;
version: number;
owner: { id: string; name: string };
@@ -1522,6 +1523,7 @@ export type MyProjectsQuery = {
description: string | null;
isPublic: boolean;
acceptsProposals: boolean;
archivedAt: string | null;
updatedAt: string;
version: number;
owner: { id: string; name: string };
@@ -1573,6 +1575,7 @@ export type ProjectQuery = {
description: string | null;
isPublic: boolean;
acceptsProposals: boolean;
archivedAt: string | null;
updatedAt: string;
version: number;
owner: { id: string; name: string };
@@ -1734,6 +1737,7 @@ export type PublicProjectsQuery = {
description: string | null;
isPublic: boolean;
acceptsProposals: boolean;
archivedAt: string | null;
updatedAt: string;
version: number;
owner: { id: string; name: string };
@@ -1781,6 +1785,22 @@ export type UpdateProjectMutation = {
updateProject: { id: string; key: string | null; version: number };
};
export type ArchiveProjectMutationVariables = Exact<{
projectId: string;
}>;
export type ArchiveProjectMutation = {
archiveProject: { id: string; key: string | null; version: number };
};
export type UnarchiveProjectMutationVariables = Exact<{
projectId: string;
}>;
export type UnarchiveProjectMutation = {
unarchiveProject: { id: string; key: string | null; version: number };
};
export type DeleteProjectMutationVariables = Exact<{
projectId: string;
confirmKey: string;
@@ -2410,6 +2430,7 @@ export type ProjectChangedSubscription = {
description: string | null;
isPublic: boolean;
acceptsProposals: boolean;
archivedAt: string | null;
updatedAt: string;
version: number;
owner: { id: string; name: string };
@@ -2464,6 +2485,7 @@ export type MyProjectsChangedSubscription = {
description: string | null;
isPublic: boolean;
acceptsProposals: boolean;
archivedAt: string | null;
updatedAt: string;
version: number;
owner: { id: string; name: string };
@@ -2730,6 +2752,7 @@ export const ProjectFieldsFragmentDoc = {
{ kind: 'Field', name: { kind: 'Name', value: 'description' } },
{ kind: 'Field', name: { kind: 'Name', value: 'isPublic' } },
{ kind: 'Field', name: { kind: 'Name', value: 'acceptsProposals' } },
{ kind: 'Field', name: { kind: 'Name', value: 'archivedAt' } },
{ kind: 'Field', name: { kind: 'Name', value: 'updatedAt' } },
{ kind: 'Field', name: { kind: 'Name', value: 'version' } },
{
@@ -9475,6 +9498,7 @@ export const MyProjectsDocument = {
{ kind: 'Field', name: { kind: 'Name', value: 'description' } },
{ kind: 'Field', name: { kind: 'Name', value: 'isPublic' } },
{ kind: 'Field', name: { kind: 'Name', value: 'acceptsProposals' } },
{ kind: 'Field', name: { kind: 'Name', value: 'archivedAt' } },
{ kind: 'Field', name: { kind: 'Name', value: 'updatedAt' } },
{ kind: 'Field', name: { kind: 'Name', value: 'version' } },
{
@@ -9722,6 +9746,7 @@ export const ProjectDocument = {
{ kind: 'Field', name: { kind: 'Name', value: 'description' } },
{ kind: 'Field', name: { kind: 'Name', value: 'isPublic' } },
{ kind: 'Field', name: { kind: 'Name', value: 'acceptsProposals' } },
{ kind: 'Field', name: { kind: 'Name', value: 'archivedAt' } },
{ kind: 'Field', name: { kind: 'Name', value: 'updatedAt' } },
{ kind: 'Field', name: { kind: 'Name', value: 'version' } },
{
@@ -10820,6 +10845,7 @@ export const PublicProjectsDocument = {
{ kind: 'Field', name: { kind: 'Name', value: 'description' } },
{ kind: 'Field', name: { kind: 'Name', value: 'isPublic' } },
{ kind: 'Field', name: { kind: 'Name', value: 'acceptsProposals' } },
{ kind: 'Field', name: { kind: 'Name', value: 'archivedAt' } },
{ kind: 'Field', name: { kind: 'Name', value: 'updatedAt' } },
{ kind: 'Field', name: { kind: 'Name', value: 'version' } },
{
@@ -11057,6 +11083,146 @@ export const UpdateProjectDocument = {
UpdateProjectMutation,
UpdateProjectMutationVariables
>;
export const ArchiveProjectDocument = {
kind: 'Document',
definitions: [
{
kind: 'OperationDefinition',
operation: 'mutation',
name: { kind: 'Name', value: 'ArchiveProject' },
variableDefinitions: [
{
kind: 'VariableDefinition',
variable: {
kind: 'Variable',
name: { kind: 'Name', value: 'projectId' },
},
type: {
kind: 'NonNullType',
type: { kind: 'NamedType', name: { kind: 'Name', value: 'ID' } },
},
},
],
selectionSet: {
kind: 'SelectionSet',
selections: [
{
kind: 'Field',
name: { kind: 'Name', value: 'archiveProject' },
arguments: [
{
kind: 'Argument',
name: { kind: 'Name', value: 'projectId' },
value: {
kind: 'Variable',
name: { kind: 'Name', value: 'projectId' },
},
},
],
selectionSet: {
kind: 'SelectionSet',
selections: [
{
kind: 'FragmentSpread',
name: { kind: 'Name', value: 'CommandResultFields' },
},
],
},
},
],
},
},
{
kind: 'FragmentDefinition',
name: { kind: 'Name', value: 'CommandResultFields' },
typeCondition: {
kind: 'NamedType',
name: { kind: 'Name', value: 'CommandResult' },
},
selectionSet: {
kind: 'SelectionSet',
selections: [
{ kind: 'Field', name: { kind: 'Name', value: 'id' } },
{ kind: 'Field', name: { kind: 'Name', value: 'key' } },
{ kind: 'Field', name: { kind: 'Name', value: 'version' } },
],
},
},
],
} as unknown as DocumentNode<
ArchiveProjectMutation,
ArchiveProjectMutationVariables
>;
export const UnarchiveProjectDocument = {
kind: 'Document',
definitions: [
{
kind: 'OperationDefinition',
operation: 'mutation',
name: { kind: 'Name', value: 'UnarchiveProject' },
variableDefinitions: [
{
kind: 'VariableDefinition',
variable: {
kind: 'Variable',
name: { kind: 'Name', value: 'projectId' },
},
type: {
kind: 'NonNullType',
type: { kind: 'NamedType', name: { kind: 'Name', value: 'ID' } },
},
},
],
selectionSet: {
kind: 'SelectionSet',
selections: [
{
kind: 'Field',
name: { kind: 'Name', value: 'unarchiveProject' },
arguments: [
{
kind: 'Argument',
name: { kind: 'Name', value: 'projectId' },
value: {
kind: 'Variable',
name: { kind: 'Name', value: 'projectId' },
},
},
],
selectionSet: {
kind: 'SelectionSet',
selections: [
{
kind: 'FragmentSpread',
name: { kind: 'Name', value: 'CommandResultFields' },
},
],
},
},
],
},
},
{
kind: 'FragmentDefinition',
name: { kind: 'Name', value: 'CommandResultFields' },
typeCondition: {
kind: 'NamedType',
name: { kind: 'Name', value: 'CommandResult' },
},
selectionSet: {
kind: 'SelectionSet',
selections: [
{ kind: 'Field', name: { kind: 'Name', value: 'id' } },
{ kind: 'Field', name: { kind: 'Name', value: 'key' } },
{ kind: 'Field', name: { kind: 'Name', value: 'version' } },
],
},
},
],
} as unknown as DocumentNode<
UnarchiveProjectMutation,
UnarchiveProjectMutationVariables
>;
export const DeleteProjectDocument = {
kind: 'Document',
definitions: [
@@ -14206,6 +14372,7 @@ export const ProjectChangedDocument = {
{ kind: 'Field', name: { kind: 'Name', value: 'description' } },
{ kind: 'Field', name: { kind: 'Name', value: 'isPublic' } },
{ kind: 'Field', name: { kind: 'Name', value: 'acceptsProposals' } },
{ kind: 'Field', name: { kind: 'Name', value: 'archivedAt' } },
{ kind: 'Field', name: { kind: 'Name', value: 'updatedAt' } },
{ kind: 'Field', name: { kind: 'Name', value: 'version' } },
{
@@ -14440,6 +14607,7 @@ export const MyProjectsChangedDocument = {
{ kind: 'Field', name: { kind: 'Name', value: 'description' } },
{ kind: 'Field', name: { kind: 'Name', value: 'isPublic' } },
{ kind: 'Field', name: { kind: 'Name', value: 'acceptsProposals' } },
{ kind: 'Field', name: { kind: 'Name', value: 'archivedAt' } },
{ kind: 'Field', name: { kind: 'Name', value: 'updatedAt' } },
{ kind: 'Field', name: { kind: 'Name', value: 'version' } },
{

View File

@@ -139,6 +139,18 @@ mutation UpdateProject($input: UpdateProjectInput!) {
}
}
mutation ArchiveProject($projectId: ID!) {
archiveProject(projectId: $projectId) {
...CommandResultFields
}
}
mutation UnarchiveProject($projectId: ID!) {
unarchiveProject(projectId: $projectId) {
...CommandResultFields
}
}
mutation DeleteProject($projectId: ID!, $confirmKey: String!) {
deleteProject(projectId: $projectId, confirmKey: $confirmKey) {
...CommandResultFields

View File

@@ -101,12 +101,27 @@ import { projectTone, PUBLIC_TONE, ROLE } from '../ui/copy';
<a routerLink="analytics" routerLinkActive="is-active">Estadísticas</a>
<a routerLink="activity" routerLinkActive="is-active">Actividad</a>
<a routerLink="members" routerLinkActive="is-active">Miembros</a>
@if (facade.canManage()) {
@if (facade.canManage() || facade.isOwner()) {
<a routerLink="settings" routerLinkActive="is-active"
>Configuración</a
>
}
</nav>
@if (project.archivedAt) {
<p class="ts-archived" role="status">
<strong>Proyecto archivado</strong>
Se puede ver todo, pero es de solo lectura.
@if (facade.isOwner()) {
<button
type="button"
class="ts-plain-link"
(click)="facade.setArchived(false)"
>
Desarchivar
</button>
}
</p>
}
<router-outlet />
} @else if (facade.error(); as error) {
<pi-note
@@ -142,6 +157,19 @@ import { projectTone, PUBLIC_TONE, ROLE } from '../ui/copy';
}
`,
styles: `
.ts-archived {
display: flex;
align-items: baseline;
flex-wrap: wrap;
gap: 0.5rem;
margin: 0 0 1rem;
padding: 0.625rem 0.875rem;
border: 1px solid var(--ts-line);
border-radius: 0.625rem;
background: var(--ts-sunken);
color: var(--ts-ink-soft);
font-size: 0.875rem;
}
.ts-eyebrow .ts-pill {
margin-left: 0.5rem;
letter-spacing: 0;

View File

@@ -693,6 +693,32 @@ function idFrom(name: string): string {
}
@if (facade.isOwner() && facade.project(); as project) {
<section
class="ts-panel ts-block ts-visibility"
aria-labelledby="archive-title"
>
<div>
<h3 id="archive-title">Archivar el proyecto</h3>
<p class="ts-muted">
@if (project.archivedAt) {
Archivado: se puede ver todo, pero nadie puede cambiar nada
hasta que lo desarchives.
} @else {
Para un proyecto terminado: queda todo a la vista (tablero,
tickets, historia, estadísticas) y en solo lectura. Se puede
desarchivar cuando quieras.
}
</p>
</div>
<button
type="button"
class="ts-secondary"
(click)="facade.setArchived(!project.archivedAt)"
>
{{ project.archivedAt ? 'Desarchivar' : 'Archivar' }}
</button>
</section>
<section
class="ts-panel ts-block ts-danger"
aria-labelledby="danger-title"

View File

@@ -25,6 +25,9 @@ import { projectTone, PUBLIC_TONE, timeAgo } from './copy';
@if (project().isPublic) {
<span class="ts-pill" [style.--tone]="publicTone">Público</span>
}
@if (project().archivedAt) {
<span class="ts-pill">Archivado</span>
}
<span class="ts-project__updated ts-mono">{{
ago(project().updatedAt)
}}</span>