-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[2759] Reactivate the SelectionDialog #3658
Conversation
4c139c8
to
578411d
Compare
packages/view/backend/sirius-components-view-diagram-edit/src/main/resources/plugin.properties
Outdated
Show resolved
Hide resolved
packages/diagrams/frontend/sirius-components-diagrams/src/renderer/palette/Palette.tsx
Outdated
Show resolved
Hide resolved
a66d309
to
58c29f7
Compare
0ddba48
to
f048137
Compare
b75142f
to
a20983f
Compare
packages/diagrams/frontend/sirius-components-diagrams/src/dialog/DialogContext.tsx
Outdated
Show resolved
Hide resolved
...rc/main/java/org/eclipse/sirius/components/compatibility/services/diagrams/ToolProvider.java
Outdated
Show resolved
Hide resolved
@@ -174,7 +176,7 @@ export const SelectionDialog = ({ | |||
color="primary" | |||
onClick={() => { | |||
if (selectedObjectId) { | |||
onFinish(selectedObjectId); | |||
onFinish([{ name: 'selectedObject', value: selectedObjectId, type: GQLToolVariableType.objectId }]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems you create a new GQLToolVariable
with the selectedObjectId
as value, but you name it selectedObject
. Why you don't name it selectedObjectId
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "specifier" will manipulate the object (the variable value will be the object and not its id)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the "operation" that will transform an objectId to an object is done on the backend right?
So why you have to create a variable here, in the frontend?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea is that the backend part does not make any assumptions on the variables provided by the frontend component. For now, we have identified 3 kinds of values which can be provided by a Dialog: An Object: in that case we use the Id. An array of objects or a simple string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get that, but it still seems strange.
Here you set the variable type to GQLToolVariableType.objectId
which indicates that the variable will contain an objectId, but you set the variable name to selectedObject
which indicates that the variable will contain an Object
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type represents a technical information to describe which kind of value is set.
We can change the variable type by object instead of objectId, in that case, it will represent the value type once converted by the backend side.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you set the variable type to GQLToolVariableType.objectId which indicates that the variable will contain an objectId, but you set the variable name to selectedObject which indicates that the variable will contain an Object
No that's not how we should think about this. As the contributor of a dialog, I want my dialog to be used to create a variable named selectedObject
. To populate this variable, I'll give the backend some string as the value and it should be interpreted as the identifier of an object to resolve.
cf524ec
to
f830573
Compare
29bc1b4
to
93b4a08
Compare
58c29f7
to
f98960d
Compare
CHANGELOG.adoc
Outdated
} | ||
``` | ||
|
||
* 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why isn't that a XXXDescription? Could you please use something like ToolDialogDescription
or DiagramToolDialogDescription
in order not to use such a common name which may be used elsewhere in the future.
Why the need for a whole concept instead of of the identifier?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It idea was to own both the id and the information about the dialog type. We need to change the id to own the information about the dialog type if we want to keep only a dialogDescriptionId field?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still don't know why we would need both this two pieces of information. Why isn't an identifier enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am modifying the way we generate this identifier to have something similar to the other representation: siriusComponents://dialogDescription?kind=selectionDialogDescription etc"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
invokeSingleClickOnDiagramElementTool( | ||
input: InvokeSingleClickOnDiagramElementToolInput! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to change the formatting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
invokeSingleClickOnDiagramElementTool( | ||
input: InvokeSingleClickOnDiagramElementToolInput! | ||
): InvokeSingleClickOnDiagramElementToolPayload! | ||
invokeSingleClickOnTwoDiagramElementsTool( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to change the formatting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
dialogDescriptionId: String! | ||
dialogDescriptionType: String! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- This should be a XxxDescription or be removed entirely since I'm not sure why it needs to be a dedicated type?
- You could use
id
andtype
- I'm not sure why this concept isn't an interface and why you need more than
id
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The id currently contains only an UUID that does not allow to identify the dialog type.
If we want to keep only an id, we need to modify the way we generate this id to own the dialog type information?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok so that's the limitation that I was missing. We should indeed change the way this identifier is computed. I don't even know how a simple UUID can be enough to open a dialog. For other description elements, the identifier has way more information. For example, the identifier of a node description is siriusComponents://nodeDescription?sourceKind=view&sourceId=c5857f07-7382-3215-8c53-b690ca983655&sourceElementId=fe82e80e-7308-35a9-986d-f010401063ee
.
So, for a selection dialog, having an identifier like this would be necessary:
siriusComponents://selectionDialogDescription?sourceKind=view&sourceId=XXX&sourceElementId=XXXX
I don't know how we could retrieve the proper Dialog object otherwise since we don't know the id of its view model.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
* | ||
* @author fbarbin | ||
*/ | ||
public record Dialog(String dialogDescriptionId, String dialogDescriptionType) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will have to be renamed not to use such a common concept name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
export interface DialogComponentProps { | ||
editingContextId: string; | ||
dialogDescriptionId: string; | ||
targetObjectId: string; | ||
onClose: () => void; | ||
onFinish: (variables: GQLToolVariable[]) => void; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure that the editingContextId
is not needed and the targetObjectId
too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, replaced by the useDialog hook to retrieve the editingContext from the DialogContext
|
||
import { GQLToolVariable } from '../renderer/palette/Palette.types'; | ||
export interface DiagramDialogContribution { | ||
canHandle: (dialogTypeId: string) => boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use the descriptionId? Why have two pieces of information?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The descriptionId is just an UUID
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed and replaced by the descriptionId that now contains the type information.
targetObjectId, | ||
onClose, | ||
onFinish, | ||
}: SelectionDialogProps) => { | ||
}: DialogComponentProps) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DialogComponentProps is too generic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
type: GQLToolVariableType; | ||
} | ||
|
||
export enum GQLToolVariableType { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not use enum in TypeScript, it creates a weird result, use an union instead:
`export type GQLToolVariableType = 'STRING' | 'OBJECT_ID' | 'OBJECT_ID_ARRAY';
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
@@ -174,7 +176,7 @@ export const SelectionDialog = ({ | |||
color="primary" | |||
onClick={() => { | |||
if (selectedObjectId) { | |||
onFinish(selectedObjectId); | |||
onFinish([{ name: 'selectedObject', value: selectedObjectId, type: GQLToolVariableType.objectId }]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you set the variable type to GQLToolVariableType.objectId which indicates that the variable will contain an objectId, but you set the variable name to selectedObject which indicates that the variable will contain an Object
No that's not how we should think about this. As the contributor of a dialog, I want my dialog to be used to create a variable named selectedObject
. To populate this variable, I'll give the backend some string as the value and it should be interpreted as the identifier of an object to resolve.
93b4a08
to
1edcd95
Compare
f98960d
to
ebbdf3e
Compare
3f6485e
to
f9ec7fb
Compare
98497f7
to
de754a8
Compare
f9ec7fb
to
c022bec
Compare
Please squash the commits before the merge |
46095ef
to
e444ba2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll have to review some details while running the code and I'll fix the last small issue remaining to merge it
...main/java/org/eclipse/sirius/components/collaborative/selection/SelectionEventProcessor.java
Outdated
Show resolved
Hide resolved
@@ -32,6 +32,7 @@ | |||
"peerDependencies": { | |||
"@apollo/client": "3.10.4", | |||
"@eclipse-sirius/sirius-components-core": "*", | |||
"@eclipse-sirius/sirius-components-diagrams": "*", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why selection needs to depend on diagrams now...
...diagrams/frontend/sirius-components-diagrams/src/dialog/diagramDialogExtensionPoint.types.ts
Outdated
Show resolved
Hide resolved
packages/diagrams/frontend/sirius-components-diagrams/src/dialog/diagramDialogExtensionPoint.ts
Outdated
Show resolved
Hide resolved
import { GQLToolVariable } from '../renderer/palette/Palette.types'; | ||
|
||
export interface DialogContextValue { | ||
currentEditingContextId: string | undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this currentEditingContextId
and why can it be undefined
? even null
would be very odd
@@ -61,6 +62,8 @@ public class ModelOperationDiagramDescriptionProvider implements IEditingContext | |||
|
|||
private NodeTool createNodeTool; | |||
|
|||
private NodeTool renameNodeTool; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A dedicated example should be created instead of just taking one to change the scope of its behavior
packages/view/backend/sirius-components-view-diagram-edit/src/main/resources/plugin.properties
Show resolved
Hide resolved
...iew-emf/src/main/java/org/eclipse/sirius/components/view/emf/diagram/IDiagramIdProvider.java
Outdated
Show resolved
Hide resolved
...c/main/java/org/eclipse/sirius/components/view/emf/IRepresentationDescriptionIdProvider.java
Outdated
Show resolved
Hide resolved
@@ -130,4 +129,48 @@ public void givenDiagramWhenToolWithComplexModelOperationsIsExecutedThenItWorksA | |||
.thenCancel() | |||
.verify(Duration.ofSeconds(10)); | |||
} | |||
|
|||
@Test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be moved to a dedicated test suite
4670a4b
to
051527c
Compare
So now things are working as expected but I still have two elements to review and possibly modify (the dependency to sirius-components-diagrams and the tests) |
I've reduced the dependency to /cc @florianbarbin When we will work on the support for dialogs in the explorer, we will have to move DialogDescription in view.ecore (from diagram.ecore now), rename Let's not add more dependencies to |
051527c
to
06bd199
Compare
In addition, this commit introduces the generic concept of Dialog to make it possible to define any kind of dialog for diagram node tools. Bug: #2759 Signed-off-by: Florian Barbin <[email protected]>
06bd199
to
89cdf78
Compare
Some tests will have to be moved later |
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: low
andpr: to review later
)area:
,difficulty:
,type:
)CHANGELOG.adoc
been 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.png
Architectural 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 potentiallynull
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
Architecture
Review
How to test this PR?
Import the Studio
Studio.zip
This studio is based on default one but with two additional tools:
Create a new project
Create a new model based on the studio MM
Create a new diagram
Create some element by using the node creation tools
Use the selectionTool in the diagram contextual palette:
Use the selection tool on an Entity1
The selection dialog should only contain the selected element
Select it and perform finish
The element should be renamed
Has the Kiwi TCMS test suite been updated with tests for this contribution?