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.
[2570] Allow details view to change its content
Bug: eclipse-sirius#2570 Signed-off-by: William Piers <[email protected]>
- Loading branch information
Showing
9 changed files
with
123 additions
and
4 deletions.
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
27 changes: 27 additions & 0 deletions
27
packages/forms/frontend/sirius-components-forms/src/views/DetailsViewConfiguration.tsx
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,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 <DetailsViewContext.Provider value={{ converter }}>{children}</DetailsViewContext.Provider>; | ||
}; | ||
|
||
export const useDetailsViewConfiguration = (): UseDetailsViewConfigurationValue => { | ||
const { converter } = React.useContext<UseDetailsViewConfigurationValue>(DetailsViewContext); | ||
return { | ||
converter, | ||
}; | ||
}; |
24 changes: 24 additions & 0 deletions
24
packages/forms/frontend/sirius-components-forms/src/views/DetailsViewConfiguration.types.ts
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,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; | ||
} |
25 changes: 25 additions & 0 deletions
25
packages/forms/frontend/sirius-components-forms/src/views/DetailsViewContext.tsx
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,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); |
17 changes: 17 additions & 0 deletions
17
packages/forms/frontend/sirius-components-forms/src/views/DetailsViewContext.types.ts
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,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; | ||
} |
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
18 changes: 18 additions & 0 deletions
18
packages/forms/frontend/sirius-components-forms/src/views/FormConverter.types.ts
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,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; | ||
} |