[5651] Add support for undo redo on label appearance and label layout data#5652
[5651] Add support for undo redo on label appearance and label layout data#5652sbegaudeau merged 2 commits intomasterfrom
Conversation
866a326 to
0898403
Compare
| const addUndoForLayout = (mutationId: string) => { | ||
| var storedUndoStack = sessionStorage.getItem('undoStack'); | ||
| var storedRedoStack = sessionStorage.getItem('redoStack'); | ||
|
|
||
| if (storedUndoStack && storedRedoStack) { | ||
| var undoStack: String[] = JSON.parse(storedUndoStack); | ||
| if (!undoStack.find((id) => id === mutationId)) { | ||
| sessionStorage.setItem('undoStack', JSON.stringify([mutationId, ...undoStack])); | ||
| } | ||
| } | ||
| }; |
There was a problem hiding this comment.
How many time would this function be copied and paster in the frontend?
There was a problem hiding this comment.
This is moved in the last PR, I wanted to have most recorders implemented before moving this function directly inside synchronizeLayoutData in order to capture all graphical changes
|
|
||
| List<DiagramLabelLayoutEvent> diagramLabelLayoutEvents = diagramEvents.stream() | ||
| .filter(DiagramLabelLayoutEvent.class::isInstance) | ||
| .map(DiagramLabelLayoutEvent.class::cast).toList(); |
There was a problem hiding this comment.
.toList() should be on the next line
| List<IAppearanceChange> computeUndoNodeLabelAppearanceChanges(Node previousNode, String labelId, Optional<ILabelAppearanceChange> change); | ||
|
|
||
| List<IAppearanceChange> computeUndoEdgeLabelAppearanceChanges(Edge previousEdge, String labelId, Optional<ILabelAppearanceChange> change); |
There was a problem hiding this comment.
Two entry points? That's odd, why not one or two interfaces which would call a same service to share some common code.
| private boolean isSameLabelLayoutData(LabelLayoutData previousLayout, LabelLayoutDataInput updatedLayout) { | ||
| return isSamePosition(previousLayout.position(), updatedLayout.position()); | ||
| } |
| public List<IAppearanceChange> computeUndoNodeLabelAppearanceChanges(Node previousNode, String labelId, Optional<ILabelAppearanceChange> optionalChange) { | ||
| List<IAppearanceChange> appearanceChanges = new ArrayList<>(); | ||
| if (optionalChange.isPresent()) { | ||
| var change = optionalChange.get(); | ||
| getNodeOutsideLabel(previousNode, labelId) | ||
| .ifPresent(previousLabel -> appearanceChanges.addAll(getAppearanceChanges(change, previousLabel.customizedStyleProperties(), previousLabel.style()))); | ||
| getNodeInsideLabel(previousNode, labelId) | ||
| .ifPresent(previousLabel -> appearanceChanges.addAll(getAppearanceChanges(change, previousLabel.getCustomizedStyleProperties(), previousLabel.getStyle()))); | ||
| } else { | ||
| getNodeOutsideLabel(previousNode, labelId) | ||
| .ifPresent(previousLabel -> appearanceChanges.addAll(getResetLabelApperanceChange(labelId, previousLabel.customizedStyleProperties(), previousLabel.style()))); | ||
| getNodeInsideLabel(previousNode, labelId) | ||
| .ifPresent(previousLabel -> appearanceChanges.addAll(getResetLabelApperanceChange(labelId, previousLabel.getCustomizedStyleProperties(), previousLabel.getStyle()))); | ||
| } | ||
| return appearanceChanges; |
There was a problem hiding this comment.
- Use `this.``
- This should be a node specific service
| public List<IAppearanceChange> computeUndoEdgeLabelAppearanceChanges(Edge previousEdge, String labelId, Optional<ILabelAppearanceChange> optionalChange) { | ||
| List<IAppearanceChange> appearanceChanges = new ArrayList<>(); | ||
| if (optionalChange.isPresent()) { | ||
| var change = optionalChange.get(); | ||
| getEdgeLabel(previousEdge, labelId) | ||
| .ifPresent(previousLabel -> appearanceChanges.addAll(getAppearanceChanges(change, previousLabel.customizedStyleProperties(), previousLabel.style()))); | ||
| } else { | ||
| getEdgeLabel(previousEdge, labelId) | ||
| .ifPresent(previousLabel -> appearanceChanges.addAll(getResetLabelApperanceChange(labelId, previousLabel.customizedStyleProperties(), previousLabel.style()))); | ||
| } | ||
| return appearanceChanges; | ||
| } |
There was a problem hiding this comment.
- Use
this. - This should be an edge specific service
| return appearanceChanges; | ||
| } | ||
|
|
||
| private List<IAppearanceChange> getAppearanceChanges(ILabelAppearanceChange change, Set<String> previousCustomizedStyleProperties, LabelStyle previousLabelStyle) { |
There was a problem hiding this comment.
This should be a common service reused by the other two
0898403 to
9842c16
Compare
dde9df9 to
748f2ec
Compare
a2ec81e to
e175c5e
Compare
e175c5e to
ef41420
Compare
sbegaudeau
left a comment
There was a problem hiding this comment.
I've fixed some minor issue in the PR (indicated in the comments) and I'll use it to publish 2025.12.5 as RC1. Nevertheless I think that there may be some small issues in some part because some kind of label appearance changes were not taken into account but we can see this later for RC2.
I'll wait for the build to merge it
| if (diagramElement instanceof Edge previousEdge) { | ||
| if (optionalChange.isPresent()) { | ||
| var change = optionalChange.get(); | ||
| getEdgeLabel(previousEdge, labelId) |
| var outsideLabel = new OutsideLabelDescriptionBuilder() | ||
| .labelExpression("aql:self.name") | ||
| .style(DiagramFactory.eINSTANCE.createOutsideLabelStyle()) | ||
| .build(); |
There was a problem hiding this comment.
Don't reuse existing test diagram description. It creates coupling between independent tests
0dcf873 to
b1d1537
Compare
sbegaudeau
left a comment
There was a problem hiding this comment.
I've made a small mistake in the PR, I'll retrigger the build
… data Bug: #5651 Signed-off-by: Michaël Charfadi <michael.charfadi@obeosoft.com>
Signed-off-by: Stéphane Bégaudeau <stephane.begaudeau@obeo.fr>
b1d1537 to
79d2fe6
Compare
Pull request template
General purpose
What is the main goal of this pull request?
Project management
priority:andpr:labels been added to the pull request? (In case of doubt, start with the labelspriority: lowandpr: to review later)area:,difficulty:,type:)CHANGELOG.adocbeen updated to reference the relevant issues?CHANGELOG.adoc? (Including changes in the GraphQL API)CHANGELOG.adoc? For example indoc/screenshots/2022.5.0-my-new-feature.pngArchitectural decision records (ADR)
[doc]?CHANGELOG.adoc?Dependencies
CHANGELOG.adoc?CHANGELOG.adoc?Frontend
This section is not relevant if your contribution does not come with changes to the frontend.
General purpose
Typing
We need to improve the typing of our code, as such, we require every contribution to come with proper TypeScript typing for both changes contributing new files and those modifying existing files.
Please ensure that the following statements are true for each file created or modified (this may require you to improve code outside of your contribution).
useMutation<DATA_TYPE, VARIABLE_TYPE>(…)useQuery<DATA_TYPE, VARIABLE_TYPE>(…)useSubscription<DATA_TYPE, VARIABLE_TYPE>(…)useMachine<CONTEXT_TYPE, EVENTS_TYPE>(…)useState<STATE_TYPE>(…)?.(if the GraphQL API specifies that a field cannot benull, do not treat it has potentiallynullfor example)let diagram: Diagram | null = null;)Backend
This section is not relevant if your contribution does not come with changes to the backend.
General purpose
Architecture
Review
How to test this PR?
Please describe here the various use cases to test this pull request