Skip to content

Commit

Permalink
Move directory api to commons ui (#2103)
Browse files Browse the repository at this point in the history
Signed-off-by: Hugo Marcellin <[email protected]>
  • Loading branch information
Meklo authored May 29, 2024
1 parent d069e38 commit 6f2698c
Show file tree
Hide file tree
Showing 32 changed files with 172 additions and 318 deletions.
165 changes: 140 additions & 25 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"dependencies": {
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.5",
"@gridsuite/commons-ui": "0.55.0",
"@gridsuite/commons-ui": "0.59.0",
"@hookform/resolvers": "^3.3.4",
"@mui/icons-material": "^5.15.14",
"@mui/lab": "5.0.0-alpha.169",
Expand Down
5 changes: 3 additions & 2 deletions src/components/app-top-bar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,12 @@ import {
EQUIPMENT_INFOS_TYPES,
EQUIPMENT_TYPES,
} from './utils/equipment-types';
import { fetchAppsAndUrls, fetchVersion } from '../services/utils';
import { fetchVersion } from '../services/utils';
import { RunButtonContainer } from './run-button-container';
import { useComputationResultsCount } from '../hooks/use-computation-results-count';

import { Settings } from '@mui/icons-material';
import { fetchAppsMetadata } from '@gridsuite/commons-ui';

const styles = {
currentNodeBox: {
Expand Down Expand Up @@ -242,7 +243,7 @@ const AppTopBar = ({ user, tabIndex, onChangeTab, userManager }) => {

useEffect(() => {
if (user !== null) {
fetchAppsAndUrls().then((res) => {
fetchAppsMetadata().then((res) => {
setAppsAndUrls(res);
});
}
Expand Down
3 changes: 2 additions & 1 deletion src/components/create-study-dialog/import-parameters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { FunctionComponent, useCallback, useState } from 'react';
import { AdvancedParameterButton } from './advanced-parameter-button';
import { CaseImportParameters } from 'services/network-conversion';
import { Box, Divider, Theme } from '@mui/material';
import { Parameter } from '@gridsuite/commons-ui';

export interface ImportParametersProps {
formatWithParameters: CaseImportParameters[];
Expand Down Expand Up @@ -50,7 +51,7 @@ export const ImportParameters: FunctionComponent<ImportParametersProps> = (
/>
{areParamsDisplayed && (
<FlatParameters
paramsAsArray={formatWithParameters}
paramsAsArray={formatWithParameters as Parameter[]}
initValues={currentParameters}
onChange={onChange}
variant="standard"
Expand Down
4 changes: 2 additions & 2 deletions src/components/dialogs/commons/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

export function getIdOrValue(value: { id: string; label: string } | string) {
export function getIdOrValue(value: any) {
return typeof value !== 'string' ? value?.id ?? null : value;
}

export function getLabelOrValue(value: { id: string; label: string } | string) {
export function getLabelOrValue(value: any) {
return typeof value !== 'string' ? value?.label ?? null : value;
}
5 changes: 0 additions & 5 deletions src/components/dialogs/contingency-list-selector.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ import { updateConfigParameter } from '../../services/config';
import { fetchContingencyAndFiltersLists } from '../../services/directory';
import { fetchContingencyCount } from '../../services/study';
import { DirectoryItemSelector } from '@gridsuite/commons-ui';
import { fetchDirectoryContent, fetchRootFolders } from 'services/directory';
import { fetchElementsMetadata } from 'services/explore';
import { isNodeBuilt } from 'components/graph/util/model-functions';

function makeButton(onClick, message, disabled) {
Expand Down Expand Up @@ -247,9 +245,6 @@ const ContingencyListSelector = (props) => {
onClose={addFavorites}
types={CONTINGENCY_TYPES}
title={intl.formatMessage({ id: 'ContingencyListsSelection' })}
fetchDirectoryContent={fetchDirectoryContent}
fetchRootFolders={fetchRootFolders}
fetchElementsInfos={fetchElementsMetadata}
/>
</>
);
Expand Down
5 changes: 0 additions & 5 deletions src/components/dialogs/import-modification-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ import { CopyType } from '../graph/menus/network-modification-node-editor';
import { copyOrMoveModifications } from '../../services/study';
import { UUID } from 'crypto';
import { FunctionComponent } from 'react';
import { fetchDirectoryContent, fetchRootFolders } from 'services/directory';
import { fetchElementsMetadata } from 'services/explore';

/**
* Dialog to select some network modifications and append them in the current node
Expand Down Expand Up @@ -74,9 +72,6 @@ const ImportModificationDialog: FunctionComponent<
title={intl.formatMessage({
id: 'ModificationsSelection',
})}
fetchDirectoryContent={fetchDirectoryContent}
fetchRootFolders={fetchRootFolders}
fetchElementsInfos={fetchElementsMetadata}
/>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@ import { EQUIPMENT_TYPES } from 'components/utils/equipment-types';

import { DirectoryItemsInput } from '@gridsuite/commons-ui';
import { getIdOrValue } from '../../commons/utils';
import {
fetchDirectoryContent,
fetchPath,
fetchRootFolders,
} from 'services/directory';
import { fetchElementsMetadata } from 'services/explore';

const ByFilterDeletionForm = () => {
const intl = useIntl();
Expand Down Expand Up @@ -69,10 +63,6 @@ const ByFilterDeletionForm = () => {
label={'filter'}
equipmentTypes={[equipmentTypeWatch]}
disable={!equipmentTypeWatch}
fetchDirectoryContent={fetchDirectoryContent}
fetchRootFolders={fetchRootFolders}
fetchElementsInfos={fetchElementsMetadata}
fetchDirectoryElementPath={fetchPath}
/>
);
}, [equipmentTypeWatch]);
Expand Down
Loading

0 comments on commit 6f2698c

Please sign in to comment.