feat: per-project workflow settings, statistics and "my work" home
Per-project settings (owners/admins, «Configuración» tab):
- Statuses with category (TODO, IN_PROGRESS, QA, DONE, CANCELLED), colour and
"requires reason"; configurable transitions; ticket types (icon, colour) and
areas. Defaults are the previous fixed values; projects created before keep
them without migration.
- Values are archived, never deleted: tickets, history and statistics keep
referring to them. Validated in the domain (ProjectSettingsChangedEvent).
- Releases, board, tracking and "my work" use categories, so custom statuses
keep working. Status changes carry name/category metadata for history.
- GraphQL: status/type/area are strings (breaking for clients sending enum
literals); Project.settings, updateProjectSettings, statusCategory,
myIssues(categories). REST: PUT /projects/{project}/settings, category filters.
- Read model: statusCategory on issues (backfilled at startup).
Statistics («Estadísticas» tab):
- New issue_timeline projection; pure functions compute created vs resolved,
cumulative flow, cycle/lead time (avg + p85), throughput per person, QA
pass/fail and release burnup. GraphQL Project.analytics(days),
Release.burnup; REST /projects/{project}/analytics, /releases/{id}/burnup.
- Web: SVG charts with validated light/dark palette, crosshair tooltip,
keyboard navigation, legend and data table.
Home "Mi trabajo": my open tickets across projects grouped by category (QA
failures first), tickets waiting for QA, upcoming releases and "Ir a…".
Tests: domain/application specs, e2e scenario for settings and analytics,
facade tests. Docs, READMEs, schema.gql/openapi.json and Word/PDF updated.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -8,8 +8,15 @@ import { ProjectCreatedEvent } from '../events/project-created.event';
|
||||
import { ProjectMemberAddedEvent } from '../events/project-member-added.event';
|
||||
import { ProjectMemberRemovedEvent } from '../events/project-member-removed.event';
|
||||
import { ProjectMemberRoleChangedEvent } from '../events/project-member-role-changed.event';
|
||||
import { ProjectSettingsChangedEvent } from '../events/project-settings-changed.event';
|
||||
import { ProjectUpdatedEvent } from '../events/project-updated.event';
|
||||
import { ProjectRole } from './project-role';
|
||||
import {
|
||||
defaultProjectSettings,
|
||||
ProjectSettings,
|
||||
ProjectWorkflow,
|
||||
validateProjectSettings,
|
||||
} from './project-settings';
|
||||
|
||||
export interface ProjectMember {
|
||||
userId: string;
|
||||
@@ -24,6 +31,8 @@ export interface ProjectProps {
|
||||
description: string | null;
|
||||
ownerId: string;
|
||||
members: ProjectMember[];
|
||||
/** Absent in projects created before settings existed: defaults apply. */
|
||||
settings?: ProjectSettings;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
@@ -38,6 +47,7 @@ export class Project extends VersionedAggregateRoot implements ProjectProps {
|
||||
public description: string | null = null;
|
||||
public ownerId!: string;
|
||||
public members: ProjectMember[] = [];
|
||||
public settings: ProjectSettings = defaultProjectSettings();
|
||||
public createdAt!: string;
|
||||
public updatedAt!: string;
|
||||
|
||||
@@ -46,6 +56,11 @@ export class Project extends VersionedAggregateRoot implements ProjectProps {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/** Statuses, transitions, types and areas of this project. */
|
||||
get workflow(): ProjectWorkflow {
|
||||
return new ProjectWorkflow(this.settings);
|
||||
}
|
||||
|
||||
roleOf(userId: string): ProjectRole | null {
|
||||
return this.members.find((m) => m.userId === userId)?.role ?? null;
|
||||
}
|
||||
@@ -98,6 +113,14 @@ export class Project extends VersionedAggregateRoot implements ProjectProps {
|
||||
this.apply(new ProjectUpdatedEvent(actorId, this.id, patch));
|
||||
}
|
||||
|
||||
/** Owners and admins customise statuses, transitions, types and areas. */
|
||||
updateSettings(actorId: string, next: ProjectSettings): void {
|
||||
this.assertCanManage(actorId);
|
||||
const settings = validateProjectSettings(next, this.settings);
|
||||
if (JSON.stringify(settings) === JSON.stringify(this.settings)) return;
|
||||
this.apply(new ProjectSettingsChangedEvent(actorId, this.id, settings));
|
||||
}
|
||||
|
||||
addMember(actorId: string, userId: string, role: ProjectRole): void {
|
||||
this.assertCanManage(actorId);
|
||||
assertThat(role !== ProjectRole.OWNER, 'A project can only have one owner');
|
||||
@@ -154,6 +177,9 @@ export class Project extends VersionedAggregateRoot implements ProjectProps {
|
||||
this.description = project.description;
|
||||
this.ownerId = project.ownerId;
|
||||
this.members = project.members.map((m) => ({ ...m }));
|
||||
this.settings = structuredClone(
|
||||
project.settings ?? defaultProjectSettings(),
|
||||
);
|
||||
this.createdAt = project.createdAt;
|
||||
this.updatedAt = project.updatedAt;
|
||||
}
|
||||
@@ -163,6 +189,11 @@ export class Project extends VersionedAggregateRoot implements ProjectProps {
|
||||
this.updatedAt = event.occurredAt;
|
||||
}
|
||||
|
||||
onProjectSettingsChangedEvent(event: ProjectSettingsChangedEvent): void {
|
||||
this.settings = structuredClone(event.settings);
|
||||
this.updatedAt = event.occurredAt;
|
||||
}
|
||||
|
||||
onProjectMemberAddedEvent(event: ProjectMemberAddedEvent): void {
|
||||
this.members = [
|
||||
...this.members,
|
||||
|
||||
Reference in New Issue
Block a user