From 827eeb6ed8959936a424f8106b7dec78fb6a2141 Mon Sep 17 00:00:00 2001 From: William Piers Date: Fri, 7 Jun 2024 11:29:58 +0200 Subject: [PATCH] [3553] Add a representationFactory extension point Bug: #3553 Signed-off-by: William Piers --- .../sirius-components-core/src/index.ts | 2 - .../src/workbench/RepresentationContext.ts | 26 -------- .../workbench/RepresentationContext.types.ts | 21 ------ .../workbench/RepresentationNavigation.tsx | 6 +- .../RepresentationNavigation.types.ts | 10 +-- .../src/workbench/Workbench.tsx | 24 ++++--- .../src/workbench/Workbench.types.ts | 10 ++- .../src/workbench/WorkbenchExtensionPoints.ts | 7 +- .../src/workbench/WorkbenchMachine.ts | 10 +-- .../representations/RepresentationFrame.tsx | 11 ++-- .../RepresentationFrame.types.ts | 4 +- .../src/application/SiriusWebApplication.tsx | 65 +++++++++++++++---- .../onboarding/NewRepresentationArea.types.ts | 4 +- .../RepresentationContextProvider.tsx | 58 ----------------- .../RepresentationContextProvider.types.ts | 16 ----- .../views/edit-project/EditProjectView.tsx | 4 +- .../edit-project/EditProjectViewMachine.ts | 8 +-- 17 files changed, 110 insertions(+), 176 deletions(-) delete mode 100644 packages/core/frontend/sirius-components-core/src/workbench/RepresentationContext.ts delete mode 100644 packages/core/frontend/sirius-components-core/src/workbench/RepresentationContext.types.ts delete mode 100644 packages/sirius-web/frontend/sirius-web-application/src/representations/RepresentationContextProvider.tsx delete mode 100644 packages/sirius-web/frontend/sirius-web-application/src/representations/RepresentationContextProvider.types.ts diff --git a/packages/core/frontend/sirius-components-core/src/index.ts b/packages/core/frontend/sirius-components-core/src/index.ts index 1bd99fd3b7..12eda8e831 100644 --- a/packages/core/frontend/sirius-components-core/src/index.ts +++ b/packages/core/frontend/sirius-components-core/src/index.ts @@ -49,8 +49,6 @@ export * from './toast/MultiToast'; export * from './toast/Toast'; export * from './toast/useReporting'; export * from './workbench/Panels'; -export * from './workbench/RepresentationContext'; -export * from './workbench/RepresentationContext.types'; export * from './workbench/Workbench'; export * from './workbench/Workbench.types'; export * from './workbench/WorkbenchExtensionPoints'; diff --git a/packages/core/frontend/sirius-components-core/src/workbench/RepresentationContext.ts b/packages/core/frontend/sirius-components-core/src/workbench/RepresentationContext.ts deleted file mode 100644 index a43cec3ede..0000000000 --- a/packages/core/frontend/sirius-components-core/src/workbench/RepresentationContext.ts +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2021, 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 { RepresentationComponentRegistry, RepresentationContextValue } from './RepresentationContext.types'; -import { Representation, RepresentationComponentProps } from './Workbench.types'; - -const registry: RepresentationComponentRegistry = { - getComponent: (_representation: Representation) => { - return (_props: RepresentationComponentProps) => null; - }, -}; - -const value: RepresentationContextValue = { - registry, -}; -export const RepresentationContext = React.createContext(value); diff --git a/packages/core/frontend/sirius-components-core/src/workbench/RepresentationContext.types.ts b/packages/core/frontend/sirius-components-core/src/workbench/RepresentationContext.types.ts deleted file mode 100644 index 2136a72252..0000000000 --- a/packages/core/frontend/sirius-components-core/src/workbench/RepresentationContext.types.ts +++ /dev/null @@ -1,21 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2021, 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 { Representation, RepresentationComponent } from './Workbench.types'; - -export type RepresentationComponentRegistry = { - getComponent: (representation: Representation) => RepresentationComponent | null; -}; - -export interface RepresentationContextValue { - registry: RepresentationComponentRegistry; -} diff --git a/packages/core/frontend/sirius-components-core/src/workbench/RepresentationNavigation.tsx b/packages/core/frontend/sirius-components-core/src/workbench/RepresentationNavigation.tsx index 00d39154c7..8b559eeb15 100644 --- a/packages/core/frontend/sirius-components-core/src/workbench/RepresentationNavigation.tsx +++ b/packages/core/frontend/sirius-components-core/src/workbench/RepresentationNavigation.tsx @@ -15,7 +15,7 @@ import Tabs from '@material-ui/core/Tabs'; import { makeStyles } from '@material-ui/core/styles'; import CloseIcon from '@material-ui/icons/Close'; import { RepresentationNavigationProps } from './RepresentationNavigation.types'; -import { Representation } from './Workbench.types'; +import { RepresentationMetadata } from './Workbench.types'; const useRepresentationNavigationStyles = makeStyles((theme) => ({ tabsRoot: { @@ -63,7 +63,7 @@ export const RepresentationNavigation = ({ const representationSelected = representations.find((representation) => representation.id === value); if (representationSelected) { const { id, label, kind } = representationSelected; - const representation: Representation = { + const representation: RepresentationMetadata = { id, label, kind, @@ -72,7 +72,7 @@ export const RepresentationNavigation = ({ } }; - const onRepresentationClose = (event: React.MouseEvent, representation: Representation) => { + const onRepresentationClose = (event: React.MouseEvent, representation: RepresentationMetadata) => { event.stopPropagation(); onClose(representation); }; diff --git a/packages/core/frontend/sirius-components-core/src/workbench/RepresentationNavigation.types.ts b/packages/core/frontend/sirius-components-core/src/workbench/RepresentationNavigation.types.ts index 85ad52ee16..2e612adb52 100644 --- a/packages/core/frontend/sirius-components-core/src/workbench/RepresentationNavigation.types.ts +++ b/packages/core/frontend/sirius-components-core/src/workbench/RepresentationNavigation.types.ts @@ -10,11 +10,11 @@ * Contributors: * Obeo - initial API and implementation *******************************************************************************/ -import { Representation } from './Workbench.types'; +import { RepresentationMetadata } from './Workbench.types'; export type RepresentationNavigationProps = { - representations: Representation[]; - displayedRepresentation: Representation; - onRepresentationClick: (representation: Representation) => void; - onClose: (representation: Representation) => void; + representations: RepresentationMetadata[]; + displayedRepresentation: RepresentationMetadata; + onRepresentationClick: (representation: RepresentationMetadata) => void; + onClose: (representation: RepresentationMetadata) => void; }; diff --git a/packages/core/frontend/sirius-components-core/src/workbench/Workbench.tsx b/packages/core/frontend/sirius-components-core/src/workbench/Workbench.tsx index 1a83757c19..b0d5c7a165 100644 --- a/packages/core/frontend/sirius-components-core/src/workbench/Workbench.tsx +++ b/packages/core/frontend/sirius-components-core/src/workbench/Workbench.tsx @@ -13,23 +13,25 @@ import { gql, useSubscription } from '@apollo/client'; import { makeStyles } from '@material-ui/core/styles'; import { useMachine } from '@xstate/react'; -import { useContext, useEffect } from 'react'; +import { useEffect } from 'react'; import { useComponent } from '../extension/useComponent'; import { useData } from '../extension/useData'; import { useSelection } from '../selection/useSelection'; import { Toast } from '../toast/Toast'; import { Panels } from './Panels'; -import { RepresentationContext } from './RepresentationContext'; -import { RepresentationContextValue } from './RepresentationContext.types'; import { RepresentationNavigation } from './RepresentationNavigation'; import { GQLEditingContextEventSubscription, - Representation, RepresentationComponentProps, + RepresentationMetadata, WorkbenchProps, WorkbenchViewContribution, } from './Workbench.types'; -import { workbenchMainAreaExtensionPoint, workbenchViewContributionExtensionPoint } from './WorkbenchExtensionPoints'; +import { + representationFactoryExtensionPoint, + workbenchMainAreaExtensionPoint, + workbenchViewContributionExtensionPoint, +} from './WorkbenchExtensionPoints'; import { HandleCompleteEvent, HandleSubscriptionResultEvent, @@ -76,7 +78,6 @@ export const Workbench = ({ readOnly, }: WorkbenchProps) => { const classes = useWorkbenchStyles(); - const { registry } = useContext(RepresentationContext); const [{ value, context }, dispatch] = useMachine(workbenchMachine, { context: { displayedRepresentation: initialRepresentationSelected, @@ -86,6 +87,7 @@ export const Workbench = ({ const { toast } = value as SchemaValue; const { id, representations, displayedRepresentation, message } = context; const { selection, setSelection } = useSelection(); + const { data: representationFactories } = useData(representationFactoryExtensionPoint); const { error } = useSubscription(editingContextEventSubscription, { variables: { @@ -117,7 +119,7 @@ export const Workbench = ({ }, [error, dispatch]); useEffect(() => { - const representations: Representation[] = selection.entries.filter((entry) => + const representations: RepresentationMetadata[] = selection.entries.filter((entry) => entry.kind.startsWith('siriusComponents://representation') ); const updateSelectedRepresentation: UpdateSelectedRepresentationEvent = { @@ -127,11 +129,11 @@ export const Workbench = ({ dispatch(updateSelectedRepresentation); }, [selection, dispatch]); - const onRepresentationClick = (representation: Representation) => { + const onRepresentationClick = (representation: RepresentationMetadata) => { setSelection({ entries: [{ id: representation.id, label: representation.label, kind: representation.kind }] }); }; - const onClose = (representation: Representation) => { + const onClose = (representation: RepresentationMetadata) => { const hideRepresentationEvent: HideRepresentationEvent = { type: 'HIDE_REPRESENTATION', representation }; dispatch(hideRepresentationEvent); }; @@ -160,7 +162,9 @@ export const Workbench = ({ let main = ; if (displayedRepresentation) { - const RepresentationComponent = registry.getComponent(displayedRepresentation); + const RepresentationComponent = representationFactories + .map((representationFactory) => representationFactory(displayedRepresentation)) + .find((component) => component != null); const props: RepresentationComponentProps = { editingContextId, readOnly, diff --git a/packages/core/frontend/sirius-components-core/src/workbench/Workbench.types.ts b/packages/core/frontend/sirius-components-core/src/workbench/Workbench.types.ts index e022e8b14a..0d461cbb12 100644 --- a/packages/core/frontend/sirius-components-core/src/workbench/Workbench.types.ts +++ b/packages/core/frontend/sirius-components-core/src/workbench/Workbench.types.ts @@ -26,7 +26,7 @@ export type GQLEditingContextEventSubscription = { editingContextEvent: GQLEditingContextEventPayload; }; -export type Representation = { +export type RepresentationMetadata = { id: string; label: string; kind: string; @@ -53,8 +53,8 @@ export interface MainAreaComponentProps { export type WorkbenchProps = { editingContextId: string; - initialRepresentationSelected: Representation | null; - onRepresentationSelected: (representation: Representation | null) => void; + initialRepresentationSelected: RepresentationMetadata | null; + onRepresentationSelected: (representation: RepresentationMetadata | null) => void; readOnly: boolean; }; @@ -65,3 +65,7 @@ export type RepresentationComponentProps = { }; export type RepresentationComponent = React.ComponentType; + +export type RepresentationComponentFactory = { + (representation: RepresentationMetadata): RepresentationComponent | null; +}; diff --git a/packages/core/frontend/sirius-components-core/src/workbench/WorkbenchExtensionPoints.ts b/packages/core/frontend/sirius-components-core/src/workbench/WorkbenchExtensionPoints.ts index 5b8b0df3d4..7935f017f4 100644 --- a/packages/core/frontend/sirius-components-core/src/workbench/WorkbenchExtensionPoints.ts +++ b/packages/core/frontend/sirius-components-core/src/workbench/WorkbenchExtensionPoints.ts @@ -12,7 +12,7 @@ *******************************************************************************/ import { ComponentExtensionPoint, DataExtensionPoint } from '../extension/ExtensionRegistry.types'; -import { MainAreaComponentProps, WorkbenchViewContribution } from './Workbench.types'; +import { MainAreaComponentProps, RepresentationComponentFactory, WorkbenchViewContribution } from './Workbench.types'; export const workbenchMainAreaExtensionPoint: ComponentExtensionPoint = { identifier: 'workbench#mainArea', @@ -23,3 +23,8 @@ export const workbenchViewContributionExtensionPoint: DataExtensionPoint> = { + identifier: 'workbench#representationFactory', + fallback: [], +}; diff --git a/packages/core/frontend/sirius-components-core/src/workbench/WorkbenchMachine.ts b/packages/core/frontend/sirius-components-core/src/workbench/WorkbenchMachine.ts index 0bd7cf0fa9..5af30fc262 100644 --- a/packages/core/frontend/sirius-components-core/src/workbench/WorkbenchMachine.ts +++ b/packages/core/frontend/sirius-components-core/src/workbench/WorkbenchMachine.ts @@ -16,7 +16,7 @@ import { GQLEditingContextEventPayload, GQLEditingContextEventSubscription, GQLRepresentationRenamedEventPayload, - Representation, + RepresentationMetadata, } from './Workbench.types'; export interface WorkbenchStateSchema { @@ -43,15 +43,15 @@ export type SchemaValue = { export interface WorkbenchContext { id: string; - representations: Representation[]; - displayedRepresentation: Representation | null; + representations: RepresentationMetadata[]; + displayedRepresentation: RepresentationMetadata | null; message: string | null; } -export type HideRepresentationEvent = { type: 'HIDE_REPRESENTATION'; representation: Representation }; +export type HideRepresentationEvent = { type: 'HIDE_REPRESENTATION'; representation: RepresentationMetadata }; export type UpdateSelectedRepresentationEvent = { type: 'UPDATE_SELECTED_REPRESENTATION'; - representations: Representation[]; + representations: RepresentationMetadata[]; }; export type ShowToastEvent = { type: 'SHOW_TOAST'; message: string }; diff --git a/packages/portals/frontend/sirius-components-portals/src/representations/RepresentationFrame.tsx b/packages/portals/frontend/sirius-components-portals/src/representations/RepresentationFrame.tsx index 4f48145d61..ebab308ded 100644 --- a/packages/portals/frontend/sirius-components-portals/src/representations/RepresentationFrame.tsx +++ b/packages/portals/frontend/sirius-components-portals/src/representations/RepresentationFrame.tsx @@ -13,14 +13,13 @@ import { RepresentationComponentProps, - RepresentationContext, - RepresentationContextValue, + representationFactoryExtensionPoint, + useData, } from '@eclipse-sirius/sirius-components-core'; import IconButton from '@material-ui/core/IconButton'; import Typography from '@material-ui/core/Typography'; import { makeStyles } from '@material-ui/core/styles'; import CloseOutlinedIcon from '@material-ui/icons/CloseOutlined'; -import { useContext } from 'react'; import { RepresentationFrameProps } from './RepresentationFrame.types'; const useFrameStyles = makeStyles((theme) => ({ @@ -59,8 +58,10 @@ export const RepresentationFrame = ({ portalMode, onDelete, }: RepresentationFrameProps) => { - const { registry } = useContext(RepresentationContext); - const RepresentationComponent = registry.getComponent(representation); + const { data: representationFactories } = useData(representationFactoryExtensionPoint); + const RepresentationComponent = representationFactories + .map((representationFactory) => representationFactory(representation)) + .find((component) => component != null); if (RepresentationComponent) { const classes = useFrameStyles(); diff --git a/packages/portals/frontend/sirius-components-portals/src/representations/RepresentationFrame.types.ts b/packages/portals/frontend/sirius-components-portals/src/representations/RepresentationFrame.types.ts index b019f9f684..ff2208470a 100644 --- a/packages/portals/frontend/sirius-components-portals/src/representations/RepresentationFrame.types.ts +++ b/packages/portals/frontend/sirius-components-portals/src/representations/RepresentationFrame.types.ts @@ -10,12 +10,12 @@ * Contributors: * Obeo - initial API and implementation *******************************************************************************/ -import { Representation } from '@eclipse-sirius/sirius-components-core'; +import { RepresentationMetadata } from '@eclipse-sirius/sirius-components-core'; import { PortalRepresentationMode } from './PortalRepresentation.types'; export type RepresentationFrameProps = { editingContextId: string; - representation: Representation; + representation: RepresentationMetadata; onDelete: () => void; portalMode: PortalRepresentationMode; }; diff --git a/packages/sirius-web/frontend/sirius-web-application/src/application/SiriusWebApplication.tsx b/packages/sirius-web/frontend/sirius-web-application/src/application/SiriusWebApplication.tsx index 4b400bc9a9..05defa9d1b 100644 --- a/packages/sirius-web/frontend/sirius-web-application/src/application/SiriusWebApplication.tsx +++ b/packages/sirius-web/frontend/sirius-web-application/src/application/SiriusWebApplication.tsx @@ -17,19 +17,30 @@ import { ExtensionProvider, ExtensionRegistry, ExtensionRegistryMergeStrategy, + RepresentationMetadata, RepresentationPathContext, ServerContext, WorkbenchViewContribution, + representationFactoryExtensionPoint, workbenchMainAreaExtensionPoint, workbenchViewContributionExtensionPoint, } from '@eclipse-sirius/sirius-components-core'; -import { NodeTypeContext, NodeTypeContextValue } from '@eclipse-sirius/sirius-components-diagrams'; +import { DeckRepresentation } from '@eclipse-sirius/sirius-components-deck'; +import { + DiagramRepresentation, + NodeTypeContext, + NodeTypeContextValue, +} from '@eclipse-sirius/sirius-components-diagrams'; +import { FormDescriptionEditorRepresentation } from '@eclipse-sirius/sirius-components-formdescriptioneditors'; import { DetailsView, + FormRepresentation, PropertySectionContext, RelatedElementsView, RepresentationsView, } from '@eclipse-sirius/sirius-components-forms'; +import { GanttRepresentation } from '@eclipse-sirius/sirius-components-gantt'; +import { PortalRepresentation } from '@eclipse-sirius/sirius-components-portals'; import { ExplorerView } from '@eclipse-sirius/sirius-components-trees'; import { ValidationView } from '@eclipse-sirius/sirius-components-validation'; import CssBaseline from '@material-ui/core/CssBaseline'; @@ -50,7 +61,6 @@ import { DiagramRepresentationConfigurationProps } from '../diagrams/DiagramRepr import { propertySectionsRegistry } from '../forms/defaultPropertySectionRegistry'; import { ApolloGraphQLProvider } from '../graphql/ApolloGraphQLProvider'; import { OnboardArea } from '../onboarding/OnboardArea'; -import { RepresentationContextProvider } from '../representations/RepresentationContextProvider'; import { Router } from '../router/Router'; import { siriusWebTheme as defaultTheme } from '../theme/siriusWebTheme'; import { createProjectAreaCardExtensionPoint } from '../views/project-browser/create-projects-area/CreateProjectAreaExtensionPoints'; @@ -180,6 +190,41 @@ export const SiriusWebApplication = ({ data: projectSettingsTabContributions, }); + const getType = (representation: RepresentationMetadata): string => { + const query = representation.kind.substring(representation.kind.indexOf('?') + 1, representation.kind.length); + const params = new URLSearchParams(query); + const type = params.get('type'); + return type; + }; + + internalExtensionRegistry.putData(representationFactoryExtensionPoint, { + identifier: 'sw_repFactory_diagram', + data: [(representation) => (getType(representation) === 'Diagram' ? DiagramRepresentation : null)], + }); + internalExtensionRegistry.putData(representationFactoryExtensionPoint, { + identifier: 'sw_repFactory_form', + data: [(representation) => (getType(representation) === 'Form' ? FormRepresentation : null)], + }); + internalExtensionRegistry.putData(representationFactoryExtensionPoint, { + identifier: 'sw_repFactory_formdesceditor', + data: [ + (representation) => + getType(representation) === 'FormDescriptionEditor' ? FormDescriptionEditorRepresentation : null, + ], + }); + internalExtensionRegistry.putData(representationFactoryExtensionPoint, { + identifier: 'sw_repFactory_gantt', + data: [(representation) => (getType(representation) === 'Gantt' ? GanttRepresentation : null)], + }); + internalExtensionRegistry.putData(representationFactoryExtensionPoint, { + identifier: 'sw_repFactory_deck', + data: [(representation) => (getType(representation) === 'Deck' ? DeckRepresentation : null)], + }); + internalExtensionRegistry.putData(representationFactoryExtensionPoint, { + identifier: 'sw_repFactory_portal', + data: [(representation) => (getType(representation) === 'Portal' ? PortalRepresentation : null)], + }); + if (extensionRegistry) { internalExtensionRegistry.addAll( extensionRegistry, @@ -197,15 +242,13 @@ export const SiriusWebApplication = ({ - - - -
- -
-
-
-
+ + +
+ +
+
+
diff --git a/packages/sirius-web/frontend/sirius-web-application/src/onboarding/NewRepresentationArea.types.ts b/packages/sirius-web/frontend/sirius-web-application/src/onboarding/NewRepresentationArea.types.ts index 296450d598..f35c4540e3 100644 --- a/packages/sirius-web/frontend/sirius-web-application/src/onboarding/NewRepresentationArea.types.ts +++ b/packages/sirius-web/frontend/sirius-web-application/src/onboarding/NewRepresentationArea.types.ts @@ -10,7 +10,7 @@ * Contributors: * Obeo - initial API and implementation *******************************************************************************/ -import { Representation } from '@eclipse-sirius/sirius-components-core'; +import { RepresentationMetadata } from '@eclipse-sirius/sirius-components-core'; export interface NewRepresentationAreaState { message: string; @@ -30,7 +30,7 @@ export interface NewRepresentationAreaProps { export interface GQLCreateRepresentationPayload { __typename: string; - representation: Representation; + representation: RepresentationMetadata; } export interface GQLErrorPayload extends GQLCreateRepresentationPayload { diff --git a/packages/sirius-web/frontend/sirius-web-application/src/representations/RepresentationContextProvider.tsx b/packages/sirius-web/frontend/sirius-web-application/src/representations/RepresentationContextProvider.tsx deleted file mode 100644 index 51fa16035a..0000000000 --- a/packages/sirius-web/frontend/sirius-web-application/src/representations/RepresentationContextProvider.tsx +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2023, 2024 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 { - Representation, - RepresentationComponent, - RepresentationComponentRegistry, - RepresentationContext, - RepresentationContextValue, -} from '@eclipse-sirius/sirius-components-core'; -import { DeckRepresentation } from '@eclipse-sirius/sirius-components-deck'; -import { DiagramRepresentation } from '@eclipse-sirius/sirius-components-diagrams'; -import { FormDescriptionEditorRepresentation } from '@eclipse-sirius/sirius-components-formdescriptioneditors'; -import { FormRepresentation } from '@eclipse-sirius/sirius-components-forms'; -import { GanttRepresentation } from '@eclipse-sirius/sirius-components-gantt'; -import { PortalRepresentation } from '@eclipse-sirius/sirius-components-portals'; - -import { RepresentationContextProviderProps } from './RepresentationContextProvider.types'; - -export const RepresentationContextProvider = ({ children }: RepresentationContextProviderProps) => { - const registry: RepresentationComponentRegistry = { - getComponent: (representation: Representation): RepresentationComponent | null => { - const query = representation.kind.substring(representation.kind.indexOf('?') + 1, representation.kind.length); - const params = new URLSearchParams(query); - const type = params.get('type'); - if (type === 'Diagram') { - return DiagramRepresentation; - } else if (type === 'Form') { - return FormRepresentation; - } else if (type === 'FormDescriptionEditor') { - return FormDescriptionEditorRepresentation; - } else if (type === 'Gantt') { - return GanttRepresentation; - } else if (type === 'Deck') { - return DeckRepresentation; - } else if (type === 'Portal') { - return PortalRepresentation; - } - return null; - }, - }; - - const representationContextValue: RepresentationContextValue = { - registry, - }; - - return {children}; -}; diff --git a/packages/sirius-web/frontend/sirius-web-application/src/representations/RepresentationContextProvider.types.ts b/packages/sirius-web/frontend/sirius-web-application/src/representations/RepresentationContextProvider.types.ts deleted file mode 100644 index 2242836837..0000000000 --- a/packages/sirius-web/frontend/sirius-web-application/src/representations/RepresentationContextProvider.types.ts +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * 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 - *******************************************************************************/ - -export interface RepresentationContextProviderProps { - children: React.ReactNode; -} diff --git a/packages/sirius-web/frontend/sirius-web-application/src/views/edit-project/EditProjectView.tsx b/packages/sirius-web/frontend/sirius-web-application/src/views/edit-project/EditProjectView.tsx index bb973d9276..1daeec6395 100644 --- a/packages/sirius-web/frontend/sirius-web-application/src/views/edit-project/EditProjectView.tsx +++ b/packages/sirius-web/frontend/sirius-web-application/src/views/edit-project/EditProjectView.tsx @@ -12,7 +12,7 @@ *******************************************************************************/ import { gql, useQuery } from '@apollo/client'; import { - Representation, + RepresentationMetadata, Selection, SelectionContextProvider, Toast, @@ -148,7 +148,7 @@ export const EditProjectView = () => { let main = null; if (editProjectView === 'loaded' && project) { - const onRepresentationSelected = (representationSelected: Representation) => { + const onRepresentationSelected = (representationSelected: RepresentationMetadata) => { const selectRepresentationEvent: SelectRepresentationEvent = { type: 'SELECT_REPRESENTATION', representation: representationSelected, diff --git a/packages/sirius-web/frontend/sirius-web-application/src/views/edit-project/EditProjectViewMachine.ts b/packages/sirius-web/frontend/sirius-web-application/src/views/edit-project/EditProjectViewMachine.ts index 7eaf2c304e..8cc6ae4554 100644 --- a/packages/sirius-web/frontend/sirius-web-application/src/views/edit-project/EditProjectViewMachine.ts +++ b/packages/sirius-web/frontend/sirius-web-application/src/views/edit-project/EditProjectViewMachine.ts @@ -10,7 +10,7 @@ * Contributors: * Obeo - initial API and implementation *******************************************************************************/ -import { Representation } from '@eclipse-sirius/sirius-components-core'; +import { RepresentationMetadata } from '@eclipse-sirius/sirius-components-core'; import { Machine, assign } from 'xstate'; import { GQLGetProjectQueryData, Project } from './EditProjectView.types'; @@ -39,14 +39,14 @@ export type SchemaValue = { export interface EditProjectViewContext { project: Project | null; - representation: Representation | null; + representation: RepresentationMetadata | null; message: string | null; } export type ShowToastEvent = { type: 'SHOW_TOAST'; message: string }; export type HideToastEvent = { type: 'HIDE_TOAST' }; export type HandleFetchedProjectEvent = { type: 'HANDLE_FETCHED_PROJECT'; data: GQLGetProjectQueryData }; -export type SelectRepresentationEvent = { type: 'SELECT_REPRESENTATION'; representation: Representation }; +export type SelectRepresentationEvent = { type: 'SELECT_REPRESENTATION'; representation: RepresentationMetadata }; export type EditProjectViewEvent = | HandleFetchedProjectEvent | SelectRepresentationEvent @@ -130,7 +130,7 @@ export const editProjectViewMachine = Machine