diff --git a/src/contracts/route-runtime-contract.ts b/src/contracts/route-runtime-contract.ts index 495d1ac..874c479 100644 --- a/src/contracts/route-runtime-contract.ts +++ b/src/contracts/route-runtime-contract.ts @@ -14,7 +14,9 @@ export type RouteCodecId = | "TechLogExploreSearch" | "TechLogExploreKindSearch" | "TechLogSearchQuery" - | "TechLogCaseStateSearch"; + | "TechLogCaseStateSearch" + | "TechLogStudioDocumentsSearch" + | "TechLogStudioPublicationsSearch"; export type RouteRuntimeDefinition = Readonly<{ routeId: string; moduleId: string; diff --git a/src/features/tech-log/application/ports/studio-gateway.ts b/src/features/tech-log/application/ports/studio-gateway.ts index 57125e1..f2cf2dd 100644 --- a/src/features/tech-log/application/ports/studio-gateway.ts +++ b/src/features/tech-log/application/ports/studio-gateway.ts @@ -1,5 +1,6 @@ import type { CatalogPage, CreateDocumentInput, CreatePreviewCommand, DocumentPage, + RecordKind, PublicationPage, PublicationSnapshot, PublicPreview, PublishDocumentCommand, PreviewDetail, PublishResult, SaveDocumentCommand, StudioDashboard, UnpublishCommand, ValidationReport, ValidateDocumentCommand, WorkingCopy, WorkingCopyDetail, @@ -8,7 +9,12 @@ import type { export type RequestOptions = { signal?: AbortSignal }; export type IdempotentOptions = RequestOptions & { idempotencyKey: string }; export type ListDocumentsQuery = { - q?: string; kind?: "CASE" | "REFERENCE" | "QUESTION" | "PROJECT_DECISION"; + /* + 종류는 계약의 `RecordKind` 를 그대로 쓴다. 여기 손으로 적어 두었던 동안 개념과 환경 구성이 + 빠져 있었고, 작업본 목록의 종류 필터는 그 둘을 아예 고를 수 없었다 — 손으로 나열한 목록에 + 새 종류를 빠뜨리는 일이 이 저장소에서 반복됐다. + */ + q?: string; kind?: RecordKind; publicationStatus?: "NEVER_PUBLISHED" | "PUBLISHED" | "UNPUBLISHED"; nextAction?: "CONTINUE_EDITING" | "VALIDATE" | "FIX_VALIDATION" | "CREATE_PREVIEW" | "PUBLISH" | "NONE"; projectId?: string; sort?: "UPDATED_DESC" | "UPDATED_ASC" | "TITLE_ASC"; diff --git a/src/features/tech-log/contracts/tech-log-route-contract.ts b/src/features/tech-log/contracts/tech-log-route-contract.ts index c2b11fb..5388f28 100644 --- a/src/features/tech-log/contracts/tech-log-route-contract.ts +++ b/src/features/tech-log/contracts/tech-log-route-contract.ts @@ -48,13 +48,13 @@ const TECH_LOG_ROUTE_SPECS = [ defineSpec({ routeId: "TECH_LOG_PROFILE", path: "/profile", layoutGroup: "PUBLIC", paramsSchema: null, searchSchema: null, title: "프로필", navigationLabel: "프로필", navigationOrder: 40 }), defineSpec({ routeId: "TECH_LOG_SEARCH", path: "/search", layoutGroup: "PUBLIC", paramsSchema: null, searchSchema: "TechLogSearchQuery", title: "검색", navigationLabel: null, navigationOrder: null }), defineSpec({ routeId: "TECH_LOG_STUDIO_HOME", path: "/studio", layoutGroup: "STUDIO", paramsSchema: null, searchSchema: null, title: "TechLog Studio", navigationLabel: null, navigationOrder: null }), - defineSpec({ routeId: "TECH_LOG_STUDIO_DOCUMENTS", path: "/studio/documents", layoutGroup: "STUDIO", paramsSchema: null, searchSchema: null, title: "작업본", navigationLabel: "작업본", navigationOrder: 10 }), + defineSpec({ routeId: "TECH_LOG_STUDIO_DOCUMENTS", path: "/studio/documents", layoutGroup: "STUDIO", paramsSchema: null, searchSchema: "TechLogStudioDocumentsSearch", title: "작업본", navigationLabel: "작업본", navigationOrder: 10 }), defineSpec({ routeId: "TECH_LOG_STUDIO_DOCUMENT_NEW", path: "/studio/documents/new", layoutGroup: "STUDIO", paramsSchema: null, searchSchema: null, title: "새 문서", navigationLabel: "새 문서", navigationOrder: 30 }), defineSpec({ routeId: "TECH_LOG_STUDIO_DOCUMENT_EDIT", path: "/studio/documents/:id/edit", layoutGroup: "STUDIO", paramsSchema: "TechLogDocumentIdParams", searchSchema: null, title: "문서 편집", navigationLabel: null, navigationOrder: null }), defineSpec({ routeId: "TECH_LOG_STUDIO_DOCUMENT_VALIDATION", path: "/studio/documents/:id/validation", layoutGroup: "STUDIO", paramsSchema: "TechLogDocumentIdParams", searchSchema: null, title: "문서 검증", navigationLabel: null, navigationOrder: null }), defineSpec({ routeId: "TECH_LOG_STUDIO_DOCUMENT_PREVIEW", path: "/studio/documents/:id/preview", layoutGroup: "STUDIO", paramsSchema: "TechLogDocumentIdParams", searchSchema: null, title: "Public Preview", navigationLabel: null, navigationOrder: null }), defineSpec({ routeId: "TECH_LOG_STUDIO_DOCUMENT_PUBLISH", path: "/studio/documents/:id/publish", layoutGroup: "STUDIO", paramsSchema: "TechLogDocumentIdParams", searchSchema: null, title: "게시", navigationLabel: null, navigationOrder: null }), - defineSpec({ routeId: "TECH_LOG_STUDIO_PUBLICATIONS", path: "/studio/publications", layoutGroup: "STUDIO", paramsSchema: null, searchSchema: null, title: "게시 기록", navigationLabel: "게시 기록", navigationOrder: 20 }), + defineSpec({ routeId: "TECH_LOG_STUDIO_PUBLICATIONS", path: "/studio/publications", layoutGroup: "STUDIO", paramsSchema: null, searchSchema: "TechLogStudioPublicationsSearch", title: "게시 기록", navigationLabel: "게시 기록", navigationOrder: 20 }), defineSpec({ routeId: "TECH_LOG_STUDIO_PUBLICATION_PREVIEW", path: "/studio/publications/:publicationEventId/preview", layoutGroup: "STUDIO", paramsSchema: "TechLogPublicationEventIdParams", searchSchema: null, title: "게시 Snapshot", navigationLabel: null, navigationOrder: null }), defineSpec({ routeId: "TECH_LOG_STUDIO_ASSETS", path: "/studio/assets", layoutGroup: "STUDIO", paramsSchema: null, searchSchema: null, title: "Asset", navigationLabel: "Asset", navigationOrder: 45 }), defineSpec({ routeId: "TECH_LOG_STUDIO_TAXONOMY", path: "/studio/taxonomy", layoutGroup: "STUDIO", paramsSchema: null, searchSchema: null, title: "주제와 프로젝트", navigationLabel: "주제·프로젝트", navigationOrder: 40 }), @@ -139,6 +139,16 @@ export const TECH_LOG_ROUTE_SCHEMA_REGISTRY = Object.freeze({ "route-search", "STRIP_UNKNOWN", ), + TechLogStudioDocumentsSearch: routeSchema( + "TechLogStudioDocumentsSearch", + "route-search", + "STRIP_UNKNOWN", + ), + TechLogStudioPublicationsSearch: routeSchema( + "TechLogStudioPublicationsSearch", + "route-search", + "STRIP_UNKNOWN", + ), }); function chunkId(routeId: TechLogRouteId): string { diff --git a/src/features/tech-log/presentation/public/components/home-topic-tabs.tsx b/src/features/tech-log/presentation/public/components/home-topic-tabs.tsx index 21aa120..b832cb1 100644 --- a/src/features/tech-log/presentation/public/components/home-topic-tabs.tsx +++ b/src/features/tech-log/presentation/public/components/home-topic-tabs.tsx @@ -77,7 +77,30 @@ export function HomeTopicTabs({ if (!active) return null; const detail = details[active.slug]; - const axisLabel = (detail?.variantLabel ?? active.variantLabel).trim(); + /* + 축을 쓰는 주제는 축끼리 견주고, 아직 쓰지 않는 주제는 그 주제의 기록을 세운다. + + 예전에는 축이 둘 이상인 주제만 탭이 됐고 나머지는 목록 아래 한 줄짜리 링크로 갔다. 축은 + 주제가 자라면서 생기는 것이지 기록이 없다는 뜻이 아니다 — 축이 없다고 이름을 숨길 이유가 + 없다. + */ + const rows: ReadonlyArray<{ path: string; title: string; line: string }> = detail + ? detail.variants.length > 1 + ? detail.variants.map((variant) => ({ + path: variant.path, + title: variant.title, + line: variant.conclusion || variant.summary, + })) + : detail.featuredCases.map((record) => ({ + path: record.path, + title: record.title, + line: record.summary || record.note, + })) + : []; + const comparing = (detail?.variants.length ?? 0) > 1; + const axisLabel = comparing + ? (detail?.variantLabel ?? active.variantLabel).trim() + : "기록"; const multiple = topics.length > 1; return ( @@ -103,7 +126,12 @@ export function HomeTopicTabs({ type="button" role={multiple ? "tab" : undefined} aria-selected={multiple ? selected : undefined} - aria-controls="home-topic-panel" + /* + 패널은 하나뿐이라 고른 탭만 그것을 가리킨다. 탭 전부가 같은 패널을 가리키면 + 고르지 않은 탭이 "내가 저 패널을 연다" 고 말하면서 패널은 다른 탭의 이름을 + 달고 있게 된다 — 화면 읽기 프로그램에게 서로 어긋난 두 문장이다. + */ + aria-controls={selected ? "home-topic-panel" : undefined} tabIndex={multiple && !selected ? -1 : 0} onClick={() => select(topic.slug)} onKeyDown={onKeyDown} @@ -136,21 +164,25 @@ export function HomeTopicTabs({ {`${active.name} 전체 보기`} - {detail ? ( + {detail && rows.length > 0 ? ( + ) : detail ? ( +

+ {`${active.name}에는 아직 공개된 기록이 없습니다.`} +

) : (

{failedSlug === active.slug diff --git a/src/features/tech-log/presentation/public/pages/home-page.tsx b/src/features/tech-log/presentation/public/pages/home-page.tsx index 95dbf05..df37639 100644 --- a/src/features/tech-log/presentation/public/pages/home-page.tsx +++ b/src/features/tech-log/presentation/public/pages/home-page.tsx @@ -140,20 +140,28 @@ function dateLabel(isoTimestamp: string): string { */ async function getTopics(publicContent: PublicContentQueries) { const topics = await publicContent.listTopics(); - // 목록의 순서는 서버가 정한다. 「가장 많이 다룬」은 여기서 직접 골라야 하는 것이고, - // 첫 항목을 쓰면 기록 3편짜리 주제가 18편짜리를 제치고 홈에 오른다. - const comparable = [...topics] - .filter((topic) => topic.variantCount > 1) - .sort((left, right) => right.recordCount - left.recordCount); - const first = comparable[0]; + /* + 주제는 전부 탭에 오른다. + + 한때 축이 둘 이상인 주제만 탭이 되고 나머지는 목록 아래 「다른 주제 N개 보기」 한 줄로 + 갔다. 그 줄은 없애려던 바로 그 줄이다 — 읽는 사람은 비교표를 다 읽고 나서야 다른 주제가 + 있다는 것을 알았고, 대개 거기까지 가지 않았다. + + 기록이 아직 없는 주제도 세운다. 주제를 만든다는 것은 앞으로 그것을 쓰겠다는 선언이고, + 그 선언이 홈에 먼저 서 있는 편이 이 사이트가 무엇을 다루는지 말해 준다. 대신 그 탭을 + 누르면 「아직 공개된 기록이 없습니다」라고 분명히 말한다 — 빈 목록으로 두지 않는다. + + 순서는 기록이 많은 것부터다. 서버가 주는 순서를 그대로 쓰면 기록 3편짜리가 18편짜리를 + 제치고 홈의 첫 화면에 오른다. + */ + const ordered = [...topics].sort((left, right) => right.recordCount - left.recordCount); + const first = ordered[0]; const firstDetail = first ? await publicContent.getTopicDetail(first.slug) : undefined; return { - /** 탭 하나씩. 축이 둘 이상이어야 견줄 것이 있다. */ - tabs: comparable, + /** 탭 하나씩. 주제 전부다. */ + tabs: ordered, /** 처음 열려 있을 주제. 이것만 미리 받는다. */ - firstDetail: firstDetail && firstDetail.variants.length > 1 ? firstDetail : undefined, - /** 축이 없어 탭이 되지 못한 주제 수. 있으면 주제 목록으로 가는 길을 남긴다. */ - remaining: topics.length - comparable.length, + firstDetail, }; } @@ -195,6 +203,27 @@ export function HomePage() {

{publicSiteConfig.identityStatement}

+ {/* + 30초 안에 알아야 할 것은 「무엇을 만들었나」가 아니라 「무엇을 견줬고 무엇이 남았나」다. + 축마다 만들어 보고 무엇을 알게 됐는지(결론)를 나란히 둔다 — 요약을 쓰면 무엇인가만 + 말하고 무엇을 알게 됐는지는 말하지 않는다. + + 이 구역이 첫 화면에 온다. 예전에는 제품명 한 줄과 일반적인 문장이 상단 300px 을 쓰고 + 그 아래 130px 이 빈 공간이었으며, 이 사이트에서 다른 데서 얻을 수 없는 유일한 것 — + 네 구조를 나란히 견주는 표 — 이 y≈600 에 11px 회색으로 묻혀 있었다. 스크롤할 이유를 + 주는 것이 그 표다. + + 제목 자리에는 주제 이름들이 탭으로 선다. 「구조별로 알게 된 것」 한 줄이 서 있던 동안 + 홈이 펴 두는 주제는 하나였고, 나머지로 가는 길은 목록 밑 작은 글씨 한 줄뿐이었다 — + 무엇이 더 있는지는 다 읽고 나서야 알 수 있었다. 이름을 나란히 세우면 목록을 읽기 + 전에 먼저 보인다. + */} + {topics.firstDetail ? ( +
+ +
+ ) : null} + {initialKey ? (

@@ -208,32 +237,6 @@ export function HomePage() {

) : null} - {/* - 30초 안에 알아야 할 것은 「무엇을 만들었나」가 아니라 「무엇을 견줬고 무엇이 남았나」다. - 축마다 만들어 보고 무엇을 알게 됐는지(결론)를 나란히 둔다 — 요약을 쓰면 무엇인가만 - 말하고 무엇을 알게 됐는지는 말하지 않는다. - - 제목 자리에는 주제 이름들이 탭으로 선다. 「구조별로 알게 된 것」 한 줄이 서 있던 동안 - 홈이 펴 두는 주제는 하나였고, 나머지로 가는 길은 목록 밑 작은 글씨 한 줄뿐이었다 — - 무엇이 더 있는지는 다 읽고 나서야 알 수 있었다. 이름을 나란히 세우면 목록을 읽기 - 전에 먼저 보인다. - */} - {topics.firstDetail ? ( -
- - - {/* - 축을 쓰지 않아 탭이 되지 못한 주제로 가는 길. 탭에 다 올라와 있으면 이 줄은 - 없다 — 같은 곳으로 가는 길이 둘일 이유가 없다. - */} - {topics.remaining > 0 ? ( -

- {`다른 주제 ${topics.remaining}개 보기`} -

- ) : null} -
- ) : null} -
{project.title} - {project.stage} + {projectStageLabel(project.stage)}
-

{project.currentGoal}

+ {project.currentGoal ?

{project.currentGoal}

: null} diff --git a/src/features/tech-log/presentation/public/pages/project-overview-page.tsx b/src/features/tech-log/presentation/public/pages/project-overview-page.tsx index 3dde488..55873ac 100644 --- a/src/features/tech-log/presentation/public/pages/project-overview-page.tsx +++ b/src/features/tech-log/presentation/public/pages/project-overview-page.tsx @@ -1,4 +1,5 @@ import { Link } from "react-router-dom"; +import { projectStageLabel } from "../../shared/project-phase-labels.ts"; import { RegisteredNotFoundRoute, @@ -50,16 +51,21 @@ export function ProjectOverviewPage() {
단계
-
{project.stage}
-
-
-
현재 목표
-
{project.currentGoal}
-
-
-
다음 작업
-
{project.nextStep}
+
{projectStageLabel(project.stage)}
+ {/* 값이 없으면 라벨도 그리지 않는다 — 목록 화면과 같은 규칙이다. */} + {project.currentGoal ? ( +
+
현재 목표
+
{project.currentGoal}
+
+ ) : null} + {project.nextStep ? ( +
+
다음 작업
+
{project.nextStep}
+
+ ) : null}
{/* 숫자 셋(기록 12 · 결정 4 · 활동 9)은 이 프로젝트가 얼마나 큰지는 말해도 어디서부터 읽어야 diff --git a/src/features/tech-log/presentation/public/pages/projects-page.tsx b/src/features/tech-log/presentation/public/pages/projects-page.tsx index 37fb127..4c2af0e 100644 --- a/src/features/tech-log/presentation/public/pages/projects-page.tsx +++ b/src/features/tech-log/presentation/public/pages/projects-page.tsx @@ -1,4 +1,5 @@ import { Link } from "react-router-dom"; +import { projectStageLabel } from "../../shared/project-phase-labels.ts"; import { usePublicContent } from "../use-public-content.tsx"; @@ -40,19 +41,31 @@ export function ProjectsPage() {

{project.title}

- {project.stage} + {projectStageLabel(project.stage)}

{project.summary}

-
-
-
현재 목표
-
{project.currentGoal}
-
-
-
다음 작업
-
{project.nextStep}
-
-
+ {/* + 값이 없으면 라벨도 그리지 않는다. 네 프로젝트 중 셋이 「현재 목표」·「다음 작업」 + 라벨만 있고 값이 빈 채로 나왔다 — 읽는 사람에게는 목표가 없다는 말이 아니라 + 화면이 덜 만들어졌다는 말로 읽힌다. Studio 홈이 이미 "셋 다 비우면 그 영역은 + 나타나지 않는다"는 규칙을 갖고 있고, 같은 규칙이 여기에는 없었다. + */} + {project.currentGoal || project.nextStep ? ( +
+ {project.currentGoal ? ( +
+
현재 목표
+
{project.currentGoal}
+
+ ) : null} + {project.nextStep ? ( +
+
다음 작업
+
{project.nextStep}
+
+ ) : null} +
+ ) : null}
diff --git a/src/features/tech-log/presentation/public/pages/search-page.tsx b/src/features/tech-log/presentation/public/pages/search-page.tsx index 08136d4..8f29d50 100644 --- a/src/features/tech-log/presentation/public/pages/search-page.tsx +++ b/src/features/tech-log/presentation/public/pages/search-page.tsx @@ -1,9 +1,24 @@ import { Link, useNavigate } from "react-router-dom"; +import { DOCUMENT_KIND_LABELS } from "../../shared/document-kind-labels.ts"; +import type { SearchablePublicEntity } from "../../../application/ports/public-content-queries.ts"; import { useRouteInput } from "../../../../../presentation/routes/route-input.tsx"; import { usePublicContent } from "../use-public-content.tsx"; -const labels = { CASE: "Case", REFERENCE: "Reference", QUESTION: "Open Question", CONCEPT: "개념", SETUP: "환경 구성", PROJECT: "Project", RELEASE: "Release" } as const; +/* + 기록 종류의 이름은 `document-kind-labels.ts` 한 곳에서만 정한다. 이 파일이 자기 표를 따로 + 갖고 있던 동안 같은 CASE 가 목록에서는 「검증 기록」, 검색 결과에서는 「Case」로 나왔다 — + 릴리즈 노트가 "화면마다 달랐던 이름을 하나로 통일했다" 고 적은 뒤에도 그랬다. + + 프로젝트와 릴리즈는 기록 종류가 아니라 검색이 함께 싣는 다른 대상이라 여기서 이름을 준다. +*/ +type SearchContentType = SearchablePublicEntity["contentType"]; + +const labels: Record = { + ...DOCUMENT_KIND_LABELS, + PROJECT: "프로젝트", + RELEASE: "릴리즈", +}; function optionalString(value: unknown): string | undefined { return typeof value === "string" ? value : undefined; diff --git a/src/features/tech-log/presentation/shared/project-phase-labels.ts b/src/features/tech-log/presentation/shared/project-phase-labels.ts new file mode 100644 index 0000000..187cf5c --- /dev/null +++ b/src/features/tech-log/presentation/shared/project-phase-labels.ts @@ -0,0 +1,37 @@ +import type { Project } from "../../application/ports/public-content-queries.ts"; + +/** + * 프로젝트가 지금 어디까지 왔는지를 사람에게 보여 주는 이름. + * + *

이 표가 없던 동안 공개 화면은 `DESIGN` 이라는 낱말을 그대로 그렸다. 한국어 화면의 영어 + * 단어였고, 같은 프로젝트를 Studio 는 「설계」로 불렀다 — 두 화면이 서로 다른 말을 했다. + * + *

Studio 와 공개 화면이 다루는 값 자체가 다르다. Studio 는 저장하는 단계 일곱을 그대로 + * 쓰고(`project_phase_check`), 공개 조회는 그것을 둘로 접어 준다. 그래서 표도 둘이다 — + * 하나로 합치면 없는 값을 화면에 노출하거나 저장이 제약에서 터진다. + */ +export const PROJECT_PHASE_LABELS: Record = { + RESEARCH: "조사", + DESIGN: "설계", + IMPLEMENTATION: "구현", + VERIFICATION: "검증", + MAINTENANCE: "유지", + PAUSED: "중단", + COMPLETED: "완료", +}; + +/** + * 공개 조회가 접어서 주는 단계. + * + *

`Record` 이므로 계약이 값을 늘리면 여기가 비어 있는 것을 + * 컴파일러가 잡는다. + */ +export const PROJECT_STAGE_LABELS: Record = { + DESIGN: "설계", + VALIDATION: "검증", +}; + +/** 모르는 값이 오면 원문을 그대로 보여 준다 — 빈 칸보다 낫고, 무엇이 빠졌는지도 드러난다. */ +export function projectStageLabel(stage: string): string { + return PROJECT_STAGE_LABELS[stage as Project["stage"]] ?? PROJECT_PHASE_LABELS[stage] ?? stage; +} diff --git a/src/features/tech-log/presentation/studio/components/document-list.tsx b/src/features/tech-log/presentation/studio/components/document-list.tsx index 9db40c0..d56a08a 100644 --- a/src/features/tech-log/presentation/studio/components/document-list.tsx +++ b/src/features/tech-log/presentation/studio/components/document-list.tsx @@ -1,8 +1,9 @@ import { useEffect, useState, type FormEvent } from "react"; +import { useSearchParams } from "react-router-dom"; import { DestructiveConfirmDialog } from "./destructive-confirm-dialog.tsx"; import type { ListDocumentsQuery } from "../../../application/ports/studio-gateway.ts"; -import type { DocumentPage } from "../../../contracts/studio/contract.ts"; +import type { CatalogPage, DocumentPage } from "../../../contracts/studio/contract.ts"; import type { components } from "../../../contracts/studio/generated.ts"; import { managementFailureMessage } from "../../../application/ports/management-gateway-error.ts"; import { useStudio } from "../use-studio.ts"; @@ -25,6 +26,16 @@ const STUDIO_KIND_ORDER: Record = { PROJECT_DECISION: 6, }; +/** 상태 필터가 받는 값. 주소에서 온 문자열을 이 목록으로 좁힌다. */ +/** 정렬 선택지. 계약의 `ListDocumentsQuery.sort` 와 같은 집합이다. */ +const SORTS = Object.freeze(["UPDATED_DESC", "UPDATED_ASC", "TITLE_ASC"] as const); + +const PUBLICATION_STATUSES = Object.freeze([ + "NEVER_PUBLISHED", + "PUBLISHED", + "UNPUBLISHED", +] as const); + const STUDIO_KINDS: ReadonlyArray = Object.freeze( (Object.keys(STUDIO_KIND_ORDER) as RecordKind[]).sort( (left, right) => STUDIO_KIND_ORDER[left] - STUDIO_KIND_ORDER[right], @@ -74,12 +85,50 @@ export function DocumentList() { */ const [pendingDelete, setPendingDelete] = useState(null); - const [searchDraft, setSearchDraft] = useState(""); - const [q, setQ] = useState(""); - const [kind, setKind] = useState(); - const [status, setStatus] = - useState(); - const [pageNumber, setPageNumber] = useState(1); + /* + 목록의 상태는 주소가 갖는다. + + 컴포넌트 state 로만 들고 있던 동안 3쪽에서 문서를 열고 뒤로 오면 1쪽이었고, 걸어 둔 + 종류·상태·검색어도 함께 사라졌다. 61개를 20개씩 넘겨 보던 사람은 그 왕복을 매번 다시 + 했다. 공개 `/search` 는 처음부터 주소에 담고 있었다 — 같은 방식을 여기에 쓴다. + + 검색 입력만 state 다. 한 글자마다 주소를 바꾸면 뒤로가기가 글자 수만큼 쌓인다. + */ + const [searchParams, setSearchParams] = useSearchParams(); + const q = searchParams.get("q") ?? ""; + const kind = STUDIO_KINDS.find((item) => item === searchParams.get("kind")); + const status = PUBLICATION_STATUSES.find((item) => item === searchParams.get("status")); + const projectId = searchParams.get("project") ?? ""; + const sort = SORTS.find((item) => item === searchParams.get("sort")) ?? "UPDATED_DESC"; + const pageNumber = Math.max(1, Number(searchParams.get("page")) || 1); + const [searchDraft, setSearchDraft] = useState(q); + const [projects, setProjects] = useState([]); + + /* + 주소를 새로 쓴다. 값이 비면 조각을 빼서 `?kind=&status=` 같은 빈 꼬리가 남지 않게 한다. + 1쪽도 빼는데, `?page=1` 은 아무것도 더 말해 주지 않으면서 주소만 길게 만든다. + */ + const go = ( + next: Readonly<{ + q?: string; + kind?: string; + status?: string; + project?: string; + sort?: string; + page?: number; + }>, + ) => { + const params = new URLSearchParams(); + const merged = { q, kind, status, project: projectId, sort, page: pageNumber, ...next }; + if (merged.q) params.set("q", merged.q); + if (merged.kind) params.set("kind", merged.kind); + if (merged.status) params.set("status", merged.status); + if (merged.project) params.set("project", merged.project); + // 기본 정렬은 주소에 적지 않는다 — 아무것도 더 말해 주지 않으면서 주소만 길어진다. + if (merged.sort && merged.sort !== "UPDATED_DESC") params.set("sort", merged.sort); + if (merged.page && merged.page > 1) params.set("page", String(merged.page)); + setSearchParams(params); + }; const [page, setPage] = useState(null); const [loading, setLoading] = useState(true); const [error, setError] = useState(""); @@ -140,6 +189,29 @@ export function DocumentList() { } }; + // 뒤로가기로 다른 검색어의 주소에 돌아오면 입력칸도 그 값이어야 한다. + useEffect(() => { + setSearchDraft(q); + }, [q]); + + /* + 프로젝트 선택지. 목록과 같은 카탈로그를 읽는다 — 편집기의 프로젝트 셀렉트가 쓰는 것과 + 같은 원천이라 두 화면이 다른 목록을 보여 주지 않는다. + + 실패는 조용히 넘긴다. 프로젝트로 거르지 못하는 것은 불편이지만, 그것 때문에 작업본 목록 + 자체를 못 보게 만들 이유는 없다. + */ + useEffect(() => { + const controller = new AbortController(); + void gateway + .getCatalog({ type: "PROJECT", limit: 100 }, { signal: controller.signal }) + .then( + (page) => setProjects(page.items), + () => undefined, + ); + return () => controller.abort(); + }, [gateway]); + useEffect(() => { const controller = new AbortController(); setLoading(true); @@ -150,6 +222,8 @@ export function DocumentList() { ...(q ? { q } : {}), ...(kind ? { kind } : {}), ...(status ? { publicationStatus: status } : {}), + ...(projectId ? { projectId } : {}), + sort, page: pageNumber, limit: 20, }, @@ -167,21 +241,22 @@ export function DocumentList() { }, ); return () => controller.abort(); - }, [gateway, kind, pageNumber, q, retryGeneration, status]); + }, [gateway, kind, pageNumber, projectId, q, retryGeneration, sort, status]); const changeFilter = (next: { kind?: ListDocumentsQuery["kind"]; status?: ListDocumentsQuery["publicationStatus"]; }) => { - if ("kind" in next) setKind(next.kind); - if ("status" in next) setStatus(next.status); // 3쪽에 있던 채로 필터를 좁히면 결과가 그보다 적어 빈 화면이 나온다. - setPageNumber(1); + go({ + ...("kind" in next ? { kind: next.kind ?? "" } : {}), + ...("status" in next ? { status: next.status ?? "" } : {}), + page: 1, + }); }; const submitSearch = (event: FormEvent) => { event.preventDefault(); - setQ(searchDraft.trim()); - setPageNumber(1); + go({ q: searchDraft.trim(), page: 1 }); }; return ( @@ -251,6 +326,33 @@ export function DocumentList() { + {/* + 프로젝트로 거르는 길이 없었다. 공개 `/explore` 는 독자에게 종류·주제·프로젝트 셋을 + 주는데, 61개를 관리하는 작성자에게는 종류·상태 둘뿐이었다 — 읽는 사람이 쓰는 사람보다 + 좋은 도구를 갖고 있었다. + */} + + {loading ? (

@@ -374,7 +476,7 @@ export function DocumentList() { go({ page: next })} /> ) : null} diff --git a/src/features/tech-log/presentation/studio/components/new-document-form.tsx b/src/features/tech-log/presentation/studio/components/new-document-form.tsx index 602e624..ffa9b64 100644 --- a/src/features/tech-log/presentation/studio/components/new-document-form.tsx +++ b/src/features/tech-log/presentation/studio/components/new-document-form.tsx @@ -1,4 +1,5 @@ import { useEffect, useRef, useState, type FormEvent } from "react"; +import { DOCUMENT_KIND_LABELS } from "../../shared/document-kind-labels.ts"; import type { CreateDocumentInput, @@ -7,40 +8,44 @@ import type { import { createLocalId } from "../../../domain/studio/local-id.ts"; import { useStudio } from "../use-studio.ts"; +/* + 이름은 `document-kind-labels.ts` 가 정한다. 여기서 따로 적던 동안 작업본 목록은 「검증 기록」, + 새 문서 화면은 「Case」였다 — 같은 것을 만드는 두 화면이 다른 말을 썼다. +*/ const types = [ { kind: "CASE", - title: "Case", + title: DOCUMENT_KIND_LABELS.CASE, description: "문제를 재현하고 검증한 결론을 기록합니다.", fields: "문제 · 결론 · 환경 · 재현 · 본문", }, { kind: "REFERENCE", - title: "Reference", + title: DOCUMENT_KIND_LABELS.REFERENCE, description: "반복해서 적용할 기술 기준을 정리합니다.", fields: "목적 · 규칙 · 적용 조건 · 예외 · 예시", }, { kind: "CONCEPT", - title: "개념", + title: DOCUMENT_KIND_LABELS.CONCEPT, description: "개념의 내부 동작과 아키텍처를 처음부터 풀어 씁니다.", fields: "기준 버전 · 본문", }, { kind: "SETUP", - title: "환경 구성", + title: DOCUMENT_KIND_LABELS.SETUP, description: "이 기록을 자기 손으로 재현하는 절차를 남깁니다.", fields: "버전 · 본문", }, { kind: "QUESTION", - title: "Question", + title: DOCUMENT_KIND_LABELS.QUESTION, description: "아직 닫히지 않은 판단과 다음 검증을 관리합니다.", fields: "상태 · 사실 · 가정 · 미지수 · 선택지", }, { kind: "PROJECT_DECISION", - title: "Decision", + title: DOCUMENT_KIND_LABELS.PROJECT_DECISION, description: "프로젝트가 선택한 방향과 그 근거·영향을 기록합니다.", fields: "상태 · 결정일 · 결정문 · 판단 이유 · 영향 · 근거", }, @@ -196,13 +201,6 @@ export function NewDocumentForm() { - {/* - 세션이 끊기면 쓴 것이 사라진다. 그 사실이 버튼 옆 작은 회색 글씨로만 있었다 — - 잃을 수 있는 것을 알리는 문구는 잃기 전에 눈에 들어와야 한다. - */} -

- 이 화면의 작업본은 현재 Studio 세션에서만 유지됩니다. 세션이 끝나면 사라집니다. -

{error ? (

diff --git a/src/features/tech-log/presentation/studio/components/project-editor.tsx b/src/features/tech-log/presentation/studio/components/project-editor.tsx index 3f0438e..28b920f 100644 --- a/src/features/tech-log/presentation/studio/components/project-editor.tsx +++ b/src/features/tech-log/presentation/studio/components/project-editor.tsx @@ -1,4 +1,5 @@ import { useCallback, useEffect, useState, type FormEvent } from "react"; +import { PROJECT_PHASE_LABELS } from "../../shared/project-phase-labels.ts"; import type { components } from "../../../contracts/studio/generated.ts"; import type { @@ -21,15 +22,7 @@ function routeId(value: unknown): string { } /** `project_phase_check` 와 같은 집합이다 — 화면이 더 많은 값을 보여 주면 저장이 제약에서 터진다. */ -const PHASES = [ - { value: "RESEARCH", label: "조사" }, - { value: "DESIGN", label: "설계" }, - { value: "IMPLEMENTATION", label: "구현" }, - { value: "VERIFICATION", label: "검증" }, - { value: "MAINTENANCE", label: "유지" }, - { value: "PAUSED", label: "중단" }, - { value: "COMPLETED", label: "완료" }, -] as const; +const PHASES = Object.entries(PROJECT_PHASE_LABELS).map(([value, label]) => ({ value, label })); /** `project_activity_activity_type_check` 와 같은 집합이다. */ const ACTIVITY_TYPES = [ diff --git a/src/features/tech-log/presentation/studio/components/publication-list.tsx b/src/features/tech-log/presentation/studio/components/publication-list.tsx index 9194ee7..0db14f5 100644 --- a/src/features/tech-log/presentation/studio/components/publication-list.tsx +++ b/src/features/tech-log/presentation/studio/components/publication-list.tsx @@ -1,4 +1,5 @@ -import { useEffect, useRef, useState, type FormEvent } from "react"; +import { type FormEvent, useEffect, useMemo, useRef, useState } from "react"; +import { useSearchParams } from "react-router-dom"; import { isStudioGatewayError, @@ -47,14 +48,43 @@ function snapshotHref(item: PublicationListItem) { return null; } +/** 이벤트 필터가 받는 값. 주소에서 온 문자열을 이 목록으로 좁힌다. */ +const EVENT_TYPES = Object.freeze(["PUBLISHED", "REPUBLISHED", "UNPUBLISHED"] as const); + export function PublicationList({ classes: styles = defaultPublicationFlowClasses, }: { classes?: PublicationFlowClasses } = {}) { const studio = useStudio(); - const [query, setQuery] = useState({ page: 1, limit: 20 }); - const [queryDraft, setQueryDraft] = useState(""); - const [typeDraft, setTypeDraft] = - useState(); + /* + 작업본 목록과 같은 규칙으로 상태를 주소에 담는다. 담지 않던 동안 게시 기록에서 Snapshot 을 + 열고 뒤로 오면 필터도 쪽수도 처음으로 돌아갔다. + + 필터 제출 방식도 작업본 목록에 맞춘다 — 셀렉트는 즉시 적용, 검색어만 버튼이다. 두 화면이 + 다른 방식을 쓰던 동안(여기는 둘을 묶어 「적용」) 작성자는 화면마다 어느 쪽인지 기억해야 했다. + */ + const [searchParams, setSearchParams] = useSearchParams(); + const q = searchParams.get("q") ?? ""; + const eventType = EVENT_TYPES.find((item) => item === searchParams.get("event")); + const pageNumber = Math.max(1, Number(searchParams.get("page")) || 1); + const query = useMemo( + () => ({ + ...(q ? { q: q.slice(0, 100) } : {}), + ...(eventType ? { type: eventType } : {}), + page: pageNumber, + limit: 20, + }), + [eventType, pageNumber, q], + ); + const [queryDraft, setQueryDraft] = useState(q); + + const go = (next: Readonly<{ q?: string; event?: string; page?: number }>) => { + const params = new URLSearchParams(); + const merged = { q, event: eventType, page: pageNumber, ...next }; + if (merged.q) params.set("q", merged.q); + if (merged.event) params.set("event", merged.event); + if (merged.page && merged.page > 1) params.set("page", String(merged.page)); + setSearchParams(params); + }; const [reload, setReload] = useState(0); const [state, setState] = useState< | { status: "LOADING" } @@ -96,11 +126,7 @@ export function PublicationList({ const applyFilter = (event: FormEvent) => { event.preventDefault(); - setQuery({ - ...(queryDraft.trim() ? { q: queryDraft.trim().slice(0, 100) } : {}), - ...(typeDraft ? { type: typeDraft } : {}), - limit: 100, - }); + go({ q: queryDraft.trim().slice(0, 100), page: 1 }); }; const dismiss = () => { @@ -163,15 +189,12 @@ export function PublicationList({ placeholder="제목 또는 요약" /> + - {announcement ? ( @@ -271,7 +293,7 @@ export function PublicationList({ setQuery((current) => ({ ...current, page: next }))} + onChange={(next) => go({ page: next })} /> ) : null} diff --git a/src/features/tech-log/presentation/studio/components/studio-dashboard.tsx b/src/features/tech-log/presentation/studio/components/studio-dashboard.tsx index 6c8c26f..89ad3db 100644 --- a/src/features/tech-log/presentation/studio/components/studio-dashboard.tsx +++ b/src/features/tech-log/presentation/studio/components/studio-dashboard.tsx @@ -41,6 +41,13 @@ function WorkRow({ item }: Readonly<{ item: DocumentSummary }>) { ); } +/** + * 할 일이 있는 구역만 그린다. + * + *

세 구역이 각각 ~150px 를 차지하면서 "없습니다" 를 말하고 있었다. 대시보드는 지금 무엇을 + * 해야 하는지 보여 주는 자리인데, 화면의 절반이 할 일이 없다는 말이었다. 셋 다 비면 그 + * 사실은 아래 「최근 게시」가 대신 말한다. + */ function WorkSection({ title, items, @@ -52,6 +59,7 @@ function WorkSection({ href: string; empty: string; }>) { + if (items.length === 0) return null; return (

@@ -131,23 +139,30 @@ export function StudioDashboard() { ) : null} {dashboard ? ( <> + {/* + 숫자는 목록으로 가는 길이다. + + 예전에는 넷 다 누를 수 없는 글자였다. 「전체 작업본 61」을 보고 그 61개로 가려면 + 위 내비게이션으로 돌아가 다시 눌러야 했다 — 대시보드가 세어 준 것과 그것을 볼 수 + 있는 곳이 이어져 있지 않았다. + */}
-
+ 전체 작업본 {dashboard.totals.documents} -
-
+ + 검증할 기록 {validationItems.length} -
-
+ + 게시 준비 {dashboard.totals.readyToPublish} -
-
+ + 게시 기록 {dashboard.totals.publications} -
+
-

최근 게시

@@ -205,6 +219,12 @@ export function StudioDashboard() { )}
+ {/* + 공개 홈에 무엇을 세울지 고르는 폼이다. 작업 목록 한가운데(「게시 준비」와 「최근 + 게시」 사이)에 있어서, 오늘 할 일을 훑는 흐름이 설정 화면에 끊겼다. 설정은 작업이 + 아니므로 목록 뒤로 보낸다. + */} + ) : null}
diff --git a/src/features/tech-log/presentation/studio/components/taxonomy-manager.tsx b/src/features/tech-log/presentation/studio/components/taxonomy-manager.tsx index ab2f6ab..6936cbe 100644 --- a/src/features/tech-log/presentation/studio/components/taxonomy-manager.tsx +++ b/src/features/tech-log/presentation/studio/components/taxonomy-manager.tsx @@ -1,4 +1,5 @@ import { useCallback, useEffect, useState, type FormEvent } from "react"; +import { PROJECT_PHASE_LABELS } from "../../shared/project-phase-labels.ts"; import { DestructiveConfirmDialog } from "./destructive-confirm-dialog.tsx"; import type { ProjectIndexItem, TopicEdit } from "../../../contracts/management/contract.ts"; @@ -17,16 +18,6 @@ import { useStudio } from "../use-studio.ts"; *

새 CSS 를 만들지 않는다. 작업본 목록이 쓰는 클래스만 재사용하므로 이 화면은 Studio 의 * 나머지와 같은 간격·타이포·색을 그대로 따른다. */ -/** 공개 프로젝트 화면과 같은 말을 쓴다 — 두 화면이 다른 낱말을 쓰면 같은 것인지 알기 어렵다. */ -const phaseLabel: Record = { - RESEARCH: "조사", - DESIGN: "설계", - IMPLEMENTATION: "구현", - VERIFICATION: "검증", - MAINTENANCE: "유지", - PAUSED: "중단", - COMPLETED: "완료", -}; const visibilityLabel: Record = { PRIVATE: "비공개", @@ -356,7 +347,7 @@ export function TaxonomyManager() {

단계
-
{phaseLabel[project.phase] ?? project.phase}
+
{PROJECT_PHASE_LABELS[project.phase] ?? project.phase}
공개
diff --git a/src/features/tech-log/presentation/tech-log-route-codecs.ts b/src/features/tech-log/presentation/tech-log-route-codecs.ts index 94442ce..c9087c2 100644 --- a/src/features/tech-log/presentation/tech-log-route-codecs.ts +++ b/src/features/tech-log/presentation/tech-log-route-codecs.ts @@ -57,4 +57,27 @@ export const TECH_LOG_ROUTE_CODECS = Object.freeze({ state: optionalString, }) .strip(), + /* + Studio 목록의 상태를 주소에 담는다. + + 담지 않던 동안 3쪽에서 문서를 열고 뒤로 오면 1쪽이었고, 종류·검색을 걸어 둔 것도 함께 + 사라졌다. 61개를 20개씩 넘겨 보던 사람은 그 왕복을 매번 다시 했다. 공개 `/search` 는 + 처음부터 주소에 담고 있었고, 같은 방식을 Studio 에 적용하지 않았을 뿐이다. + */ + TechLogStudioDocumentsSearch: z + .object({ + q: optionalSelection, + kind: optionalString, + status: optionalString, + page: optionalString, + }) + .strip(), + TechLogStudioPublicationsSearch: z + .object({ + q: optionalSelection, + kind: optionalString, + event: optionalString, + page: optionalString, + }) + .strip(), } as const); diff --git a/src/presentation/layouts/app-shell.tsx b/src/presentation/layouts/app-shell.tsx index 0ec7ba1..d01b9f8 100644 --- a/src/presentation/layouts/app-shell.tsx +++ b/src/presentation/layouts/app-shell.tsx @@ -169,12 +169,33 @@ export function AppShell() { function PrimaryNavigation({ id }: Readonly<{ id: string }>) { const { resolve, message } = useLocale(); const { runtime } = useApplication(); + const { pathname } = useLocation(); // §3.5. A feature the runtime document disabled does not advertise itself. // The router refuses its routes too, so this is presentation, not the switch. const routes = NAVIGATION_ROUTES.filter((definition) => { const owner = ROUTE_FEATURE_OWNER[definition.routeId]; return owner === undefined || runtime.isFeatureActive(owner); }); + + /* + `aria-current="page"` 와 시각적 강조는 서로 다른 것을 말한다. + + `end` 없이 `NavLink` 를 쓰면 `/studio/documents` 링크가 `/studio/documents/:id/edit` 에서도 + 활성으로 잡히고, 그때 `aria-current="page"` 가 붙는다. 그 화면은 그 페이지가 아니다 — + 화면 읽기 프로그램에게는 잘못된 말이다. + + 그래서 `end` 로 정확히 일치할 때만 `aria-current` 가 붙게 하고, 「지금 이 구역에 있다」는 + 표시는 여기서 따로 계산한다. 가장 긴 접두사 하나만 고른다 — 그러지 않으면 `/studio` 가 + 모든 Studio 화면에서 함께 켜진다. + */ + const sectionPath = routes + .map((definition) => definition.path) + .filter( + (path) => + path !== "/" && (pathname === path || pathname.startsWith(`${path}/`)), + ) + .sort((left, right) => right.length - left.length)[0]; + return (