forked from eclipse-sirius/sirius-web
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[1146] Add an ADR on EditingContext actions
Bug: eclipse-sirius#1146 Signed-off-by: Raphaël Pagé <raphael.page@obeo.fr>
- Loading branch information
1 parent
c903ffc
commit fb2aefd
Showing
1 changed file
with
125 additions
and
0 deletions.
There are no files selected for viewing
125 changes: 125 additions & 0 deletions
125
doc/adrs/051_add_support_for_editing_context_action.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,125 @@ | ||
= ADR-051 - Add Support for EditingContext Action | ||
|
||
== Context | ||
|
||
Stereotypes descriptions are hard-coded and limited. | ||
The main thing that they can do is to copy JSON into the resource set. | ||
We want to do more things, for example defining when an action is available based on the editing context. | ||
Replacing stereotypes descriptions would also reduce the dependency to the concept of Document. | ||
|
||
== Decision | ||
|
||
In order to allow for more flexibility, Stereotypes descriptions will be transformed in EditingContext Actions. | ||
There won't be any visible changes for the end user. | ||
They should be supported by both the programmatic API and the GraphQL API. | ||
Every action will not be available all the time. Their availability will be computed and will depend on the editing context. | ||
The actions will be able to manipulate the editing context or contact a remote service. | ||
|
||
=== Backend | ||
|
||
The actions will be represented by the following POJO which will be sent back to the frontend to be displayed in the user interface : | ||
|
||
```java | ||
public class EditingContextAction { | ||
private final String id; | ||
private final String label; | ||
} | ||
``` | ||
|
||
The following interfaces will need to be implemented in order to contribute new actions : | ||
|
||
```java | ||
public interface IEditingContextActionProvider { | ||
List<IEditingContextAction> getEditingContextAction(IEditingContext editingContext); | ||
} | ||
``` | ||
|
||
```java | ||
public interface IEditingContextAction { | ||
boolean isApplicable(IEditingContext editingContext); | ||
|
||
void apply(IEditingContext editingContext); | ||
} | ||
``` | ||
|
||
An InvokeEditingContextActionEventHandler will be called by the GraphQL data fetcher in order to execute an action selected by the end user : | ||
|
||
```java | ||
public class InvokeEditingContextActionEventHandler implements IEditingContextEventHandler { | ||
|
||
private final List<IEditingContextActionHandler> editingContextActionHandlers; | ||
|
||
public boolean canHandle(IEditingContext editingContext, IInput input) { | ||
return input instanceof InvokeEditingContextActionInput; | ||
} | ||
|
||
public void handle(One<IPayload> payloadSink, Many<ChangeDescription> changeDescriptionSink, IEditingContext editingContext, IInput input) { | ||
// Use the relevant editingContextActionHandler to handle the input | ||
} | ||
} | ||
``` | ||
|
||
This event handler will be used to call the appropriate action handler which will be provided by the same person who has contributed the action : | ||
|
||
```java | ||
public interface IEditingContextActionHandler { | ||
boolean canHandle(IEditingContext editingContext, InvokeEditingContextActionInput); | ||
|
||
IPayload handle(IEditingContext editingContext, InvokeEditingContextActionInput); | ||
} | ||
``` | ||
|
||
```java | ||
public final class InvokeEditingContextActionInput implements IInput { | ||
private UUID id; | ||
private String actionId; | ||
} | ||
``` | ||
|
||
```java | ||
public class InvokeEditingContextActionSuccessPayload implements IPayload { | ||
private UUID id; | ||
} | ||
``` | ||
|
||
=== GraphQL API | ||
|
||
The GraphQL API will look like this : | ||
``` | ||
type EditingContext { | ||
actions: EditingContextEditingContextActionsConnection! | ||
} | ||
|
||
type EditingContextEditingContextActionsConnection { | ||
edges: [EditingContextEditingContextActionsEdge!]! | ||
pageInfo: PageInfo! | ||
} | ||
|
||
type EditingContextEditingContextActionsEdge { | ||
node: EditingContextAction! | ||
} | ||
|
||
type EditingContextAction { | ||
id: ID! | ||
label: String! | ||
} | ||
|
||
type Mutation { | ||
invokeEditingContextAction(input: InvokeEditingContextActionInput!): InvokeEditingContextActionPayload! | ||
} | ||
|
||
input InvokeEditingContextActionInput { | ||
id: ID! | ||
actionId: String! | ||
} | ||
|
||
union InvokeEditingContextActionPayload = ErrorPayload | InvokeEditingContextActionSuccessPayload | ||
|
||
type InvokeEditingContextActionSuccessPayload { | ||
id: ID! | ||
} | ||
``` | ||
|
||
== Status | ||
|
||
WIP |