feat: 환경 구성(SETUP) 기록 종류를 더한다
다섯 종류는 전부 끝난 일을 남긴다. 없는 것은 읽는 사람이 자기 손으로 다시 하려면 무엇부터 하는가다. Case 의 environment 는 평문 한 칸이라 명령이 들어가지 않고, 같은 셋업을 쓰는 Case 가 넷이면 같은 문장이 네 벌 복제된다. 프로젝트는 필수, 주제는 선택으로 둔다. 주제 없는 셋업이 그 프로젝트의 공통 구성이고, 주제를 붙이면 그 주제의 구성이다 — 스키마를 나누지 않고 두 범위를 같은 종류로 받는다. 버전만 본문 밖에 둔다(pinnedVersions). 이 절차가 어느 버전 위에서 성립했는지는 그 기록의 유효 범위이고, 목록과 머리말이 본문을 열지 않고 보여 줘야 한다. 나머지 셋(실행 절차·구성 값·확인 방법)은 명령과 표를 담아야 하므로 본문이다. 이름은 SETUP 이다. ENVIRONMENT 가 영어로는 자연스럽지만 case_detail.environment 와 겹친다 — 이 저장소가 열네 번 밟은 실패가 「종류를 손으로 나열한 곳을 빠뜨린다」이고 그걸 찾는 수단이 grep 이다. 손으로 나열해 두었던 자리를 이번에 표로 바꿨다. publicPath 의 삼항 사슬은 마지막 else 가 「나머지 전부」여서 새 종류의 주소가 조용히 /questions/… 가 됐고, document-editor 의 칸 경로도 같은 모양이었다. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PTnWufiY9ATv57egkKKVAV
This commit is contained in:
co-authored by
Claude Opus 5
parent
3374f286be
commit
3af9be9e09
@@ -18,6 +18,7 @@ const EXPLORE_KIND_ORDER: Record<RecordKind, number> = {
|
||||
REFERENCE: 2,
|
||||
QUESTION: 3,
|
||||
CONCEPT: 4,
|
||||
SETUP: 5,
|
||||
};
|
||||
|
||||
export const EXPLORE_KINDS: ReadonlyArray<RecordKind> = Object.freeze(
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
import type { SetupRecord } from "../../../application/ports/public-content-queries.ts";
|
||||
import {
|
||||
parseCaseContent,
|
||||
type CaseAuthoringBlock,
|
||||
} from "../../../domain/content-format/parse-case-content.ts";
|
||||
import { resolveCaseEvidenceAssets } from "../../../domain/content-format/project-public-render-model.ts";
|
||||
import { PublicRecordRenderer } from "../../shared/public-render/public-record-renderer.tsx";
|
||||
import { publicRenderModelBase } from "./public-document-header.tsx";
|
||||
|
||||
/**
|
||||
* 환경 구성의 본문도 Case 와 같은 파서를 탄다 — `##` 소제목이 목차가 되고 `:::evidence` 가
|
||||
* 도식을 끌어온다. 셋업 절차에 구성도가 붙는 길이 그것뿐이다.
|
||||
*
|
||||
* <p>본문이 지원하지 않는 문법을 담고 있으면 화면 전체를 잃는 대신 빈 블록으로 돌아간다.
|
||||
* 읽는 사람에게는 덜 정확한 화면이 빈 화면보다 낫다 — Case 가 쓰는 것과 같은 판단이다.
|
||||
*/
|
||||
function setupBodyBlocks(record: SetupRecord): CaseAuthoringBlock[] {
|
||||
if (!record.content.trim()) return [];
|
||||
try {
|
||||
return parseCaseContent(record.content);
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
export function SetupDocumentPage({ record }: { record: SetupRecord }) {
|
||||
/*
|
||||
본문은 evidence 를 key 로만 가리키고 `/media/{assetId}` 는 UUID 로만 서빙하므로, 계약이 함께
|
||||
준 `bodyAssets` 로 key 를 주소로 바꾼다. 대응이 없는 key 는 그 블록을 지운다 — 해석기가
|
||||
던지면 문서 전체가 사라지고, 남겨 두면 주소 없는 그림 자리가 남는다.
|
||||
*/
|
||||
const assetsByKey = new Map(
|
||||
record.bodyAssets.map((asset) => [asset.assetKey, asset]),
|
||||
);
|
||||
const blocks = setupBodyBlocks(record).filter(
|
||||
(block) => block.type !== "EVIDENCE_FIGURE" || assetsByKey.has(block.key),
|
||||
);
|
||||
|
||||
const model = resolveCaseEvidenceAssets(
|
||||
{
|
||||
...publicRenderModelBase(record),
|
||||
kind: "SETUP",
|
||||
pinnedVersions: record.pinnedVersions.map((pinned) => ({ ...pinned })),
|
||||
bodyBlocks: blocks,
|
||||
},
|
||||
(key) => {
|
||||
const asset = assetsByKey.get(key);
|
||||
// 위에서 이미 걸렀다 — 여기 닿으면 필터와 해석기가 어긋난 것이다.
|
||||
if (!asset) throw new Error(`setup evidence asset not found: ${key}`);
|
||||
return {
|
||||
assetId: asset.assetId,
|
||||
assetKey: asset.assetKey,
|
||||
mediaType: asset.contentType,
|
||||
publicPath: asset.url,
|
||||
width: asset.width,
|
||||
height: asset.height,
|
||||
decorative: asset.decorative,
|
||||
};
|
||||
},
|
||||
);
|
||||
|
||||
return (
|
||||
<PublicRecordRenderer
|
||||
model={model}
|
||||
resolveEvidenceAsset={(key) => {
|
||||
const asset = assetsByKey.get(key);
|
||||
if (!asset) throw new Error(`setup evidence asset not found: ${key}`);
|
||||
return {
|
||||
src: asset.url,
|
||||
width: asset.width ?? 0,
|
||||
height: asset.height ?? 0,
|
||||
triggerLabel: `${asset.altText || asset.assetKey} 크게 보기`,
|
||||
dialogLabel: asset.altText || asset.assetKey,
|
||||
};
|
||||
}}
|
||||
resolvePublishedLabel={(path) =>
|
||||
path === record.path ? record.publishedLabel : undefined
|
||||
}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -14,6 +14,7 @@ const kinds = {
|
||||
references: { kind: "REFERENCE", title: DOCUMENT_KIND_LABELS.REFERENCE, description: "다시 확인할 수 있는 기술 기준과 적용 범위를 정리합니다." },
|
||||
questions: { kind: "QUESTION", title: DOCUMENT_KIND_LABELS.QUESTION, description: "확인한 사실과 미지수, 다음 검증을 공개적으로 추적합니다." },
|
||||
concepts: { kind: "CONCEPT", title: DOCUMENT_KIND_LABELS.CONCEPT, description: "개념의 내부 동작과 아키텍처를 처음부터 풀어 씁니다." },
|
||||
setups: { kind: "SETUP", title: DOCUMENT_KIND_LABELS.SETUP, description: "이 기록을 자기 손으로 재현하는 절차를 남깁니다." },
|
||||
} as const;
|
||||
|
||||
function optionalString(value: unknown): string | undefined {
|
||||
@@ -25,7 +26,8 @@ function getKindConfig(value: string | undefined) {
|
||||
value === "cases" ||
|
||||
value === "references" ||
|
||||
value === "questions" ||
|
||||
value === "concepts"
|
||||
value === "concepts" ||
|
||||
value === "setups"
|
||||
) {
|
||||
return kinds[value];
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { Link, useNavigate } from "react-router-dom";
|
||||
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: "개념", PROJECT: "Project", RELEASE: "Release" } as const;
|
||||
const labels = { CASE: "Case", REFERENCE: "Reference", QUESTION: "Open Question", CONCEPT: "개념", SETUP: "환경 구성", PROJECT: "Project", RELEASE: "Release" } as const;
|
||||
|
||||
function optionalString(value: unknown): string | undefined {
|
||||
return typeof value === "string" ? value : undefined;
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
import {
|
||||
RegisteredNotFoundRoute,
|
||||
useRouteInput,
|
||||
} from "../../../../../presentation/routes/route-input.tsx";
|
||||
import { SetupDocumentPage } from "../components/setup-document-page.tsx";
|
||||
import { usePublicContent } from "../use-public-content.tsx";
|
||||
|
||||
function optionalString(value: unknown): string | undefined {
|
||||
return typeof value === "string" ? value : undefined;
|
||||
}
|
||||
|
||||
export function SetupPage() {
|
||||
const { params } = useRouteInput<"TECH_LOG_SETUP">();
|
||||
const slug = optionalString(params.slug);
|
||||
const view = usePublicContent(
|
||||
["tech-log", "setup", slug],
|
||||
async (queries) => ({
|
||||
record: slug ? await queries.getRecord("SETUP", slug) : undefined,
|
||||
}),
|
||||
);
|
||||
if (!view.ready) return view.fallback;
|
||||
|
||||
const { record } = view.data;
|
||||
return record ? (
|
||||
<SetupDocumentPage record={record} />
|
||||
) : (
|
||||
<RegisteredNotFoundRoute />
|
||||
);
|
||||
}
|
||||
@@ -23,6 +23,7 @@ export const DOCUMENT_KIND_LABELS: Record<RecordKind, string> = {
|
||||
REFERENCE: "적용 기준",
|
||||
PROJECT_DECISION: "설계 결정",
|
||||
QUESTION: "열린 질문",
|
||||
SETUP: "환경 구성",
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -38,6 +39,8 @@ export const DOCUMENT_KIND_STATES: Record<RecordKind, "CONFIRMED" | "SETTLED" |
|
||||
REFERENCE: "SETTLED",
|
||||
PROJECT_DECISION: "SETTLED",
|
||||
QUESTION: "OPEN",
|
||||
/* 셋업은 확인한 것도 열린 것도 아니다 — 절차를 정리해 둔 것이다. */
|
||||
SETUP: "SETTLED",
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -56,4 +59,5 @@ export const EXPLORE_KIND_PATHS: Record<RecordKind, string> = {
|
||||
REFERENCE: "/explore/references",
|
||||
QUESTION: "/explore/questions",
|
||||
PROJECT_DECISION: "/projects",
|
||||
SETUP: "/explore/setups",
|
||||
};
|
||||
|
||||
@@ -21,6 +21,7 @@ type PublicRenderModelBase = components["schemas"]["PublicRenderModelBase"];
|
||||
type ResolvedRelation = components["schemas"]["ResolvedRelation"];
|
||||
type CasePublicRenderModel = components["schemas"]["CasePublicRenderModel"];
|
||||
type ConceptPublicRenderModel = components["schemas"]["ConceptPublicRenderModel"];
|
||||
type SetupPublicRenderModel = components["schemas"]["SetupPublicRenderModel"];
|
||||
type ReferencePublicRenderModel =
|
||||
components["schemas"]["ReferencePublicRenderModel"];
|
||||
type QuestionPublicRenderModel =
|
||||
@@ -308,6 +309,93 @@ function ConceptDocument({
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 환경 구성.
|
||||
*
|
||||
* <p>개념과 같은 본문·목차·Asset 을 쓰되 머리말이 다르다. 낡음을 말하는 것이 한 줄짜리
|
||||
* 「기준」이 아니라 이름·버전 쌍의 표다 — Keycloak 과 Spring Boot 와 PostgreSQL 이 각각
|
||||
* 어느 버전이었는지가 이 절차의 유효 범위다.
|
||||
*
|
||||
* <p>주제는 없을 수 있다. 주제 없는 셋업이 그 프로젝트의 공통 구성이고, 그때는 경로에서
|
||||
* 주제 마디를 뺀다 — 빈 링크가 남으면 누를 것이 없는 자리가 생긴다.
|
||||
*/
|
||||
function SetupDocument({
|
||||
model,
|
||||
embedded,
|
||||
resolveEvidenceAsset,
|
||||
resolvePublishedLabel,
|
||||
}: {
|
||||
model: SetupPublicRenderModel;
|
||||
embedded: boolean;
|
||||
} & RenderDependencies) {
|
||||
const headings = model.bodyBlocks
|
||||
.filter((block) => block.type === "HEADING")
|
||||
.map((heading) => ({
|
||||
id: heading.id,
|
||||
label: inlinePlainText(heading.content),
|
||||
}));
|
||||
|
||||
const Root = embedded ? "div" : "main";
|
||||
return (
|
||||
<Root
|
||||
id={embedded ? undefined : "main-content"}
|
||||
className={`case-page${embedded ? " public-record-embedded" : ""}`}
|
||||
>
|
||||
<header className="shell case-header">
|
||||
<nav className="case-breadcrumb" aria-label="문서 경로">
|
||||
<Link to="/explore/setups">{DOCUMENT_KIND_LABELS.SETUP}</Link>
|
||||
{model.topic.label ? (
|
||||
<>
|
||||
<span aria-hidden="true">/</span>
|
||||
<TargetLink target={model.topic} />
|
||||
</>
|
||||
) : null}
|
||||
{model.project ? (
|
||||
<>
|
||||
<span aria-hidden="true">/</span>
|
||||
<TargetLink target={model.project} />
|
||||
</>
|
||||
) : null}
|
||||
</nav>
|
||||
|
||||
<h1>{model.title}</h1>
|
||||
<ProseText text={model.summary} className="case-summary" />
|
||||
|
||||
{model.pinnedVersions.length > 0 ? (
|
||||
<dl className="case-meta setup-versions">
|
||||
{model.pinnedVersions.map((pinned) => (
|
||||
<div key={`${pinned.name}-${pinned.version}`}>
|
||||
<dt>{pinned.name}</dt>
|
||||
<dd>{pinned.version}</dd>
|
||||
</div>
|
||||
))}
|
||||
</dl>
|
||||
) : null}
|
||||
|
||||
<dl className="case-meta">
|
||||
<div>
|
||||
<dt>기록</dt>
|
||||
<dd>게시 {publishedLabel(model, resolvePublishedLabel)}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
</header>
|
||||
|
||||
<DocumentToc headings={headings} variant="mobile" />
|
||||
|
||||
<div className="shell document-layout">
|
||||
<article className="document-body">
|
||||
<CaseBodyRenderer
|
||||
blocks={model.bodyBlocks}
|
||||
resolveEvidenceAsset={resolveEvidenceAsset}
|
||||
/>
|
||||
<PublicDocumentRelations relations={publicRelations(model.relations)} />
|
||||
</article>
|
||||
<DocumentToc headings={headings} variant="desktop" />
|
||||
</div>
|
||||
</Root>
|
||||
);
|
||||
}
|
||||
|
||||
function ReferenceDocument({
|
||||
model,
|
||||
embedded,
|
||||
@@ -613,6 +701,15 @@ export function PublicRecordRenderer({
|
||||
resolvePublishedLabel={resolvePublishedLabel}
|
||||
/>
|
||||
);
|
||||
case "SETUP":
|
||||
return (
|
||||
<SetupDocument
|
||||
model={model}
|
||||
embedded={embedded}
|
||||
resolveEvidenceAsset={resolveEvidenceAsset}
|
||||
resolvePublishedLabel={resolvePublishedLabel}
|
||||
/>
|
||||
);
|
||||
case "PROJECT_DECISION":
|
||||
return (
|
||||
<ProjectDecisionDocument model={model} embedded={embedded} />
|
||||
|
||||
@@ -11,8 +11,10 @@ import { DECISION_FIELD_PATHS, ProjectDecisionFields } from "./project-decision-
|
||||
import { issuesOutside } from "./field-issues.tsx";
|
||||
import { QUESTION_FIELD_PATHS, QuestionFields } from "./question-fields.tsx";
|
||||
import { REFERENCE_FIELD_PATHS, ReferenceFields } from "./reference-fields.tsx";
|
||||
import { SETUP_FIELD_PATHS, SetupFields } from "./setup-fields.tsx";
|
||||
|
||||
type CatalogEntry = components["schemas"]["CatalogEntry"];
|
||||
type RecordKind = components["schemas"]["RecordKind"];
|
||||
|
||||
export function DocumentEditor({
|
||||
controller,
|
||||
@@ -44,15 +46,20 @@ export function DocumentEditor({
|
||||
남는다.
|
||||
*/
|
||||
const issues = controller.publishIssues;
|
||||
const kindPaths = controller.draft.kind === "CASE"
|
||||
? CASE_FIELD_PATHS
|
||||
: controller.draft.kind === "CONCEPT"
|
||||
? CONCEPT_FIELD_PATHS
|
||||
: controller.draft.kind === "REFERENCE"
|
||||
? REFERENCE_FIELD_PATHS
|
||||
: controller.draft.kind === "QUESTION"
|
||||
? QUESTION_FIELD_PATHS
|
||||
: DECISION_FIELD_PATHS;
|
||||
/*
|
||||
삼항 사슬의 마지막 else 가 「나머지 전부」였다. 종류를 더하면 그 종류의 지적이 결정의
|
||||
칸 경로로 걸러져, 자기 칸 아래에 붙지도 게시 버튼 옆에 남지도 않고 사라진다. 표로 두면
|
||||
컴파일러가 빈 자리를 잡는다.
|
||||
*/
|
||||
const KIND_PATHS: Record<RecordKind, readonly string[]> = {
|
||||
CASE: CASE_FIELD_PATHS,
|
||||
CONCEPT: CONCEPT_FIELD_PATHS,
|
||||
REFERENCE: REFERENCE_FIELD_PATHS,
|
||||
QUESTION: QUESTION_FIELD_PATHS,
|
||||
SETUP: SETUP_FIELD_PATHS,
|
||||
PROJECT_DECISION: DECISION_FIELD_PATHS,
|
||||
};
|
||||
const kindPaths = KIND_PATHS[controller.draft.kind];
|
||||
const unplaced = issuesOutside(issues, [...COMMON_FIELD_PATHS, ...kindPaths]);
|
||||
|
||||
/*
|
||||
@@ -77,6 +84,8 @@ export function DocumentEditor({
|
||||
? <CaseFields draft={controller.draft} issues={issues} onChange={controller.replace} onAssetsObserved={onAssetsObserved} onAssetUploaded={onAssetUploaded} />
|
||||
: controller.draft.kind === "CONCEPT"
|
||||
? <ConceptFields draft={controller.draft} issues={issues} onChange={controller.replace} onAssetsObserved={onAssetsObserved} onAssetUploaded={onAssetUploaded} />
|
||||
: controller.draft.kind === "SETUP"
|
||||
? <SetupFields draft={controller.draft} issues={issues} onChange={controller.replace} onAssetsObserved={onAssetsObserved} onAssetUploaded={onAssetUploaded} />
|
||||
: controller.draft.kind === "REFERENCE"
|
||||
? <ReferenceFields draft={controller.draft} issues={issues} onChange={controller.replace} />
|
||||
: controller.draft.kind === "QUESTION"
|
||||
|
||||
@@ -20,7 +20,8 @@ const STUDIO_KIND_ORDER: Record<RecordKind, number> = {
|
||||
CONCEPT: 2,
|
||||
REFERENCE: 3,
|
||||
QUESTION: 4,
|
||||
PROJECT_DECISION: 5,
|
||||
SETUP: 5,
|
||||
PROJECT_DECISION: 6,
|
||||
};
|
||||
|
||||
const STUDIO_KINDS: ReadonlyArray<RecordKind> = Object.freeze(
|
||||
|
||||
@@ -26,6 +26,12 @@ const types = [
|
||||
description: "개념의 내부 동작과 아키텍처를 처음부터 풀어 씁니다.",
|
||||
fields: "기준 버전 · 본문",
|
||||
},
|
||||
{
|
||||
kind: "SETUP",
|
||||
title: "환경 구성",
|
||||
description: "이 기록을 자기 손으로 재현하는 절차를 남깁니다.",
|
||||
fields: "버전 · 본문",
|
||||
},
|
||||
{
|
||||
kind: "QUESTION",
|
||||
title: "Question",
|
||||
@@ -76,6 +82,18 @@ function emptyDocument(kind: RecordKind): CreateDocumentInput {
|
||||
if (kind === "CONCEPT") {
|
||||
return { ...common, kind, bodyMarkdown: "", basisVersion: "" };
|
||||
}
|
||||
if (kind === "SETUP") {
|
||||
/*
|
||||
절 이름을 스키마로 강제하지 않는다 — 프로젝트마다 셋업의 모양이 다르다. 대신 빈 본문
|
||||
대신 뼈대를 넣어 준다. 지우고 자기 절을 써도 되고, 그대로 채워도 된다.
|
||||
*/
|
||||
return {
|
||||
...common,
|
||||
kind,
|
||||
bodyMarkdown: "## 실행 절차\n\n## 구성 값\n\n## 확인 방법\n",
|
||||
pinnedVersions: [],
|
||||
};
|
||||
}
|
||||
if (kind === "QUESTION") {
|
||||
return {
|
||||
...common,
|
||||
|
||||
@@ -0,0 +1,202 @@
|
||||
import { useRef, useState } from "react";
|
||||
|
||||
import type { components } from "../../../contracts/studio/generated.ts";
|
||||
import type { Asset, AssetKind } from "../../../contracts/studio/contract.ts";
|
||||
import { useStudioAssetGateway } from "../use-studio.ts";
|
||||
import { AssetPicker, buildEvidenceDirective } from "./asset-picker.tsx";
|
||||
import { AssetUploadDialog } from "./asset-upload-dialog.tsx";
|
||||
import { MarkdownToolbar } from "./markdown-toolbar.tsx";
|
||||
import { FieldNotice, type FieldIssue } from "./field-issues.tsx";
|
||||
|
||||
type SetupInput = components["schemas"]["SetupInput"];
|
||||
type PinnedVersion = components["schemas"]["PinnedVersion"];
|
||||
|
||||
/** 이 화면이 자기 칸 아래에 보여 줄 수 있는 경로. */
|
||||
export const SETUP_FIELD_PATHS = ["/pinnedVersions", "/bodyMarkdown"] as const;
|
||||
|
||||
const ASSET_KIND_OPTIONS: ReadonlyArray<{ value: AssetKind; label: string }> = [
|
||||
{ value: "IMAGE", label: "이미지" },
|
||||
{ value: "DIAGRAM", label: "다이어그램" },
|
||||
{ value: "ATTACHMENT", label: "첨부파일" },
|
||||
];
|
||||
|
||||
/**
|
||||
* `:::evidence ...` is a block directive, so the parser requires a blank line
|
||||
* before and after it. Inserting straight into `selectionStart`/`selectionEnd`
|
||||
* without normalizing the surrounding whitespace would produce a directive
|
||||
* glued to adjacent text -- a well-formed-looking block that the parser still
|
||||
* rejects.
|
||||
*/
|
||||
function insertAtCursor(
|
||||
textarea: HTMLTextAreaElement,
|
||||
directive: string,
|
||||
commit: (next: string) => void,
|
||||
) {
|
||||
const { selectionStart, selectionEnd, value } = textarea;
|
||||
const prefix = value.slice(0, selectionStart);
|
||||
const suffix = value.slice(selectionEnd);
|
||||
const before = prefix.length === 0 || prefix.endsWith("\n\n") ? prefix : `${prefix}\n\n`;
|
||||
const after = suffix.startsWith("\n") ? suffix : `\n${suffix}`;
|
||||
commit(`${before}${directive}${after}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 환경 구성 편집 화면.
|
||||
*
|
||||
* <p>다른 다섯 종류는 끝난 일을 적는다. 이 종류만 읽는 사람이 그대로 따라 하는 절차를 적으므로,
|
||||
* 본문에 명령과 표가 들어간다 — Case 의 「검증 환경」 같은 평문 한 칸으로는 담기지 않는다.
|
||||
*
|
||||
* <p>버전만 본문 밖에 둔다. 이 절차가 어느 버전 위에서 성립했는지는 그 기록의 유효 범위이고,
|
||||
* 목록과 머리말이 본문을 열지 않고 보여 줘야 하는 값이기 때문이다. 개념의 「기준 버전」이 같은
|
||||
* 이유로 따로 있고, 다른 점은 셋업의 버전이 하나가 아니라 여럿이라는 것뿐이다.
|
||||
*/
|
||||
export function SetupFields({
|
||||
draft,
|
||||
issues,
|
||||
onChange,
|
||||
onAssetsObserved,
|
||||
onAssetUploaded,
|
||||
}: {
|
||||
draft: SetupInput;
|
||||
/** 마지막 게시 시도가 남긴 지적. 각 칸 아래에는 그 칸의 것만 붙는다. */
|
||||
issues: readonly FieldIssue[];
|
||||
onChange(draft: SetupInput): void;
|
||||
onAssetsObserved?: (assets: readonly Asset[]) => void;
|
||||
onAssetUploaded?: (asset: Asset) => void;
|
||||
}) {
|
||||
const assetGateway = useStudioAssetGateway();
|
||||
const bodyRef = useRef<HTMLTextAreaElement>(null);
|
||||
const uploadTriggerRef = useRef<HTMLButtonElement>(null);
|
||||
const [uploadKind, setUploadKind] = useState<AssetKind>("DIAGRAM");
|
||||
const [uploadOpen, setUploadOpen] = useState(false);
|
||||
const update = (patch: Partial<SetupInput>) => onChange({ ...draft, ...patch });
|
||||
|
||||
const replaceVersion = (index: number, patch: Partial<PinnedVersion>) => {
|
||||
update({
|
||||
pinnedVersions: draft.pinnedVersions.map((pinned, at) =>
|
||||
at === index ? { ...pinned, ...patch } : pinned,
|
||||
),
|
||||
});
|
||||
};
|
||||
|
||||
const insertDirective = (directive: string) => {
|
||||
const textarea = bodyRef.current;
|
||||
if (!textarea) {
|
||||
update({
|
||||
bodyMarkdown: draft.bodyMarkdown
|
||||
? `${draft.bodyMarkdown}\n\n${directive}\n`
|
||||
: `${directive}\n`,
|
||||
});
|
||||
return;
|
||||
}
|
||||
insertAtCursor(textarea, directive, (next) => update({ bodyMarkdown: next }));
|
||||
};
|
||||
|
||||
const closeUpload = () => {
|
||||
setUploadOpen(false);
|
||||
queueMicrotask(() => uploadTriggerRef.current?.focus());
|
||||
};
|
||||
|
||||
return (
|
||||
<section className="studio-editor-section" aria-labelledby="studio-setup-fields-title">
|
||||
<div className="studio-editor-section-heading">
|
||||
<p className="studio-eyebrow">SETUP</p>
|
||||
<h2 id="studio-setup-fields-title">환경 구성</h2>
|
||||
</div>
|
||||
<div className="studio-field-grid">
|
||||
<div className="studio-field studio-field--wide" role="group" aria-labelledby="studio-pinned-versions-title">
|
||||
<span id="studio-pinned-versions-title">고정한 버전</span>
|
||||
<ul className="studio-pinned-versions">
|
||||
{draft.pinnedVersions.map((pinned, index) => (
|
||||
// 행에는 안정된 식별자가 없다. 값으로 키를 만들면 이름을 지우는 순간 키가
|
||||
// 겹쳐 입력 중이던 칸이 다른 행으로 옮겨 간다.
|
||||
<li key={index}>
|
||||
<label>
|
||||
<span>이름</span>
|
||||
<input
|
||||
value={pinned.name}
|
||||
onChange={(event) => replaceVersion(index, { name: event.currentTarget.value })}
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
<span>버전</span>
|
||||
<input
|
||||
value={pinned.version}
|
||||
onChange={(event) => replaceVersion(index, { version: event.currentTarget.value })}
|
||||
/>
|
||||
</label>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() =>
|
||||
update({
|
||||
pinnedVersions: draft.pinnedVersions.filter((_, at) => at !== index),
|
||||
})
|
||||
}
|
||||
>
|
||||
{`${pinned.name || `${index + 1}번째`} 삭제`}
|
||||
</button>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() =>
|
||||
update({ pinnedVersions: [...draft.pinnedVersions, { name: "", version: "" }] })
|
||||
}
|
||||
>
|
||||
버전 추가
|
||||
</button>
|
||||
<small>“Keycloak” / “26.7.0” 처럼 적습니다. 비우면 화면에 표를 그리지 않습니다.</small>
|
||||
<FieldNotice issues={issues} path="/pinnedVersions" />
|
||||
</div>
|
||||
<div className="studio-field studio-field--wide">
|
||||
<label htmlFor="studio-field-body">절차 Markdown</label>
|
||||
<MarkdownToolbar target={bodyRef} onInsert={(next) => update({ bodyMarkdown: next })} />
|
||||
<textarea
|
||||
id="studio-field-body"
|
||||
ref={bodyRef}
|
||||
className="studio-markdown-field"
|
||||
value={draft.bodyMarkdown}
|
||||
onChange={(event) => update({ bodyMarkdown: event.currentTarget.value })}
|
||||
/>
|
||||
<small>“##” 소제목이 목차가 됩니다. 명령은 코드블록으로 적어야 그대로 복사됩니다.</small>
|
||||
<FieldNotice issues={issues} path="/bodyMarkdown" />
|
||||
</div>
|
||||
</div>
|
||||
<div className="studio-asset-panel" role="group" aria-labelledby="studio-asset-panel-title">
|
||||
<p className="studio-eyebrow">EVIDENCE</p>
|
||||
<h3 id="studio-asset-panel-title">본문에 Asset 삽입</h3>
|
||||
<p>목록에서 선택하면 본문 커서 위치에 evidence 구문을 삽입합니다. READY 상태의 Asset만 선택할 수 있습니다.</p>
|
||||
<div className="studio-asset-panel-actions">
|
||||
<label className="studio-asset-kind-field">
|
||||
<span>업로드 종류</span>
|
||||
<select value={uploadKind} onChange={(event) => setUploadKind(event.currentTarget.value as AssetKind)}>
|
||||
{ASSET_KIND_OPTIONS.map((option) => <option key={option.value} value={option.value}>{option.label}</option>)}
|
||||
</select>
|
||||
</label>
|
||||
<button ref={uploadTriggerRef} type="button" onClick={() => setUploadOpen(true)}>
|
||||
Asset 업로드
|
||||
</button>
|
||||
</div>
|
||||
<AssetPicker gateway={assetGateway} onAssetsObserved={onAssetsObserved} onInsert={insertDirective} />
|
||||
</div>
|
||||
{uploadOpen ? (
|
||||
<AssetUploadDialog
|
||||
gateway={assetGateway}
|
||||
kind={uploadKind}
|
||||
onUploaded={(asset) => {
|
||||
onAssetUploaded?.(asset);
|
||||
insertDirective(buildEvidenceDirective({
|
||||
assetKey: asset.assetKey,
|
||||
alt: asset.decorative ? "" : (asset.altText ?? ""),
|
||||
caption: "",
|
||||
zoom: asset.kind === "DIAGRAM",
|
||||
}));
|
||||
closeUpload();
|
||||
}}
|
||||
onClose={closeUpload}
|
||||
/>
|
||||
) : null}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -75,6 +75,13 @@ export const TECH_LOG_ROUTE_RUNTIME = Object.freeze({
|
||||
"ConceptPage",
|
||||
),
|
||||
),
|
||||
TECH_LOG_SETUP: runtime(
|
||||
"TECH_LOG_SETUP",
|
||||
routeModule(
|
||||
() => import("./public/pages/setup-page.tsx"),
|
||||
"SetupPage",
|
||||
),
|
||||
),
|
||||
TECH_LOG_QUESTION: runtime(
|
||||
"TECH_LOG_QUESTION",
|
||||
routeModule(
|
||||
|
||||
Reference in New Issue
Block a user