console.log('onRowClick', args)}
onClick={(...args) => console.log('onClick', args)}
onCellClick={(...args) => console.log('onCellClick', args)}
diff --git a/demo/src/TreeViewFinderConfig.jsx b/demo/src/TreeViewFinderConfig.jsx
index 9dcf5432..dbce87da 100644
--- a/demo/src/TreeViewFinderConfig.jsx
+++ b/demo/src/TreeViewFinderConfig.jsx
@@ -6,15 +6,7 @@
*/
import PropTypes from 'prop-types';
-import {
- Checkbox,
- FormControl,
- FormControlLabel,
- FormGroup,
- FormLabel,
- Radio,
- RadioGroup,
-} from '@mui/material';
+import { Checkbox, FormControl, FormControlLabel, FormGroup, FormLabel, Radio, RadioGroup } from '@mui/material';
/**
* TreeViewFinderConfig documentation:
@@ -66,69 +58,39 @@ function TreeViewFinderConfig(props) {
}}
>
-
- Data Format
-
+ Data Format
- }
- label="Tree"
- />
- }
- label="List"
- />
+ } label="Tree" />
+ } label="List" />
-
- Data update
-
+ Data update
- }
- label="static"
- />
- }
- label="dynamic"
- />
+ } label="static" />
+ } label="dynamic" />
-
- Selection Type
-
+ Selection Type
- }
- label="single selection"
- />
- }
- label="multiselect"
- />
+ } label="single selection" />
+ } label="multiselect" />
@@ -136,11 +98,7 @@ function TreeViewFinderConfig(props) {
+
}
label="Only leaves selection"
/>
diff --git a/demo/src/app.jsx b/demo/src/app.jsx
index 6ad017b2..3a30de0a 100644
--- a/demo/src/app.jsx
+++ b/demo/src/app.jsx
@@ -76,10 +76,7 @@ import PowsyblLogo from '../images/powsybl_logo.svg?react';
import AppPackage from '../../package.json';
import ReportViewerDialog from '../../src/components/ReportViewerDialog';
-import {
- TreeViewFinder,
- generateTreeViewFinderClass,
-} from '../../src/components/TreeViewFinder';
+import { TreeViewFinder, generateTreeViewFinderClass } from '../../src/components/TreeViewFinder';
import TreeViewFinderConfig from './TreeViewFinderConfig';
import {
@@ -182,13 +179,8 @@ const TreeViewFinderCustomStyles = (theme) => ({
});
const TreeViewFinderCustomStylesEmotion = ({ theme }) =>
- toNestedGlobalSelectors(
- TreeViewFinderCustomStyles(theme),
- generateTreeViewFinderClass
- );
-const CustomTreeViewFinder = styled(TreeViewFinder)(
- TreeViewFinderCustomStylesEmotion
-);
+ toNestedGlobalSelectors(TreeViewFinderCustomStyles(theme), generateTreeViewFinderClass);
+const CustomTreeViewFinder = styled(TreeViewFinder)(TreeViewFinderCustomStylesEmotion);
function Crasher() {
const [crash, setCrash] = useState(false);
@@ -309,12 +301,8 @@ function AppContent({ language, onLanguageClick }) {
error: null,
});
const [user, setUser] = useState(null);
- const [authenticationRouterError, setAuthenticationRouterError] =
- useState(null);
- const [
- showAuthenticationRouterLoginState,
- setShowAuthenticationRouterLoginState,
- ] = useState(false);
+ const [authenticationRouterError, setAuthenticationRouterError] = useState(null);
+ const [showAuthenticationRouterLoginState, setShowAuthenticationRouterLoginState] = useState(false);
const [theme, setTheme] = useState(LIGHT_THEME);
@@ -323,17 +311,11 @@ function AppContent({ language, onLanguageClick }) {
const [equipmentLabelling, setEquipmentLabelling] = useState(false);
const [openReportViewer, setOpenReportViewer] = useState(false);
- const [openTreeViewFinderDialog, setOpenTreeViewFinderDialog] =
- useState(false);
- const [
- openTreeViewFinderDialogCustomDialog,
- setOpenTreeViewFinderDialogCustomDialog,
- ] = useState(false);
+ const [openTreeViewFinderDialog, setOpenTreeViewFinderDialog] = useState(false);
+ const [openTreeViewFinderDialogCustomDialog, setOpenTreeViewFinderDialogCustomDialog] = useState(false);
// Can't use lazy initializer because useMatch is a hook
- const [initialMatchSilentRenewCallbackUrl] = useState(
- useMatch('/silent-renew-callback')
- );
+ const [initialMatchSilentRenewCallbackUrl] = useState(useMatch('/silent-renew-callback'));
// TreeViewFinder data
const [nodesTree, setNodesTree] = useState(testDataTree);
@@ -382,9 +364,7 @@ function AppContent({ language, onLanguageClick }) {
if (equipment != null) {
equipment.type === EQUIPMENT_TYPE.SUBSTATION.name
? alert(`Equipment ${equipment.label} found !`)
- : alert(
- `Equipment ${equipment.label} (${equipment.voltageLevelLabel}) found !`
- );
+ : alert(`Equipment ${equipment.label} (${equipment.voltageLevelLabel}) found !`);
}
};
const [searchTermDisableReason] = useState('search disabled');
@@ -402,9 +382,7 @@ function AppContent({ language, onLanguageClick }) {
} else if (e.type === 'RESET_AUTHENTICATION_ROUTER_ERROR') {
setAuthenticationRouterError(null);
} else if (e.type === 'SHOW_AUTH_INFO_LOGIN') {
- setShowAuthenticationRouterLoginState(
- e.showAuthenticationRouterLogin
- );
+ setShowAuthenticationRouterLoginState(e.showAuthenticationRouterLogin);
}
};
@@ -428,11 +406,7 @@ function AppContent({ language, onLanguageClick }) {
];
useEffect(() => {
- initializeAuthenticationDev(
- dispatch,
- initialMatchSilentRenewCallbackUrl != null,
- validateUser
- )
+ initializeAuthenticationDev(dispatch, initialMatchSilentRenewCallbackUrl != null, validateUser)
.then((userManager) => {
setUserManager({
instance: userManager,
@@ -471,21 +445,14 @@ function AppContent({ language, onLanguageClick }) {
return a.name.localeCompare(b.name);
}
- const handleToggleDisableSearch = useCallback(
- () => setSearchDisabled((oldState) => !oldState),
- []
- );
+ const handleToggleDisableSearch = useCallback(() => setSearchDisabled((oldState) => !oldState), []);
const aboutTimerVersion = useRef();
const aboutTimerCmpnt = useRef();
function simulateGetGlobalVersion() {
console.log('getGlobalVersion() called');
return new Promise(
- (resolve, reject) =>
- (aboutTimerVersion.current = window.setTimeout(
- () => resolve('1.0.0-demo'),
- 1250
- ))
+ (resolve, reject) => (aboutTimerVersion.current = window.setTimeout(() => resolve('1.0.0-demo'), 1250))
);
}
function simulateGetAdditionalComponents() {
@@ -619,21 +586,11 @@ function AppContent({ language, onLanguageClick }) {
multiSelect={multiSelect}
onlyLeaves={onlyLeaves}
sortedAlphabetically={sortedAlphabetically}
- onDynamicDataChange={(event) =>
- setDynamicData(event.target.value === 'dynamic')
- }
- onDataFormatChange={(event) =>
- setDataFormat(event.target.value)
- }
- onSelectionTypeChange={(event) =>
- setMultiSelect(event.target.value === 'multiselect')
- }
- onOnlyLeavesChange={(event) =>
- setOnlyLeaves(event.target.checked)
- }
- onSortedAlphabeticallyChange={(event) =>
- setSortedAlphabetically(event.target.checked)
- }
+ onDynamicDataChange={(event) => setDynamicData(event.target.value === 'dynamic')}
+ onDataFormatChange={(event) => setDataFormat(event.target.value)}
+ onSelectionTypeChange={(event) => setMultiSelect(event.target.value === 'multiselect')}
+ onOnlyLeavesChange={(event) => setOnlyLeaves(event.target.checked)}
+ onSortedAlphabeticallyChange={(event) => setSortedAlphabetically(event.target.checked)}
/>
@@ -766,10 +717,7 @@ function AppContent({ language, onLanguageClick }) {
onChange={() => {
setSearchTermDisabled(!searchTermDisabled);
// TO TEST search activation after some times
- setTimeout(
- () => setSearchTermDisabled(false),
- 4000
- );
+ setTimeout(() => setSearchTermDisabled(false), 4000);
}}
name="search-disabled"
/>
@@ -794,21 +742,15 @@ function AppContent({ language, onLanguageClick }) {
appColor="#808080"
appLogo={}
onParametersClick={() => console.log('settings')}
- onLogoutClick={() =>
- logout(dispatch, userManager.instance)
- }
+ onLogoutClick={() => logout(dispatch, userManager.instance)}
onLogoClick={() => console.log('logo')}
onThemeClick={handleThemeClick}
theme={theme}
appVersion={AppPackage.version}
appLicense={AppPackage.license}
globalVersionPromise={simulateGetGlobalVersion}
- additionalModulesPromise={
- simulateGetAdditionalComponents
- }
- onEquipmentLabellingClick={
- handleEquipmentLabellingClick
- }
+ additionalModulesPromise={simulateGetAdditionalComponents}
+ onEquipmentLabellingClick={handleEquipmentLabellingClick}
equipmentLabelling={equipmentLabelling}
withElementsSearch
searchingLabel={intl.formatMessage({
@@ -821,11 +763,7 @@ function AppContent({ language, onLanguageClick }) {
searchTermDisableReason={searchTermDisableReason}
elementsFound={equipmentsFound}
renderElement={(props) => (
-
+
)}
onLanguageClick={onLanguageClick}
language={language}
@@ -849,12 +787,7 @@ function AppContent({ language, onLanguageClick }) {
{user !== null ? (
-
- setTabIndex(newTabIndex)
- }
- >
+ setTabIndex(newTabIndex)}>
@@ -869,12 +802,8 @@ function AppContent({ language, onLanguageClick }) {
-
-
+
+
);
diff --git a/demo/src/equipment-search.tsx b/demo/src/equipment-search.tsx
index eca1e660..771ce301 100644
--- a/demo/src/equipment-search.tsx
+++ b/demo/src/equipment-search.tsx
@@ -8,13 +8,7 @@ import { useState } from 'react';
import { Button, TextField } from '@mui/material';
import { Search } from '@mui/icons-material';
import { useIntl } from 'react-intl';
-import {
- ElementSearchDialog,
- EquipmentItem,
- equipmentStyles,
- EquipmentType,
- useElementSearch,
-} from '../../src/index';
+import { ElementSearchDialog, EquipmentItem, equipmentStyles, EquipmentType, useElementSearch } from '../../src/index';
interface AnyElementInterface {
id: string;
@@ -49,10 +43,9 @@ const searchEquipmentPromise = () => {
export function EquipmentSearchDialog() {
const [isSearchOpen, setIsSearchOpen] = useState(false);
- const { elementsFound, isLoading, searchTerm, updateSearchTerm } =
- useElementSearch({
- fetchElements: searchEquipmentPromise,
- });
+ const { elementsFound, isLoading, searchTerm, updateSearchTerm } = useElementSearch({
+ fetchElements: searchEquipmentPromise,
+ });
const intl = useIntl();
@@ -68,18 +61,12 @@ export function EquipmentSearchDialog() {
}}
elementsFound={elementsFound}
renderElement={(props: any) => (
-
+
)}
searchTerm={searchTerm}
loading={isLoading}
getOptionLabel={(option) => option.label}
- isOptionEqualToValue={(option1, option2) =>
- option1.id === option2.id
- }
+ isOptionEqualToValue={(option1, option2) => option1.id === option2.id}
renderInput={(displayedValue, params) => (
(
-
+
)}
searchTerm={searchTerm}
loading={isLoading}
getOptionLabel={(option) => option.label}
- isOptionEqualToValue={(option1, option2) =>
- option1.id === option2.id
- }
+ isOptionEqualToValue={(option1, option2) => option1.id === option2.id}
renderInput={(displayedValue, params) => (
>(
- (props, ref) =>
-);
+const SvgrMock = forwardRef>((props, ref) => );
export default SvgrMock;
diff --git a/src/components/AuthenticationRouter/AuthenticationRouter.tsx b/src/components/AuthenticationRouter/AuthenticationRouter.tsx
index 2772b73d..204345ef 100644
--- a/src/components/AuthenticationRouter/AuthenticationRouter.tsx
+++ b/src/components/AuthenticationRouter/AuthenticationRouter.tsx
@@ -6,23 +6,12 @@
*/
import { Dispatch, useCallback } from 'react';
-import {
- Location,
- Navigate,
- NavigateFunction,
- Route,
- Routes,
-} from 'react-router-dom';
+import { Location, Navigate, NavigateFunction, Route, Routes } from 'react-router-dom';
import { Alert, AlertTitle, Grid } from '@mui/material';
import { FormattedMessage } from 'react-intl';
import { UserManager } from 'oidc-client';
import SignInCallbackHandler from '../SignInCallbackHandler';
-import {
- handleSigninCallback,
- handleSilentRenewCallback,
- login,
- logout,
-} from '../../utils/AuthService';
+import { handleSigninCallback, handleSilentRenewCallback, login, logout } from '../../utils/AuthService';
import SilentRenewCallbackHandler from '../SilentRenewCallbackHandler';
import Login from '../Login';
import Logout from '../Login/Logout';
@@ -71,15 +60,8 @@ function AuthenticationRouter({
}
}, [userManager.instance]);
return (
-
- {userManager.error !== null && (
- Error : Getting userManager; {userManager.error}
- )}
+
+ {userManager.error !== null && Error : Getting userManager; {userManager.error}
}
{signInCallbackError !== null && (
Error : SignIn Callback Error;
@@ -101,9 +83,7 @@ function AuthenticationRouter({
element={
}
/>
@@ -115,9 +95,7 @@ function AuthenticationRouter({
authenticationRouterError == null && (
- login(location, userManager.instance)
- }
+ onLoginClick={() => login(location, userManager.instance)}
/>
)
}
@@ -129,9 +107,7 @@ function AuthenticationRouter({
- logout(dispatch, userManager.instance)
- }
+ onLogoutClick={() => logout(dispatch, userManager.instance)}
/>
@@ -143,20 +119,13 @@ function AuthenticationRouter({
-
- {
- authenticationRouterError.logoutError
- .error.message
- }
-
+ {authenticationRouterError.logoutError.error.message}
)}
- {authenticationRouterError?.userValidationError !=
- null && (
+ {authenticationRouterError?.userValidationError != null && (
@@ -164,20 +133,13 @@ function AuthenticationRouter({
-
- {
- authenticationRouterError
- .userValidationError.error.message
- }
-
+ {authenticationRouterError.userValidationError.error.message}
)}
- {authenticationRouterError?.unauthorizedUserInfo !=
- null && (
+ {authenticationRouterError?.unauthorizedUserInfo != null && (
@@ -185,8 +147,7 @@ function AuthenticationRouter({
diff --git a/src/components/CardErrorBoundary/card-error-boundary.tsx b/src/components/CardErrorBoundary/card-error-boundary.tsx
index 71494f9f..c3f86a50 100644
--- a/src/components/CardErrorBoundary/card-error-boundary.tsx
+++ b/src/components/CardErrorBoundary/card-error-boundary.tsx
@@ -9,10 +9,7 @@
// https://reactjs.org/docs/error-boundaries.html
// https://mui.com/material-ui/react-card/#complex-interaction
-import {
- ExpandMore as ExpandMoreIcon,
- Replay as ReplayIcon,
-} from '@mui/icons-material';
+import { ExpandMore as ExpandMoreIcon, Replay as ReplayIcon } from '@mui/icons-material';
import {
Box,
Card,
@@ -59,10 +56,7 @@ type CardErrorBoundaryStateSuccess = {
hasError: false;
};
-type CardErrorBoundaryState = (
- | CardErrorBoundaryStateError
- | CardErrorBoundaryStateSuccess
-) & {
+type CardErrorBoundaryState = (CardErrorBoundaryStateError | CardErrorBoundaryStateSuccess) & {
expanded: boolean;
};
@@ -126,10 +120,7 @@ class CardErrorBoundary extends Component {
-
+
{
-
+
-
- {error.message}
-
+ {error.message}
diff --git a/src/components/CustomAGGrid/custom-aggrid.style.ts b/src/components/CustomAGGrid/custom-aggrid.style.ts
index bb1613bd..9ad9c15d 100644
--- a/src/components/CustomAGGrid/custom-aggrid.style.ts
+++ b/src/components/CustomAGGrid/custom-aggrid.style.ts
@@ -16,8 +16,7 @@ export const styles = {
position: 'relative',
[`&.${CUSTOM_AGGRID_THEME}`]: {
- '--ag-value-change-value-highlight-background-color':
- theme.aggrid.valueChangeHighlightBackgroundColor,
+ '--ag-value-change-value-highlight-background-color': theme.aggrid.valueChangeHighlightBackgroundColor,
'--ag-selected-row-background-color': theme.aggrid.highlightColor,
'--ag-row-hover-color': theme.aggrid.highlightColor,
},
diff --git a/src/components/CustomAGGrid/custom-aggrid.tsx b/src/components/CustomAGGrid/custom-aggrid.tsx
index abb55ee5..c26f2b5d 100644
--- a/src/components/CustomAGGrid/custom-aggrid.tsx
+++ b/src/components/CustomAGGrid/custom-aggrid.tsx
@@ -36,60 +36,52 @@ const onColumnResized = (params: ColumnResizedEvent) => {
}
};
-const CustomAGGrid = React.forwardRef(
- (props, ref) => {
- const {
- shouldHidePinnedHeaderRightBorder = false,
- overlayNoRowsTemplate,
- loadingOverlayComponent,
- loadingOverlayComponentParams,
- showOverlay = false,
- } = props;
- const theme = useTheme();
- const intl = useIntl();
+const CustomAGGrid = React.forwardRef((props, ref) => {
+ const {
+ shouldHidePinnedHeaderRightBorder = false,
+ overlayNoRowsTemplate,
+ loadingOverlayComponent,
+ loadingOverlayComponentParams,
+ showOverlay = false,
+ } = props;
+ const theme = useTheme();
+ const intl = useIntl();
- const GRID_PREFIX = 'grid.';
+ const GRID_PREFIX = 'grid.';
- const getLocaleText = useCallback(
- (params: GetLocaleTextParams) => {
- const key = GRID_PREFIX + params.key;
- return intl.formatMessage({
- id: key,
- defaultMessage: params.defaultValue,
- });
- },
- [intl]
- );
+ const getLocaleText = useCallback(
+ (params: GetLocaleTextParams) => {
+ const key = GRID_PREFIX + params.key;
+ return intl.formatMessage({
+ id: key,
+ defaultMessage: params.defaultValue,
+ });
+ },
+ [intl]
+ );
- return (
-
-
-
- );
- }
-);
+ return (
+
+
+
+ );
+});
export default CustomAGGrid;
diff --git a/src/components/DirectoryItemSelector/directory-item-selector.tsx b/src/components/DirectoryItemSelector/directory-item-selector.tsx
index 7416858b..f47e09c4 100644
--- a/src/components/DirectoryItemSelector/directory-item-selector.tsx
+++ b/src/components/DirectoryItemSelector/directory-item-selector.tsx
@@ -10,16 +10,9 @@ import { SxProps, Theme } from '@mui/material';
import { UUID } from 'crypto';
import getFileIcon from '../../utils/ElementIcon';
import { ElementType } from '../../utils/ElementType';
-import TreeViewFinder, {
- TreeViewFinderNodeProps,
- TreeViewFinderProps,
-} from '../TreeViewFinder/TreeViewFinder';
+import TreeViewFinder, { TreeViewFinderNodeProps, TreeViewFinderProps } from '../TreeViewFinder/TreeViewFinder';
import { useSnackMessage } from '../../hooks/useSnackMessage';
-import {
- fetchDirectoryContent,
- fetchElementsInfos,
- fetchRootFolders,
-} from '../../services';
+import { fetchDirectoryContent, fetchElementsInfos, fetchRootFolders } from '../../services';
const styles = {
icon: (theme: Theme) => ({
@@ -44,10 +37,7 @@ function flattenDownNodes(n: any, cef: (n: any) => any[]): any[] {
if (subs.length === 0) {
return [n];
}
- return Array.prototype.concat(
- [n],
- ...subs.map((sn: any) => flattenDownNodes(sn, cef))
- );
+ return Array.prototype.concat([n], ...subs.map((sn: any) => flattenDownNodes(sn, cef)));
}
function refreshedUpNodes(m: any[], nn: any): any[] {
@@ -58,9 +48,7 @@ function refreshedUpNodes(m: any[], nn: any): any[] {
return [nn];
}
const parent = m[nn.parentUuid];
- const nextChildren = parent.children.map((c: any) =>
- c.elementUuid === nn.elementUuid ? nn : c
- );
+ const nextChildren = parent.children.map((c: any) => (c.elementUuid === nn.elementUuid ? nn : c));
const nextParent = { ...parent, children: nextChildren };
return [nn, ...refreshedUpNodes(m, nextParent)];
}
@@ -72,12 +60,7 @@ function refreshedUpNodes(m: any[], nn: any): any[] {
* @param nodeId uuid of the node to update children, may be null or undefined (means root)
* @param children new value of the node children (shallow nodes)
*/
-function updatedTree(
- prevRoots: any[],
- prevMap: any,
- nodeId: UUID | null,
- children: any[]
-) {
+function updatedTree(prevRoots: any[], prevMap: any, nodeId: UUID | null, children: any[]) {
const nextChildren = children
.sort((a, b) => a.elementName.localeCompare(b.elementName))
.map((n: any) => {
@@ -113,12 +96,8 @@ function updatedTree(
return [prevRoots, prevMap];
}
- const nextUuids = new Set(
- children ? children.map((n) => n.elementUuid) : []
- );
- const prevUuids = prevChildren
- ? prevChildren.map((n: any) => n.elementUuid)
- : [];
+ const nextUuids = new Set(children ? children.map((n) => n.elementUuid) : []);
+ const prevUuids = prevChildren ? prevChildren.map((n: any) => n.elementUuid) : [];
const mayNodeId = nodeId ? [nodeId] : [];
const nonCopyUuids = new Set([
@@ -127,11 +106,7 @@ function updatedTree(
...Array.prototype.concat(
...prevUuids
.filter((u: UUID) => !nextUuids.has(u))
- .map((u: UUID) =>
- flattenDownNodes(prevMap[u], (n) => n.children).map(
- (n) => n.elementUuid
- )
- )
+ .map((u: UUID) => flattenDownNodes(prevMap[u], (n) => n.children).map((n) => n.elementUuid))
),
]);
@@ -150,10 +125,7 @@ function updatedTree(
...refreshedUpNodes(prevMap, nextNode).map((n) => [n.elementUuid, n]),
]);
- const nextRoots =
- nodeId === null
- ? nextChildren
- : prevRoots.map((r) => nextMap[r.elementUuid]);
+ const nextRoots = nodeId === null ? nextChildren : prevRoots.map((r) => nextMap[r.elementUuid]);
return [nextRoots, nextMap];
}
@@ -175,10 +147,7 @@ interface DirectoryItemSelectorProps extends TreeViewFinderProps {
expanded?: UUID[];
}
-function sortHandlingDirectories(
- a: TreeViewFinderNodeProps,
- b: TreeViewFinderNodeProps
-): number {
+function sortHandlingDirectories(a: TreeViewFinderNodeProps, b: TreeViewFinderNodeProps): number {
// If children property is set it means it's a directory, they are handled differently in order to keep them at the top of the list
if (a.children && !b.children) {
return -1;
@@ -206,10 +175,7 @@ function DirectoryItemSelector({
const rootsRef = useRef([]);
rootsRef.current = rootDirectories;
const { snackError } = useSnackMessage();
- const contentFilter = useCallback(
- () => new Set([ElementType.DIRECTORY, ...types]),
- [types]
- );
+ const contentFilter = useCallback(() => new Set([ElementType.DIRECTORY, ...types]), [types]);
const convertChildren = useCallback((children: any[]): any[] => {
return children.map((e) => {
@@ -218,14 +184,8 @@ function DirectoryItemSelector({
name: e.elementName,
specificMetadata: e.specificMetadata,
icon: getFileIcon(e.type, styles.icon as SxProps),
- children:
- e.type === ElementType.DIRECTORY
- ? convertChildren(e.children)
- : undefined,
- childrenCount:
- e.type === ElementType.DIRECTORY
- ? e.subdirectoriesCount
- : undefined,
+ children: e.type === ElementType.DIRECTORY ? convertChildren(e.children) : undefined,
+ childrenCount: e.type === ElementType.DIRECTORY ? e.subdirectoriesCount : undefined,
};
});
}, []);
@@ -239,14 +199,9 @@ function DirectoryItemSelector({
icon: getFileIcon(e.type, styles.icon as SxProps),
children:
e.type === ElementType.DIRECTORY
- ? convertChildren(
- nodeMap.current[e.elementUuid].children
- )
- : undefined,
- childrenCount:
- e.type === ElementType.DIRECTORY
- ? e.subdirectoriesCount
+ ? convertChildren(nodeMap.current[e.elementUuid].children)
: undefined,
+ childrenCount: e.type === ElementType.DIRECTORY ? e.subdirectoriesCount : undefined,
};
});
},
@@ -255,12 +210,7 @@ function DirectoryItemSelector({
const addToDirectory = useCallback(
(nodeId: UUID, content: any[]) => {
- const [nrs, mdr] = updatedTree(
- rootsRef.current,
- nodeMap.current,
- nodeId,
- content
- );
+ const [nrs, mdr] = updatedTree(rootsRef.current, nodeMap.current, nodeId, content);
setRootDirectories(nrs);
nodeMap.current = mdr;
setData(convertRoots(nrs));
@@ -271,12 +221,7 @@ function DirectoryItemSelector({
const updateRootDirectories = useCallback(() => {
fetchRootFolders(types)
.then((newData) => {
- const [nrs, mdr] = updatedTree(
- rootsRef.current,
- nodeMap.current,
- null,
- newData
- );
+ const [nrs, mdr] = updatedTree(rootsRef.current, nodeMap.current, null, newData);
setRootDirectories(nrs);
nodeMap.current = mdr;
setData(convertRoots(nrs));
@@ -294,15 +239,9 @@ function DirectoryItemSelector({
const typeList = types.includes(ElementType.DIRECTORY) ? [] : types;
fetchDirectoryContent(nodeId, typeList)
.then((children) => {
- const childrenMatchedTypes = children.filter((item: any) =>
- contentFilter().has(item.type)
- );
+ const childrenMatchedTypes = children.filter((item: any) => contentFilter().has(item.type));
- if (
- childrenMatchedTypes.length > 0 &&
- equipmentTypes &&
- equipmentTypes.length > 0
- ) {
+ if (childrenMatchedTypes.length > 0 && equipmentTypes && equipmentTypes.length > 0) {
fetchElementsInfos(
childrenMatchedTypes.map((e: any) => e.elementUuid),
types,
@@ -327,9 +266,7 @@ function DirectoryItemSelector({
}
})
.catch((error) => {
- console.warn(
- `Could not update subs (and content) of '${nodeId}' : ${error.message}`
- );
+ console.warn(`Could not update subs (and content) of '${nodeId}' : ${error.message}`);
});
},
[types, equipmentTypes, itemFilter, contentFilter, addToDirectory]
diff --git a/src/components/ElementSearchDialog/element-search-dialog.tsx b/src/components/ElementSearchDialog/element-search-dialog.tsx
index c3bdbdde..6b7bdc9c 100644
--- a/src/components/ElementSearchDialog/element-search-dialog.tsx
+++ b/src/components/ElementSearchDialog/element-search-dialog.tsx
@@ -7,13 +7,9 @@
import { useCallback } from 'react';
import { Dialog, DialogContent } from '@mui/material';
-import {
- ElementSearchInput,
- ElementSearchInputProps,
-} from './element-search-input';
+import { ElementSearchInput, ElementSearchInputProps } from './element-search-input';
-export interface ElementSearchDialogProps
- extends ElementSearchInputProps {
+export interface ElementSearchDialogProps extends ElementSearchInputProps {
onClose?: () => void;
open: boolean;
}
@@ -27,18 +23,9 @@ export function ElementSearchDialog(props: ElementSearchDialogProps) {
}, [onSearchTermChange, onClose]);
return (
-