Skip to content

[6290] Move diagram layout configurations from frontend to backend#6298

Open
OrlannC wants to merge 1 commit intoeclipse-sirius:masterfrom
OrlannC:orc/enh/expandable-layout
Open

[6290] Move diagram layout configurations from frontend to backend#6298
OrlannC wants to merge 1 commit intoeclipse-sirius:masterfrom
OrlannC:orc/enh/expandable-layout

Conversation

@OrlannC
Copy link
Copy Markdown

@OrlannC OrlannC commented Mar 13, 2026

Bug: #6290

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?

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

@frouene frouene self-requested a review March 13, 2026 10:30
Copy link
Copy Markdown
Contributor

@frouene frouene left a comment

Choose a reason for hiding this comment

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

You need to add integration tests for this type of contribution
For inspiration ManageVisibilityActionControllerTests

import { useLayoutConfigurations } from '../layout/arrange-all/useLayoutConfigurations';
import { LayoutConfiguration } from '../layout/arrange-all/useLayoutConfigurations.types';
import { ArrangeAllButtonProps, ArrangeAllButtonState } from './ArrangeAllButton.types';
import { IconOverlay } from '@eclipse-sirius/sirius-components-core';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

wrong order

Objects.requireNonNull(layoutOptions);
}

public static Builder newLayout(String id) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

newLayoutConfiguration instead

DiagramDescription diagramDescription = optionalDiagramDescription.get();
var optionalLayoutProvider = this.layoutConfigurationProviders.stream()
.filter(layoutProvider -> layoutProvider.canHandle(editingContext, diagramContext, diagramDescription))
.findFirst();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We shouldn't limit ourselves to the first option. We could consider the layout options offered by several providers

@OrlannC OrlannC force-pushed the orc/enh/expandable-layout branch from f77a26a to bb565a7 Compare March 13, 2026 14:04
@sbegaudeau sbegaudeau linked an issue Mar 16, 2026 that may be closed by this pull request
1 task
id: ID!
label: String!
iconURL: [String!]!
layoutOptions: String!
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ELK Layout options are a Map of String to String, unless I'm mistaken. As such, it should not be sent to the frontend as a raw untyped Json string.

Image

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I've updated the code based on your feedback.

@OrlannC OrlannC force-pushed the orc/enh/expandable-layout branch 2 times, most recently from 698450e to ed4ae9e Compare March 20, 2026 10:30

export const useLayoutConfigurations = (): UseLayoutConfigurationsValue => {
const { diagramDescription } = useDiagramDescription();
const { t } = useTranslation('sirius-components-diagrams', { keyPrefix: 'useLayoutConfigurations' });
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We used the useTranslation hook only for hard coded static string in the frontend.
Like the label comes from the backend, it should be translated before be sent to the frontend

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Ok I will look in to it

@OrlannC OrlannC force-pushed the orc/enh/expandable-layout branch from ed4ae9e to c55a558 Compare March 23, 2026 15:58
*/

@Component
public class DefaultLayoutConfiguration implements ILayoutConfigurationProvider {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We used to name this kind of class with Provider
Prefer something like DefaultLayoutConfigurationProvider

return List.of(layoutLayered, layoutRectPacking);
}

@SuppressWarnings({"checkstyle:MultipleStringLiterals", "checkstyle:AvoidInlineConditionals"})
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't see where the AvoidInlineConditionals is necessary

Comment thread CHANGELOG.adoc Outdated
- https://github.com/eclipse-sirius/sirius-web/issues/6020[#6020] [diagram] Allow the execution of the hardcoded semantic delete tool on a multi selection
- https://github.com/eclipse-sirius/sirius-web/issues/6246[#6246] [sirius-web] Add missing export of `useCurrentLibrary` and related types.
- https://github.com/eclipse-sirius/sirius-web/issues/6226[#6226] [diagram] Remove overlap resolution in node layout tools
- https://github.com/eclipse-sirius/sirius-web/issues/6290[#6290] [diagram] Move diagram layout configurations from frontend to backend
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Need to be moved in the new 2026.3.0 section

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sorry, to the 2026.5.0 section

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Ok I've fixed it

@OrlannC OrlannC force-pushed the orc/enh/expandable-layout branch from c55a558 to 6e4f240 Compare March 26, 2026 15:55
@OrlannC OrlannC requested a review from frouene March 26, 2026 15:56
return true;
}

@SuppressWarnings("checkstyle:MultipleStringLiterals")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Useless

@OrlannC OrlannC force-pushed the orc/enh/expandable-layout branch 2 times, most recently from bff85ca to 778b146 Compare March 26, 2026 16:12
@OrlannC OrlannC requested a review from frouene March 26, 2026 16:15

LayoutConfiguration layoutLayered = LayoutConfiguration.newLayoutConfiguration("elk-layered")
.label(this.messageService.diagramLayoutFlow())
.iconURL(List.of(DiagramImageConstants.RESET_HANDLES))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Wrong icon

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yes, there are no icons for them at the moment, and we can't just take them from the mui library


LayoutConfiguration layoutRectPacking = LayoutConfiguration.newLayoutConfiguration("elk-rect-packing")
.label(this.messageService.diagramLayoutCompact())
.iconURL(List.of(DiagramImageConstants.RESET_BENDING_POINTS))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Wrong icon

@OrlannC OrlannC force-pushed the orc/enh/expandable-layout branch from 778b146 to 6582c47 Compare March 27, 2026 09:21
@OrlannC OrlannC requested a review from frouene March 27, 2026 09:22
@sbegaudeau sbegaudeau added this to the 2026.5.0 milestone Mar 27, 2026
@OrlannC OrlannC force-pushed the orc/enh/expandable-layout branch from 6582c47 to b13e767 Compare March 30, 2026 08:48
@OrlannC OrlannC requested a review from sbegaudeau March 30, 2026 08:49
@OrlannC OrlannC force-pushed the orc/enh/expandable-layout branch 5 times, most recently from bc331da to 534d2e2 Compare March 30, 2026 12:55
@OrlannC OrlannC force-pushed the orc/enh/expandable-layout branch 4 times, most recently from ae91d61 to 8fb205c Compare March 31, 2026 07:40
Bug: eclipse-sirius#6290
Signed-off-by: Orlann Cailleau <orlann.cailleau@obeosoft.com>
@OrlannC OrlannC force-pushed the orc/enh/expandable-layout branch from 8fb205c to 5aef59e Compare March 31, 2026 07:59
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.

Move diagram layout configurations from frontend to backend

3 participants