UI-laag voor de sprint-definitie-flow (state A′).
Nieuw:
- NewSprintMetadataDialog (stap 1): sprint_goal + optionele dates;
'Verder' schrijft via useUserSettingsStore.setPendingSprintDraft.
- SprintDefinitionBanner (sticky): toont doel + X PBI's / Y stories teller;
'Annuleren' → AlertDialog confirm → clearPendingSprintDraft;
'Sprint aanmaken' nog niet aangesloten (wacht op ST-1339).
- NewSprintTrigger: button in page header die de metadata-dialog opent;
verbergt zichzelf zolang er al een draft loopt.
- SprintDraftBanner: client-wrapper, rendert banner alleen als draft bestaat.
Wijzigingen:
- lib/user-settings.ts: pendingSprintDraft startAt/endAt → z.string().date().
- PbiList: oude selectionMode + selectedIds + NewSprintDialog vervangen door
hasDraft-afgeleide A′-mode met tri-state vinkjes; togglen muteert
upsertPbiIntent('all'|'none') en wist storyOverrides per PBI.
- StoryPanel: in A′-mode toont elke story een cherrypick-checkbox die
upsertStoryOverride('add'/'remove'/'clear') aanroept; cross-sprint-blocked
stories krijgen disabled-icoon met sprint-naam tooltip.
- app/(app)/products/[id]/page.tsx: StartSprintButton vervangen door
NewSprintTrigger; SprintDraftBanner gepositioneerd boven split-pane.
Tests: bestaande tests blijven groen (806 cases) — UI-specifieke component
tests volgen later. ST-1339 sluit createSprintWithSelectionAction aan.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
112 lines
3.5 KiB
TypeScript
112 lines
3.5 KiB
TypeScript
import { z } from 'zod'
|
|
|
|
const PriorityFilter = z.union([
|
|
z.number().int().min(1).max(4),
|
|
z.literal('all'),
|
|
])
|
|
|
|
const SortDir = z.enum(['asc', 'desc'])
|
|
|
|
const SprintBacklogPrefs = z.object({
|
|
filterPriority: PriorityFilter.optional(),
|
|
filterStatus: z.enum(['OPEN', 'IN_SPRINT', 'DONE', 'all']).optional(),
|
|
sort: z.enum(['priority', 'status', 'code']).optional(),
|
|
sortDir: SortDir.optional(),
|
|
collapsedPbis: z.array(z.string()).optional(),
|
|
filterPopoverOpen: z.boolean().optional(),
|
|
}).strict()
|
|
|
|
const PbiListPrefs = z.object({
|
|
sort: z.enum(['priority', 'code', 'date']).optional(),
|
|
filterPriority: PriorityFilter.optional(),
|
|
filterStatus: z.enum(['ready', 'blocked', 'done', 'all']).optional(),
|
|
sortDir: SortDir.optional(),
|
|
}).strict()
|
|
|
|
const StoryPanelPrefs = z.object({
|
|
sort: z.enum(['priority', 'code', 'date']).optional(),
|
|
}).strict()
|
|
|
|
const JobsColumnPrefs = z.object({
|
|
kinds: z.array(z.string()),
|
|
statuses: z.array(z.string()),
|
|
}).strict()
|
|
|
|
const ViewsPrefs = z.object({
|
|
sprintBacklog: SprintBacklogPrefs.optional(),
|
|
pbiList: PbiListPrefs.optional(),
|
|
storyPanel: StoryPanelPrefs.optional(),
|
|
jobsColumns: z.record(z.string(), JobsColumnPrefs).optional(),
|
|
}).strict()
|
|
|
|
const DevToolsPrefs = z.object({
|
|
debugMode: z.boolean().optional(),
|
|
}).strict()
|
|
|
|
const LayoutPrefs = z.object({
|
|
splitPanePositions: z.record(z.string(), z.array(z.number())).optional(),
|
|
activeSprints: z.record(z.string(), z.string().nullable()).optional(),
|
|
}).strict()
|
|
|
|
const PbiIntent = z.enum(['all', 'none'])
|
|
|
|
const StoryOverrides = z.object({
|
|
add: z.array(z.string()),
|
|
remove: z.array(z.string()),
|
|
}).strict()
|
|
|
|
const PendingSprintDraftSchema = z.object({
|
|
goal: z.string().min(1),
|
|
startAt: z.string().date().optional(),
|
|
endAt: z.string().date().optional(),
|
|
pbiIntent: z.record(z.string(), PbiIntent).default({}),
|
|
storyOverrides: z.record(z.string(), StoryOverrides).default({}),
|
|
}).strict()
|
|
|
|
const WorkflowPrefs = z.object({
|
|
pendingSprintDraft: z.record(z.string(), PendingSprintDraftSchema).optional(),
|
|
}).strict()
|
|
|
|
export const UserSettingsSchema = z.object({
|
|
views: ViewsPrefs.optional(),
|
|
devTools: DevToolsPrefs.optional(),
|
|
layout: LayoutPrefs.optional(),
|
|
workflow: WorkflowPrefs.optional(),
|
|
}).strict()
|
|
|
|
export type UserSettings = z.infer<typeof UserSettingsSchema>
|
|
export type PendingSprintDraft = z.infer<typeof PendingSprintDraftSchema>
|
|
export type PbiIntent = z.infer<typeof PbiIntent>
|
|
export type StoryOverrides = z.infer<typeof StoryOverrides>
|
|
|
|
export const DEFAULT_USER_SETTINGS: UserSettings = {}
|
|
|
|
function isPlainObject(value: unknown): value is Record<string, unknown> {
|
|
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
}
|
|
|
|
export function mergeSettings(
|
|
prev: UserSettings,
|
|
patch: Partial<UserSettings>,
|
|
): UserSettings {
|
|
const out: Record<string, unknown> = { ...prev }
|
|
for (const [key, patchValue] of Object.entries(patch)) {
|
|
if (patchValue === undefined) continue
|
|
const prevValue = (prev as Record<string, unknown>)[key]
|
|
if (isPlainObject(patchValue) && isPlainObject(prevValue)) {
|
|
out[key] = mergeSettings(
|
|
prevValue as UserSettings,
|
|
patchValue as Partial<UserSettings>,
|
|
)
|
|
} else {
|
|
out[key] = patchValue
|
|
}
|
|
}
|
|
return out as UserSettings
|
|
}
|
|
|
|
export function parseUserSettings(raw: unknown): UserSettings {
|
|
if (raw === null || raw === undefined) return DEFAULT_USER_SETTINGS
|
|
const result = UserSettingsSchema.safeParse(raw)
|
|
return result.success ? result.data : DEFAULT_USER_SETTINGS
|
|
}
|