-
Notifications
You must be signed in to change notification settings - Fork 58
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
[doc] Add an ADR on support actions in table row context menu #4394
Merged
sbegaudeau
merged 1 commit into
eclipse-sirius:master
from
jerome-obeo:jgo/doc/add_adr_for_adding_support_of_actions_in_table_rows
Jan 8, 2025
+101
−0
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
doc/adrs/178_add_support_of_actions_in_table_row_menu.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
= ADR-178 Add support of actions in table row menu | ||
|
||
== Context | ||
|
||
Currently, there are no actions at the row level in table representations. | ||
|
||
== Decision | ||
|
||
We need to introduce a general way to handle actions at the table row level. | ||
MUI React Table provides a convenient way to add menu items on each row inside a dedicated column which could be naturally used in the front end part. | ||
As a developer or specifier, we want to be able to specify a list of actions that could be applied on an row description. | ||
|
||
=== View DSL | ||
|
||
The specifier could add `RowContextMenuEntry` elements under a `RowDescription` element. | ||
`RowContextMenuEntry` has the following properties: | ||
|
||
* Label Expression | ||
* Icon URL Expression | ||
* Precondition Expression | ||
* Body Operation | ||
|
||
=== Table API | ||
|
||
At the API level, we need to introduce a new provider interface `IRowContextMenuEntryProvider` that could be implemented to provide a list of actions at a row level (`RowContextMenuEntry`). | ||
|
||
```java | ||
public interface IRowContextMenuEntryProvider { | ||
|
||
boolean canHandle(IEditingContext editingContext, TableDescription tableDescription, Table table, Line row); | ||
|
||
List<RowContextMenuEntry> getRowContextMenuEntries(IEditingContext editingContext, TableDescription tableDescription, Table table, Line row); | ||
} | ||
``` | ||
|
||
The `RowContextMenuEntry` class is as simple as: | ||
|
||
```java | ||
public record RowContextMenuEntry(String id, String label, List<String> iconURL) { } | ||
``` | ||
|
||
=== GraphQL | ||
|
||
In order to display the content of the context menu in the front end, we need to introduce a GraphQL field to retrieve all context menu entries associated to a given row. | ||
It will behaves the same way as `DiagramDescription#palette`. | ||
|
||
```graphQL | ||
type TableDescription implements RepresentationDescription { | ||
... | ||
contextMenu(rowId: ID!): [RowContextMenuEntry!]! | ||
... | ||
} | ||
|
||
type RowContextMenuEntry { | ||
id: ID! | ||
label: String! | ||
iconURL: [String!]! | ||
} | ||
``` | ||
|
||
In order to execute a specific action entry, we need to introduce a GraphQL mutation to perform the action itself by the backend. | ||
|
||
```graphQL | ||
extend type Mutation { | ||
... | ||
invokeRowContextMenuEntry(input: InvokeRowContextMenuEntryInput!): InvokeRowContextMenuEntryPayload! | ||
... | ||
} | ||
|
||
input InvokeRowContextMenuEntryInput { | ||
id: ID! | ||
editingContextId: ID! | ||
representationId: ID! | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You will also need the tableId here given how tables are working |
||
tableId: ID! | ||
rowId: ID! | ||
menuEntryId: ID! | ||
} | ||
``` | ||
|
||
=== Back end | ||
|
||
As far as the context menu entries retrieval is concerned, the handler has an injected list of implementations of `IRowContextMenuEntryProvider`. | ||
A developer could create directly an implementation of `IRowContextMenuEntryProvider` to use in a row of his/her table. | ||
To manage the view DSL menu entries descriptions, we need to provide an implementation to expose the entries described at the View model level to the DTO element. | ||
|
||
For context menu entry execution, we need to introduce a new interface to allow gathering the execution handler `IRowContextMenuEntryExecutor`. | ||
The mutation handler has to select the right executor among the injected list using its `canExecute` method. | ||
Therefore, the `execute` method can be called. | ||
As for the context menu entries collect, we need to provide an implementation of this interface to manage the view DSL cases. | ||
|
||
=== Front end | ||
|
||
The front end code relies on the GraphQL query `contextMenu` to populate the menu of each table row. | ||
We cannot afford to request all context menu entries for all rows when the component renders, instead, we need to request only the content of the context menu when it is open. | ||
|
||
Once an action is triggered, the mutation `invokeRowContextMenuEntry` should be called. | ||
|
||
== Status | ||
|
||
Work in progress |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 context menu would have a similar behavior as a diagram palette, it should be retrieved using TableDescription#contextMenu. We are always placing those kind of information on the representation description.
See the GraphQL schema of DiagramDescription#palette for example.