diff --git a/packages/forms/frontend/sirius-components-forms/src/index.ts b/packages/forms/frontend/sirius-components-forms/src/index.ts index 16cd045285..a25d3aaf1d 100644 --- a/packages/forms/frontend/sirius-components-forms/src/index.ts +++ b/packages/forms/frontend/sirius-components-forms/src/index.ts @@ -30,5 +30,8 @@ export * from './propertysections/getTextDecorationLineValue'; export * from './propertysections/useClickHandler'; export * from './representations/FormRepresentation'; export * from './views/DetailsView'; +export * from './views/DetailsViewConfiguration'; +export * from './views/DetailsViewConfiguration.types'; +export * from './views/FormConverter.types'; export * from './views/RelatedElementsView'; export * from './views/RepresentationsView'; diff --git a/packages/forms/frontend/sirius-components-forms/src/views/DetailsView.tsx b/packages/forms/frontend/sirius-components-forms/src/views/DetailsView.tsx index ad2c96ce91..a1549ff8eb 100644 --- a/packages/forms/frontend/sirius-components-forms/src/views/DetailsView.tsx +++ b/packages/forms/frontend/sirius-components-forms/src/views/DetailsView.tsx @@ -11,8 +11,10 @@ * Obeo - initial API and implementation *******************************************************************************/ import { WorkbenchViewComponentProps } from '@eclipse-sirius/sirius-components-core'; +import { useDetailsViewConfiguration } from './DetailsViewConfiguration'; import { FormBasedView } from './FormBasedView'; -export const DetailsView = (props: WorkbenchViewComponentProps) => ( - -); +export const DetailsView = (props: WorkbenchViewComponentProps) => { + const { converter } = useDetailsViewConfiguration(); + return ; +}; diff --git a/packages/forms/frontend/sirius-components-forms/src/views/DetailsViewConfiguration.tsx b/packages/forms/frontend/sirius-components-forms/src/views/DetailsViewConfiguration.tsx new file mode 100644 index 0000000000..6ed6416531 --- /dev/null +++ b/packages/forms/frontend/sirius-components-forms/src/views/DetailsViewConfiguration.tsx @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2023 Obeo. + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ + +import React from 'react'; +import { DetailsViewConfigurationProps, UseDetailsViewConfigurationValue } from './DetailsViewConfiguration.types'; +import { DetailsViewContext } from './DetailsViewContext'; + +export const DetailsViewConfiguration = ({ children, converter }: DetailsViewConfigurationProps) => { + return {children}; +}; + +export const useDetailsViewConfiguration = (): UseDetailsViewConfigurationValue => { + const { converter } = React.useContext(DetailsViewContext); + return { + converter, + }; +}; diff --git a/packages/forms/frontend/sirius-components-forms/src/views/DetailsViewConfiguration.types.ts b/packages/forms/frontend/sirius-components-forms/src/views/DetailsViewConfiguration.types.ts new file mode 100644 index 0000000000..f6487f4dec --- /dev/null +++ b/packages/forms/frontend/sirius-components-forms/src/views/DetailsViewConfiguration.types.ts @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2023 Obeo. + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ + +import { ReactNode } from 'react'; +import { FormConverter } from './FormConverter.types'; + +export interface DetailsViewConfigurationProps { + converter: FormConverter; + children: ReactNode; +} + +export interface UseDetailsViewConfigurationValue { + converter: FormConverter; +} diff --git a/packages/forms/frontend/sirius-components-forms/src/views/DetailsViewContext.tsx b/packages/forms/frontend/sirius-components-forms/src/views/DetailsViewContext.tsx new file mode 100644 index 0000000000..c5743b4619 --- /dev/null +++ b/packages/forms/frontend/sirius-components-forms/src/views/DetailsViewContext.tsx @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2023 Obeo. + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +import React from 'react'; +import { DetailsViewContextValue } from './DetailsViewContext.types'; +import { FormConverter } from './FormConverter.types'; + +const converter: FormConverter = { + convert: (form) => form, +}; + +const defaultContext: DetailsViewContextValue = { + converter, +}; + +export const DetailsViewContext = React.createContext(defaultContext); diff --git a/packages/forms/frontend/sirius-components-forms/src/views/DetailsViewContext.types.ts b/packages/forms/frontend/sirius-components-forms/src/views/DetailsViewContext.types.ts new file mode 100644 index 0000000000..62852b6bad --- /dev/null +++ b/packages/forms/frontend/sirius-components-forms/src/views/DetailsViewContext.types.ts @@ -0,0 +1,17 @@ +/******************************************************************************* + * Copyright (c) 2023 Obeo. + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ + +import { FormConverter } from './FormConverter.types'; +export interface DetailsViewContextValue { + converter: FormConverter; +} diff --git a/packages/forms/frontend/sirius-components-forms/src/views/FormBasedView.tsx b/packages/forms/frontend/sirius-components-forms/src/views/FormBasedView.tsx index 7ebb6b4aee..d2cc5d1098 100644 --- a/packages/forms/frontend/sirius-components-forms/src/views/FormBasedView.tsx +++ b/packages/forms/frontend/sirius-components-forms/src/views/FormBasedView.tsx @@ -80,6 +80,7 @@ export const FormBasedView = ({ setSelection, readOnly, subscriptionName, + converter, }: FormBasedViewProps) => { const classes = useFormBasedViewStyles(); const [{ value, context }, dispatch] = useMachine(formBasedViewMachine); @@ -156,7 +157,7 @@ export const FormBasedView = ({ content = (
void; readOnly: boolean; subscriptionName: string; + converter: FormConverter; } diff --git a/packages/forms/frontend/sirius-components-forms/src/views/FormConverter.types.ts b/packages/forms/frontend/sirius-components-forms/src/views/FormConverter.types.ts new file mode 100644 index 0000000000..527e5de09e --- /dev/null +++ b/packages/forms/frontend/sirius-components-forms/src/views/FormConverter.types.ts @@ -0,0 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2023 Obeo. + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ + +import { GQLForm } from '../form/FormEventFragments.types'; + +export interface FormConverter { + convert(form: GQLForm): GQLForm; +}