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.
[doc] Add ADR for details view changes support
Signed-off-by: William Piers <[email protected]>
- Loading branch information
Showing
2 changed files
with
99 additions
and
1 deletion.
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
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,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. |