Skip to content

Commit b847039

Browse files
authored
[Update commons ui]Remove mutualized functions (#434)
Signed-off-by: Hugo Marcellin <[email protected]>
1 parent 14e64f2 commit b847039

13 files changed

+36
-161
lines changed

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"dependencies": {
88
"@emotion/react": "^11.11.4",
99
"@emotion/styled": "^11.11.5",
10-
"@gridsuite/commons-ui": "0.58.0",
10+
"@gridsuite/commons-ui": "0.59.1",
1111
"@hookform/resolvers": "^3.3.4",
1212
"@mui/icons-material": "^5.15.14",
1313
"@mui/lab": "5.0.0-alpha.169",

src/components/app-top-bar.jsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,18 @@
55
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
66
*/
77
import React, { useEffect, useRef, useState } from 'react';
8-
import { LIGHT_THEME, logout, TopBar } from '@gridsuite/commons-ui';
8+
import {
9+
LIGHT_THEME,
10+
logout,
11+
TopBar,
12+
fetchAppsMetadata,
13+
} from '@gridsuite/commons-ui';
914
import ParametersDialog, {
1015
useParameterState,
1116
} from './dialogs/parameters-dialog';
1217
import { APP_NAME, PARAM_LANGUAGE, PARAM_THEME } from '../utils/config-params';
1318
import { useDispatch, useSelector } from 'react-redux';
14-
import {
15-
fetchAppsAndUrls,
16-
fetchVersion,
17-
getServersInfos,
18-
} from '../utils/rest-api';
19+
import { fetchVersion, getServersInfos } from '../utils/rest-api';
1920
import PropTypes from 'prop-types';
2021
import { useNavigate } from 'react-router-dom';
2122
import GridExploreLogoLight from '../images/GridExplore_logo_light.svg?react';
@@ -44,7 +45,7 @@ const AppTopBar = ({ user, userManager }) => {
4445

4546
useEffect(() => {
4647
if (user !== null) {
47-
fetchAppsAndUrls().then((res) => {
48+
fetchAppsMetadata().then((res) => {
4849
dispatch(setAppsAndUrls(res));
4950
});
5051
}

src/components/dialogs/create-study-dialog/importParametersSection.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const ImportParametersSection: FunctionComponent = () => {
2727

2828
const handleParamsChange = (
2929
paramName: string,
30-
value: string | string[] | boolean,
30+
value: unknown,
3131
isEdit: boolean
3232
): void => {
3333
if (!isEdit) {

src/components/dialogs/field-hook.jsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ import { FormattedMessage, useIntl } from 'react-intl';
1010
import { elementExists, rootDirectoryExists } from '../../utils/rest-api';
1111
import { CircularProgress, InputAdornment, TextField } from '@mui/material';
1212
import CheckIcon from '@mui/icons-material/Check';
13-
import { ElementType } from '@gridsuite/commons-ui';
14-
import { useDebounce } from '@gridsuite/commons-ui';
13+
import { ElementType, useDebounce } from '@gridsuite/commons-ui';
1514

1615
const styles = {
1716
helperText: {

src/components/dialogs/move-dialog.jsx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@ import PropTypes from 'prop-types';
1010
import { DirectoryItemSelector } from '@gridsuite/commons-ui';
1111
import { useIntl } from 'react-intl';
1212
import { ElementType } from '@gridsuite/commons-ui';
13-
import {
14-
fetchDirectoryContent,
15-
fetchElementsInfos,
16-
fetchRootFolders,
17-
} from '../../utils/rest-api';
1813

1914
const MoveDialog = ({ open, onClose, items }) => {
2015
const intl = useIntl();
@@ -38,9 +33,6 @@ const MoveDialog = ({ open, onClose, items }) => {
3833
id: 'moveItemTitle',
3934
})}
4035
contentText={intl.formatMessage({ id: 'moveItemContentText' })}
41-
fetchDirectoryContent={fetchDirectoryContent}
42-
fetchRootFolders={fetchRootFolders}
43-
fetchElementsInfos={fetchElementsInfos}
4436
/>
4537
);
4638
};

src/components/directory-content.jsx

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,11 @@ import {
3030
ExpertFilterEditionDialog,
3131
CriteriaBasedFilterEditionDialog,
3232
DescriptionModificationDialog,
33+
fetchElementsInfos,
3334
} from '@gridsuite/commons-ui';
3435
import { Box, Checkbox } from '@mui/material';
3536

36-
import {
37-
elementExists,
38-
fetchAppsAndUrls,
39-
fetchElementsInfos,
40-
getFilterById,
41-
fetchDirectoryContent,
42-
fetchRootFolders,
43-
updateElement,
44-
} from '../utils/rest-api';
37+
import { elementExists, getFilterById, updateElement } from '../utils/rest-api';
4538

4639
import ContentContextualMenu from './menus/content-contextual-menu';
4740
import ContentToolbar from './toolbars/content-toolbar';
@@ -1059,7 +1052,6 @@ const DirectoryContent = () => {
10591052
titleId={'editFilter'}
10601053
name={name}
10611054
broadcastChannel={broadcastChannel}
1062-
fetchAppsAndUrls={fetchAppsAndUrls}
10631055
getFilterById={getFilterById}
10641056
activeDirectory={activeDirectory}
10651057
elementExists={elementExists}
@@ -1075,7 +1067,6 @@ const DirectoryContent = () => {
10751067
titleId={'editFilter'}
10761068
name={name}
10771069
broadcastChannel={broadcastChannel}
1078-
fetchAppsAndUrls={fetchAppsAndUrls}
10791070
getFilterById={getFilterById}
10801071
selectionForCopy={selectionForCopy}
10811072
activeDirectory={activeDirectory}
@@ -1092,15 +1083,11 @@ const DirectoryContent = () => {
10921083
titleId={'editFilter'}
10931084
name={name}
10941085
broadcastChannel={broadcastChannel}
1095-
fetchAppsAndUrls={fetchAppsAndUrls}
10961086
selectionForCopy={selectionForCopy}
10971087
getFilterById={getFilterById}
10981088
activeDirectory={activeDirectory}
10991089
elementExists={elementExists}
11001090
language={languageLocal}
1101-
fetchDirectoryContent={fetchDirectoryContent}
1102-
fetchRootFolders={fetchRootFolders}
1103-
fetchElementsInfos={fetchElementsInfos}
11041091
/>
11051092
);
11061093
default:

src/components/menus/content-contextual-menu.jsx

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,12 @@ import {
3131
deleteElements,
3232
duplicateElement,
3333
elementExists,
34-
fetchAppsAndUrls,
3534
moveElementsToDirectory,
3635
newScriptFromFilter,
3736
newScriptFromFiltersContingencyList,
3837
renameElement,
3938
replaceFiltersWithScript,
4039
replaceFormContingencyListWithScript,
41-
fetchDirectoryContent,
42-
fetchRootFolders,
43-
fetchElementsInfos,
44-
fetchPath,
4540
} from '../../utils/rest-api';
4641

4742
import { ContingencyListType, FilterType } from '../../utils/elementType';
@@ -783,13 +778,8 @@ const ContentContextualMenu = (props) => {
783778
activeElement.specificMetadata.equipmentType,
784779
}}
785780
activeDirectory={activeDirectory}
786-
fetchAppsAndUrls={fetchAppsAndUrls}
787781
elementExists={elementExists}
788782
language={languageLocal}
789-
fetchDirectoryContent={fetchDirectoryContent}
790-
fetchRootFolders={fetchRootFolders}
791-
fetchElementsInfos={fetchElementsInfos}
792-
fetchPath={fetchPath}
793783
/>
794784
);
795785
case DialogsId.ADD_NEW_STUDY_FROM_CASE:

src/components/menus/directory-tree-contextual-menu.jsx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ import {
2929
insertDirectory,
3030
insertRootDirectory,
3131
renameElement,
32-
fetchDirectoryContent,
33-
fetchRootFolders,
34-
fetchAppsAndUrls,
35-
fetchElementsInfos,
3632
elementExists,
3733
} from '../../utils/rest-api';
3834

@@ -384,12 +380,8 @@ const DirectoryTreeContextualMenu = (props) => {
384380
open={true}
385381
onClose={handleCloseDialog}
386382
activeDirectory={activeDirectory}
387-
fetchAppsAndUrls={fetchAppsAndUrls}
388383
elementExists={elementExists}
389384
language={languageLocal}
390-
fetchDirectoryContent={fetchDirectoryContent}
391-
fetchRootFolders={fetchRootFolders}
392-
fetchElementsInfos={fetchElementsInfos}
393385
/>
394386
);
395387
case DialogsId.ADD_NEW_CASE:

src/components/search/search-bar.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,12 @@ import {
1515
useState,
1616
} from 'react';
1717
import { Autocomplete, TextField } from '@mui/material';
18-
import {
19-
fetchDirectoryContent,
20-
searchElementsInfos,
21-
} from '../../utils/rest-api';
18+
import { searchElementsInfos } from '../../utils/rest-api';
2219
import {
2320
ElementType,
2421
useDebounce,
2522
useSnackMessage,
23+
fetchDirectoryContent,
2624
} from '@gridsuite/commons-ui';
2725
import { Search } from '@mui/icons-material';
2826
import { useDispatch, useSelector } from 'react-redux';
@@ -36,13 +34,14 @@ import {
3634
ITreeData,
3735
ReduxState,
3836
} from '../../redux/reducer.type';
37+
import { UUID } from 'crypto';
3938

4039
export const SEARCH_FETCH_TIMEOUT_MILLIS = 1000; // 1 second
4140

4241
interface matchingElementProps {
4342
id: string;
4443
name: string;
45-
type: string;
44+
type: ElementType;
4645
pathName: string[];
4746
pathUuid: string[];
4847
}
@@ -161,7 +160,7 @@ export const SearchBar: FunctionComponent<SearchBarProps> = ({ inputRef }) => {
161160
if (matchingElement !== undefined) {
162161
const elementUuidPath = matchingElement?.pathUuid.reverse();
163162
const promises = elementUuidPath.map((e: string) => {
164-
return fetchDirectoryContent(e)
163+
return fetchDirectoryContent(e as UUID)
165164
.then((res: IElement[]) => {
166165
updateMapData(
167166
e,

0 commit comments

Comments
 (0)