Skip to content

Commit aa66237

Browse files
florianbarbinfrouene
authored andcommitted
[6295] Make it possible to hide the minimap by default
- The specifier can choose to hide the minimap by default for a specific diagram description - The minimap hide/reveal action is now persisted for a specific diagram. Bug: #6295 Signed-off-by: Florian Barbin <florian.barbin@obeosoft.com> Signed-off-by: Florian ROUËNÉ <florian.rouene@obeosoft.com>
1 parent be103bc commit aa66237

File tree

25 files changed

+708
-14
lines changed

25 files changed

+708
-14
lines changed

CHANGELOG.adoc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ The new template for functional specification is located in `doc/iterations/YYYY
4646
The technical specifications will now rely on a new architectural decision record template located in `doc/adrs/adr.adoc`.
4747
This new template for ADRs will have several additional requirements compared to the previous one.
4848
It will require contributors to specify the persons involved in the decision process, to details the qualities expected of the solution, to list the various options considered, to clarify why a specific option has been selected, its advantages and drawbacks, which steps will be taken for the implementation among other things.
49-
49+
- https://github.com/eclipse-sirius/sirius-web/issues/6295[#6295] [diagram] Make it possible to hide the minimap by default.
5050

5151

5252
== 2026.3.0
@@ -205,7 +205,6 @@ Trees defined via the view DSL can alternatively provide a tooltip expression vi
205205
- https://github.com/eclipse-sirius/sirius-web/issues/6268[#6268] [sirius-web] Allow customizing the labels of the Views Explorer via delegates.
206206

207207

208-
209208
== 2026.1.0
210209

211210
=== Pitches

integration-tests-playwright/playwright/e2e/diagrams/diagram.spec.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ test.describe('diagram', () => {
5252
});
5353

5454
test('when the mini map is shown or hidden, then mini map is available or not', async ({ page }) => {
55-
// by default, the mini map is shown
55+
//1. by default, the mini map is shown
5656
await expect(page.getByTestId('hide-mini-map')).toBeAttached();
5757
await expect(page.getByTestId('show-mini-map')).not.toBeAttached();
5858
await expect(page.locator('.react-flow__minimap')).toBeAttached();
@@ -62,6 +62,23 @@ test.describe('diagram', () => {
6262
await expect(page.getByTestId('show-mini-map')).toBeAttached();
6363
await expect(page.getByTestId('hide-mini-map')).not.toBeAttached();
6464

65+
//2. We Create a new diagram
66+
await page.goto(`/projects/${projectId}/edit`);
67+
const explorer = await new PlaywrightExplorer(page);
68+
await explorer.expand('Flow');
69+
await explorer.expand('NewSystem');
70+
await explorer.createRepresentation('NewSystem', 'Topography unsynchronized', 'Topography2');
71+
await expect(page.getByTestId('rf__wrapper')).toBeAttached();
72+
73+
//3. by default, the mini map is shown, even if it has been hidden in the previous diagram.
74+
await expect(page.getByTestId('hide-mini-map')).toBeAttached();
75+
await expect(page.getByTestId('show-mini-map')).not.toBeAttached();
76+
await expect(page.locator('.react-flow__minimap')).toBeAttached();
77+
78+
//4. We switch to the initial Topography diagram
79+
await explorer.select('Topography');
80+
81+
//5. We show the mini map
6582
await page.getByTestId('show-mini-map').click();
6683
await expect(page.locator('.react-flow__minimap')).toBeAttached();
6784
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2026 Obeo.
3+
* This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v2.0
5+
* which accompanies this distribution, and is available at
6+
* https://www.eclipse.org/legal/epl-2.0/
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
*
10+
* Contributors:
11+
* Obeo - initial API and implementation
12+
*******************************************************************************/
13+
14+
package org.eclipse.sirius.components.collaborative.diagrams.api;
15+
16+
import org.eclipse.sirius.components.collaborative.diagrams.DiagramContext;
17+
import org.eclipse.sirius.components.core.api.IEditingContext;
18+
import org.eclipse.sirius.components.diagrams.description.DiagramDescription;
19+
20+
/**
21+
* Interface for services providing the diagram showminimap.
22+
*
23+
* @author fbarbin
24+
*/
25+
public interface IShowMinimapProvider {
26+
27+
boolean canHandle(IEditingContext editingContext, DiagramContext diagramContext, DiagramDescription diagramDescription);
28+
29+
boolean showMinimap(IEditingContext editingContext, DiagramContext diagramContext, DiagramDescription diagramDescription);
30+
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2026 Obeo.
3+
* This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v2.0
5+
* which accompanies this distribution, and is available at
6+
* https://www.eclipse.org/legal/epl-2.0/
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
*
10+
* Contributors:
11+
* Obeo - initial API and implementation
12+
*******************************************************************************/
13+
package org.eclipse.sirius.components.collaborative.diagrams.dto;
14+
15+
import java.util.UUID;
16+
17+
import org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramInput;
18+
19+
/**
20+
* The input for the "Show Minimap" query.
21+
*
22+
* @author fbarbin
23+
*/
24+
public record ShowMinimapInput(UUID id, String editingContextId, String representationId) implements IDiagramInput {
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2026 Obeo.
3+
* This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v2.0
5+
* which accompanies this distribution, and is available at
6+
* https://www.eclipse.org/legal/epl-2.0/
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
*
10+
* Contributors:
11+
* Obeo - initial API and implementation
12+
*******************************************************************************/
13+
package org.eclipse.sirius.components.collaborative.diagrams.dto;
14+
15+
import java.util.Objects;
16+
import java.util.UUID;
17+
18+
import org.eclipse.sirius.components.core.api.IPayload;
19+
20+
/**
21+
* The payload of the "Show Minimap" query returned on success.
22+
*
23+
* @author fbarbin
24+
*/
25+
public record ShowMinimapSuccessPayload(UUID id, boolean showMinimap) implements IPayload {
26+
27+
public ShowMinimapSuccessPayload {
28+
Objects.requireNonNull(id);
29+
}
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2026 Obeo.
3+
* This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v2.0
5+
* which accompanies this distribution, and is available at
6+
* https://www.eclipse.org/legal/epl-2.0/
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
*
10+
* Contributors:
11+
* Obeo - initial API and implementation
12+
*******************************************************************************/
13+
package org.eclipse.sirius.components.collaborative.diagrams.handlers;
14+
15+
import java.util.List;
16+
import java.util.Objects;
17+
18+
import org.eclipse.sirius.components.collaborative.api.ChangeDescription;
19+
import org.eclipse.sirius.components.collaborative.api.ChangeKind;
20+
import org.eclipse.sirius.components.collaborative.api.Monitoring;
21+
import org.eclipse.sirius.components.collaborative.diagrams.DiagramContext;
22+
import org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramEventHandler;
23+
import org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramInput;
24+
import org.eclipse.sirius.components.collaborative.diagrams.api.IShowMinimapProvider;
25+
import org.eclipse.sirius.components.collaborative.diagrams.dto.ShowMinimapInput;
26+
import org.eclipse.sirius.components.collaborative.diagrams.dto.ShowMinimapSuccessPayload;
27+
import org.eclipse.sirius.components.collaborative.messages.ICollaborativeMessageService;
28+
import org.eclipse.sirius.components.core.api.ErrorPayload;
29+
import org.eclipse.sirius.components.core.api.IEditingContext;
30+
import org.eclipse.sirius.components.core.api.IPayload;
31+
import org.eclipse.sirius.components.core.api.IRepresentationDescriptionSearchService;
32+
import org.eclipse.sirius.components.diagrams.Diagram;
33+
import org.eclipse.sirius.components.diagrams.description.DiagramDescription;
34+
import org.springframework.stereotype.Service;
35+
36+
import io.micrometer.core.instrument.Counter;
37+
import io.micrometer.core.instrument.MeterRegistry;
38+
import reactor.core.publisher.Sinks.Many;
39+
import reactor.core.publisher.Sinks.One;
40+
41+
/**
42+
* Handler used to get the diagram show minimap default value.
43+
*
44+
* @author fbarbin
45+
*/
46+
@Service
47+
public class ShowMinimapEventHandler implements IDiagramEventHandler {
48+
49+
private final IRepresentationDescriptionSearchService representationDescriptionSearchService;
50+
51+
private final List<IShowMinimapProvider> showMinimapProviders;
52+
53+
private final ICollaborativeMessageService messageService;
54+
55+
private final Counter counter;
56+
57+
public ShowMinimapEventHandler(IRepresentationDescriptionSearchService representationDescriptionSearchService, List<IShowMinimapProvider> showMinimapProviders, ICollaborativeMessageService messageService, MeterRegistry meterRegistry) {
58+
this.representationDescriptionSearchService = Objects.requireNonNull(representationDescriptionSearchService);
59+
this.showMinimapProviders = Objects.requireNonNull(showMinimapProviders);
60+
this.messageService = Objects.requireNonNull(messageService);
61+
62+
this.counter = Counter.builder(Monitoring.EVENT_HANDLER)
63+
.tag(Monitoring.NAME, this.getClass().getSimpleName())
64+
.register(meterRegistry);
65+
}
66+
67+
@Override
68+
public boolean canHandle(IEditingContext editingContext, IDiagramInput diagramInput) {
69+
return diagramInput instanceof ShowMinimapInput;
70+
}
71+
72+
@Override
73+
public void handle(One<IPayload> payloadSink, Many<ChangeDescription> changeDescriptionSink, IEditingContext editingContext, DiagramContext diagramContext, IDiagramInput diagramInput) {
74+
this.counter.increment();
75+
76+
String message = this.messageService.invalidInput(diagramInput.getClass().getSimpleName(), ShowMinimapInput.class.getSimpleName());
77+
IPayload payload = new ErrorPayload(diagramInput.id(), message);
78+
79+
ChangeDescription changeDescription = new ChangeDescription(ChangeKind.NOTHING, editingContext.getId(), diagramInput);
80+
81+
if (diagramInput instanceof ShowMinimapInput) {
82+
Diagram diagram = diagramContext.diagram();
83+
var optionalDiagramDescription = this.representationDescriptionSearchService.findById(editingContext, diagram.getDescriptionId())
84+
.filter(DiagramDescription.class::isInstance)
85+
.map(DiagramDescription.class::cast);
86+
if (optionalDiagramDescription.isPresent()) {
87+
DiagramDescription diagramDescription = optionalDiagramDescription.get();
88+
boolean showMinimap = this.showMinimapProviders.stream()
89+
.filter(provider -> provider.canHandle(editingContext, diagramContext, diagramDescription))
90+
.allMatch(provider -> provider.showMinimap(editingContext, diagramContext, diagramDescription));
91+
92+
payload = new ShowMinimapSuccessPayload(diagramInput.id(), showMinimap);
93+
}
94+
}
95+
payloadSink.tryEmitValue(payload);
96+
changeDescriptionSink.tryEmitNext(changeDescription);
97+
}
98+
}

packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/resources/schema/diagram.graphqls

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,7 @@ type DiagramDescription implements RepresentationDescription {
418418
id: ID!
419419
label: String!
420420
autoLayout: Boolean!
421+
showMinimap: Boolean!
421422
arrangeLayoutDirection: ArrangeLayoutDirection!
422423
nodeDescriptions: [NodeDescription!]!
423424
childNodeDescriptionIds: [ID!]!
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2026 Obeo.
3+
* This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v2.0
5+
* which accompanies this distribution, and is available at
6+
* https://www.eclipse.org/legal/epl-2.0/
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
*
10+
* Contributors:
11+
* Obeo - initial API and implementation
12+
*******************************************************************************/
13+
package org.eclipse.sirius.components.diagrams.graphql.datafetchers.diagram;
14+
15+
import java.util.Map;
16+
import java.util.Objects;
17+
import java.util.Optional;
18+
import java.util.UUID;
19+
import java.util.concurrent.CompletableFuture;
20+
21+
import org.eclipse.sirius.components.annotations.spring.graphql.QueryDataFetcher;
22+
import org.eclipse.sirius.components.collaborative.diagrams.dto.ShowMinimapInput;
23+
import org.eclipse.sirius.components.collaborative.diagrams.dto.ShowMinimapSuccessPayload;
24+
import org.eclipse.sirius.components.graphql.api.IDataFetcherWithFieldCoordinates;
25+
import org.eclipse.sirius.components.graphql.api.IEditingContextDispatcher;
26+
import org.eclipse.sirius.components.graphql.api.LocalContextConstants;
27+
28+
import graphql.schema.DataFetchingEnvironment;
29+
import reactor.core.publisher.Mono;
30+
31+
/**
32+
* Datafetcher to retrieve the showMinimap diagram property.
33+
*
34+
* @author fbarbin
35+
*/
36+
@QueryDataFetcher(type = "DiagramDescription", field = "showMinimap")
37+
public class DiagramDescriptionShowMinimapDataFetcher implements IDataFetcherWithFieldCoordinates<CompletableFuture<Boolean>> {
38+
39+
private final IEditingContextDispatcher editingContextDispatcher;
40+
41+
public DiagramDescriptionShowMinimapDataFetcher(IEditingContextDispatcher editingContextDispatcher) {
42+
this.editingContextDispatcher = Objects.requireNonNull(editingContextDispatcher);
43+
}
44+
45+
@Override
46+
public CompletableFuture<Boolean> get(DataFetchingEnvironment environment) throws Exception {
47+
Map<String, Object> localContext = environment.getLocalContext();
48+
String editingContextId = Optional.ofNullable(localContext.get(LocalContextConstants.EDITING_CONTEXT_ID)).map(Object::toString).orElse(null);
49+
String representationId = Optional.ofNullable(localContext.get(LocalContextConstants.REPRESENTATION_ID)).map(Object::toString).orElse(null);
50+
51+
if (editingContextId != null && representationId != null) {
52+
ShowMinimapInput input = new ShowMinimapInput(UUID.randomUUID(), editingContextId, representationId);
53+
54+
return this.editingContextDispatcher.dispatchQuery(input.editingContextId(), input)
55+
.filter(ShowMinimapSuccessPayload.class::isInstance)
56+
.map(ShowMinimapSuccessPayload.class::cast)
57+
.map(ShowMinimapSuccessPayload::showMinimap)
58+
.toFuture();
59+
}
60+
61+
return Mono.just(true).toFuture();
62+
}
63+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2026 Obeo.
3+
* This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v2.0
5+
* which accompanies this distribution, and is available at
6+
* https://www.eclipse.org/legal/epl-2.0/
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
*
10+
* Contributors:
11+
* Obeo - initial API and implementation
12+
*******************************************************************************/
13+
package org.eclipse.sirius.components.diagrams.tests.graphql;
14+
15+
import java.util.Map;
16+
import java.util.Objects;
17+
18+
import org.eclipse.sirius.components.graphql.tests.api.GraphQLResult;
19+
import org.eclipse.sirius.components.graphql.tests.api.IGraphQLRequestor;
20+
import org.eclipse.sirius.components.graphql.tests.api.IQueryRunner;
21+
import org.springframework.stereotype.Service;
22+
23+
/**
24+
* Used to retrieve the show minimap of a diagram.
25+
*
26+
* @author fbarbin
27+
*/
28+
@Service
29+
public class ShowMinimapQueryRunner implements IQueryRunner {
30+
31+
private static final String TOOLBAR_QUERY = """
32+
query getToolbar($editingContextId: ID!, $representationId: ID!) {
33+
viewer {
34+
editingContext(editingContextId: $editingContextId) {
35+
representation(representationId: $representationId) {
36+
description {
37+
... on DiagramDescription {
38+
showMinimap
39+
}
40+
}
41+
}
42+
}
43+
}
44+
}
45+
""";
46+
47+
private final IGraphQLRequestor graphQLRequestor;
48+
49+
public ShowMinimapQueryRunner(IGraphQLRequestor graphQLRequestor) {
50+
this.graphQLRequestor = Objects.requireNonNull(graphQLRequestor);
51+
}
52+
53+
@Override
54+
public GraphQLResult run(Map<String, Object> variables) {
55+
return this.graphQLRequestor.execute(TOOLBAR_QUERY, variables);
56+
}
57+
}

packages/diagrams/frontend/sirius-components-diagrams/src/contexts/DiagramDescriptionContext.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const defaultValue: DiagramDescriptionContextValue = {
2222
debug: false,
2323
arrangeLayoutDirection: 'RIGHT',
2424
autoLayout: false,
25+
showMinimap: true,
2526
},
2627
};
2728

0 commit comments

Comments
 (0)