diff --git a/src/features/tech-log/presentation/studio/components/asset-library.tsx b/src/features/tech-log/presentation/studio/components/asset-library.tsx index 19dc1de..7cc969e 100644 --- a/src/features/tech-log/presentation/studio/components/asset-library.tsx +++ b/src/features/tech-log/presentation/studio/components/asset-library.tsx @@ -6,6 +6,29 @@ import type { StudioAssetGateway } from "../../../application/ports/studio-asset import { isStudioGatewayError } from "../../../application/ports/studio-gateway-error.ts"; import { createLocalId } from "../../../domain/studio/local-id.ts"; +/** 관리 상태. 화면에 영문 상수가 그대로 나오던 자리다. */ +const ASSET_STATUS_LABELS: Record = { + READY: "사용 가능", + ARCHIVED: "보관됨", + REJECTED: "거부됨", + QUARANTINED: "검사 보류", +}; + +/** 사람이 고를 때 실제로 보는 사실들 — 무엇이고, 얼마나 크고, 몇 바이트인가. */ +function assetFacts(asset: Asset): string { + const parts = [asset.mediaType.replace(/^image\//u, "").toUpperCase()]; + // 치수를 모르는 자료가 있다(첨부파일, 처리 중). 모르면 적지 않는다 — 0×0 은 거짓이다. + if (asset.width && asset.height) parts.push(`${asset.width}×${asset.height}`); + parts.push(byteLabel(asset.byteSize)); + return parts.join(" · "); +} + +function byteLabel(bytes: number): string { + if (bytes < 1024) return `${bytes} B`; + if (bytes < 1024 * 1024) return `${Math.round(bytes / 1024)} KB`; + return `${(bytes / (1024 * 1024)).toFixed(1)} MB`; +} + /** `document-list.tsx`'s page size for the same screen shape. */ const PAGE_SIZE = 20; @@ -314,6 +337,12 @@ export function AssetLibrary(props: Readonly<{ gateway: StudioAssetGateway }>) { {asset.kind === "ATTACHMENT" ? "파일" : "—"} )} + {/* + 사람이 고르는 이름은 파일 이름이다. 목록이 `assetKey` 를 앞세우던 동안 작성자는 + 해시 같은 문자열 스무 줄에서 찾던 도식을 눈으로 골라야 했다 — key 는 본문이 + 가리키는 불변 식별자이지 사람이 기억하는 이름이 아니다. 이름을 앞에 두고 key 는 + 아래에 작게 남긴다. + */} - {asset.managementStatus} - 사용 {asset.usageCount}건 + {ASSET_STATUS_LABELS[asset.managementStatus]} + {/* + 쓰이지 않는 자료는 지워도 되는 것이고, 쓰이는 자료는 지우면 화면이 깨진다. 그 + 차이가 숫자 하나로만 표시되던 동안 「사용 0건」과 「사용 3건」이 같은 회색으로 + 나란했다. + */} + + {asset.usageCount === 0 ? "쓰이지 않음" : `${asset.usageCount}곳에서 사용`} + ))} @@ -345,19 +386,43 @@ export function AssetLibrary(props: Readonly<{ gateway: StudioAssetGateway }>) { ) : null} {selected ? ( -
+

- {selected.asset.assetKey} + {selected.asset.originalFilename || selected.asset.assetKey}

-

{selected.asset.managementStatus}

+
+
상태
{ASSET_STATUS_LABELS[selected.asset.managementStatus]}
+
파일
{assetFacts(selected.asset)}
+ {/* 본문이 가리키는 불변 식별자. 사람이 기억하는 이름이 아니라 복사해 쓰는 값이다. */} +
Key
{selected.asset.assetKey}
+ {selected.asset.altText ? ( +
대체 텍스트
{selected.asset.altText}
+ ) : null} +
+ {/* + 바꾸거나 지우기 전에 어디에 쓰이는지 전부 보여야 한다. 숫자만으로는 무엇이 깨질지 + 알 수 없다. + */} +

쓰이는 곳

