diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 61017141260..a52e0a1c4d8 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -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 @@ -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 diff --git a/doc/adrs/115_allow_detailsview_to_change_its_content.adoc b/doc/adrs/115_allow_detailsview_to_change_its_content.adoc new file mode 100644 index 00000000000..7d660801a7b --- /dev/null +++ b/doc/adrs/115_allow_detailsview_to_change_its_content.adoc @@ -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 ( + + {children} + + ); +} +---- + +* 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(); + + +---- + +* Update of the FormView to use the converter (/packages/forms/frontend/sirius-components-forms/src/views/FormView.tsx) + +[source,typescript] +---- +
+---- + +* 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] +---- + + + +---- + +== Status + +To be reviewed + +== Consequences + +None, by default the Details view works as before.