Skip to content

Commit

Permalink
[3748] Store current diagram payload in DiagramContext
Browse files Browse the repository at this point in the history
Bug: #3748
Signed-off-by: Michaël Charfadi <[email protected]>
  • Loading branch information
mcharfadi authored and frouene committed Jul 23, 2024
1 parent 9e1f595 commit 35c2172
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const value: DiagramContextValue = {
editingContextId: '',
diagramId: '',
refreshEventPayloadId: '',
payload: null,
readOnly: false,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export const DiagramRepresentation = ({
const [state, setState] = useState<DiagramRepresentationState>({
id: crypto.randomUUID(),
diagramRefreshedEventPayload: null,
payload: null,
complete: false,
message: null,
});
Expand All @@ -105,6 +106,7 @@ export const DiagramRepresentation = ({
if (isDiagramRefreshedEventPayload(diagramEvent)) {
setState((prevState) => ({ ...prevState, diagramRefreshedEventPayload: diagramEvent }));
}
setState((prevState) => ({ ...prevState, payload: diagramEvent }));
}
};

Expand Down Expand Up @@ -167,6 +169,7 @@ export const DiagramRepresentation = ({
editingContextId,
diagramId: representationId,
refreshEventPayloadId: state.diagramRefreshedEventPayload.id,
payload: state.payload,
readOnly,
}}>
<DiagramDescriptionContext.Provider value={{ diagramDescription }}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
export interface DiagramRepresentationState {
id: string;
diagramRefreshedEventPayload: GQLDiagramRefreshedEventPayload | null;
payload: GQLDiagramEventPayload | null;
complete: boolean;
message: string | null;
}
Expand Down

0 comments on commit 35c2172

Please sign in to comment.