-
Notifications
You must be signed in to change notification settings - Fork 6
Manage DS mapping by directory #1183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
567c780
Manage DS mapping by directory
thangqp 0454cc4
Merge branch 'main' into manage_ds_mapping_via_directory
thangqp c05e0c6
Merge branch 'main' into manage_ds_mapping_via_directory
thangqp 18c58ec
Merge branch 'main' into manage_ds_mapping_via_directory
thangqp 0044f7b
renaming ElementType
thangqp 2e9f6fc
Merge branch 'main' into manage_ds_mapping_via_directory
thangqp b4bffac
move directory-item-input rhf component to commons-ui
thangqp 96bd5fb
Merge remote-tracking branch 'origin/manage_ds_mapping_via_directory'…
thangqp 654b5a3
Merge branch 'main' into manage_ds_mapping_via_directory
thangqp b83807b
error compile
thangqp 774a50c
Merge remote-tracking branch 'origin/manage_ds_mapping_via_directory'…
thangqp b2ee530
Mapping as array of one element
thangqp 7060e1a
Merge branch 'main' into manage_ds_mapping_via_directory
thangqp 04b96e6
Sonar
thangqp f4ffdc4
Sonar
thangqp d9e4f3b
Merge branch 'main' into manage_ds_mapping_via_directory
thangqp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
93 changes: 93 additions & 0 deletions
93
src/components/ui/reactHookForm/directory-item-input/directory-item-input.tsx
This file contains hidden or 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,93 @@ | ||
| /** | ||
| * Copyright (c) 2026, RTE (http://www.rte-france.com) | ||
| * This Source Code Form is subject to the terms of the Mozilla Public | ||
| * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| * file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
| */ | ||
|
|
||
| import { Box, Button, FormHelperText, Grid2 as Grid, Stack, Tooltip, Typography } from '@mui/material'; | ||
| import { FormattedMessage, useIntl } from 'react-intl'; | ||
| import { useCallback, useMemo, useState } from 'react'; | ||
| import { useController } from 'react-hook-form'; | ||
| import { UUID } from 'node:crypto'; | ||
| import { FolderOutlined } from '@mui/icons-material'; | ||
| import { DIRECTORY_ITEM_FULL_PATH, DIRECTORY_ITEM_ID } from '../constants'; | ||
| import { DirectoryItemSchema, getAbsenceLabelKeyFromType } from './directory-item-utils'; | ||
| import { DirectoryItemSelector, DirectoryItemSelectorProps } from '../../directoryItemSelector'; | ||
| import { TreeViewFinderNodeProps } from '../../treeViewFinder'; | ||
|
|
||
| export interface DirectoryItemSelectorInputProps extends Omit<DirectoryItemSelectorProps, 'onClose' | 'open'> { | ||
| name: string; | ||
| } | ||
|
|
||
| export function DirectoryItemInput({ name, types, ...props }: Readonly<DirectoryItemSelectorInputProps>) { | ||
| const [isOpen, setIsOpen] = useState<boolean>(false); | ||
|
|
||
| const { | ||
| field: { onChange, value }, | ||
| fieldState: { error }, | ||
| } = useController({ name }); | ||
|
|
||
| const nodeInfos: DirectoryItemSchema | undefined | null = value; | ||
| const intl = useIntl(); | ||
|
|
||
| const breadcrumb = useMemo(() => { | ||
| return nodeInfos?.[DIRECTORY_ITEM_FULL_PATH] ? nodeInfos[DIRECTORY_ITEM_FULL_PATH] : undefined; | ||
| }, [nodeInfos]); | ||
|
|
||
| const onNodeChanged = useCallback( | ||
| (nodes: TreeViewFinderNodeProps[]) => { | ||
| if (nodes.length > 0) { | ||
| const fullPath = nodes[0]?.name; | ||
| const nodeId: UUID | null = nodes[0]?.id; | ||
| if (nodeId) { | ||
| const newNodeInfos = { | ||
| [DIRECTORY_ITEM_ID]: nodeId, | ||
| [DIRECTORY_ITEM_FULL_PATH]: fullPath, | ||
| }; | ||
| onChange(newNodeInfos); | ||
|
Comment on lines
+40
to
+48
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. to build the full path, as demanded by our PO, the full path shoud be built by a specific maner to avoid cases in which path is so long.. This wil be done later.. |
||
| } | ||
| } | ||
| setIsOpen(false); | ||
| }, | ||
| [onChange] | ||
| ); | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| return ( | ||
| <Box> | ||
| <Stack direction="row" alignItems="center" justifyContent="space-between"> | ||
| <Grid container alignItems="center"> | ||
| <Grid paddingTop={1}> | ||
| <FolderOutlined /> | ||
| </Grid> | ||
| <Grid paddingTop={1} paddingLeft={1}> | ||
| <Tooltip | ||
| title={nodeInfos?.[DIRECTORY_ITEM_FULL_PATH] ?? ''} | ||
| slotProps={{ | ||
| tooltip: { | ||
| sx: { | ||
| maxWidth: 'none', // to override the background of text is auto cut | ||
| }, | ||
| }, | ||
| }} | ||
| > | ||
| <Typography fontWeight={breadcrumb ? undefined : 'bold'} noWrap> | ||
| {breadcrumb || <FormattedMessage id={getAbsenceLabelKeyFromType(types?.[0])} />} | ||
| </Typography> | ||
| </Tooltip> | ||
| </Grid> | ||
| <Grid paddingTop={1} paddingLeft={1}> | ||
| {error?.message && ( | ||
| <FormHelperText error>{intl.formatMessage({ id: error?.message })}</FormHelperText> | ||
| )} | ||
| </Grid> | ||
| </Grid> | ||
| <Button onClick={() => setIsOpen(true)} variant="contained" color="primary" component="label"> | ||
| <FormattedMessage id={breadcrumb ? 'edit' : 'Select'} /> | ||
| </Button> | ||
| </Stack> | ||
|
|
||
| <DirectoryItemSelector open={isOpen} onClose={onNodeChanged} types={types} {...props} /> | ||
| </Box> | ||
| ); | ||
| } | ||
30 changes: 30 additions & 0 deletions
30
src/components/ui/reactHookForm/directory-item-input/directory-item-utils.ts
This file contains hidden or 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,30 @@ | ||
| /** | ||
| * Copyright (c) 2026, RTE (http://www.rte-france.com) | ||
| * This Source Code Form is subject to the terms of the Mozilla Public | ||
| * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| * file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
| */ | ||
|
|
||
| import * as yup from 'yup'; | ||
| import { DIRECTORY_ITEM_FULL_PATH, DIRECTORY_ITEM_ID } from '../constants'; | ||
| import { ElementType } from '../../../../utils'; | ||
|
|
||
| export function getAbsenceLabelKeyFromType(elementType: string) { | ||
| switch (elementType) { | ||
| case ElementType.DIRECTORY: | ||
| return 'NoFolder'; | ||
| case ElementType.CASE: | ||
| return 'NoCase'; | ||
| case ElementType.STUDY: | ||
| return 'NoStudy'; | ||
| default: | ||
| return 'NoItem'; | ||
| } | ||
| } | ||
|
|
||
| export const directoryItemSchema = yup.object().shape({ | ||
| [DIRECTORY_ITEM_ID]: yup.string().required(), | ||
| [DIRECTORY_ITEM_FULL_PATH]: yup.string().required(), | ||
| }); | ||
|
|
||
| export type DirectoryItemSchema = yup.InferType<typeof directoryItemSchema>; |
8 changes: 8 additions & 0 deletions
8
src/components/ui/reactHookForm/directory-item-input/index.ts
This file contains hidden or 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,8 @@ | ||
| /** | ||
| * Copyright (c) 2026, RTE (http://www.rte-france.com) | ||
| * This Source Code Form is subject to the terms of the Mozilla Public | ||
| * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| * file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
| */ | ||
| export * from './directory-item-utils'; | ||
| export * from './directory-item-input'; |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
be sure to clean in study
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will be done in Sprint 38