{selected.usages.length > 0 ? (
    {selected.usages.map((usage) => ( -
  • {usage.title}
  • +
  • + {/* + 평범한 링크다. 이 화면은 Studio 컨텍스트를 받지 않고 게이트웨이 하나만 받아 + 혼자 설 수 있게 되어 있고, 여기서 떠날 때 지킬 편집 상태도 없다. + */} + + {usage.title || "제목 없는 작업본"} + +
  • ))}
) : ( -

사용 중인 문서가 없습니다.

+

아직 어느 기록도 이 자료를 쓰지 않습니다.

)}
{/* diff --git a/src/features/tech-log/presentation/studio/components/validation-report.tsx b/src/features/tech-log/presentation/studio/components/validation-report.tsx index 2e93f5c..09d9506 100644 --- a/src/features/tech-log/presentation/studio/components/validation-report.tsx +++ b/src/features/tech-log/presentation/studio/components/validation-report.tsx @@ -78,28 +78,49 @@ export function ValidationReport({
검증 시각
{formatDateTime(report.validatedAt)}
유효 시각
{formatDateTime(report.validUntil)}
+ {/* + 오류와 경고를 갈라 세고 각각의 수를 제목에 적는다. + + 한 목록에 섞여 있으면 "게시를 막는 것이 몇 개인가" 라는 질문에 답하려면 줄마다 배지를 + 읽어야 한다. 게시 전에 작성자가 알아야 하는 것은 그 수 하나다 — 경고는 지금 고치지 + 않아도 나갈 수 있고 오류는 아니다. + */} {issues.length ? ( -
    - {issues.map((issue, index) => ( -
  1. - - - {severityLabel[issue.severity]} - - - {issue.message} - {issue.code} · {issue.path || "/"} - - - -
  2. - ))} -
+ <> + {(["ERROR", "WARNING"] as const).map((severity) => { + const group = issues.filter((issue) => issue.severity === severity); + if (group.length === 0) return null; + return ( +
+

+ {severity === "ERROR" ? "게시를 막는 것" : "확인해 둘 것"} + {group.length} +

+
    + {group.map((issue, index) => ( +
  1. + + + {severityLabel[issue.severity]} + + + {issue.message} + {issue.code} · {issue.path || "/"} + + + +
  2. + ))} +
+
+ ); + })} + ) : (

오류와 경고가 없습니다.

)} diff --git a/src/features/tech-log/presentation/styles/studio.css b/src/features/tech-log/presentation/styles/studio.css index 6e40e60..e6791e1 100644 --- a/src/features/tech-log/presentation/styles/studio.css +++ b/src/features/tech-log/presentation/styles/studio.css @@ -468,3 +468,22 @@ .studio-app .studio-row-overflow > summary:hover { background: var(--canvas); color: var(--ink); } .studio-app .studio-row-overflow > div { position: absolute; z-index: 5; top: 100%; right: 0; padding: 7px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--paper); box-shadow: 0 6px 18px rgb(0 0 0 / 8%); } .studio-app .studio-unpublished-mark { color: var(--warning); } + +/* 검증 결과 — 게시를 막는 것과 확인해 둘 것을 갈라 센다 */ +.studio-app .studio-workflow-issue-group + .studio-workflow-issue-group { margin-top: 26px; } +.studio-app .studio-workflow-issue-group > h3 { display: flex; gap: 10px; align-items: baseline; margin: 22px 0 0; font-size: 14px; font-weight: 650; } +.studio-app .studio-workflow-issue-group > h3 > span { color: var(--faint); font-family: "IBM Plex Mono", monospace; font-size: 13px; } + +/* Asset — 해시가 아니라 뜻으로 고른다 */ +.studio-app .asset-library-list button { display: flex; flex-direction: column; gap: 3px; align-items: flex-start; text-align: left; } +.studio-app .asset-library-list button strong { color: var(--ink); font-size: 15px; font-weight: 600; } +.studio-app .asset-library-list button small { color: var(--muted); font-size: 12px; } +.studio-app .asset-library-list__key { color: var(--faint) !important; font-family: "IBM Plex Mono", monospace; font-size: 11px !important; } +.studio-app .asset-usage { color: var(--muted); font-size: 12px; } +.studio-app .asset-usage--none { color: var(--faint); } +.studio-app .asset-detail-facts { display: grid; gap: 8px 22px; margin: 14px 0 0; } +.studio-app .asset-detail-facts > div { display: flex; gap: 12px; align-items: baseline; } +.studio-app .asset-detail-facts dt { min-width: 84px; color: var(--faint); font-size: 12px; font-weight: 620; } +.studio-app .asset-detail-facts dd { margin: 0; color: var(--ink-soft); font-size: 14px; } +.studio-app .asset-detail-facts code { font-family: "IBM Plex Mono", monospace; font-size: 12px; } +.studio-app .asset-detail-usage-title { margin: 24px 0 10px; font-size: 13px; font-weight: 650; } diff --git a/tests/features/tech-log/asset-library.test.tsx b/tests/features/tech-log/asset-library.test.tsx index 98a9541..dea0702 100644 --- a/tests/features/tech-log/asset-library.test.tsx +++ b/tests/features/tech-log/asset-library.test.tsx @@ -162,7 +162,7 @@ test("shows archive instead of delete for an asset in use", async () => { hasPublicationHistory: true, })} />); - await user.click(await screen.findByRole("button", { name: "boundary" })); + await user.click(await screen.findByRole("button", { name: "b.svg" })); assert.ok(await screen.findByRole("button", { name: "보관" })); expect(screen.queryByRole("button", { name: "삭제" })).not.toBeInTheDocument(); @@ -183,7 +183,7 @@ test("surfaces ASSET_IN_USE when the server rejects a delete", async () => { }, )} />); - await user.click(await screen.findByRole("button", { name: "boundary" })); + await user.click(await screen.findByRole("button", { name: "b.svg" })); // 삭제는 이제 확인을 한 번 거친다. 상세의 버튼이 창을 열고, 창의 버튼이 실제로 지운다. await user.click(await screen.findByRole("button", { name: "삭제" })); await user.click( @@ -205,9 +205,9 @@ test("archives an asset by sending the expected command and merging the server's }); render(); - const row = (await screen.findByRole("button", { name: "boundary" })).closest("li"); + const row = (await screen.findByRole("button", { name: "b.svg" })).closest("li"); assert.ok(row); - await user.click(await screen.findByRole("button", { name: "boundary" })); + await user.click(await screen.findByRole("button", { name: "b.svg" })); await user.click(await screen.findByRole("button", { name: "보관" })); assert.ok(await screen.findByText("보관했습니다.")); @@ -225,7 +225,8 @@ test("archives an asset by sending the expected command and merging the server's // response instead of just leaving the old row in place. `findByText` // above already settled on the post-update render, so this can assert // directly instead of polling. - assert.ok(row.textContent?.includes("ARCHIVED")); + // 상태는 이제 사람이 읽는 말로 나온다 — 화면에 영문 상수를 그대로 찍던 자리였다. + assert.ok(row.textContent?.includes("보관됨")); }); // Fix round 1 (I1 + Minor 4). Combines the delete success path's gateway @@ -244,7 +245,7 @@ test("removes the asset and restores focus to the page heading, not the detached }); render(); - await user.click(await screen.findByRole("button", { name: "boundary" })); + await user.click(await screen.findByRole("button", { name: "b.svg" })); // 삭제는 이제 확인을 한 번 거친다. 상세의 버튼이 창을 열고, 창의 버튼이 실제로 지운다. await user.click(await screen.findByRole("button", { name: "삭제" })); await user.click( @@ -257,7 +258,7 @@ test("removes the asset and restores focus to the page heading, not the detached const options = deleteCalls[0].options as { idempotencyKey?: unknown }; assert.equal(typeof options.idempotencyKey, "string"); assert.ok((options.idempotencyKey as string).length > 0); - expect(screen.queryByRole("button", { name: "boundary" })).not.toBeInTheDocument(); + expect(screen.queryByRole("button", { name: "b.svg" })).not.toBeInTheDocument(); // `findByText` above already settled on the post-delete render -- the // `queueMicrotask`-scheduled focus call has necessarily run by then, since @@ -288,8 +289,12 @@ test("removes the asset and restores focus to the page heading, not the detached type ListCall = Readonly<{ q?: string; cursor?: string; limit?: number }>; type ListPage = Readonly<{ items: unknown[]; nextCursor: string | null }>; +/* + 자료마다 사람이 부르는 이름이 다르다. 목록이 `assetKey` 를 앞세우던 동안 픽스처도 key 로만 + 갈라져 있었는데, 화면이 파일 이름으로 고르게 되었으므로 픽스처도 그 이름을 따로 갖는다. +*/ function assetNamed(assetKey: string, id: string) { - return { ...(ASSET as object), id, assetKey } as never; + return { ...(ASSET as object), id, assetKey, originalFilename: `${assetKey}.svg` } as never; } function libraryGateway(respond: (query: ListCall) => ListPage) { @@ -324,12 +329,12 @@ test("searches assets with the typed query and announces the new result count", ); render(); - await screen.findByRole("button", { name: "newer-diagram" }); + await screen.findByRole("button", { name: "newer-diagram.svg" }); await user.type(screen.getByLabelText("Asset 검색"), "older"); await user.click(screen.getByRole("button", { name: "검색" })); - assert.ok(await screen.findByRole("button", { name: "older-diagram" })); - expect(screen.queryByRole("button", { name: "newer-diagram" })).not.toBeInTheDocument(); + assert.ok(await screen.findByRole("button", { name: "older-diagram.svg" })); + expect(screen.queryByRole("button", { name: "newer-diagram.svg" })).not.toBeInTheDocument(); assert.equal(calls.at(-1)?.q, "older"); // The result count lives in a `role="status"` region so a screen reader is // told the list changed -- a silently re-rendered list is the failure mode @@ -345,7 +350,7 @@ test("typing alone never reaches the gateway -- only the submitted query does", const { gateway, calls } = libraryGateway(() => ({ items: [ASSET], nextCursor: null })); render(); - await screen.findByRole("button", { name: "boundary" }); + await screen.findByRole("button", { name: "b.svg" }); assert.equal(calls.length, 1); await user.type(screen.getByLabelText("Asset 검색"), "boundary"); @@ -364,12 +369,12 @@ test("loads the next page with the server cursor and appends it to the list", as ); render(); - await screen.findByRole("button", { name: "page-one" }); + await screen.findByRole("button", { name: "page-one.svg" }); await user.click(screen.getByRole("button", { name: "더 보기" })); - assert.ok(await screen.findByRole("button", { name: "page-two" })); + assert.ok(await screen.findByRole("button", { name: "page-two.svg" })); // Appended, not replaced: the first page must stay reachable. - assert.ok(screen.getByRole("button", { name: "page-one" })); + assert.ok(screen.getByRole("button", { name: "page-one.svg" })); assert.equal(calls.at(-1)?.cursor, "cursor-1"); // Exhausted paging removes the control rather than leaving a button that // does nothing. @@ -387,17 +392,17 @@ test("더 보기 moves focus to the first newly loaded asset instead of strandin ); render(); - await screen.findByRole("button", { name: "focus-page-one" }); + await screen.findByRole("button", { name: "focus-page-one.svg" }); await user.click(screen.getByRole("button", { name: "더 보기" })); - const appended = await screen.findByRole("button", { name: "focus-page-two" }); + const appended = await screen.findByRole("button", { name: "focus-page-two.svg" }); expect(appended).toHaveFocus(); }); test("offers no 더 보기 control when the server reports no next cursor", async () => { render(); - await screen.findByRole("button", { name: "boundary" }); + await screen.findByRole("button", { name: "b.svg" }); expect(screen.queryByRole("button", { name: "더 보기" })).not.toBeInTheDocument(); }); @@ -414,16 +419,16 @@ test("a new search restarts paging from the first page instead of carrying the o }); render(); - await screen.findByRole("button", { name: "reset-page-one" }); + await screen.findByRole("button", { name: "reset-page-one.svg" }); await user.click(screen.getByRole("button", { name: "더 보기" })); - await screen.findByRole("button", { name: "reset-page-two" }); + await screen.findByRole("button", { name: "reset-page-two.svg" }); await user.type(screen.getByLabelText("Asset 검색"), "reset-found"); await user.click(screen.getByRole("button", { name: "검색" })); - assert.ok(await screen.findByRole("button", { name: "reset-found" })); - expect(screen.queryByRole("button", { name: "reset-page-one" })).not.toBeInTheDocument(); - expect(screen.queryByRole("button", { name: "reset-page-two" })).not.toBeInTheDocument(); + assert.ok(await screen.findByRole("button", { name: "reset-found.svg" })); + expect(screen.queryByRole("button", { name: "reset-page-one.svg" })).not.toBeInTheDocument(); + expect(screen.queryByRole("button", { name: "reset-page-two.svg" })).not.toBeInTheDocument(); assert.equal(calls.at(-1)?.cursor, undefined); }); @@ -456,7 +461,7 @@ test("a slow earlier search never overwrites the newer search's results", async await act(async () => { pending[0]!.settle({ items: [initial], nextCursor: null }); }); - await screen.findByRole("button", { name: "race-initial" }); + await screen.findByRole("button", { name: "race-initial.svg" }); const input = screen.getByLabelText("Asset 검색"); await user.clear(input); @@ -472,7 +477,7 @@ test("a slow earlier search never overwrites the newer search's results", async await act(async () => { pending[2]!.settle({ items: [fast], nextCursor: null }); }); - await screen.findByRole("button", { name: "race-fast" }); + await screen.findByRole("button", { name: "race-fast.svg" }); // The abandoned "slow" request lands last. Nothing about it may reach the // screen: the user is looking at "fast" results. @@ -480,8 +485,8 @@ test("a slow earlier search never overwrites the newer search's results", async pending[1]!.settle({ items: [slow], nextCursor: null }); }); - expect(screen.queryByRole("button", { name: "race-slow" })).not.toBeInTheDocument(); - assert.ok(screen.getByRole("button", { name: "race-fast" })); + expect(screen.queryByRole("button", { name: "race-slow.svg" })).not.toBeInTheDocument(); + assert.ok(screen.getByRole("button", { name: "race-fast.svg" })); }); test("a search that matches nothing says so instead of claiming no asset was ever uploaded", async () => { @@ -491,7 +496,7 @@ test("a search that matches nothing says so instead of claiming no asset was eve ); render(); - await screen.findByRole("button", { name: "boundary" }); + await screen.findByRole("button", { name: "b.svg" }); await user.type(screen.getByLabelText("Asset 검색"), "없는키"); await user.click(screen.getByRole("button", { name: "검색" }));