* feat(user-settings): voeg IdeasListPrefs schema toe met filterStatuses Nieuw IdeasListPrefs-subschema met filterStatuses (array van IdeaStatusApi-waarden), ingehangen als views.ideasList in ViewsPrefs. Testdekking voor geldig, ongeldig en leeg filterStatuses. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * refactor: extraheer MultiFilterPills naar backlog-filter-popover Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(ideas): voeg IdeasFilterPopover component toe Nieuwe client-component met multi-select statusfilter popover voor het Ideeënscherm; hergebruikt MultiFilterPills uit backlog-filter-popover. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(ideas): vervang inline statuschips door IdeasFilterPopover met user-settings persistentie Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * test(ideas): voeg componenttests toe voor IdeasFilterPopover en persistentie Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(ideas): voeg activeProductId-prop toe aan IdeaList IdeaListProps uitgebreid met activeProductId: string | null. Create-form initialiseert en reset naar het actieve product na aanmaken. Tests en page.tsx bijgewerkt (page.tsx krijgt echte waarde in volgende taak). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(ideas): resolve active_product_id en geef door aan IdeaList Haalt active_product_id op via prisma.user.findUnique en resolveert het tegen de al opgehaalde toegankelijke productenlijst (AC4). Geeft het resultaat als prop door aan IdeaList in plaats van hardcoded null. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(ideas): stuur activeProductId mee bij snel idee aanmaken Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * test(ideas): voeg component-tests toe voor activeProductId-voorvulling AC1: "Nieuw idee"-select voorgevuld met activeProductId AC2: "Nieuw idee"-select leeg bij activeProductId=null AC3: "Snel idee" stuurt product_id=activeProductId mee bij createIdeaAction Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(notifications): toon textarea altijd in answer-modal naast opties Vervang opties-XOR-textarea door twee onafhankelijke blokken: opties alleen wanneer aanwezig, vrij tekstveld altijd zichtbaar. Bij opties een visuele scheiding (border-t) en label 'Of typ een eigen antwoord'. Verstuur-knop nu altijd in footer zichtbaar (was verborgen bij opties). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * refactor(notifications): gebruik question.options?.length als conditie Gebruik de kortere optional chaining variant consistent, conform plan. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * test(notifications): voeg component-tests toe voor AnswerModal Dekt: optieknoppen + textarea + Verstuur zichtbaar met opties, submit via optieknop, submit via vrij tekstveld, disabled Verstuur bij leeg veld, en demo-modus (textarea + Verstuur disabled). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * docs(notifications): werk answer-modal spec bij voor vrije tekstveld naast opties Beschrijft dat textarea + Verstuur altijd zichtbaar zijn in multiple-choice mode. Corrigeert de Cmd/Ctrl+Enter-bullet: shortcut werkt nu ook daar. Bijgewerkt naar 2026-05-15. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
128 lines
4.1 KiB
TypeScript
128 lines
4.1 KiB
TypeScript
import { z } from 'zod'
|
|
import { JOBS_TIME_FILTER_VALUES } from '@/lib/jobs-time-filter'
|
|
import { IDEA_STATUS_API_VALUES, type IdeaStatusApi } from '@/lib/idea-status'
|
|
|
|
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 JobsViewPrefs = z.object({
|
|
timeFilter: z.enum(JOBS_TIME_FILTER_VALUES).optional(),
|
|
}).strict()
|
|
|
|
const IdeasListPrefs = z.object({
|
|
filterStatuses: z.array(
|
|
z.enum(IDEA_STATUS_API_VALUES as [IdeaStatusApi, ...IdeaStatusApi[]])
|
|
).optional(),
|
|
}).strict()
|
|
|
|
const ViewsPrefs = z.object({
|
|
sprintBacklog: SprintBacklogPrefs.optional(),
|
|
pbiList: PbiListPrefs.optional(),
|
|
storyPanel: StoryPanelPrefs.optional(),
|
|
jobsColumns: z.record(z.string(), JobsColumnPrefs).optional(),
|
|
jobs: JobsViewPrefs.optional(),
|
|
ideasList: IdeasListPrefs.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(),
|
|
activePbis: z.record(z.string(), z.string().nullable()).optional(),
|
|
activeStories: 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
|
|
}
|