Skip to content

Commit

Permalink
[3684] Replace form & tree converters configurations with extensions
Browse files Browse the repository at this point in the history
Bug: eclipse-sirius#3684
Signed-off-by: William Piers <william.piers@obeo.fr>
  • Loading branch information
wpiers authored and sbegaudeau committed Jul 9, 2024
1 parent 020b00e commit eceadc7
Show file tree
Hide file tree
Showing 15 changed files with 47 additions and 173 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ The error messages displayed in case of an error while uploading a file have bee
We cannot rely on the error message recaived from the backend since Cross Origin Resource Sharing may prevent us from seeing both the message and the 413 status code.
- https://github.com/eclipse-sirius/sirius-web/issues/3697[#3697] [diagram] Improve arrange-all performance by reducing overlap management complexity
- https://github.com/eclipse-sirius/sirius-web/issues/3669[#3669] [diagram] Add migration participant to hide label borders by default
- https://github.com/eclipse-sirius/sirius-web/issues/3684[#3684] [form, tree] Replace form & tree converters configurations with extensions

== v2024.5.0

Expand Down
3 changes: 1 addition & 2 deletions packages/forms/frontend/sirius-components-forms/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ 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/DetailsViewExtensionPoints';
export * from './views/FormBasedView';
export * from './views/FormBasedView.types';
export * from './views/FormConverter.types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,17 @@
* Contributors:
* Obeo - initial API and implementation
*******************************************************************************/
import { WorkbenchViewComponentProps } from '@eclipse-sirius/sirius-components-core';
import { useDetailsViewConfiguration } from './DetailsViewConfiguration';
import { WorkbenchViewComponentProps, useData } from '@eclipse-sirius/sirius-components-core';
import { detailsViewFormConverterProviderExtensionPoint } from './DetailsViewExtensionPoints';
import { FormBasedView } from './FormBasedView';

export const DetailsView = (props: WorkbenchViewComponentProps) => {
const { converter } = useDetailsViewConfiguration();
return <FormBasedView {...props} subscriptionName="propertiesEvent" converter={converter} />;
const { data: converterProvider } = useData(detailsViewFormConverterProviderExtensionPoint);
return (
<FormBasedView
{...props}
subscriptionName="propertiesEvent"
converter={converterProvider.converter(props.editingContextId)}
/>
);
};

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2023 Obeo.
* Copyright (c) 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
Expand All @@ -10,16 +10,16 @@
* Contributors:
* Obeo - initial API and implementation
*******************************************************************************/
import React from 'react';
import { TreeConverter } from './TreeConverter.types';
import { ExplorerViewContextValue } from './ExplorerViewContext.types';
import { DataExtensionPoint } from '@eclipse-sirius/sirius-components-core';
import { FormConverterProvider } from './FormConverter.types';

const converter: TreeConverter = {
convert: (tree) => tree,
export const detailsViewFormConverterProviderExtensionPoint: DataExtensionPoint<FormConverterProvider> = {
identifier: 'detailsView#formConverterProvider',
fallback: {
converter: () => {
return {
convert: (form) => form,
};
},
},
};

const defaultContext: ExplorerViewContextValue = {
converter,
};

export const ExplorerViewContext = React.createContext(defaultContext);
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
*******************************************************************************/

import { GQLForm } from '../form/FormEventFragments.types';
export interface FormConverterProvider {
converter(editingContextId: string): FormConverter;
}

export interface FormConverter {
convert(form: GQLForm): GQLForm;
Expand Down
3 changes: 1 addition & 2 deletions packages/trees/frontend/sirius-components-trees/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ export * from './treeitems/TreeItemContextMenuContribution';
export * from './treeitems/TreeItemContextMenuContribution.types';
export * from './treeitems/filterTreeItem';
export * from './views/ExplorerView';
export * from './views/ExplorerViewConfiguration';
export * from './views/ExplorerViewConfiguration.types';
export * from './views/ExplorerViewExtensionPoints';
export * from './views/TreeConverter.types';
export * from './views/TreeView';
export * from './views/TreeView.types';
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
* Contributors:
* Obeo - initial API and implementation
*******************************************************************************/
import { WorkbenchViewComponentProps } from '@eclipse-sirius/sirius-components-core';
import { WorkbenchViewComponentProps, useData } from '@eclipse-sirius/sirius-components-core';
import { makeStyles } from '@material-ui/core/styles';
import { useContext, useEffect, useRef, useState } from 'react';
import { TreeToolBar } from '../toolbar/TreeToolBar';
import { TreeToolBarContext } from '../toolbar/TreeToolBarContext';
import { TreeToolBarContextValue } from '../toolbar/TreeToolBarContext.types';
import { FilterBar } from '../trees/FilterBar';
import { ExplorerViewState, TreeFilter } from './ExplorerView.types';
import { useExplorerViewConfiguration } from './ExplorerViewConfiguration';
import { explorerViewTreeConverterProviderExtensionPoint } from './ExplorerViewExtensionPoints';
import { TreeView } from './TreeView';
import { useTreeFilters } from './useTreeFilters';

Expand All @@ -36,7 +36,7 @@ const useStyles = makeStyles((theme) => ({

export const ExplorerView = ({ editingContextId, readOnly }: WorkbenchViewComponentProps) => {
const styles = useStyles();
const { converter } = useExplorerViewConfiguration();
const { data: converterProvider } = useData(explorerViewTreeConverterProviderExtensionPoint);

const initialState: ExplorerViewState = {
synchronizedWithSelection: true,
Expand Down Expand Up @@ -142,7 +142,7 @@ export const ExplorerView = ({ editingContextId, readOnly }: WorkbenchViewCompon
activeFilterIds={activeTreeFilterIds}
textToHighlight={state.filterBarText}
textToFilter={state.filterBarTreeFiltering ? state.filterBarText : null}
converter={converter}
converter={converterProvider.converter(editingContextId)}
/>
</div>
</div>
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2023 Obeo.
* Copyright (c) 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
Expand All @@ -10,16 +10,16 @@
* Contributors:
* Obeo - initial API and implementation
*******************************************************************************/
import React from 'react';
import { DetailsViewContextValue } from './DetailsViewContext.types';
import { FormConverter } from './FormConverter.types';
import { DataExtensionPoint } from '@eclipse-sirius/sirius-components-core';
import { TreeConverterProvider } from './TreeConverter.types';

const converter: FormConverter = {
convert: (form) => form,
export const explorerViewTreeConverterProviderExtensionPoint: DataExtensionPoint<TreeConverterProvider> = {
identifier: 'explorerView#treeConverterProvider',
fallback: {
converter: () => {
return {
convert: (tree) => tree,
};
},
},
};

const defaultContext: DetailsViewContextValue = {
converter,
};

export const DetailsViewContext = React.createContext(defaultContext);
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

import { GQLTree } from './TreeView.types';

export interface TreeConverterProvider {
converter(editingContextId: string): TreeConverter;
}
export interface TreeConverter {
convert(tree: GQLTree): GQLTree;
}

0 comments on commit eceadc7

Please sign in to comment.