feat(workbench): add junction tools workspace shell
This commit is contained in:
1 parent
96833d3a63
commit
2504e8342f
6 files changed
+277
No files matched your search
@@ -0,0 +1,59 @@
|
||||
import { useMemo } from 'react';
|
||||
import type { JunctionDescriptor } from './hotspots';
|
||||
import { canEditJunction, type JunctionSession } from './workspace';
|
||||
import { Button } from '../ui/button';
|
||||
|
||||
interface Props {
|
||||
descriptor: JunctionDescriptor;
|
||||
session: JunctionSession;
|
||||
onClose: () => void;
|
||||
onApply: () => void;
|
||||
onDiscard: () => void;
|
||||
onSave: () => void;
|
||||
}
|
||||
|
||||
export function JunctionWorkspace({ descriptor, session, onClose, onApply, onDiscard, onSave }: Props) {
|
||||
const editable = useMemo(() => canEditJunction(descriptor), [descriptor]);
|
||||
return (
|
||||
<section className="junction-workspace" aria-label="路口编辑工作区">
|
||||
<header className="junction-workspace__header">
|
||||
<div>
|
||||
<span className="junction-workspace__eyebrow">JunctionTools</span>
|
||||
<h2>
|
||||
{descriptor.ref.type === 'node' ? '路口节点' : '复杂路口上下文'} {descriptor.ref.id}
|
||||
</h2>
|
||||
<p>{editable ? '可编辑路口几何参数' : '只读上下文:当前路口类型暂不支持编辑'}</p>
|
||||
</div>
|
||||
<Button onClick={onClose}>返回主地图</Button>
|
||||
</header>
|
||||
<div className="junction-workspace__body">
|
||||
<dl>
|
||||
<dt>组成节点</dt>
|
||||
<dd>{descriptor.nodeIds.join(', ') || '—'}</dd>
|
||||
<dt>进口道路</dt>
|
||||
<dd>{descriptor.approachRoadIds.join(', ') || '—'}</dd>
|
||||
<dt>诊断</dt>
|
||||
<dd>{descriptor.diagnosticIds.length ? `${descriptor.diagnosticIds.length} 条` : '无'}</dd>
|
||||
<dt>状态</dt>
|
||||
<dd>
|
||||
{session.status}
|
||||
{session.dirty ? '(有未应用草稿)' : ''}
|
||||
</dd>
|
||||
</dl>
|
||||
{editable ? (
|
||||
<div className="junction-workspace__actions">
|
||||
<Button onClick={onApply} disabled={!session.dirty}>
|
||||
应用到工作区
|
||||
</Button>
|
||||
<Button onClick={onSave} disabled={session.dirty}>
|
||||
保存
|
||||
</Button>
|
||||
<Button onClick={onDiscard} disabled={!session.dirty}>
|
||||
放弃草稿
|
||||
</Button>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user