From b3e8a36c25ab3d1c52be06a6b77406f9759ab10c Mon Sep 17 00:00:00 2001 From: ddelpiano Date: Wed, 11 Dec 2024 11:38:05 +0100 Subject: [PATCH] disable graph commands when in readonly --- .../ProofingTab/GraphDiagram/GraphDiagram.tsx | 3 + .../GraphDiagram/NavigationMenu.tsx | 91 +++++++++++-------- .../components/ProofingTab/ProofingTab.tsx | 2 +- .../components/ProofingTab/StatementChart.tsx | 5 +- 4 files changed, 62 insertions(+), 39 deletions(-) diff --git a/frontend/src/components/ProofingTab/GraphDiagram/GraphDiagram.tsx b/frontend/src/components/ProofingTab/GraphDiagram/GraphDiagram.tsx index 76ada753..890aff4a 100644 --- a/frontend/src/components/ProofingTab/GraphDiagram/GraphDiagram.tsx +++ b/frontend/src/components/ProofingTab/GraphDiagram/GraphDiagram.tsx @@ -50,6 +50,7 @@ interface GraphDiagramProps { serializedGraph?: any | undefined; statement: ConnectivityStatement; setStatement: (statement: any) => void; + isDisabled?: boolean; } const GraphDiagram: React.FC = ({ @@ -60,6 +61,7 @@ const GraphDiagram: React.FC = ({ serializedGraph, statement, setStatement, + isDisabled = false, }) => { const theme = useTheme(); const { statementId } = useParams(); @@ -285,6 +287,7 @@ const GraphDiagram: React.FC = ({ switchLockedGraph={switchLockedGraph} statement={statement} setStatement={setStatement} + isDisabled={isDisabled} /> void; statement: ConnectivityStatement; setStatement: (statement: any) => void; + isDisabled?: boolean; } const NavigationMenu = (props: NavigationMenuProps) => { - const {engine, statementId, toggleRankdir, resetGraph, isGraphLocked, switchLockedGraph, statement, setStatement} = props + const { + engine, + statementId, + toggleRankdir, + resetGraph, + isGraphLocked, + switchLockedGraph, + statement, + setStatement, + isDisabled + } = props const [isSaving, setIsSaving] = useState(false) const [isConfirmationDialogOpen, setIsConfirmationDialogOpen] = useState(false); const [dialogConfig, setDialogConfig] = useState({ @@ -239,43 +250,51 @@ const NavigationMenu = (props: NavigationMenuProps) => { - - - - - - - - - - - - - - { - wasChangeDetected || positionChangeOnly ? ( - - The diagram is outdated, please use the reset button on the left to update the diagram + {!isDisabled && ( + <> + + + + - ) : ( - !isResetInvoked && ( - - - - ) - ) - } - - toggleGraphLock(lock)} - /> + + + + + + + + )} + {!isDisabled && ( + <> + + { + wasChangeDetected || positionChangeOnly ? ( + + The diagram is outdated, please use the reset button on the left to update the diagram + + ) : ( + !isResetInvoked && ( + + + + ) + ) + } + + toggleGraphLock(lock)} + /> + + + )} ) } diff --git a/frontend/src/components/ProofingTab/ProofingTab.tsx b/frontend/src/components/ProofingTab/ProofingTab.tsx index 6a4e71f0..2ea15242 100644 --- a/frontend/src/components/ProofingTab/ProofingTab.tsx +++ b/frontend/src/components/ProofingTab/ProofingTab.tsx @@ -81,7 +81,7 @@ const ProofingTab = (props: any) => { p: 0 }}>Download graph - + {hasJourney && ( <> diff --git a/frontend/src/components/ProofingTab/StatementChart.tsx b/frontend/src/components/ProofingTab/StatementChart.tsx index a1ac1068..4c72ede9 100644 --- a/frontend/src/components/ProofingTab/StatementChart.tsx +++ b/frontend/src/components/ProofingTab/StatementChart.tsx @@ -5,8 +5,8 @@ import {ConnectivityStatement} from "../../apiclient/backend"; import {useTheme} from "@mui/system"; import GraphDiagram from "./GraphDiagram/GraphDiagram"; -const StatementChart = (props: { statement: ConnectivityStatement, setStatement: () => void }) => { - const {statement, setStatement} = props; +const StatementChart = (props: { statement: ConnectivityStatement, setStatement: () => void, isDisabled: boolean }) => { + const {statement, setStatement, isDisabled} = props; const theme = useTheme(); const displayChart = statement.origins && statement.origins.length > 0 @@ -21,6 +21,7 @@ const StatementChart = (props: { statement: ConnectivityStatement, setStatement: serializedGraph={statement.graph_rendering_state?.serialized_graph} statement={statement} setStatement={setStatement} + isDisabled={isDisabled} /> ) : (