Skip to content

Commit

Permalink
[1269] Prevent dropping elements in a read only diagram
Browse files Browse the repository at this point in the history
Copyright update

Bug: eclipse-sirius#1269
Signed-off-by: Nicolas Vannier <nicolas.vannier@obeo.fr>
  • Loading branch information
nvannr committed Jun 14, 2022
1 parent d24c074 commit 250097e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
3 changes: 1 addition & 2 deletions frontend/src/diagram/DiagramWebSocketContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,6 @@ export const DiagramWebSocketContainer = ({
handleError,
resetTools,
setSelection,
selection,
]);
useEffect(() => {
handleError(
Expand All @@ -902,7 +901,6 @@ export const DiagramWebSocketContainer = ({
invokeSingleClickOnTwoDiagramElementsToolError,
handleError,
setSelection,
selection,
]);
useEffect(() => {
handleError(arrangeAllLoading, arrangeAllData, arrangeAllError);
Expand Down Expand Up @@ -1059,6 +1057,7 @@ export const DiagramWebSocketContainer = ({
representationId={representationId}
invokeHover={invokeHover}
convertInSprottyCoordinate={convertInSprottyCoordinate}
readOnly={readOnly}
>
<div id="diagram-wrapper" className={classes.diagramWrapper}>
<div ref={diagramDomElement} id="diagram" className={classes.diagram} />
Expand Down
27 changes: 15 additions & 12 deletions frontend/src/workbench/Workbench.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { useMachine } from '@xstate/react';
import { Panels } from 'core/panels/Panels';
import gql from 'graphql-tag';
import { OnboardArea } from 'onboarding/OnboardArea';
import React, { useContext, useEffect } from 'react';
import React, { useCallback, useContext, useEffect } from 'react';
import { DiagramTreeItemContextMenuContribution } from 'tree/DiagramTreeItemContextMenuContribution';
import { TreeItemType } from 'tree/TreeItem.types';
import { TreeItemContextMenuContext } from 'tree/TreeItemContextMenu';
Expand Down Expand Up @@ -121,17 +121,20 @@ export const Workbench = ({
}
}, [error, dispatch]);

const setSelection = (selection: Selection) => {
const representations: Representation[] = selection.entries.filter((entry) =>
entry.kind.startsWith('siriusComponents://representation')
);
const updateSelectionEvent: UpdateSelectionEvent = {
type: 'UPDATE_SELECTION',
selection,
representations,
};
dispatch(updateSelectionEvent);
};
const setSelection = useCallback(
(selection: Selection) => {
const representations: Representation[] = selection.entries.filter((entry) =>
entry.kind.startsWith('siriusComponents://representation')
);
const updateSelectionEvent: UpdateSelectionEvent = {
type: 'UPDATE_SELECTION',
selection,
representations,
};
dispatch(updateSelectionEvent);
},
[dispatch]
);

const onRepresentationClick = (representation: Representation) => {
setSelection({ entries: [{ id: representation.id, label: representation.label, kind: representation.kind }] });
Expand Down

0 comments on commit 250097e

Please sign in to comment.