Asset 목록이 `assetKey` 를 앞세우고 있었다. key 는 본문이 가리키는 불변 식별자이지 사람이 기억하는 이름이 아니다 — 스무 줄이면 해시 같은 문자열 스무 개에서 찾던 도식을 눈으로 골라야 했다. 파일 이름을 앞에 두고 형식·치수·크기를 함께 적는다. key 는 아래에 작게 남긴다(복사해 쓰는 값이라 지우지 않는다). 「사용 0건」과 「사용 3건」이 같은 회색으로 나란했다. 쓰이지 않는 자료는 지워도 되는 것이고 쓰이는 자료는 지우면 화면이 깨지므로, 그 차이를 말로 가른다. 상세에서는 어느 기록이 쓰는지를 링크로 연다 — 바꾸거나 지우기 전에 무엇이 깨질지 숫자만으로는 알 수 없다. 관리 상태도 `ARCHIVED` 대신 「보관됨」으로 적는다. 검증 결과는 오류와 경고가 한 목록에 섞여 있었다. 게시 전에 작성자가 알아야 하는 것은 "게시를 막는 것이 몇 개인가" 하나인데, 그 답을 얻으려면 줄마다 배지를 읽어야 했다. 둘을 갈라 각각의 수를 제목에 적는다. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015c8cBFUaVr7KLVUx6ujz7D
130 lines
5.2 KiB
TypeScript
130 lines
5.2 KiB
TypeScript
import type { ValidationReport as ValidationReportModel } from "../../../contracts/studio/contract.ts";
|
|
import { GuardedStudioLink } from "./guarded-studio-link.tsx";
|
|
|
|
const severityLabel = { ERROR: "오류", WARNING: "경고" } as const;
|
|
|
|
function pointerSegments(path: string): string[] {
|
|
return path
|
|
.split("/")
|
|
.slice(1)
|
|
.map((segment) => segment.replaceAll("~1", "/").replaceAll("~0", "~"))
|
|
.filter(Boolean);
|
|
}
|
|
|
|
export function validationFieldTarget(path: string): string {
|
|
const segments = pointerSegments(path).map((segment) =>
|
|
segment.replace(/[^a-zA-Z0-9_-]/g, "-")
|
|
);
|
|
return segments.length
|
|
? `studio-field-${segments.join("-")}`
|
|
: "studio-edit-panel";
|
|
}
|
|
|
|
function formatDateTime(value: string): string {
|
|
const date = new Date(value);
|
|
if (Number.isNaN(date.getTime())) return value;
|
|
return new Intl.DateTimeFormat("ko-KR", {
|
|
dateStyle: "medium",
|
|
timeStyle: "short",
|
|
timeZone: "Asia/Seoul",
|
|
}).format(date);
|
|
}
|
|
|
|
export function ValidationReport({
|
|
documentId,
|
|
report,
|
|
current,
|
|
}: {
|
|
documentId: string;
|
|
report: ValidationReportModel;
|
|
current: boolean;
|
|
}) {
|
|
const issues = [...report.issues].sort((left, right) => {
|
|
const rank = { ERROR: 0, WARNING: 1 } as const;
|
|
return rank[left.severity] - rank[right.severity];
|
|
});
|
|
|
|
return (
|
|
<section
|
|
className="studio-workflow-report"
|
|
aria-labelledby="studio-validation-report-title"
|
|
>
|
|
<div className="studio-workflow-section-heading">
|
|
<div>
|
|
<p className="studio-eyebrow">VALIDATION REPORT</p>
|
|
<h2 id="studio-validation-report-title">검증 결과</h2>
|
|
</div>
|
|
<span
|
|
className={`studio-workflow-status studio-workflow-status--${current ? report.status.toLowerCase() : "stale"}`}
|
|
>
|
|
{current ? report.status : "지난 결과"}
|
|
</span>
|
|
</div>
|
|
{/*
|
|
낡은 판정을 현재 것과 같은 모양으로 보여주면 읽는 사람은 지금 상태로 읽는다. 실제로
|
|
버전 2 때의 오류 목록을 보고 버전 5 가 그렇다고 이해한 일이 있었다 — "이전 결과" 라는
|
|
작은 글씨 하나로는 그 오해를 막지 못한다. 무엇에 대한 판정인지 먼저 말한다.
|
|
*/}
|
|
{current ? null : (
|
|
<p className="studio-workflow-stale-notice" role="status">
|
|
아래는 <strong>버전 {report.validatedVersion}</strong> 을 검사한 지난 결과입니다.
|
|
그 뒤 문서가 바뀌었으니 지금 상태와 다를 수 있습니다 — 위의 <strong>다시 검증</strong>을
|
|
눌러 현재 버전을 확인해 주세요.
|
|
</p>
|
|
)}
|
|
<dl className="studio-workflow-metadata">
|
|
<div><dt>대상 버전</dt><dd>{report.validatedVersion}</dd></div>
|
|
<div><dt>상태</dt><dd>{current ? "현재" : "이전 결과"}</dd></div>
|
|
<div><dt>검증 시각</dt><dd>{formatDateTime(report.validatedAt)}</dd></div>
|
|
<div><dt>유효 시각</dt><dd>{formatDateTime(report.validUntil)}</dd></div>
|
|
</dl>
|
|
{/*
|
|
오류와 경고를 갈라 세고 각각의 수를 제목에 적는다.
|
|
|
|
한 목록에 섞여 있으면 "게시를 막는 것이 몇 개인가" 라는 질문에 답하려면 줄마다 배지를
|
|
읽어야 한다. 게시 전에 작성자가 알아야 하는 것은 그 수 하나다 — 경고는 지금 고치지
|
|
않아도 나갈 수 있고 오류는 아니다.
|
|
*/}
|
|
{issues.length ? (
|
|
<>
|
|
{(["ERROR", "WARNING"] as const).map((severity) => {
|
|
const group = issues.filter((issue) => issue.severity === severity);
|
|
if (group.length === 0) return null;
|
|
return (
|
|
<div className="studio-workflow-issue-group" key={severity}>
|
|
<h3>
|
|
{severity === "ERROR" ? "게시를 막는 것" : "확인해 둘 것"}
|
|
<span>{group.length}</span>
|
|
</h3>
|
|
<ol
|
|
className={`studio-workflow-issue-list${current ? "" : " studio-workflow-issue-list--stale"}`}
|
|
aria-label={`${severityLabel[severity]} 항목`}
|
|
>
|
|
{group.map((issue, index) => (
|
|
<li key={`${issue.severity}-${issue.code}-${issue.path}-${index}`}>
|
|
<GuardedStudioLink
|
|
href={`/studio/documents/${documentId}/edit#${validationFieldTarget(issue.path)}`}
|
|
>
|
|
<span className="studio-workflow-issue-severity">
|
|
{severityLabel[issue.severity]}
|
|
</span>
|
|
<span className="studio-workflow-issue-body">
|
|
<strong>{issue.message}</strong>
|
|
<small>{issue.code} · {issue.path || "/"}</small>
|
|
</span>
|
|
<span aria-hidden="true">편집 →</span>
|
|
</GuardedStudioLink>
|
|
</li>
|
|
))}
|
|
</ol>
|
|
</div>
|
|
);
|
|
})}
|
|
</>
|
|
) : (
|
|
<p className="studio-workflow-empty-issues">오류와 경고가 없습니다.</p>
|
|
)}
|
|
</section>
|
|
);
|
|
}
|