diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 87be67c469b..6aa4350beed 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -52,22 +52,7 @@ More existing APIs will be migrated to this new common pattern. } ``` - * The `SingleClickOnDiagramElementTool#dialogDescriptionId` has been replaced by a `dialog: Dialog` field to provide the information about the dialog that the frontend needs to retrieve in the extension point. -``` -type SingleClickOnDiagramElementTool implements Tool { - id: ID! - label: String! - iconURL: [String!]! - appliesToDiagramRoot: Boolean! - dialog: Dialog - targetDescriptions: [DiagramElementDescription!]! -} -``` * The `String` attribute `org.eclipse.sirius.components.collaborative.diagrams.dto.InvokeSingleClickOnDiagramElementToolInput#selectedObjectId` has been replaced by the attribute `variables` of type `List` -* The `String` attribute `org.eclipse.sirius.components.collaborative.diagrams.dto.SingleClickOnDiagramElementTool#selectionDescriptionId` has been replaced by the attribute `dialog` of type `Dialog` -* The `String` attribute `org.eclipse.sirius.components.diagrams.tools.SingleClickOnDiagramElementTool` has been replaced by the attribute `dialog` of type `Dialog` -* The `Palette` component in `sirius-components-diagrams` has a new property `diagramElementTargetObjectId` that represents the id of the diagram element target object. -* The `DiagramPalette` component in `sirius-components-diagrams` has a new property `diagramTargetObjectId: string` that represents the diagram target object. === Dependency update diff --git a/packages/compatibility/backend/sirius-components-compatibility/src/main/java/org/eclipse/sirius/components/compatibility/services/diagrams/CompatibilityPaletteProvider.java b/packages/compatibility/backend/sirius-components-compatibility/src/main/java/org/eclipse/sirius/components/compatibility/services/diagrams/CompatibilityPaletteProvider.java index 7f6c5384220..92e8796a7de 100644 --- a/packages/compatibility/backend/sirius-components-compatibility/src/main/java/org/eclipse/sirius/components/compatibility/services/diagrams/CompatibilityPaletteProvider.java +++ b/packages/compatibility/backend/sirius-components-compatibility/src/main/java/org/eclipse/sirius/components/compatibility/services/diagrams/CompatibilityPaletteProvider.java @@ -132,7 +132,7 @@ private ITool convertTool(org.eclipse.sirius.components.diagrams.tools.ITool too if (tool instanceof org.eclipse.sirius.components.diagrams.tools.SingleClickOnDiagramElementTool singleClickOnDiagramElementTool) { convertedTool = new SingleClickOnDiagramElementTool(singleClickOnDiagramElementTool.getId(), singleClickOnDiagramElementTool.getLabel(), singleClickOnDiagramElementTool.getIconURL(), singleClickOnDiagramElementTool.getTargetDescriptions(), - singleClickOnDiagramElementTool.getDialog(), singleClickOnDiagramElementTool.isAppliesToDiagramRoot()); + singleClickOnDiagramElementTool.getDialogDescriptionId(), singleClickOnDiagramElementTool.isAppliesToDiagramRoot()); } if (tool instanceof org.eclipse.sirius.components.diagrams.tools.SingleClickOnTwoDiagramElementsTool singleClickOnTwoDiagramElementsTool) { List candidates = new ArrayList<>(); diff --git a/packages/compatibility/backend/sirius-components-compatibility/src/main/java/org/eclipse/sirius/components/compatibility/services/diagrams/ToolProvider.java b/packages/compatibility/backend/sirius-components-compatibility/src/main/java/org/eclipse/sirius/components/compatibility/services/diagrams/ToolProvider.java index 88640968f04..917a0a6bb42 100644 --- a/packages/compatibility/backend/sirius-components-compatibility/src/main/java/org/eclipse/sirius/components/compatibility/services/diagrams/ToolProvider.java +++ b/packages/compatibility/backend/sirius-components-compatibility/src/main/java/org/eclipse/sirius/components/compatibility/services/diagrams/ToolProvider.java @@ -34,7 +34,6 @@ import org.eclipse.sirius.components.diagrams.description.EdgeDescription; import org.eclipse.sirius.components.diagrams.description.IDiagramElementDescription; import org.eclipse.sirius.components.diagrams.description.NodeDescription; -import org.eclipse.sirius.components.diagrams.tools.Dialog; import org.eclipse.sirius.components.diagrams.tools.ITool; import org.eclipse.sirius.components.diagrams.tools.Palette; import org.eclipse.sirius.components.diagrams.tools.SingleClickOnDiagramElementTool; @@ -46,7 +45,6 @@ import org.eclipse.sirius.components.representations.IStatus; import org.eclipse.sirius.components.representations.Success; import org.eclipse.sirius.components.representations.VariableManager; -import org.eclipse.sirius.components.selection.description.SelectionDescription; import org.eclipse.sirius.diagram.description.AbstractNodeMapping; import org.eclipse.sirius.diagram.description.AdditionalLayer; import org.eclipse.sirius.diagram.description.ContainerMapping; @@ -230,16 +228,17 @@ private SingleClickOnDiagramElementTool convertNodeCreationDescription(Map imagePath = this.toolImageProvider.getIcon(nodeCreationTool); List targetDescriptions = this.getParentNodeDescriptions(nodeCreationTool.getNodeMappings(), id2NodeDescriptions); var selectModelElementVariableOpt = new SelectModelElementVariableProvider().getSelectModelElementVariable(nodeCreationTool.getVariable()); - Dialog dialog = selectModelElementVariableOpt - .map(selectModelElementVariable -> new Dialog(this.identifierProvider.getIdentifier(selectModelElementVariable), SelectionDescription.TYPE)) - .orElse(null); + String dialogDescriptionId = null; + if (selectModelElementVariableOpt.isPresent()) { + dialogDescriptionId = this.identifierProvider.getIdentifier(selectModelElementVariableOpt.get()); + } return SingleClickOnDiagramElementTool.newSingleClickOnDiagramElementTool(id) .label(label) .iconURL(imagePath) .handler(this.createNodeCreationHandler(interpreter, nodeCreationTool)) .targetDescriptions(targetDescriptions) .appliesToDiagramRoot(this.atLeastOneRootMapping(nodeCreationTool.getNodeMappings())) - .dialog(dialog) + .dialogDescriptionId(dialogDescriptionId) .build(); } @@ -250,16 +249,17 @@ private SingleClickOnDiagramElementTool convertContainerCreationDescription(Map< List imagePath = this.toolImageProvider.getIcon(containerCreationDescription); List targetDescriptions = this.getParentNodeDescriptions(containerCreationDescription.getContainerMappings(), id2NodeDescriptions); var selectModelElementVariableOpt = new SelectModelElementVariableProvider().getSelectModelElementVariable(containerCreationDescription.getVariable()); - Dialog dialog = selectModelElementVariableOpt - .map(selectModelElementVariable -> new Dialog(this.identifierProvider.getIdentifier(selectModelElementVariable), SelectionDescription.TYPE)) - .orElse(null); + String dialogDescriptionId = null; + if (selectModelElementVariableOpt.isPresent()) { + dialogDescriptionId = this.identifierProvider.getIdentifier(selectModelElementVariableOpt.get()); + } return SingleClickOnDiagramElementTool.newSingleClickOnDiagramElementTool(id) .label(label) .iconURL(imagePath) .handler(this.createContainerCreationHandler(interpreter, containerCreationDescription)) .targetDescriptions(targetDescriptions) .appliesToDiagramRoot(this.atLeastOneRootMapping(containerCreationDescription.getContainerMappings())) - .dialog(dialog) + .dialogDescriptionId(dialogDescriptionId) .build(); } diff --git a/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/java/org/eclipse/sirius/components/collaborative/diagrams/dto/SingleClickOnDiagramElementTool.java b/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/java/org/eclipse/sirius/components/collaborative/diagrams/dto/SingleClickOnDiagramElementTool.java index bd89fec6c65..790ebcb032e 100644 --- a/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/java/org/eclipse/sirius/components/collaborative/diagrams/dto/SingleClickOnDiagramElementTool.java +++ b/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/java/org/eclipse/sirius/components/collaborative/diagrams/dto/SingleClickOnDiagramElementTool.java @@ -16,14 +16,13 @@ import java.util.Objects; import org.eclipse.sirius.components.diagrams.description.IDiagramElementDescription; -import org.eclipse.sirius.components.diagrams.tools.Dialog; /** * A tool triggered by a single click in the palette on a diagram element. * * @author mcharfadi */ -public record SingleClickOnDiagramElementTool(String id, String label, List iconURL, List targetDescriptions, Dialog dialog, +public record SingleClickOnDiagramElementTool(String id, String label, List iconURL, List targetDescriptions, String dialogDescriptionId, boolean appliesToDiagramRoot) implements ITool { public SingleClickOnDiagramElementTool { @@ -54,7 +53,7 @@ public static final class Builder { private List targetDescriptions; - private Dialog dialog; + private String dialogDescriptionId; private boolean appliesToDiagramRoot; @@ -82,13 +81,13 @@ public Builder appliesToDiagramRoot(boolean appliesToDiagramRoot) { return this; } - public Builder dialog(Dialog dialog) { - this.dialog = dialog; + public Builder dialogDescriptionId(String dialogDescriptionId) { + this.dialogDescriptionId = dialogDescriptionId; return this; } public SingleClickOnDiagramElementTool build() { - return new SingleClickOnDiagramElementTool(this.id, this.label, this.iconURL, this.targetDescriptions, this.dialog, this.appliesToDiagramRoot); + return new SingleClickOnDiagramElementTool(this.id, this.label, this.iconURL, this.targetDescriptions, this.dialogDescriptionId, this.appliesToDiagramRoot); } } diff --git a/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/java/org/eclipse/sirius/components/collaborative/diagrams/handlers/InvokeSingleClickOnDiagramElementToolEventHandler.java b/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/java/org/eclipse/sirius/components/collaborative/diagrams/handlers/InvokeSingleClickOnDiagramElementToolEventHandler.java index a21feb1e4c9..f6662850e55 100644 --- a/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/java/org/eclipse/sirius/components/collaborative/diagrams/handlers/InvokeSingleClickOnDiagramElementToolEventHandler.java +++ b/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/java/org/eclipse/sirius/components/collaborative/diagrams/handlers/InvokeSingleClickOnDiagramElementToolEventHandler.java @@ -144,13 +144,13 @@ private IStatus executeTool(IEditingContext editingContext, IDiagramContext diag if (self.isPresent()) { VariableManager variableManager = this.populateVariableManager(editingContext, diagramContext, node, edge, self); - var dialog = tool.getDialog(); - if (dialog != null && !variables.isEmpty()) { + var dialogDescriptionId = tool.getDialogDescriptionId(); + if (dialogDescriptionId != null && !variables.isEmpty()) { this.handleDialogVariables(editingContext, variableManager, variables); } //We do not apply the tool if a dialog is defined but no variables have been provided - if (dialog == null || !variables.isEmpty()) { + if (dialogDescriptionId == null || !variables.isEmpty()) { result = tool.getHandler().apply(variableManager); Position newPosition = Position.at(startingPositionX, startingPositionY); diagramContext.getDiagramEvents().add(new SinglePositionEvent(diagramElementId, newPosition)); diff --git a/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/resources/schema/diagram.graphqls b/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/resources/schema/diagram.graphqls index 6ecbf90c952..126732caff1 100644 --- a/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/resources/schema/diagram.graphqls +++ b/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/resources/schema/diagram.graphqls @@ -291,15 +291,10 @@ type SingleClickOnDiagramElementTool implements Tool { label: String! iconURL: [String!]! appliesToDiagramRoot: Boolean! - dialog: Dialog + dialogDescriptionId: String targetDescriptions: [DiagramElementDescription!]! } -type Dialog { - dialogDescriptionId: String! - dialogDescriptionType: String! -} - type SingleClickOnTwoDiagramElementsTool implements Tool { id: ID! label: String! @@ -371,12 +366,8 @@ extend type Mutation { arrangeAll(input: ArrangeAllInput!): ArrangeAllPayload! deleteFromDiagram(input: DeleteFromDiagramInput!): DeleteFromDiagramPayload! editLabel(input: EditLabelInput!): EditLabelPayload! - invokeSingleClickOnDiagramElementTool( - input: InvokeSingleClickOnDiagramElementToolInput! - ): InvokeSingleClickOnDiagramElementToolPayload! - invokeSingleClickOnTwoDiagramElementsTool( - input: InvokeSingleClickOnTwoDiagramElementsToolInput! - ): InvokeSingleClickOnTwoDiagramElementsToolPayload! + invokeSingleClickOnDiagramElementTool(input: InvokeSingleClickOnDiagramElementToolInput!): InvokeSingleClickOnDiagramElementToolPayload! + invokeSingleClickOnTwoDiagramElementsTool(input: InvokeSingleClickOnTwoDiagramElementsToolInput!): InvokeSingleClickOnTwoDiagramElementsToolPayload! updateNodeBounds(input: UpdateNodeBoundsInput!): UpdateNodeBoundsPayload! updateNodePosition(input: UpdateNodePositionInput!): UpdateNodePositionPayload! dropOnDiagram(input: DropOnDiagramInput!): DropOnDiagramPayload! @@ -460,7 +451,7 @@ input InvokeSingleClickOnTwoDiagramElementsToolInput { } union InvokeSingleClickOnTwoDiagramElementsToolPayload = - ErrorPayload + ErrorPayload | InvokeSingleClickOnTwoDiagramElementsToolSuccessPayload type InvokeSingleClickOnTwoDiagramElementsToolSuccessPayload { @@ -492,7 +483,9 @@ enum ToolVariableType { OBJECT_ID_ARRAY } -union InvokeSingleClickOnDiagramElementToolPayload = ErrorPayload | InvokeSingleClickOnDiagramElementToolSuccessPayload +union InvokeSingleClickOnDiagramElementToolPayload = + ErrorPayload + | InvokeSingleClickOnDiagramElementToolSuccessPayload type InvokeSingleClickOnDiagramElementToolSuccessPayload { id: ID! @@ -527,7 +520,9 @@ input UpdateNodePositionInput { newPositionY: Float! } -union UpdateNodePositionPayload = ErrorPayload | UpdateNodePositionSuccessPayload +union UpdateNodePositionPayload = + ErrorPayload + | UpdateNodePositionSuccessPayload type UpdateNodePositionSuccessPayload { id: ID! diff --git a/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/test/java/org/eclipse/sirius/components/collaborative/diagrams/handlers/InvokeSingleClickOnDiagramElementToolEventHandlerTests.java b/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/test/java/org/eclipse/sirius/components/collaborative/diagrams/handlers/InvokeSingleClickOnDiagramElementToolEventHandlerTests.java index 6867f88addf..69587cc2fa3 100644 --- a/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/test/java/org/eclipse/sirius/components/collaborative/diagrams/handlers/InvokeSingleClickOnDiagramElementToolEventHandlerTests.java +++ b/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/test/java/org/eclipse/sirius/components/collaborative/diagrams/handlers/InvokeSingleClickOnDiagramElementToolEventHandlerTests.java @@ -61,7 +61,6 @@ import org.eclipse.sirius.components.diagrams.description.InsideLabelDescription; import org.eclipse.sirius.components.diagrams.description.LabelStyleDescription; import org.eclipse.sirius.components.diagrams.description.NodeDescription; -import org.eclipse.sirius.components.diagrams.tools.Dialog; import org.eclipse.sirius.components.diagrams.tools.ITool; import org.eclipse.sirius.components.diagrams.tools.SingleClickOnDiagramElementTool; import org.eclipse.sirius.components.representations.IStatus; @@ -81,8 +80,6 @@ */ public class InvokeSingleClickOnDiagramElementToolEventHandlerTests { - private static final String SELECTION_DIALOG_TYPE = "SELECTION_DIALOG_TYPE"; - private static final String NAME_VARIABLE_VALUE = "nameVariableValue"; private static final String NAME_VARIABLE = "name"; @@ -244,7 +241,7 @@ public Optional findNodeById(Diagram diagram, String nodeId) { return new Success(ChangeKind.SEMANTIC_CHANGE, Map.of()); }; - var tool = this.createTool(TOOL_ID, false, List.of(nodeDescription), new Dialog(DIALOG_DESCRIPTION_ID, SELECTION_DIALOG_TYPE), toolHandler); + var tool = this.createTool(TOOL_ID, false, List.of(nodeDescription), DIALOG_DESCRIPTION_ID, toolHandler); var toolService = new IToolService.NoOp() { @Override @@ -444,13 +441,12 @@ private SingleClickOnDiagramElementTool createTool(String toolId, boolean applie return this.createTool(toolId, appliesToDiagramRoot, diagramElementsDescriptions, null, variableManager -> new Success(ChangeKind.SEMANTIC_CHANGE, Map.of())); } - private SingleClickOnDiagramElementTool createTool(String toolId, boolean appliesToDiagramRoot, List diagramElementsDescriptions, Dialog dialog, - Function handler) { + private SingleClickOnDiagramElementTool createTool(String toolId, boolean appliesToDiagramRoot, List diagramElementsDescriptions, String dialogDescriptionId, Function handler) { return SingleClickOnDiagramElementTool.newSingleClickOnDiagramElementTool(toolId) .label(TOOL_LABEL) .iconURL(List.of(TOOL_IMAGE_URL)) .targetDescriptions(diagramElementsDescriptions) - .dialog(dialog) + .dialogDescriptionId(dialogDescriptionId) .handler(handler) .appliesToDiagramRoot(appliesToDiagramRoot) .build(); diff --git a/packages/diagrams/backend/sirius-components-diagrams-tests/src/main/java/org/eclipse/sirius/components/diagrams/tests/graphql/PaletteQueryRunner.java b/packages/diagrams/backend/sirius-components-diagrams-tests/src/main/java/org/eclipse/sirius/components/diagrams/tests/graphql/PaletteQueryRunner.java index 93f9a086ad9..798a8b58693 100644 --- a/packages/diagrams/backend/sirius-components-diagrams-tests/src/main/java/org/eclipse/sirius/components/diagrams/tests/graphql/PaletteQueryRunner.java +++ b/packages/diagrams/backend/sirius-components-diagrams-tests/src/main/java/org/eclipse/sirius/components/diagrams/tests/graphql/PaletteQueryRunner.java @@ -65,9 +65,7 @@ query getPalette($editingContextId: ID!, $representationId: ID!, $diagramElement id } appliesToDiagramRoot - dialog { - dialogDescriptionId - } + dialogDescriptionId } } """; diff --git a/packages/diagrams/backend/sirius-components-diagrams/src/main/java/org/eclipse/sirius/components/diagrams/tools/Dialog.java b/packages/diagrams/backend/sirius-components-diagrams/src/main/java/org/eclipse/sirius/components/diagrams/tools/Dialog.java deleted file mode 100644 index 61ff5bdfea7..00000000000 --- a/packages/diagrams/backend/sirius-components-diagrams/src/main/java/org/eclipse/sirius/components/diagrams/tools/Dialog.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2024 Obeo. - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Obeo - initial API and implementation - *******************************************************************************/ -package org.eclipse.sirius.components.diagrams.tools; - -import java.util.Objects; - -/** - * Represents the Dialog type of the SingleClickOnDiagramElementTool#dialog attribute. - * - * @author fbarbin - */ -public record Dialog(String dialogDescriptionId, String dialogDescriptionType) { - - public Dialog { - Objects.requireNonNull(dialogDescriptionId); - Objects.requireNonNull(dialogDescriptionType); - } -} diff --git a/packages/diagrams/backend/sirius-components-diagrams/src/main/java/org/eclipse/sirius/components/diagrams/tools/SingleClickOnDiagramElementTool.java b/packages/diagrams/backend/sirius-components-diagrams/src/main/java/org/eclipse/sirius/components/diagrams/tools/SingleClickOnDiagramElementTool.java index 799ef18145d..570b757d87d 100644 --- a/packages/diagrams/backend/sirius-components-diagrams/src/main/java/org/eclipse/sirius/components/diagrams/tools/SingleClickOnDiagramElementTool.java +++ b/packages/diagrams/backend/sirius-components-diagrams/src/main/java/org/eclipse/sirius/components/diagrams/tools/SingleClickOnDiagramElementTool.java @@ -45,7 +45,7 @@ public final class SingleClickOnDiagramElementTool implements ITool { private boolean appliesToDiagramRoot; - private Dialog dialog; + private String dialogDescriptionId; private SingleClickOnDiagramElementTool() { // Prevent instantiation @@ -78,8 +78,8 @@ public String getLabel() { return this.label; } - public Dialog getDialog() { - return this.dialog; + public String getDialogDescriptionId() { + return this.dialogDescriptionId; } @Override @@ -113,7 +113,7 @@ public static final class Builder { private boolean appliesToDiagramRoot; - private Dialog dialog; + private String dialogDescriptionId; private Builder(String id) { this.id = Objects.requireNonNull(id); @@ -144,8 +144,8 @@ public Builder handler(Function handler) { return this; } - public Builder dialog(Dialog dialog) { - this.dialog = dialog; + public Builder dialogDescriptionId(String dialogDescriptionId) { + this.dialogDescriptionId = dialogDescriptionId; return this; } @@ -157,7 +157,7 @@ public SingleClickOnDiagramElementTool build() { tool.handler = Objects.requireNonNull(this.handler); tool.targetDescriptions = Objects.requireNonNull(this.targetDescriptions); tool.appliesToDiagramRoot = this.appliesToDiagramRoot; - tool.dialog = this.dialog; + tool.dialogDescriptionId = this.dialogDescriptionId; return tool; } } diff --git a/packages/diagrams/frontend/sirius-components-diagrams/src/dialog/DialogContext.tsx b/packages/diagrams/frontend/sirius-components-diagrams/src/dialog/DialogContext.tsx index 8ca58415748..502eb33e7fd 100644 --- a/packages/diagrams/frontend/sirius-components-diagrams/src/dialog/DialogContext.tsx +++ b/packages/diagrams/frontend/sirius-components-diagrams/src/dialog/DialogContext.tsx @@ -16,10 +16,11 @@ import React, { useState } from 'react'; import { GQLToolVariable } from '../renderer/palette/Palette.types'; import { DialogContextProviderState, DialogContextValue } from './DialogContext.types'; import { diagramDialogContributionExtensionPoint } from './diagramDialogExtensionPoint'; -import { DiagramDialogContribution, DialogComponentProps } from './diagramDialogExtensionPoint.types'; +import { DiagramDialogComponentProps, DiagramDialogContribution } from './diagramDialogExtensionPoint.types'; const defaultValue: DialogContextValue = { showDialog: () => {}, + currentEditingContextId: '', }; export const DialogContext = React.createContext(defaultValue); @@ -27,22 +28,18 @@ export const DialogContext = React.createContext(defaultValu export const DialogContextProvider = ({ children }) => { const [state, setState] = useState({ dialogDescriptionId: undefined, - dialogTypeId: undefined, editingContextId: undefined, - targetObjectId: undefined, onConfirm: () => {}, open: false, }); const { data: dialogContributions } = useData(diagramDialogContributionExtensionPoint); const showDialog = ( - dialogTypeId: string, editingContextId: string, dialogDescriptionId, - targetObjectId, onConfirm: (variables: GQLToolVariable[]) => void ) => { - setState({ open: true, dialogTypeId, editingContextId, dialogDescriptionId, targetObjectId, onConfirm }); + setState({ open: true, editingContextId, dialogDescriptionId, onConfirm }); }; const onFinish = (toolVariables: GQLToolVariable[]) => { @@ -54,25 +51,23 @@ export const DialogContextProvider = ({ children }) => { setState((prevState) => ({ ...prevState, open: false, dialogTypeId: undefined })); }; - let DialogComponent: React.ComponentType | undefined; - const dialogComponentProps: DialogComponentProps = { + let DialogComponent: React.ComponentType | undefined; + const dialogComponentProps: DiagramDialogComponentProps = { dialogDescriptionId: state.dialogDescriptionId ?? '', - editingContextId: state.editingContextId ?? '', - targetObjectId: state.targetObjectId ?? '', onFinish, onClose, }; - if (state.open && state.dialogTypeId) { - const dialogTypeId: string = state.dialogTypeId; + if (state.open && state.dialogDescriptionId) { + const dialogDescriptionId: string = state.dialogDescriptionId; const dialogContribution: DiagramDialogContribution | undefined = dialogContributions.find((dialogContribution) => - dialogContribution.canHandle(dialogTypeId) + dialogContribution.canHandle(dialogDescriptionId) ); if (dialogContribution) { DialogComponent = dialogContribution.component; } } return ( - + {children} {state.open && DialogComponent && } diff --git a/packages/diagrams/frontend/sirius-components-diagrams/src/dialog/DialogContext.types.ts b/packages/diagrams/frontend/sirius-components-diagrams/src/dialog/DialogContext.types.ts index ffb32fc46de..fee6d3a1366 100644 --- a/packages/diagrams/frontend/sirius-components-diagrams/src/dialog/DialogContext.types.ts +++ b/packages/diagrams/frontend/sirius-components-diagrams/src/dialog/DialogContext.types.ts @@ -14,20 +14,17 @@ import { GQLToolVariable } from '../renderer/palette/Palette.types'; export interface DialogContextValue { + currentEditingContextId: string | undefined; showDialog: ( - dialogTypeId: string, editingContextId: string, dialogDescriptionId: string, - targetObjectId: string, onConfirm: (variables: GQLToolVariable[]) => void ) => void; } export interface DialogContextProviderState { open: boolean; - dialogTypeId: string | undefined; editingContextId: string | undefined; dialogDescriptionId: string | undefined; - targetObjectId: string | undefined; onConfirm: (variables: GQLToolVariable[]) => void; } diff --git a/packages/diagrams/frontend/sirius-components-diagrams/src/dialog/diagramDialogExtensionPoint.types.ts b/packages/diagrams/frontend/sirius-components-diagrams/src/dialog/diagramDialogExtensionPoint.types.ts index ba01bc7f420..c71b2024b90 100644 --- a/packages/diagrams/frontend/sirius-components-diagrams/src/dialog/diagramDialogExtensionPoint.types.ts +++ b/packages/diagrams/frontend/sirius-components-diagrams/src/dialog/diagramDialogExtensionPoint.types.ts @@ -13,14 +13,12 @@ import { GQLToolVariable } from '../renderer/palette/Palette.types'; export interface DiagramDialogContribution { - canHandle: (dialogTypeId: string) => boolean; - component: React.ComponentType; + canHandle: (dialogDescriptionId: string) => boolean; + component: React.ComponentType; } -export interface DialogComponentProps { - editingContextId: string; +export interface DiagramDialogComponentProps { dialogDescriptionId: string; - targetObjectId: string; onClose: () => void; onFinish: (variables: GQLToolVariable[]) => void; } diff --git a/packages/diagrams/frontend/sirius-components-diagrams/src/dialog/useDialog.tsx b/packages/diagrams/frontend/sirius-components-diagrams/src/dialog/useDialog.tsx index 1d422c4bd6b..4ccf4dcfa7b 100644 --- a/packages/diagrams/frontend/sirius-components-diagrams/src/dialog/useDialog.tsx +++ b/packages/diagrams/frontend/sirius-components-diagrams/src/dialog/useDialog.tsx @@ -16,7 +16,7 @@ import { DialogContext } from './DialogContext'; import { UseDialogValue } from './useDialog.types'; export const useDialog = (): UseDialogValue => { - const { showDialog } = useContext(DialogContext); + const { showDialog, currentEditingContextId } = useContext(DialogContext); - return { showDialog }; + return { showDialog, currentEditingContextId }; }; diff --git a/packages/diagrams/frontend/sirius-components-diagrams/src/dialog/useDialog.types.ts b/packages/diagrams/frontend/sirius-components-diagrams/src/dialog/useDialog.types.ts index 59f94ade6a4..e311f7f8965 100644 --- a/packages/diagrams/frontend/sirius-components-diagrams/src/dialog/useDialog.types.ts +++ b/packages/diagrams/frontend/sirius-components-diagrams/src/dialog/useDialog.types.ts @@ -12,11 +12,10 @@ *******************************************************************************/ import { GQLToolVariable } from '../renderer/palette/Palette.types'; export interface UseDialogValue { + currentEditingContextId: string | undefined; showDialog: ( - dialogTypeId: string, editingContextID: string, dialogDescriptionId: string, - targetObjectId: string, onConfirm: (variables: GQLToolVariable[]) => void ) => void; } diff --git a/packages/diagrams/frontend/sirius-components-diagrams/src/index.ts b/packages/diagrams/frontend/sirius-components-diagrams/src/index.ts index 592c62a9031..139c1cf18bc 100644 --- a/packages/diagrams/frontend/sirius-components-diagrams/src/index.ts +++ b/packages/diagrams/frontend/sirius-components-diagrams/src/index.ts @@ -21,7 +21,12 @@ export { AlignmentMap } from './converter/convertDiagram.types'; export { convertHandles } from './converter/convertHandles'; export { convertInsideLabel, convertLabelStyle, convertOutsideLabels } from './converter/convertLabel'; export { diagramDialogContributionExtensionPoint } from './dialog/diagramDialogExtensionPoint'; -export type { DiagramDialogContribution, DialogComponentProps } from './dialog/diagramDialogExtensionPoint.types'; +export type { + DiagramDialogComponentProps, + DiagramDialogContribution, +} from './dialog/diagramDialogExtensionPoint.types'; +export { useDialog } from './dialog/useDialog'; +export type { UseDialogValue } from './dialog/useDialog.types'; export type { GQLNodeDescription } from './graphql/query/nodeDescriptionFragment.types'; export type { GQLDiagram, GQLNodeLayoutData } from './graphql/subscription/diagramFragment.types'; export type { GQLEdge } from './graphql/subscription/edgeFragment.types'; @@ -55,8 +60,7 @@ export type { DiagramPaletteToolContextValue } from './renderer/palette/DiagramP export { DiagramPaletteToolContext } from './renderer/palette/DiagramPaletteToolContext'; export { DiagramPaletteToolContribution } from './renderer/palette/DiagramPaletteToolContribution'; export type { DiagramPaletteToolContributionComponentProps } from './renderer/palette/DiagramPaletteToolContribution.types'; -export { GQLToolVariableType } from './renderer/palette/Palette.types'; -export type { GQLToolVariable } from './renderer/palette/Palette.types'; +export type { GQLToolVariable, GQLToolVariableType } from './renderer/palette/Palette.types'; export type { DiagramPanelActionProps } from './renderer/panel/DiagramPanel.types'; export { diagramPanelActionExtensionPoint } from './renderer/panel/DiagramPanelExtensionPoints'; export { DiagramRepresentation } from './representation/DiagramRepresentation'; diff --git a/packages/diagrams/frontend/sirius-components-diagrams/src/renderer/DiagramRenderer.tsx b/packages/diagrams/frontend/sirius-components-diagrams/src/renderer/DiagramRenderer.tsx index a73464928ee..d0bbe4c2ef6 100644 --- a/packages/diagrams/frontend/sirius-components-diagrams/src/renderer/DiagramRenderer.tsx +++ b/packages/diagrams/frontend/sirius-components-diagrams/src/renderer/DiagramRenderer.tsx @@ -361,10 +361,7 @@ export const DiagramRenderer = memo(({ diagramRefreshedEventPayload }: DiagramRe refElementId={groupPaletteRefElementId} hidePalette={hideGroupPalette} /> - + {diagramDescription.debug ? : null} {helperLinesEnabled ? : null} diff --git a/packages/diagrams/frontend/sirius-components-diagrams/src/renderer/edge/MultiLabelEdge.tsx b/packages/diagrams/frontend/sirius-components-diagrams/src/renderer/edge/MultiLabelEdge.tsx index d87bb94d635..5b87e67d93b 100644 --- a/packages/diagrams/frontend/sirius-components-diagrams/src/renderer/edge/MultiLabelEdge.tsx +++ b/packages/diagrams/frontend/sirius-components-diagrams/src/renderer/edge/MultiLabelEdge.tsx @@ -79,7 +79,7 @@ export const MultiLabelEdge = memo( sourceHandleId, targetHandleId, }: EdgeProps) => { - const { beginLabel, endLabel, label, faded, targetObjectId } = data || {}; + const { beginLabel, endLabel, label, faded } = data || {}; const theme = useTheme(); const { nodeLayoutHandlers } = useContext(NodeTypeContext); @@ -169,13 +169,7 @@ export const MultiLabelEdge = memo( markerEnd={selected ? `${markerEnd?.slice(0, markerEnd.length - 1)}--selected)` : markerEnd} markerStart={selected ? `${markerStart?.slice(0, markerStart.length - 1)}--selected)` : markerStart} /> - {selected ? ( - - ) : null} + {selected ? : null} {beginLabel && (
diff --git a/packages/diagrams/frontend/sirius-components-diagrams/src/renderer/node/FreeFormNode.tsx b/packages/diagrams/frontend/sirius-components-diagrams/src/renderer/node/FreeFormNode.tsx index e72a7b6f641..d30aa69d98b 100644 --- a/packages/diagrams/frontend/sirius-components-diagrams/src/renderer/node/FreeFormNode.tsx +++ b/packages/diagrams/frontend/sirius-components-diagrams/src/renderer/node/FreeFormNode.tsx @@ -145,13 +145,7 @@ export const FreeFormNode = memo(({ data, id, selected, dragging }: NodeProps
{data.insideLabel &&
); diff --git a/packages/diagrams/frontend/sirius-components-diagrams/src/renderer/node/ListNode.tsx b/packages/diagrams/frontend/sirius-components-diagrams/src/renderer/node/ListNode.tsx index c39c4a804ec..7cf7be71830 100644 --- a/packages/diagrams/frontend/sirius-components-diagrams/src/renderer/node/ListNode.tsx +++ b/packages/diagrams/frontend/sirius-components-diagrams/src/renderer/node/ListNode.tsx @@ -81,11 +81,7 @@ export const ListNode = memo(({ data, id, selected, dragging }: NodeProps {data.insideLabel ?