diff --git a/src/features/tech-log/presentation/public/components/home-investigation-path.tsx b/src/features/tech-log/presentation/public/components/home-investigation-path.tsx index 9c21601..0bbbd35 100644 --- a/src/features/tech-log/presentation/public/components/home-investigation-path.tsx +++ b/src/features/tech-log/presentation/public/components/home-investigation-path.tsx @@ -57,13 +57,29 @@ export function HomeInvestigationPath({ entries }: { entries: ReadonlyArray - {path.map((record) => ( + {path.map((record, index) => (
  • {[record.typeLabel, record.topic].filter(Boolean).join(" · ")} - {record.title} +
    + {record.title} + {/* + 무엇이 이어지는지만 적으면 목록이고, 왜 이어지는지를 적어야 길이 된다. 요약의 + 첫 문장을 쓴다 — 작성자가 이 줄을 위해 따로 쓸 것을 만들지 않는다. + */} + {record.summary.trim() ?

    {firstSentence(record.summary)}

    : null} +
    + {index < path.length - 1 ? : null}
  • ))} ); } + + +/** 요약의 첫 문장. 한 줄이면 충분하고, 문단째 넣으면 길이 다시 목록이 된다. */ +function firstSentence(summary: string): string { + const line = summary.split(/\n+/u)[0]?.trim() ?? ""; + const stop = line.search(/[.。]\s|다\s/u); + return stop > 0 ? line.slice(0, stop + 1) : line; +} diff --git a/src/features/tech-log/presentation/shared/public-render/rail-context.tsx b/src/features/tech-log/presentation/shared/public-render/rail-context.tsx index d0d7d54..135123f 100644 --- a/src/features/tech-log/presentation/shared/public-render/rail-context.tsx +++ b/src/features/tech-log/presentation/shared/public-render/rail-context.tsx @@ -1,6 +1,7 @@ import { Link } from "react-router-dom"; import type { components } from "../../../contracts/studio/generated.ts"; +import { resolvesToPublicRoute } from "../../../domain/navigation/public-path.ts"; import { DOCUMENT_KIND_LABELS } from "../document-kind-labels.ts"; type PublicRenderModelBase = components["schemas"]["PublicRenderModelBase"]; @@ -17,7 +18,14 @@ type PublicRenderModelBase = components["schemas"]["PublicRenderModelBase"]; */ export function RailContext({ model }: { model: PublicRenderModelBase }) { const topic = model.topic.label ? model.topic : null; - if (!model.project && !topic) return null; + const reachable = [...model.relations] + .filter((relation) => resolvesToPublicRoute(relation.publicPath ?? "")) + .sort((left, right) => left.order - right.order); + const path = [ + reachable[0] ? { ...reachable[0], mark: "다음" } : null, + reachable.length > 1 ? { ...reachable.at(-1)!, mark: "앞" } : null, + ].filter((step) => step !== null); + if (!model.project && !topic && path.length === 0) return null; return ( ); } 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 38e6a38..114af00 100644 --- a/src/features/tech-log/presentation/studio/components/asset-library.tsx +++ b/src/features/tech-log/presentation/studio/components/asset-library.tsx @@ -2,6 +2,8 @@ import { useEffect, useId, useRef, useState, type FormEvent } from "react"; import { DestructiveConfirmDialog } from "./destructive-confirm-dialog.tsx"; import type { Asset, AssetDetail } from "../../../contracts/studio/contract.ts"; + +type AssetKind = Asset["kind"]; import type { StudioAssetGateway } from "../../../application/ports/studio-asset-gateway.ts"; import { isStudioGatewayError } from "../../../application/ports/studio-gateway-error.ts"; import { createLocalId } from "../../../domain/studio/local-id.ts"; @@ -60,6 +62,13 @@ export function AssetLibrary(props: Readonly<{ gateway: StudioAssetGateway }>) { // request per deliberate search, never a trailing one after the user stops. const [searchDraft, setSearchDraft] = useState(""); const [q, setQ] = useState(""); + /* + 종류는 서버가 걸러 준다(`kind`). 쓰임 여부는 계약에 없는 조건이라 받아 온 목록에서 거른다 — + 다음 쪽에 있는 것까지 세지는 못하므로 그 사실을 화면에 적는다. 없는 필터를 있는 척하는 것이 + 가장 나쁘다. + */ + const [kindFilter, setKindFilter] = useState(""); + const [usageFilter, setUsageFilter] = useState<"" | "USED" | "UNUSED">(""); const [nextCursor, setNextCursor] = useState(null); const [morePending, setMorePending] = useState(false); const [selected, setSelected] = useState(null); @@ -88,7 +97,7 @@ export function AssetLibrary(props: Readonly<{ gateway: StudioAssetGateway }>) { setListStatus("LOADING"); props.gateway .listAssets( - { ...(q ? { q } : {}), limit: PAGE_SIZE }, + { ...(q ? { q } : {}), ...(kindFilter ? { kind: kindFilter } : {}), limit: PAGE_SIZE }, { signal: controller.signal }, ) .then((page) => { @@ -108,7 +117,7 @@ export function AssetLibrary(props: Readonly<{ gateway: StudioAssetGateway }>) { active = false; controller.abort(); }; - }, [props.gateway, q]); + }, [props.gateway, q, kindFilter]); // A freshly opened detail panel should take focus so keyboard and screen // reader users land on it without hunting; re-rendering the same asset @@ -162,6 +171,7 @@ export function AssetLibrary(props: Readonly<{ gateway: StudioAssetGateway }>) { try { const page = await props.gateway.listAssets({ ...(q ? { q } : {}), + ...(kindFilter ? { kind: kindFilter } : {}), cursor, limit: PAGE_SIZE, }); @@ -252,6 +262,52 @@ export function AssetLibrary(props: Readonly<{ gateway: StudioAssetGateway }>) { } } + const [altDraft, setAltDraft] = useState(""); + const [decorativeDraft, setDecorativeDraft] = useState(false); + + /* 상세를 열 때마다 그 자료의 값으로 칸을 맞춘다 — 앞서 보던 자료의 글이 남아 있으면 안 된다. */ + useEffect(() => { + setAltDraft(selected?.asset.altText ?? ""); + setDecorativeDraft(selected?.asset.decorative ?? false); + }, [selected?.asset.id, selected?.asset.altText, selected?.asset.decorative]); + + const saveAltText = async () => { + const detail = selected; + if (!detail || pending) return; + setPending(true); + setNotice(""); + try { + const updated = await props.gateway.updateAssetMetadata( + detail.asset.id, + { + expectedVersion: detail.asset.version, + altText: altDraft.trim() ? altDraft : null, + decorative: decorativeDraft, + }, + { idempotencyKey: createLocalId("studio-asset-alt") }, + ); + setAssets((current) => + current.map((item) => (item.id === updated.id ? updated : item)), + ); + setSelected({ ...detail, asset: updated }); + setNotice("대체 텍스트를 저장했습니다."); + } catch (error) { + setNotice( + isStudioGatewayError(error) ? error.problem.detail : "저장하지 못했습니다.", + ); + } finally { + setPending(false); + } + }; + + const visibleAssets = assets.filter((asset) => + usageFilter === "USED" + ? asset.usageCount > 0 + : usageFilter === "UNUSED" + ? asset.usageCount === 0 + : true, + ); + return (
    @@ -277,6 +333,40 @@ export function AssetLibrary(props: Readonly<{ gateway: StudioAssetGateway }>) {
    + {/* + 종류는 서버가 걸러 준다. 쓰임 여부는 계약에 없어 받아 온 목록에서 거르므로, 다음 쪽에 + 있는 것까지 세지 못한다는 사실을 함께 적는다 — 없는 필터를 있는 척하지 않는다. + */} +
    + + + {usageFilter ? ( + 불러온 목록 안에서만 거릅니다. + ) : null} +
    {/* @@ -318,9 +408,9 @@ export function AssetLibrary(props: Readonly<{ gateway: StudioAssetGateway }>) { ) : null} - {assets.length > 0 ? ( + {visibleAssets.length > 0 ? (
      - {assets.map((asset) => ( + {visibleAssets.map((asset) => (
    • {/* key 만 있던 동안 이 목록은 "무엇을 고르는지" 를 말해 주지 못했다. Asset 이 스무 @@ -409,10 +499,44 @@ export function AssetLibrary(props: Readonly<{ gateway: StudioAssetGateway }>) {
      파일
      {assetFacts(selected.asset)}
      {/* 본문이 가리키는 불변 식별자. 사람이 기억하는 이름이 아니라 복사해 쓰는 값이다. */}
      Key
      {selected.asset.assetKey}
      - {selected.asset.altText ? ( -
      대체 텍스트
      {selected.asset.altText}
      - ) : null} + {/* + 대체 텍스트는 이 자료의 성질이므로 여기서 고친다. 예전에는 업로드할 때 한 번 적고 + 끝이라, 나중에 잘못 적은 것을 알아도 고칠 자리가 없었다 — 그 글은 그림을 못 보는 + 사람에게는 그림 자체다. + + 설명(caption)은 여기 없다. 같은 그림을 다른 기록에서 다른 말로 설명할 수 있어서 + 자료가 아니라 본문이 갖는 값이다(`:::evidence caption=…`). + */} +
      { + event.preventDefault(); + void saveAltText(); + }} + > + +