diff --git a/src/uhm/components/Editor.tsx b/src/uhm/components/Editor.tsx index 0c1c699..0f0d01c 100644 --- a/src/uhm/components/Editor.tsx +++ b/src/uhm/components/Editor.tsx @@ -1,9 +1,17 @@ "use client"; -import { useState, type ReactNode } from "react"; +import { useState } from "react"; import type { UndoAction } from "@/uhm/lib/useEditorState"; import type { EditorMode } from "@/uhm/lib/editor/session/sessionTypes"; +import { ProjectPanel } from "./editor/ProjectPanel"; +import { ToolsPanel } from "./editor/ToolsPanel"; +import { CommitPanel } from "./editor/CommitPanel"; +import { CommitHistoryPanel } from "./editor/CommitHistoryPanel"; +import { UndoListPanel } from "./editor/UndoListPanel"; +import { SessionPanel } from "./editor/SessionPanel"; +import { SubmitModal } from "./editor/SubmitModal"; + type Props = { mode: EditorMode; setMode: (mode: EditorMode) => void; @@ -68,14 +76,6 @@ export default function Editor({ createdGeometries, width = 280, }: Props) { - const toggleMode = (newMode: EditorMode) => { - if (mode === newMode) { - setMode("idle"); - } else { - setMode(newMode); - } - }; - const [isSubmitModalOpen, setIsSubmitModalOpen] = useState(false); const [submitContent, setSubmitContent] = useState(""); @@ -93,46 +93,6 @@ export default function Editor({ setIsSubmitModalOpen(false); }; - const recentUndoLabels = (() => { - const seen = new Set(); - const labels: string[] = []; - for (let i = undoStack.length - 1; i >= 0 && labels.length < 8; i -= 1) { - const label = formatUndoLabel(undoStack[i]); - if (seen.has(label)) continue; - seen.add(label); - labels.push(label); - } - return labels.reverse(); - })(); - - const formatCommitTitle = (commit: Props["commits"][number]) => - commit.edit_summary?.trim() || `Commit ${commit.id.slice(0, 8)}`; - - const modeButtonStyle = (btnMode: EditorMode) => - ({ - padding: "8px 10px", - borderRadius: 6, - border: "1px solid #334155", - background: mode === btnMode ? "#16a34a" : "#111827", - color: "white", - cursor: "pointer", - fontWeight: 800, - fontSize: 12, - minHeight: 34, - boxSizing: "border-box", - }) as const; - - const primaryButtonStyle = - ({ - width: "100%", - padding: "8px 10px", - borderRadius: 6, - border: "none", - cursor: "pointer", - fontWeight: 850, - fontSize: 12, - }) as const; - return (
-
Editor
- -
-
{sectionTitle}
-
- Status: {sectionStatus} -
-
- Commits: {commitCount} -
-
- {latestCommitLabel ? ( - {latestCommitLabel} - ) : ( - Chưa có head commit - )} -
-
-
+ - -
- - - - - - -
- -
- Mode: {mode} -
- - -
- - -
-
+ {entityStatus ? (
- - onCommitTitleChange(event.target.value)} - placeholder="Edit Summary (Commit Title)" - disabled={isSaving || isSubmitting} - style={textInputStyle} - /> - - - + - - {commits.length === 0 ? ( -
Chưa có commit
- ) : ( -
    - {commits.slice(0, 8).map((commit) => { - const isHead = Boolean(headCommitId && commit.id === headCommitId); - return ( -
  • -
    -
    - {formatCommitTitle(commit)} -
    -
    - {commit.created_at ? new Date(commit.created_at).toLocaleString() : ""} -
    -
    + - -
  • - ); - })} -
- )} -
+ - - {recentUndoLabels.length === 0 ? ( -
Chưa có thao tác
- ) : ( -
    - {recentUndoLabels.map((label, idx) => ( -
  • - {label} -
  • - ))} -
- )} -
+ - -
- Entities ({createdEntities.length}) -
- {createdEntities.length === 0 ? ( -
Chưa tạo entity mới
- ) : ( -
    - {createdEntities.map((entity) => ( -
  • - {entity.name} -
  • - ))} -
- )} - -
- Geometries mới chưa commit ({createdGeometries.length}) -
- {createdGeometries.length === 0 ? ( -
Chưa có geometry mới chờ commit
- ) : ( -
    - {createdGeometries.map((geometry) => ( -
  • - #{geometry.id} [{geometry.geometryType}]{" "} - {geometry.semanticType ? `- ${geometry.semanticType}` : ""} - {geometry.entityNames.length ? ` | ${geometry.entityNames.join(", ")}` : ""} -
  • - ))} -
- )} -
- - {isSubmitModalOpen && ( -
-
-

Nội dung Submit

-