Skip to content

Commit

Permalink
[doc] Add ADR for details view changes support
Browse files Browse the repository at this point in the history
Signed-off-by: William Piers <[email protected]>
  • Loading branch information
wpiers committed Nov 15, 2023
1 parent 53fb93c commit ea752ec
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- [ADR-112] Provide only valid view descriptions to the renderer
- [ADR-113] Add support for multiple IObjectService
- [ADR-114] Add support for multiple IEditService
- [ADR-115] Allow details view to change its content

=== Breaking changes

Expand Down Expand Up @@ -99,7 +100,7 @@ Note that the custom shape replaces the parametric SVG, which is deprecated and
That includes the support during the direct edit.
The user can use 'shift+enter' to insert a line break.
- https://github.com/eclipse-sirius/sirius-web/issues/2522[#2522] [diagram] Add the support for rotatable border node.
- https://github.com/eclipse-sirius/sirius-web/issues/2255[#2255] [diagram] Add the possibility to specify a ratio on node to guarantee its aspect.
- https://github.com/eclipse-sirius/sirius-web/issues/2570[#2570] [forms] Allow details view to change its content.

=== Improvements

Expand Down
97 changes: 97 additions & 0 deletions doc/adrs/115_allow_detailsview_to_change_its_content.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
= ADR-115 - Allow details view to change its content

== Context

The Details view displays the same version of a form to all users. There is now way for the frontend to change the form for a specific user.

== Decision

* Addition of a FormConverter API allowing to redefine the form content (/packages/forms/frontend/sirius-components-forms/src/views/FormConverter.types.ts)

[source,typescript]
----
interface FormConverter {
convert(form: GQLForm): GQLForm;
)
----

* Addition of an DetailsViewContext providing a default FormConverter (/packages/forms/frontend/sirius-components-forms/src/views/DetailsViewContext.tsx)

[source,typescript]
----
const converter: FormConverter = {
convert: (form) => form;
};
const defaultContext: DetailsViewContextValue = {
converter
};
export const DetailsViewContext = React.createContext(defaultContext);
----

* Addition of an DetailsViewConfiguration providing the context to children (/packages/forms/frontend/sirius-components-forms/src/views/DetailsViewConfiguration.tsx)

[source,typescript]
----
export const DetailsViewConfiguration = ({ children, converter }: DetailsViewConfigurationProps) => {
return (
<DetailsViewContext.Provider value={{ converter }}>
{children}
</DetailsViewContext.Provider>
);
}
----

* Addition of an useDetailsViewConfiguration function to provide the configuration to interested components (/packages/forms/frontend/sirius-components-forms/src/views/useDetailsViewConfiguration.ts)

[source,typescript]
----
export const useDetailsViewConfiguration = (): UseDetailsViewConfigurationValue => {
const { converter } = useContext(DetailsViewContext);
return {
converter
};
}
----

* Update of the DetailsView to use the converter (/packages/forms/frontend/sirius-components-forms/src/views/DetailsView.tsx)

[source,typescript]
----
const { converter } = useDetailsViewConfiguration();
<FormView converter={converter} ... />
----

* Update of the FormView to use the converter (/packages/forms/frontend/sirius-components-forms/src/views/FormView.tsx)

[source,typescript]
----
<Form form={converter.convert(form)} ... />
----

* Export new APIs (/packages/forms/frontend/sirius-components-forms/src/index.ts):

[source,typescript]
----
DetailsViewConfiguration
DetailsViewConfigurationProps
FormConverter
----

* Usage:
A sirius consumer may encapsulate its components in a DetailsViewConfiguration which will provide the required filters.

[source,typescript]
----
<DetailsViewConfiguration converter={MyCustomFormConverter}>
<Workbench ... />
</DetailsViewConfiguration>
----

== Status

To be reviewed

== Consequences

None, by default the Details view works as before.

0 comments on commit ea752ec

Please sign in to comment.