Skip to content

[5651] Add support for undo redo on label appearance and label layout data#5652

Merged
sbegaudeau merged 2 commits intomasterfrom
mch/enh/undo-redo-label
Jan 16, 2026
Merged

[5651] Add support for undo redo on label appearance and label layout data#5652
sbegaudeau merged 2 commits intomasterfrom
mch/enh/undo-redo-label

Conversation

@mcharfadi
Copy link
Contributor

Pull request template

General purpose

What is the main goal of this pull request?

  • Bug fixes
  • New features
  • Documentation
  • Cleanup
  • Tests
  • Build / releng

Project management

  • Has the pull request been added to the relevant project and milestone? (Only if you know that your work is part of a specific iteration such as the current one)
  • Have the priority: and pr: labels been added to the pull request? (In case of doubt, start with the labels priority: low and pr: to review later)
  • Have the relevant issues been added to the pull request?
  • Have the relevant labels been added to the issues? (area:, difficulty:, type:)
  • Have the relevant issues been added to the same project and milestone as the pull request?
  • Has the CHANGELOG.adoc been updated to reference the relevant issues?
  • Have the relevant API breaks been described in the CHANGELOG.adoc? (Including changes in the GraphQL API)
  • In case of a change with a visual impact, are there any screenshots in the CHANGELOG.adoc? For example in doc/screenshots/2022.5.0-my-new-feature.png

Architectural decision records (ADR)

  • Does the title of the commit contributing the ADR start with [doc]?
  • Are the ADRs mentioned in the relevant section of the CHANGELOG.adoc?

Dependencies

  • Are the new / upgraded dependencies mentioned in the relevant section of the CHANGELOG.adoc?
  • Are the new dependencies justified in the CHANGELOG.adoc?

Frontend

This section is not relevant if your contribution does not come with changes to the frontend.

General purpose

  • Is the code properly tested? (Plain old JavaScript tests for business code and tests based on React Testing Library for the components)

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).

  • Variables have a proper type
  • Functions’ arguments have a proper type
  • Functions’ return type are specified
  • Hooks are properly typed:
    • useMutation<DATA_TYPE, VARIABLE_TYPE>(…)
    • useQuery<DATA_TYPE, VARIABLE_TYPE>(…)
    • useSubscription<DATA_TYPE, VARIABLE_TYPE>(…)
    • useMachine<CONTEXT_TYPE, EVENTS_TYPE>(…)
    • useState<STATE_TYPE>(…)
  • All components have a proper typing for their props
  • No useless optional chaining with ?. (if the GraphQL API specifies that a field cannot be null, do not treat it has potentially null for example)
  • Nullable values have a proper type (for 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

  • Are all the event handlers tested?
  • Are the event processor tested?
  • Is the business code (services) tested?
  • Are diagram layout changes tested?

Architecture

  • Are data structure classes properly separated from behavioral classes?
  • Are all the relevant fields final?
  • Is any data structure mutable? If so, please write a comment indicating why
  • Are behavioral classes either stateless or side effect free?

Review

How to test this PR?

Please describe here the various use cases to test this pull request

  • Has the Kiwi TCMS test suite been updated with tests for this contribution?

@mcharfadi mcharfadi added this to the 2025.12.0 milestone Oct 8, 2025
@mcharfadi mcharfadi linked an issue Oct 8, 2025 that may be closed by this pull request
@mcharfadi mcharfadi force-pushed the mch/enh/undo-redo-label branch 14 times, most recently from 866a326 to 0898403 Compare October 10, 2025 08:01
@mcharfadi mcharfadi marked this pull request as ready for review October 10, 2025 09:01
Comment on lines +22 to +32
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]));
}
}
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How many time would this function be copied and paster in the frontend?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.toList() should be on the next line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines +30 to +32
List<IAppearanceChange> computeUndoNodeLabelAppearanceChanges(Node previousNode, String labelId, Optional<ILabelAppearanceChange> change);

List<IAppearanceChange> computeUndoEdgeLabelAppearanceChanges(Edge previousEdge, String labelId, Optional<ILabelAppearanceChange> change);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two entry points? That's odd, why not one or two interfaces which would call a same service to share some common code.

Comment on lines +117 to +119
private boolean isSameLabelLayoutData(LabelLayoutData previousLayout, LabelLayoutDataInput updatedLayout) {
return isSamePosition(previousLayout.position(), updatedLayout.position());
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is useless

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

Comment on lines +55 to +69
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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Use `this.``
  • This should be a node specific service

Comment on lines +73 to +84
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;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Use this.
  • This should be an edge specific service

return appearanceChanges;
}

private List<IAppearanceChange> getAppearanceChanges(ILabelAppearanceChange change, Set<String> previousCustomizedStyleProperties, LabelStyle previousLabelStyle) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a common service reused by the other two

@mcharfadi mcharfadi force-pushed the mch/enh/undo-redo-label branch from 0898403 to 9842c16 Compare October 24, 2025 09:07
@mcharfadi mcharfadi modified the milestones: 2025.12.0, 2026.1.0 Nov 28, 2025
@mcharfadi mcharfadi force-pushed the mch/enh/undo-redo-label branch 6 times, most recently from dde9df9 to 748f2ec Compare January 14, 2026 15:58
@mcharfadi mcharfadi force-pushed the mch/enh/undo-redo-label branch 3 times, most recently from a2ec81e to e175c5e Compare January 14, 2026 16:35
@sbegaudeau sbegaudeau force-pushed the mch/enh/undo-redo-label branch from e175c5e to ef41420 Compare January 16, 2026 10:03
Copy link
Member

@sbegaudeau sbegaudeau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing this.

Comment on lines +124 to +127
var outsideLabel = new OutsideLabelDescriptionBuilder()
.labelExpression("aql:self.name")
.style(DiagramFactory.eINSTANCE.createOutsideLabelStyle())
.build();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't reuse existing test diagram description. It creates coupling between independent tests

@sbegaudeau sbegaudeau force-pushed the mch/enh/undo-redo-label branch 2 times, most recently from 0dcf873 to b1d1537 Compare January 16, 2026 10:20
Copy link
Member

@sbegaudeau sbegaudeau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made a small mistake in the PR, I'll retrigger the build

mcharfadi and others added 2 commits January 16, 2026 13:45
… data

Bug: #5651
Signed-off-by: Michaël Charfadi <michael.charfadi@obeosoft.com>
Signed-off-by: Stéphane Bégaudeau <stephane.begaudeau@obeo.fr>
@sbegaudeau sbegaudeau force-pushed the mch/enh/undo-redo-label branch from b1d1537 to 79d2fe6 Compare January 16, 2026 12:46
@sbegaudeau sbegaudeau merged commit b7ebc9b into master Jan 16, 2026
4 checks passed
@sbegaudeau sbegaudeau deleted the mch/enh/undo-redo-label branch January 16, 2026 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for undo redo on label appearance and label layout data

2 participants