게시 화면이 버전 번호만 말했다. 관계는 공개 화면의 「다음에 읽을 것」이 되고 본문의 자료는 그림 자리가 되므로, 무엇이 함께 나가는지를 수로 먼저 보인다. 둘 다 0 이면 이 기록은 홀로 서는 글이라는 뜻이고, 그건 게시 전에 알아야 하는 사실이다. 프로젝트의 논지와 주제가 답하는 질문이 비어 있으면 화면이 빈 문단을 그렸다. 아직 안 쓴 것과 쓸 것이 없는 것은 다르다 — 빈 자리는 화면이 덜 만들어진 것처럼 보이고, 읽는 사람은 이 프로젝트에 결론이 없다고 읽는다. 조사가 어디쯤인지를 말한다. Studio 구조 화면은 현재 목표가 비어 있는 프로젝트와 답하는 질문이 비어 있는 주제를 짚는다. 그 값들이 공개 화면의 첫 문단을 그리는데, 무엇이 비었는지는 편집기를 하나씩 열어야 알 수 있었다. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015c8cBFUaVr7KLVUx6ujz7D
592 lines
24 KiB
TypeScript
592 lines
24 KiB
TypeScript
import { useCallback, useEffect, useState, type FormEvent } from "react";
|
|
import { PROJECT_PHASE_LABELS } from "../../../domain/public/project-phase-labels.ts";
|
|
import { DestructiveConfirmDialog } from "./destructive-confirm-dialog.tsx";
|
|
|
|
import type { ProjectIndexItem, TopicEdit } from "../../../contracts/management/contract.ts";
|
|
import { managementFailureMessage } from "../../../application/ports/management-gateway-error.ts";
|
|
import { GuardedStudioLink } from "./guarded-studio-link.tsx";
|
|
import { slugFromName } from "./slug-from-name.ts";
|
|
import { useStudio } from "../use-studio.ts";
|
|
|
|
/**
|
|
* 주제와 프로젝트 관리.
|
|
*
|
|
* <p>이 화면이 존재하는 이유는 문서 발행이 주제를 요구하는데 주제를 만들 곳이 없었기 때문이다.
|
|
* 그래서 범위를 목록·생성·삭제로 끊었다 — 편집(이름 변경, 단계 전환, 공개 범위)은 계약에 있고
|
|
* 백엔드도 구현돼 있으나, 그 화면은 별도 설계가 필요하다.
|
|
*
|
|
* <p>새 CSS 를 만들지 않는다. 작업본 목록이 쓰는 클래스만 재사용하므로 이 화면은 Studio 의
|
|
* 나머지와 같은 간격·타이포·색을 그대로 따른다.
|
|
*/
|
|
|
|
const visibilityLabel: Record<string, string> = {
|
|
PRIVATE: "비공개",
|
|
UNLISTED: "주소로만",
|
|
PUBLIC: "공개",
|
|
};
|
|
|
|
export function TaxonomyManager() {
|
|
const { managementGateway, setRequestAnnouncement } = useStudio();
|
|
const [topics, setTopics] = useState<TopicEdit[] | null>(null);
|
|
const [projects, setProjects] = useState<ProjectIndexItem[] | null>(null);
|
|
const [loading, setLoading] = useState(true);
|
|
const [error, setError] = useState("");
|
|
const [pending, setPending] = useState(false);
|
|
/*
|
|
주제와 프로젝트는 다른 기록이 매달려 있는 자리다. 지우기 직전에 무엇이 지워지는지 이름으로
|
|
보여 주고 한 번 묻는다 — 목록에서 두 줄 아래를 눌렀다는 것을 여기서 잡는다.
|
|
*/
|
|
/*
|
|
한 화면이 성격이 다른 두 엔티티를 같은 문법으로 다루고 있었다. 만들기 폼 둘이 한 줄에 붙어
|
|
「추가」 버튼 두 개가 같은 이름·같은 모양으로 나란히 섰고, 주제 행은 프로젝트에 맞춘 그리드라
|
|
절반이 빈칸이었다. 탭으로 나눠 한 번에 한 종류만 다룬다.
|
|
*/
|
|
const [tab, setTab] = useState<"STRUCTURE" | "TOPIC" | "PROJECT">("STRUCTURE");
|
|
/* 프로젝트마다 어느 주제를 묶었는지. 목록에는 없고 상세에만 있어 따로 읽는다. */
|
|
const [links, setLinks] = useState<ReadonlyMap<string, readonly string[]>>(new Map());
|
|
const [pendingDelete, setPendingDelete] = useState<
|
|
{ kind: "TOPIC"; topic: TopicEdit } | { kind: "PROJECT"; project: ProjectIndexItem } | null
|
|
>(null);
|
|
const [generation, setGeneration] = useState(0);
|
|
|
|
const [topicName, setTopicName] = useState("");
|
|
const [topicSlug, setTopicSlug] = useState("");
|
|
const [projectTitle, setProjectTitle] = useState("");
|
|
|
|
const reload = useCallback(() => setGeneration((value) => value + 1), []);
|
|
|
|
useEffect(() => {
|
|
let cancelled = false;
|
|
setLoading(true);
|
|
setError("");
|
|
void Promise.all([managementGateway.listTopics(), managementGateway.listProjects(0, 50)]).then(
|
|
([topicList, projectPage]) => {
|
|
if (cancelled) return;
|
|
setTopics(topicList);
|
|
const items = projectPage.items ?? [];
|
|
setProjects(items);
|
|
setLoading(false);
|
|
/*
|
|
어느 프로젝트가 어느 주제를 묶었는지는 목록에 없고 상세에만 있다. 구조를 그리려면
|
|
그 연결이 필요하므로 따로 읽는다 — 실패해도 목록 두 개는 이미 그려져 있으므로
|
|
구조 탭만 비고 화면 전체가 죽지는 않는다.
|
|
*/
|
|
void Promise.all(
|
|
items.map(async (project) =>
|
|
project.id
|
|
? ([project.id, (await managementGateway.getProject(project.id)).topicIds ?? []] as const)
|
|
: null,
|
|
),
|
|
).then(
|
|
(pairs) => {
|
|
if (cancelled) return;
|
|
setLinks(new Map(pairs.filter((pair) => pair !== null)));
|
|
},
|
|
() => undefined,
|
|
);
|
|
},
|
|
() => {
|
|
if (cancelled) return;
|
|
setError("주제와 프로젝트를 불러오지 못했습니다.");
|
|
setLoading(false);
|
|
},
|
|
);
|
|
return () => {
|
|
cancelled = true;
|
|
};
|
|
}, [managementGateway, generation]);
|
|
|
|
/**
|
|
* slug 를 비워 두면 이름에서 만든다. 한글 이름이 흔한데 이전 규칙은 한글을 전부 버려서, 이름에
|
|
* 섞인 영문·숫자만 남았다 — `인증` 은 빈 slug 가 되고 `Redis 캐시` 와 `Redis 클러스터` 는 둘 다
|
|
* `redis` 가 됐다. 지금은 로마자로 옮긴다 ({@link slugFromName}).
|
|
*/
|
|
const slugify = slugFromName;
|
|
|
|
const submitTopic = async (event: FormEvent) => {
|
|
event.preventDefault();
|
|
if (pending) return;
|
|
const name = topicName.trim();
|
|
const slug = slugify(topicSlug || topicName);
|
|
if (!name || !slug) {
|
|
setError("주제 이름과 slug 를 입력해 주세요. slug 는 영문·숫자·하이픈만 가능합니다.");
|
|
return;
|
|
}
|
|
setPending(true);
|
|
setError("");
|
|
try {
|
|
await managementGateway.createTopic({ name, slug } as TopicEdit);
|
|
setTopicName("");
|
|
setTopicSlug("");
|
|
setRequestAnnouncement(`주제 ${name} 을(를) 만들었습니다.`);
|
|
reload();
|
|
} catch (error) {
|
|
setError(managementFailureMessage(error, "주제를 만들지 못했습니다."));
|
|
} finally {
|
|
setPending(false);
|
|
}
|
|
};
|
|
|
|
const submitProject = async (event: FormEvent) => {
|
|
event.preventDefault();
|
|
if (pending) return;
|
|
const title = projectTitle.trim();
|
|
if (!title) {
|
|
setError("프로젝트 이름을 입력해 주세요.");
|
|
return;
|
|
}
|
|
setPending(true);
|
|
setError("");
|
|
try {
|
|
const created = await managementGateway.createProject(title);
|
|
/*
|
|
생성 계약은 이름만 받는데(`CreateDraftRequest`), slug 가 없는 프로젝트는 공개 화면에
|
|
나타날 수 없다 — 공개 계약의 `ProjectSummary` 는 `slug` 와 `path` 를 요구하므로 서버는
|
|
slug 가 빈 프로젝트를 통째로 생략한다. 기록에 프로젝트를 붙여 게시해도 공개 문서의
|
|
프로젝트 칸이 비어 있던 이유가 이것이다.
|
|
|
|
그래서 만든 직후에 이름에서 만든 slug 를 채운다. 주제가 `{name, slug}` 를 함께 보내는
|
|
것과 같은 규칙이고(`slugFromName`), 한글 이름도 로마자로 옮겨 유효한 slug 가 된다.
|
|
*/
|
|
const project = await managementGateway.getProject(created.id);
|
|
await managementGateway.updateProject(created.id, {
|
|
expectedVersion: project.version,
|
|
name: project.name,
|
|
slug: slugFromName(project.name),
|
|
oneLinePurpose: project.oneLinePurpose ?? "",
|
|
purposeMarkdown: project.purposeMarkdown ?? "",
|
|
boundaryMarkdown: project.boundaryMarkdown ?? "",
|
|
phase: project.phase,
|
|
technologyLabels: project.technologyLabels ?? [],
|
|
targetVisibility:
|
|
project.targetVisibility === "PUBLIC" || project.targetVisibility === "UNLISTED"
|
|
? project.targetVisibility
|
|
: "PRIVATE",
|
|
});
|
|
setProjectTitle("");
|
|
setRequestAnnouncement(`프로젝트 ${title} 을(를) 만들었습니다.`);
|
|
reload();
|
|
} catch (error) {
|
|
setError(managementFailureMessage(error, "프로젝트를 만들지 못했습니다."));
|
|
} finally {
|
|
setPending(false);
|
|
}
|
|
};
|
|
|
|
const removeTopic = async (topic: TopicEdit) => {
|
|
if (pending || topic.id === undefined || topic.version === undefined) return;
|
|
setPending(true);
|
|
setError("");
|
|
try {
|
|
await managementGateway.deleteTopic(topic.id, topic.version);
|
|
setRequestAnnouncement(`주제 ${topic.name} 을(를) 삭제했습니다.`);
|
|
setPendingDelete(null);
|
|
reload();
|
|
} catch (error) {
|
|
setError(managementFailureMessage(error, "주제를 삭제하지 못했습니다."));
|
|
} finally {
|
|
setPending(false);
|
|
}
|
|
};
|
|
|
|
const removeProject = async (project: ProjectIndexItem) => {
|
|
if (pending) return;
|
|
setPending(true);
|
|
setError("");
|
|
try {
|
|
await managementGateway.deleteProject(project.id, project.version);
|
|
setRequestAnnouncement(`프로젝트 ${project.name} 을(를) 삭제했습니다.`);
|
|
setPendingDelete(null);
|
|
reload();
|
|
} catch (error) {
|
|
setError(managementFailureMessage(error, "프로젝트를 삭제하지 못했습니다."));
|
|
} finally {
|
|
setPending(false);
|
|
}
|
|
};
|
|
|
|
/*
|
|
프로젝트 게시는 문서 게시와 별개다. 문서를 게시해도 그 문서가 속한 프로젝트는 비공개로 남고,
|
|
공개 화면들(프로젝트 목록·프로필의 "현재 프로젝트"·홈의 focus)은 전부 게시된 프로젝트만 읽는다.
|
|
그래서 그 화면들이 조용히 비어 있었다 — 게시할 방법 자체가 없었기 때문이다.
|
|
*/
|
|
const togglePublish = async (project: ProjectIndexItem) => {
|
|
if (pending) return;
|
|
setPending(true);
|
|
setError("");
|
|
const published = project.targetVisibility !== "PRIVATE";
|
|
try {
|
|
if (published) {
|
|
await managementGateway.unpublishProject(project.id, project.version);
|
|
setRequestAnnouncement(`프로젝트 ${project.name} 을(를) 비공개로 되돌렸습니다.`);
|
|
} else {
|
|
await managementGateway.publishProject(project.id, project.version, "PUBLIC");
|
|
setRequestAnnouncement(`프로젝트 ${project.name} 을(를) 공개했습니다.`);
|
|
}
|
|
reload();
|
|
} catch (error) {
|
|
setError(
|
|
managementFailureMessage(
|
|
error,
|
|
published ? "프로젝트를 비공개로 되돌리지 못했습니다." : "프로젝트를 게시하지 못했습니다.",
|
|
),
|
|
);
|
|
} finally {
|
|
setPending(false);
|
|
}
|
|
};
|
|
|
|
return (
|
|
<div className="studio-page studio-documents-page">
|
|
<header className="studio-page-top">
|
|
<div className="studio-page-heading">
|
|
<p className="studio-eyebrow">TAXONOMY</p>
|
|
<h1>주제와 프로젝트</h1>
|
|
<p>문서를 게시하려면 주제가 필요합니다. 여기서 만들고 정리합니다.</p>
|
|
</div>
|
|
</header>
|
|
|
|
<div className="studio-taxonomy-tabs" role="tablist" aria-label="주제와 프로젝트">
|
|
{/*
|
|
구조가 먼저다. 주제와 프로젝트를 따로 세는 목록 둘만 있으면 이 화면은 여느 CMS 의
|
|
분류 관리와 같아진다 — 이 제품에서 값어치 있는 것은 그 둘의 <em>관계</em>다.
|
|
*/}
|
|
<button
|
|
type="button"
|
|
role="tab"
|
|
id="taxonomy-tab-structure"
|
|
aria-selected={tab === "STRUCTURE"}
|
|
aria-controls={tab === "STRUCTURE" ? "taxonomy-panel" : undefined}
|
|
tabIndex={tab === "STRUCTURE" ? 0 : -1}
|
|
onClick={() => setTab("STRUCTURE")}
|
|
>
|
|
구조
|
|
</button>
|
|
<button
|
|
type="button"
|
|
role="tab"
|
|
id="taxonomy-tab-topic"
|
|
aria-selected={tab === "TOPIC"}
|
|
aria-controls={tab === "TOPIC" ? "taxonomy-panel" : undefined}
|
|
tabIndex={tab === "TOPIC" ? 0 : -1}
|
|
onClick={() => setTab("TOPIC")}
|
|
>
|
|
{`주제 ${topics?.length ?? 0}`}
|
|
</button>
|
|
<button
|
|
type="button"
|
|
role="tab"
|
|
id="taxonomy-tab-project"
|
|
aria-selected={tab === "PROJECT"}
|
|
aria-controls={tab === "PROJECT" ? "taxonomy-panel" : undefined}
|
|
tabIndex={tab === "PROJECT" ? 0 : -1}
|
|
onClick={() => setTab("PROJECT")}
|
|
>
|
|
{`프로젝트 ${projects?.length ?? 0}`}
|
|
</button>
|
|
</div>
|
|
|
|
<section
|
|
id="taxonomy-panel"
|
|
role="tabpanel"
|
|
aria-labelledby={tab === "TOPIC" ? "taxonomy-tab-topic" : "taxonomy-tab-project"}
|
|
className="studio-document-tools"
|
|
aria-label={tab === "TOPIC" ? "주제 만들기" : "프로젝트 만들기"}
|
|
>
|
|
{tab === "TOPIC" ? (
|
|
<form onSubmit={submitTopic}>
|
|
<label htmlFor="taxonomy-topic-name">새 주제</label>
|
|
<div>
|
|
<input
|
|
id="taxonomy-topic-name"
|
|
type="text"
|
|
value={topicName}
|
|
placeholder="주제 이름"
|
|
onChange={(event) => setTopicName(event.target.value)}
|
|
/>
|
|
<input
|
|
type="text"
|
|
value={topicSlug}
|
|
placeholder="slug (비우면 이름에서 생성)"
|
|
aria-label="주제 slug"
|
|
onChange={(event) => setTopicSlug(event.target.value)}
|
|
/>
|
|
<button type="submit" disabled={pending}>
|
|
주제 추가
|
|
</button>
|
|
</div>
|
|
</form>
|
|
) : (
|
|
<form onSubmit={submitProject}>
|
|
<label htmlFor="taxonomy-project-title">새 프로젝트</label>
|
|
<div>
|
|
<input
|
|
id="taxonomy-project-title"
|
|
type="text"
|
|
value={projectTitle}
|
|
placeholder="프로젝트 이름"
|
|
onChange={(event) => setProjectTitle(event.target.value)}
|
|
/>
|
|
<button type="submit" disabled={pending}>
|
|
프로젝트 추가
|
|
</button>
|
|
</div>
|
|
</form>
|
|
)}
|
|
</section>
|
|
|
|
{loading ? (
|
|
<p className="studio-loading" role="status">
|
|
주제와 프로젝트를 불러오는 중입니다.
|
|
</p>
|
|
) : null}
|
|
{error ? (
|
|
<p className="studio-screen-error" role="alert">
|
|
{error}
|
|
</p>
|
|
) : null}
|
|
|
|
{!loading && topics && projects && tab === "STRUCTURE" ? (
|
|
<div className="studio-structure-tree">
|
|
<ol>
|
|
{projects.map((project) => {
|
|
const linked = links.get(project.id ?? "") ?? [];
|
|
const inProject = topics.filter((topic) => topic.id && linked.includes(topic.id));
|
|
return (
|
|
<li key={project.id ?? project.slug}>
|
|
<div className="studio-structure-project">
|
|
{project.id ? (
|
|
<GuardedStudioLink href={`/studio/projects/${project.id}`}>
|
|
{project.name}
|
|
</GuardedStudioLink>
|
|
) : (
|
|
<strong>{project.name}</strong>
|
|
)}
|
|
<span>{PROJECT_PHASE_LABELS[project.phase] ?? project.phase}</span>
|
|
{/*
|
|
공개 프로젝트 화면의 첫 문단과 상태 줄이 이 값들로 그려진다. 비어 있으면
|
|
그 화면이 헐거워지는데, 무엇이 비었는지는 편집기를 열어야 알 수 있었다.
|
|
*/}
|
|
{project.currentObjective?.trim() ? null : <em>현재 목표 없음</em>}
|
|
</div>
|
|
{inProject.length > 0 ? (
|
|
<ul>
|
|
{inProject.map((topic) => (
|
|
<li key={topic.id ?? topic.slug}>
|
|
{topic.id ? (
|
|
<GuardedStudioLink href={`/studio/topics/${topic.id}`}>
|
|
{topic.name}
|
|
</GuardedStudioLink>
|
|
) : (
|
|
topic.name
|
|
)}
|
|
{/* 질문이 비어 있으면 공개 주제 화면의 첫 문장이 비어 나온다. */}
|
|
{topic.thesis?.trim() ? null : <em>답하는 질문 없음</em>}
|
|
</li>
|
|
))}
|
|
</ul>
|
|
) : (
|
|
<p className="studio-structure-empty">묶은 주제가 없습니다.</p>
|
|
)}
|
|
</li>
|
|
);
|
|
})}
|
|
</ol>
|
|
{/*
|
|
어느 프로젝트에도 걸리지 않은 주제. 걸리지 않았다는 사실 자체가 구조의 상태이므로
|
|
숨기지 않는다 — 숨기면 그 주제는 어느 화면에서도 보이지 않는다.
|
|
*/}
|
|
{(() => {
|
|
const linkedIds = new Set([...links.values()].flat());
|
|
const orphans = topics.filter((topic) => topic.id && !linkedIds.has(topic.id));
|
|
if (orphans.length === 0) return null;
|
|
return (
|
|
<section className="studio-structure-orphans" aria-labelledby="orphan-topics-title">
|
|
<h2 id="orphan-topics-title">어느 프로젝트에도 걸리지 않은 주제</h2>
|
|
<ul>
|
|
{orphans.map((topic) => (
|
|
<li key={topic.id ?? topic.slug}>
|
|
{topic.id ? (
|
|
<GuardedStudioLink href={`/studio/topics/${topic.id}`}>
|
|
{topic.name}
|
|
</GuardedStudioLink>
|
|
) : (
|
|
topic.name
|
|
)}
|
|
</li>
|
|
))}
|
|
</ul>
|
|
</section>
|
|
);
|
|
})()}
|
|
</div>
|
|
) : null}
|
|
|
|
{!loading && topics && tab === "TOPIC" ? (
|
|
<>
|
|
<p className="studio-result-count">{topics.length}개의 주제</p>
|
|
{topics.length ? (
|
|
<div className="studio-document-list">
|
|
{topics.map((topic) => (
|
|
<article className="studio-document-row" key={topic.id ?? topic.slug}>
|
|
<p className="studio-row-label">TOPIC</p>
|
|
<div className="studio-document-title">
|
|
{/*
|
|
주제는 만들고 지울 수만 있었다. 이름과 slug 말고 쓸 자리가 없어, 주제가
|
|
답하는 질문도 축의 이름도 어디에도 적을 수 없었다 — 공개 주제 화면이 그
|
|
둘을 읽는데 쓸 곳이 없으니 늘 비어 있었다. 프로젝트와 같은 자리에 링크를 둔다.
|
|
*/}
|
|
<h2>
|
|
{topic.id ? (
|
|
<GuardedStudioLink href={`/studio/topics/${topic.id}`}>
|
|
{topic.name}
|
|
</GuardedStudioLink>
|
|
) : (
|
|
topic.name
|
|
)}
|
|
</h2>
|
|
<p>{topic.slug}</p>
|
|
</div>
|
|
<dl>
|
|
<div>
|
|
<dt>상태</dt>
|
|
{/*
|
|
`ACTIVE` 를 "사용 중" 이라 적었더니, 방금 만들어 아무도 쓰지 않는 주제까지
|
|
"사용 중" 으로 보였다. 그 상태에서 삭제가 거절되면 작성자는 둘을 같은
|
|
말로 읽는다 — 실제로는 서로 다른 이야기다.
|
|
*/}
|
|
<dd>{topic.status === "ARCHIVED" ? "보관" : "활성"}</dd>
|
|
</div>
|
|
</dl>
|
|
<div className="studio-row-actions">
|
|
{/*
|
|
편집 진입점이 제목 링크뿐이었다. 라벨이 없어 누를 수 있는지 알 수 없었고,
|
|
그 화면에 축·논지·범위가 있다는 사실도 목록에서는 드러나지 않았다 —
|
|
프로젝트 행과 같은 격으로 버튼을 둔다.
|
|
*/}
|
|
{topic.id ? (
|
|
<GuardedStudioLink
|
|
className="studio-secondary-button"
|
|
href={`/studio/topics/${topic.id}`}
|
|
>
|
|
편집
|
|
</GuardedStudioLink>
|
|
) : null}
|
|
<button
|
|
className="studio-secondary-button studio-danger-button"
|
|
type="button"
|
|
disabled={pending}
|
|
onClick={() => {
|
|
setError("");
|
|
setPendingDelete({ kind: "TOPIC", topic });
|
|
}}
|
|
>
|
|
삭제
|
|
</button>
|
|
</div>
|
|
</article>
|
|
))}
|
|
</div>
|
|
) : (
|
|
<p className="studio-empty">아직 주제가 없습니다. 위에서 하나 만들어 주세요.</p>
|
|
)}
|
|
</>
|
|
) : null}
|
|
|
|
{!loading && projects && tab === "PROJECT" ? (
|
|
<>
|
|
<p className="studio-result-count">{projects.length}개의 프로젝트</p>
|
|
{projects.length ? (
|
|
<div className="studio-document-list">
|
|
{projects.map((project) => (
|
|
<article className="studio-document-row" key={project.id}>
|
|
<p className="studio-row-label">PROJECT</p>
|
|
<div className="studio-document-title">
|
|
<h2>
|
|
<GuardedStudioLink href={`/studio/projects/${project.id}`}>
|
|
{project.name}
|
|
</GuardedStudioLink>
|
|
</h2>
|
|
<p>{project.currentObjective ?? "목표 미지정"}</p>
|
|
</div>
|
|
<dl>
|
|
<div>
|
|
<dt>단계</dt>
|
|
<dd>{PROJECT_PHASE_LABELS[project.phase] ?? project.phase}</dd>
|
|
</div>
|
|
<div>
|
|
<dt>공개</dt>
|
|
{/*
|
|
"게시됨" 이 아니라 어디까지 보이는지를 적는다 — UNLISTED 는 주소를 아는
|
|
사람만 닿고 목록에는 없다. 둘을 같은 말로 적으면 왜 목록에 안 나오는지
|
|
설명할 방법이 없다.
|
|
*/}
|
|
<dd>{visibilityLabel[project.targetVisibility] ?? project.targetVisibility}</dd>
|
|
</div>
|
|
</dl>
|
|
<div className="studio-row-actions">
|
|
{/*
|
|
편집 진입점은 이 버튼 하나다. 예전에는 「다음: 내용 편집」 이라는 dl 칸과
|
|
이 버튼이 같은 주소를 가리키며 한 행에 150px 간격으로 두 번 나왔다 —
|
|
읽는 사람은 둘이 다른 일을 한다고 읽는다.
|
|
*/}
|
|
<GuardedStudioLink
|
|
className="studio-secondary-button"
|
|
href={`/studio/projects/${project.id}`}
|
|
>
|
|
내용 편집
|
|
</GuardedStudioLink>
|
|
<button
|
|
className="studio-secondary-button"
|
|
type="button"
|
|
disabled={pending}
|
|
onClick={() => void togglePublish(project)}
|
|
>
|
|
{project.targetVisibility === "PRIVATE" ? "게시" : "게시 취소"}
|
|
</button>
|
|
<button
|
|
className="studio-secondary-button studio-danger-button"
|
|
type="button"
|
|
disabled={pending}
|
|
onClick={() => {
|
|
setError("");
|
|
setPendingDelete({ kind: "PROJECT", project });
|
|
}}
|
|
>
|
|
삭제
|
|
</button>
|
|
</div>
|
|
</article>
|
|
))}
|
|
</div>
|
|
) : (
|
|
<p className="studio-empty">아직 프로젝트가 없습니다.</p>
|
|
)}
|
|
</>
|
|
) : null}
|
|
<DestructiveConfirmDialog
|
|
open={pendingDelete !== null}
|
|
pending={pending}
|
|
title={pendingDelete?.kind === "PROJECT" ? "프로젝트를 삭제합니다" : "주제를 삭제합니다"}
|
|
targetName={
|
|
pendingDelete?.kind === "PROJECT"
|
|
? pendingDelete.project.name
|
|
: (pendingDelete?.topic.name ?? "")
|
|
}
|
|
description={
|
|
pendingDelete?.kind === "PROJECT"
|
|
? "이 프로젝트에 매달린 기록이 있으면 서버가 거절합니다."
|
|
: "이 주제에 매달린 기록이 있으면 서버가 거절합니다."
|
|
}
|
|
error={error}
|
|
onCancel={() => setPendingDelete(null)}
|
|
onConfirm={() => {
|
|
if (!pendingDelete) return;
|
|
if (pendingDelete.kind === "PROJECT") void removeProject(pendingDelete.project);
|
|
else void removeTopic(pendingDelete.topic);
|
|
}}
|
|
/>
|
|
</div>
|
|
);
|
|
}
|