From 35c2172c8fbb4f07d87413eae4332c0e97afc5cc Mon Sep 17 00:00:00 2001 From: Michael Charfadi Date: Thu, 11 Jul 2024 10:18:02 +0200 Subject: [PATCH] [3748] Store current diagram payload in DiagramContext MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: https://github.com/eclipse-sirius/sirius-web/issues/3748 Signed-off-by: Michaƫl Charfadi --- CHANGELOG.adoc | 2 ++ .../sirius-components-diagrams/src/contexts/DiagramContext.ts | 1 + .../src/contexts/DiagramContext.types.ts | 3 +++ .../src/representation/DiagramRepresentation.tsx | 3 +++ .../src/representation/DiagramRepresentation.types.ts | 1 + 5 files changed, 10 insertions(+) diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index cd39a03739..a080149d50 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -65,6 +65,8 @@ As a result, the following maven modules have been deleted: `sirius-web-sample-a === New Features +- https://github.com/eclipse-sirius/sirius-web/issues/3748[#3748] [diagram] Store current diagram payload in `DiagramContext` + === Improvements diff --git a/packages/diagrams/frontend/sirius-components-diagrams/src/contexts/DiagramContext.ts b/packages/diagrams/frontend/sirius-components-diagrams/src/contexts/DiagramContext.ts index 3dc62d8879..58cb393ef7 100644 --- a/packages/diagrams/frontend/sirius-components-diagrams/src/contexts/DiagramContext.ts +++ b/packages/diagrams/frontend/sirius-components-diagrams/src/contexts/DiagramContext.ts @@ -17,6 +17,7 @@ const value: DiagramContextValue = { editingContextId: '', diagramId: '', refreshEventPayloadId: '', + payload: null, readOnly: false, }; diff --git a/packages/diagrams/frontend/sirius-components-diagrams/src/contexts/DiagramContext.types.ts b/packages/diagrams/frontend/sirius-components-diagrams/src/contexts/DiagramContext.types.ts index d5322e5b6d..2fa29085e0 100644 --- a/packages/diagrams/frontend/sirius-components-diagrams/src/contexts/DiagramContext.types.ts +++ b/packages/diagrams/frontend/sirius-components-diagrams/src/contexts/DiagramContext.types.ts @@ -11,9 +11,12 @@ * Obeo - initial API and implementation *******************************************************************************/ +import { GQLDiagramEventPayload } from '../graphql/subscription/diagramEventSubscription.types'; + export interface DiagramContextValue { editingContextId: string; diagramId: string; refreshEventPayloadId: string; + payload: GQLDiagramEventPayload | null; readOnly: boolean; } diff --git a/packages/diagrams/frontend/sirius-components-diagrams/src/representation/DiagramRepresentation.tsx b/packages/diagrams/frontend/sirius-components-diagrams/src/representation/DiagramRepresentation.tsx index 417e38a75c..a5ff0b9619 100644 --- a/packages/diagrams/frontend/sirius-components-diagrams/src/representation/DiagramRepresentation.tsx +++ b/packages/diagrams/frontend/sirius-components-diagrams/src/representation/DiagramRepresentation.tsx @@ -86,6 +86,7 @@ export const DiagramRepresentation = ({ const [state, setState] = useState({ id: crypto.randomUUID(), diagramRefreshedEventPayload: null, + payload: null, complete: false, message: null, }); @@ -105,6 +106,7 @@ export const DiagramRepresentation = ({ if (isDiagramRefreshedEventPayload(diagramEvent)) { setState((prevState) => ({ ...prevState, diagramRefreshedEventPayload: diagramEvent })); } + setState((prevState) => ({ ...prevState, payload: diagramEvent })); } }; @@ -167,6 +169,7 @@ export const DiagramRepresentation = ({ editingContextId, diagramId: representationId, refreshEventPayloadId: state.diagramRefreshedEventPayload.id, + payload: state.payload, readOnly, }}> diff --git a/packages/diagrams/frontend/sirius-components-diagrams/src/representation/DiagramRepresentation.types.ts b/packages/diagrams/frontend/sirius-components-diagrams/src/representation/DiagramRepresentation.types.ts index ec9a886801..98224e5bed 100644 --- a/packages/diagrams/frontend/sirius-components-diagrams/src/representation/DiagramRepresentation.types.ts +++ b/packages/diagrams/frontend/sirius-components-diagrams/src/representation/DiagramRepresentation.types.ts @@ -20,6 +20,7 @@ import { export interface DiagramRepresentationState { id: string; diagramRefreshedEventPayload: GQLDiagramRefreshedEventPayload | null; + payload: GQLDiagramEventPayload | null; complete: boolean; message: string | null; }