mirror of
https://github.com/drawdb-io/drawdb.git
synced 2025-09-01 10:25:13 +00:00
disable input from control panel and popovers
This commit is contained in:
@@ -179,6 +179,7 @@ export default function Area({
|
|||||||
backgroundColor: "#2F68ADB3",
|
backgroundColor: "#2F68ADB3",
|
||||||
}}
|
}}
|
||||||
onClick={lockUnlockArea}
|
onClick={lockUnlockArea}
|
||||||
|
disabled={layout.readOnly}
|
||||||
/>
|
/>
|
||||||
<Popover
|
<Popover
|
||||||
visible={areaIsOpen() && !layout.sidebar}
|
visible={areaIsOpen() && !layout.sidebar}
|
||||||
@@ -257,7 +258,7 @@ function EditPopoverContent({ data }) {
|
|||||||
const { updateArea, deleteArea } = useAreas();
|
const { updateArea, deleteArea } = useAreas();
|
||||||
const { setUndoStack, setRedoStack } = useUndoRedo();
|
const { setUndoStack, setRedoStack } = useUndoRedo();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const {layout} = useLayout();
|
const { layout } = useLayout();
|
||||||
const initialColorRef = useRef(data.color);
|
const initialColorRef = useRef(data.color);
|
||||||
|
|
||||||
const handleColorPick = (color) => {
|
const handleColorPick = (color) => {
|
||||||
@@ -303,7 +304,7 @@ function EditPopoverContent({ data }) {
|
|||||||
value={data.name}
|
value={data.name}
|
||||||
placeholder={t("name")}
|
placeholder={t("name")}
|
||||||
className="me-2"
|
className="me-2"
|
||||||
readOnly={layout.readOnly}
|
readonly={layout.readOnly}
|
||||||
onChange={(value) => updateArea(data.id, { name: value })}
|
onChange={(value) => updateArea(data.id, { name: value })}
|
||||||
onFocus={(e) => setEditField({ name: e.target.value })}
|
onFocus={(e) => setEditField({ name: e.target.value })}
|
||||||
onBlur={(e) => {
|
onBlur={(e) => {
|
||||||
@@ -327,7 +328,7 @@ function EditPopoverContent({ data }) {
|
|||||||
/>
|
/>
|
||||||
<ColorPicker
|
<ColorPicker
|
||||||
usePopover={true}
|
usePopover={true}
|
||||||
readOnly={true}
|
readOnly={layout.readOnly}
|
||||||
value={data.color}
|
value={data.color}
|
||||||
onChange={(color) => updateArea(data.id, { color })}
|
onChange={(color) => updateArea(data.id, { color })}
|
||||||
onColorPick={(color) => handleColorPick(color)}
|
onColorPick={(color) => handleColorPick(color)}
|
||||||
@@ -339,6 +340,7 @@ function EditPopoverContent({ data }) {
|
|||||||
type="danger"
|
type="danger"
|
||||||
block
|
block
|
||||||
onClick={() => deleteArea(data.id, true)}
|
onClick={() => deleteArea(data.id, true)}
|
||||||
|
disabled={layout.readOnly}
|
||||||
>
|
>
|
||||||
{t("delete")}
|
{t("delete")}
|
||||||
</Button>
|
</Button>
|
||||||
|
@@ -249,6 +249,7 @@ export default function Note({ data, onPointerDown }) {
|
|||||||
backgroundColor: "#2F68ADB3",
|
backgroundColor: "#2F68ADB3",
|
||||||
}}
|
}}
|
||||||
onClick={lockUnlockNote}
|
onClick={lockUnlockNote}
|
||||||
|
disabled={layout.readOnly}
|
||||||
/>
|
/>
|
||||||
<Popover
|
<Popover
|
||||||
visible={
|
visible={
|
||||||
@@ -280,6 +281,7 @@ export default function Note({ data, onPointerDown }) {
|
|||||||
value={data.title}
|
value={data.title}
|
||||||
placeholder={t("title")}
|
placeholder={t("title")}
|
||||||
className="me-2"
|
className="me-2"
|
||||||
|
readonly={layout.readOnly}
|
||||||
onChange={(value) =>
|
onChange={(value) =>
|
||||||
updateNote(data.id, { title: value })
|
updateNote(data.id, { title: value })
|
||||||
}
|
}
|
||||||
@@ -307,6 +309,7 @@ export default function Note({ data, onPointerDown }) {
|
|||||||
/>
|
/>
|
||||||
<ColorPicker
|
<ColorPicker
|
||||||
usePopover={true}
|
usePopover={true}
|
||||||
|
readOnly={layout.readOnly}
|
||||||
value={data.color}
|
value={data.color}
|
||||||
onChange={(color) => updateNote(data.id, { color })}
|
onChange={(color) => updateNote(data.id, { color })}
|
||||||
onColorPick={(color) => handleColorPick(color)}
|
onColorPick={(color) => handleColorPick(color)}
|
||||||
@@ -314,9 +317,10 @@ export default function Note({ data, onPointerDown }) {
|
|||||||
</div>
|
</div>
|
||||||
<div className="flex">
|
<div className="flex">
|
||||||
<Button
|
<Button
|
||||||
icon={<IconDeleteStroked />}
|
|
||||||
type="danger"
|
|
||||||
block
|
block
|
||||||
|
type="danger"
|
||||||
|
disabled={layout.readOnly}
|
||||||
|
icon={<IconDeleteStroked />}
|
||||||
onClick={() => deleteNote(data.id, true)}
|
onClick={() => deleteNote(data.id, true)}
|
||||||
>
|
>
|
||||||
{t("delete")}
|
{t("delete")}
|
||||||
@@ -343,6 +347,7 @@ export default function Note({ data, onPointerDown }) {
|
|||||||
</div>
|
</div>
|
||||||
<textarea
|
<textarea
|
||||||
id={`note_${data.id}`}
|
id={`note_${data.id}`}
|
||||||
|
readOnly={layout.readOnly}
|
||||||
value={data.content}
|
value={data.content}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
onFocus={(e) =>
|
onFocus={(e) =>
|
||||||
|
@@ -171,6 +171,7 @@ export default function Table({
|
|||||||
style={{
|
style={{
|
||||||
backgroundColor: "#2f68adb3",
|
backgroundColor: "#2f68adb3",
|
||||||
}}
|
}}
|
||||||
|
disabled={layout.readOnly}
|
||||||
onClick={lockUnlockTable}
|
onClick={lockUnlockTable}
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
@@ -234,6 +235,7 @@ export default function Table({
|
|||||||
block
|
block
|
||||||
style={{ marginTop: "8px" }}
|
style={{ marginTop: "8px" }}
|
||||||
onClick={() => deleteTable(tableData.id)}
|
onClick={() => deleteTable(tableData.id)}
|
||||||
|
disabled={layout.readOnly}
|
||||||
>
|
>
|
||||||
{t("delete")}
|
{t("delete")}
|
||||||
</Button>
|
</Button>
|
||||||
|
@@ -1603,47 +1603,46 @@ export default function ControlPanel({
|
|||||||
<Divider layout="vertical" margin="8px" />
|
<Divider layout="vertical" margin="8px" />
|
||||||
<Tooltip content={t("undo")} position="bottom">
|
<Tooltip content={t("undo")} position="bottom">
|
||||||
<button
|
<button
|
||||||
className="py-1 px-2 hover-2 rounded-sm flex items-center"
|
className="py-1 px-2 hover-2 rounded-sm flex items-center disabled:opacity-50"
|
||||||
|
disabled={undoStack.length === 0}
|
||||||
onClick={undo}
|
onClick={undo}
|
||||||
>
|
>
|
||||||
<IconUndo
|
<IconUndo size="large" />
|
||||||
size="large"
|
|
||||||
style={{ color: undoStack.length === 0 ? "#9598a6" : "" }}
|
|
||||||
/>
|
|
||||||
</button>
|
</button>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<Tooltip content={t("redo")} position="bottom">
|
<Tooltip content={t("redo")} position="bottom">
|
||||||
<button
|
<button
|
||||||
className="py-1 px-2 hover-2 rounded-sm flex items-center"
|
className="py-1 px-2 hover-2 rounded-sm flex items-center disabled:opacity-50"
|
||||||
|
disabled={redoStack.length === 0}
|
||||||
onClick={redo}
|
onClick={redo}
|
||||||
>
|
>
|
||||||
<IconRedo
|
<IconRedo size="large" />
|
||||||
size="large"
|
|
||||||
style={{ color: redoStack.length === 0 ? "#9598a6" : "" }}
|
|
||||||
/>
|
|
||||||
</button>
|
</button>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<Divider layout="vertical" margin="8px" />
|
<Divider layout="vertical" margin="8px" />
|
||||||
<Tooltip content={t("add_table")} position="bottom">
|
<Tooltip content={t("add_table")} position="bottom">
|
||||||
<button
|
<button
|
||||||
className="flex items-center py-1 px-2 hover-2 rounded-sm"
|
className="flex items-center py-1 px-2 hover-2 rounded-sm disabled:opacity-50"
|
||||||
onClick={() => addTable()}
|
onClick={() => addTable()}
|
||||||
|
disabled={layout.readOnly}
|
||||||
>
|
>
|
||||||
<IconAddTable />
|
<IconAddTable />
|
||||||
</button>
|
</button>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<Tooltip content={t("add_area")} position="bottom">
|
<Tooltip content={t("add_area")} position="bottom">
|
||||||
<button
|
<button
|
||||||
className="py-1 px-2 hover-2 rounded-sm flex items-center"
|
className="py-1 px-2 hover-2 rounded-sm flex items-center disabled:opacity-50"
|
||||||
onClick={() => addArea()}
|
onClick={() => addArea()}
|
||||||
|
disabled={layout.readOnly}
|
||||||
>
|
>
|
||||||
<IconAddArea />
|
<IconAddArea />
|
||||||
</button>
|
</button>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<Tooltip content={t("add_note")} position="bottom">
|
<Tooltip content={t("add_note")} position="bottom">
|
||||||
<button
|
<button
|
||||||
className="py-1 px-2 hover-2 rounded-sm flex items-center"
|
className="py-1 px-2 hover-2 rounded-sm flex items-center disabled:opacity-50"
|
||||||
onClick={() => addNote()}
|
onClick={() => addNote()}
|
||||||
|
disabled={layout.readOnly}
|
||||||
>
|
>
|
||||||
<IconAddNote />
|
<IconAddNote />
|
||||||
</button>
|
</button>
|
||||||
@@ -1651,8 +1650,9 @@ export default function ControlPanel({
|
|||||||
<Divider layout="vertical" margin="8px" />
|
<Divider layout="vertical" margin="8px" />
|
||||||
<Tooltip content={t("save")} position="bottom">
|
<Tooltip content={t("save")} position="bottom">
|
||||||
<button
|
<button
|
||||||
className="py-1 px-2 hover-2 rounded-sm flex items-center"
|
className="py-1 px-2 hover-2 rounded-sm flex items-center disabled:opacity-50"
|
||||||
onClick={save}
|
onClick={save}
|
||||||
|
disabled={layout.readOnly}
|
||||||
>
|
>
|
||||||
<IconSaveStroked size="extra-large" />
|
<IconSaveStroked size="extra-large" />
|
||||||
</button>
|
</button>
|
||||||
@@ -1887,11 +1887,7 @@ export default function ControlPanel({
|
|||||||
</Dropdown>
|
</Dropdown>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
{layout.readOnly && (
|
{layout.readOnly && <Tag size="small">{t("read_only")}</Tag>}
|
||||||
<Tag size="small">
|
|
||||||
{t("read_only")}
|
|
||||||
</Tag>
|
|
||||||
)}
|
|
||||||
{!layout.readOnly && (
|
{!layout.readOnly && (
|
||||||
<Tag
|
<Tag
|
||||||
size="small"
|
size="small"
|
||||||
|
@@ -1,13 +1,14 @@
|
|||||||
import { Button } from "@douyinfe/semi-ui";
|
import { Button } from "@douyinfe/semi-ui";
|
||||||
import { IconPlus } from "@douyinfe/semi-icons";
|
import { IconPlus } from "@douyinfe/semi-icons";
|
||||||
import Empty from "../Empty";
|
import Empty from "../Empty";
|
||||||
import { useAreas } from "../../../hooks";
|
import { useAreas, useLayout } from "../../../hooks";
|
||||||
import SearchBar from "./SearchBar";
|
import SearchBar from "./SearchBar";
|
||||||
import AreaInfo from "./AreaDetails";
|
import AreaInfo from "./AreaDetails";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
export default function AreasTab() {
|
export default function AreasTab() {
|
||||||
const { areas, addArea } = useAreas();
|
const { areas, addArea } = useAreas();
|
||||||
|
const { layout } = useLayout();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -15,7 +16,12 @@ export default function AreasTab() {
|
|||||||
<div className="flex gap-2">
|
<div className="flex gap-2">
|
||||||
<SearchBar />
|
<SearchBar />
|
||||||
<div>
|
<div>
|
||||||
<Button icon={<IconPlus />} block onClick={() => addArea()}>
|
<Button
|
||||||
|
icon={<IconPlus />}
|
||||||
|
block
|
||||||
|
onClick={() => addArea()}
|
||||||
|
disabled={layout.readOnly}
|
||||||
|
>
|
||||||
{t("add_area")}
|
{t("add_area")}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
Reference in New Issue
Block a user