Skip to content

Commit d9476d4

Browse files
update printWidth to 120 (#46)
1 parent f53075b commit d9476d4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+268
-726
lines changed

.eslintrc.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
{
22
"root": true,
3-
"extends": [
4-
"react-app",
5-
"plugin:prettier/recommended"
6-
],
3+
"extends": ["react-app", "plugin:prettier/recommended"],
74
"ignorePatterns": [
85
// node_modules is implicitly always ignored
96
"build"

.prettierrc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"trailingComma": "es5",
33
"tabWidth": 4,
4+
"printWidth": 120,
45
"singleQuote": true
56
}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# GridAdmin-App
2+
23
Application to manage users in GridSuite.
34

45
## Typescript config

src/components/App/app-top-bar.tsx

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,12 @@
55
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
66
*/
77

8-
import {
9-
forwardRef,
10-
FunctionComponent,
11-
ReactElement,
12-
useEffect,
13-
useMemo,
14-
useState,
15-
} from 'react';
8+
import { forwardRef, FunctionComponent, ReactElement, useEffect, useMemo, useState } from 'react';
169
import { capitalize, Tab, Tabs, useTheme } from '@mui/material';
1710
import { ManageAccounts, PeopleAlt } from '@mui/icons-material';
1811
import { logout, TopBar } from '@gridsuite/commons-ui';
1912
import { useParameterState } from '../parameters';
20-
import {
21-
APP_NAME,
22-
PARAM_LANGUAGE,
23-
PARAM_THEME,
24-
} from '../../utils/config-params';
13+
import { APP_NAME, PARAM_LANGUAGE, PARAM_THEME } from '../../utils/config-params';
2514
import { NavLink, useMatches, useNavigate } from 'react-router-dom';
2615
import { useDispatch, useSelector } from 'react-redux';
2716
import { FormattedMessage } from 'react-intl';
@@ -68,9 +57,7 @@ const AppTopBar: FunctionComponent = () => {
6857
const theme = useTheme();
6958
const dispatch = useDispatch<AppDispatch>();
7059
const user = useSelector((state: AppState) => state.user);
71-
const userManagerInstance = useSelector(
72-
(state: AppState) => state.userManager?.instance
73-
);
60+
const userManagerInstance = useSelector((state: AppState) => state.userManager?.instance);
7461

7562
const navigate = useNavigate();
7663
const matches = useMatches();
@@ -84,8 +71,7 @@ const AppTopBar: FunctionComponent = () => {
8471
}, [matches]);
8572

8673
const [themeLocal, handleChangeTheme] = useParameterState(PARAM_THEME);
87-
const [languageLocal, handleChangeLanguage] =
88-
useParameterState(PARAM_LANGUAGE);
74+
const [languageLocal, handleChangeLanguage] = useParameterState(PARAM_LANGUAGE);
8975

9076
const [appsAndUrls, setAppsAndUrls] = useState<MetadataJson[]>([]);
9177
useEffect(() => {
@@ -100,24 +86,14 @@ const AppTopBar: FunctionComponent = () => {
10086
<TopBar
10187
appName={capitalize(APP_NAME)}
10288
appColor="#FD3745"
103-
appLogo={
104-
theme.palette.mode === 'light' ? (
105-
<GridAdminLogoLight />
106-
) : (
107-
<GridAdminLogoDark />
108-
)
109-
}
89+
appLogo={theme.palette.mode === 'light' ? <GridAdminLogoLight /> : <GridAdminLogoDark />}
11090
appVersion={AppPackage.version}
11191
appLicense={AppPackage.license}
11292
onLogoutClick={() => logout(dispatch, userManagerInstance)}
11393
onLogoClick={() => navigate('/', { replace: true })}
11494
user={user ?? undefined}
11595
appsAndUrls={appsAndUrls}
116-
globalVersionPromise={() =>
117-
AppsMetadataSrv.fetchVersion().then(
118-
(res) => res?.deployVersion ?? 'unknown'
119-
)
120-
}
96+
globalVersionPromise={() => AppsMetadataSrv.fetchVersion().then((res) => res?.deployVersion ?? 'unknown')}
12197
additionalModulesPromise={StudySrv.getServersInfos}
12298
onThemeClick={handleChangeTheme}
12399
theme={themeLocal}

src/components/App/app-wrapper.tsx

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,7 @@
88
import App from './app';
99
import { FunctionComponent, useMemo } from 'react';
1010
import { CssBaseline, responsiveFontSizes, ThemeOptions } from '@mui/material';
11-
import {
12-
createTheme,
13-
StyledEngineProvider,
14-
Theme,
15-
ThemeProvider,
16-
} from '@mui/material/styles';
11+
import { createTheme, StyledEngineProvider, Theme, ThemeProvider } from '@mui/material/styles';
1712
import { enUS as MuiCoreEnUS, frFR as MuiCoreFrFR } from '@mui/material/locale';
1813
import {
1914
card_error_boundary_en,
@@ -121,20 +116,11 @@ const basename = new URL(document.baseURI ?? '').pathname;
121116
* Layer injecting Theme, Internationalization (i18n) and other tools (snackbar, error boundary, ...)
122117
*/
123118
const AppWrapperRouterLayout: typeof App = (props, context) => {
124-
const computedLanguage = useSelector(
125-
(state: AppState) => state.computedLanguage
126-
);
119+
const computedLanguage = useSelector((state: AppState) => state.computedLanguage);
127120
const theme = useSelector((state: AppState) => state[PARAM_THEME]);
128-
const themeCompiled = useMemo(
129-
() => getMuiTheme(theme, computedLanguage),
130-
[computedLanguage, theme]
131-
);
121+
const themeCompiled = useMemo(() => getMuiTheme(theme, computedLanguage), [computedLanguage, theme]);
132122
return (
133-
<IntlProvider
134-
locale={computedLanguage}
135-
defaultLocale={LANG_ENGLISH}
136-
messages={messages[computedLanguage]}
137-
>
123+
<IntlProvider locale={computedLanguage} defaultLocale={LANG_ENGLISH} messages={messages[computedLanguage]}>
138124
<StyledEngineProvider injectFirst>
139125
<ThemeProvider theme={themeCompiled}>
140126
<SnackbarProvider hideIconVariant={false}>

src/components/App/app.test.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@ import { Provider } from 'react-redux';
88
import { createMemoryRouter, Outlet, RouterProvider } from 'react-router-dom';
99
import App from './app';
1010
import { store } from '../../redux/store';
11-
import {
12-
createTheme,
13-
StyledEngineProvider,
14-
ThemeProvider,
15-
} from '@mui/material/styles';
11+
import { createTheme, StyledEngineProvider, ThemeProvider } from '@mui/material/styles';
1612
import { SnackbarProvider } from '@gridsuite/commons-ui';
1713
import { CssBaseline } from '@mui/material';
1814
import { appRoutes } from '../../routes';
@@ -37,9 +33,7 @@ it.skip('renders', async () => {
3733
throw new Error('No container was defined');
3834
}
3935
const root = createRoot(container);
40-
const AppWrapperRouterLayout: FunctionComponent<
41-
PropsWithChildren<{}>
42-
> = () => (
36+
const AppWrapperRouterLayout: FunctionComponent<PropsWithChildren<{}>> = () => (
4337
<IntlProvider locale="en">
4438
<StyledEngineProvider injectFirst>
4539
<ThemeProvider theme={createTheme({})}>

src/components/App/app.tsx

Lines changed: 26 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,14 @@
55
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
66
*/
77

8-
import {
9-
FunctionComponent,
10-
PropsWithChildren,
11-
useCallback,
12-
useEffect,
13-
} from 'react';
8+
import { FunctionComponent, PropsWithChildren, useCallback, useEffect } from 'react';
149
import { useDispatch, useSelector } from 'react-redux';
1510
import { Grid } from '@mui/material';
1611
import { CardErrorBoundary, useSnackMessage } from '@gridsuite/commons-ui';
17-
import {
18-
selectComputedLanguage,
19-
selectLanguage,
20-
selectTheme,
21-
} from '../../redux/actions';
12+
import { selectComputedLanguage, selectLanguage, selectTheme } from '../../redux/actions';
2213
import { AppState } from '../../redux/reducer';
2314
import { ConfigNotif, ConfigParameters, ConfigSrv } from '../../services';
24-
import {
25-
APP_NAME,
26-
COMMON_APP_NAME,
27-
PARAM_LANGUAGE,
28-
PARAM_THEME,
29-
} from '../../utils/config-params';
15+
import { APP_NAME, COMMON_APP_NAME, PARAM_LANGUAGE, PARAM_THEME } from '../../utils/config-params';
3016
import { getComputedLanguage } from '../../utils/language';
3117
import AppTopBar from './app-top-bar';
3218
import ReconnectingWebSocket from 'reconnecting-websocket';
@@ -51,11 +37,7 @@ const App: FunctionComponent<PropsWithChildren<{}>> = (props, context) => {
5137
break;
5238
case PARAM_LANGUAGE:
5339
dispatch(selectLanguage(param.value));
54-
dispatch(
55-
selectComputedLanguage(
56-
getComputedLanguage(param.value)
57-
)
58-
);
40+
dispatch(selectComputedLanguage(getComputedLanguage(param.value)));
5941
break;
6042
default:
6143
break;
@@ -65,29 +47,26 @@ const App: FunctionComponent<PropsWithChildren<{}>> = (props, context) => {
6547
[dispatch]
6648
);
6749

68-
const connectNotificationsUpdateConfig =
69-
useCallback((): ReconnectingWebSocket => {
70-
const ws = ConfigNotif.connectNotificationsWsUpdateConfig();
71-
ws.onmessage = function (event) {
72-
let eventData = JSON.parse(event.data);
73-
if (eventData?.headers?.parameterName) {
74-
ConfigSrv.fetchConfigParameter(
75-
eventData.headers.parameterName
76-
)
77-
.then((param) => updateParams([param]))
78-
.catch((error) =>
79-
snackError({
80-
messageTxt: error.message,
81-
headerId: 'paramsRetrievingError',
82-
})
83-
);
84-
}
85-
};
86-
ws.onerror = function (event) {
87-
console.error('Unexpected Notification WebSocket error', event);
88-
};
89-
return ws;
90-
}, [updateParams, snackError]);
50+
const connectNotificationsUpdateConfig = useCallback((): ReconnectingWebSocket => {
51+
const ws = ConfigNotif.connectNotificationsWsUpdateConfig();
52+
ws.onmessage = function (event) {
53+
let eventData = JSON.parse(event.data);
54+
if (eventData?.headers?.parameterName) {
55+
ConfigSrv.fetchConfigParameter(eventData.headers.parameterName)
56+
.then((param) => updateParams([param]))
57+
.catch((error) =>
58+
snackError({
59+
messageTxt: error.message,
60+
headerId: 'paramsRetrievingError',
61+
})
62+
);
63+
}
64+
};
65+
ws.onerror = function (event) {
66+
console.error('Unexpected Notification WebSocket error', event);
67+
};
68+
return ws;
69+
}, [updateParams, snackError]);
9170

9271
useEffect(() => {
9372
if (user !== null) {
@@ -112,13 +91,7 @@ const App: FunctionComponent<PropsWithChildren<{}>> = (props, context) => {
11291
const ws = connectNotificationsUpdateConfig();
11392
return () => ws.close();
11493
}
115-
}, [
116-
user,
117-
dispatch,
118-
updateParams,
119-
snackError,
120-
connectNotificationsUpdateConfig,
121-
]);
94+
}, [user, dispatch, updateParams, snackError, connectNotificationsUpdateConfig]);
12295

12396
return (
12497
<Grid
@@ -131,9 +104,7 @@ const App: FunctionComponent<PropsWithChildren<{}>> = (props, context) => {
131104
>
132105
<Grid item xs="auto" component={AppTopBar} />
133106
<Grid item container xs component="main">
134-
<CardErrorBoundary>
135-
{/*Router outlet ->*/ props.children}
136-
</CardErrorBoundary>
107+
<CardErrorBoundary>{/*Router outlet ->*/ props.children}</CardErrorBoundary>
137108
</Grid>
138109
</Grid>
139110
);

src/components/Grid/AgGrid.tsx

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,8 @@ type ForwardRefComponent<Props, Ref> = ReturnType<ForwardRef<Props, Ref>>;
4949

5050
interface AgGridWithRef extends FunctionComponent<GridOptions<unknown>> {
5151
<TData, TContext extends {}>(
52-
props: PropsWithoutRef<GridOptions<TData>> &
53-
RefAttributes<AgGridRef<TData, TContext>>
54-
): ReturnType<
55-
ForwardRefComponent<GridOptions<TData>, AgGridRef<TData, TContext>>
56-
>;
52+
props: PropsWithoutRef<GridOptions<TData>> & RefAttributes<AgGridRef<TData, TContext>>
53+
): ReturnType<ForwardRefComponent<GridOptions<TData>, AgGridRef<TData, TContext>>>;
5754
}
5855

5956
const style = {
@@ -65,10 +62,7 @@ const style = {
6562
},
6663
};
6764

68-
export const AgGrid: AgGridWithRef = forwardRef(function AgGrid<
69-
TData,
70-
TContext extends {} = {}
71-
>(
65+
export const AgGrid: AgGridWithRef = forwardRef(function AgGrid<TData, TContext extends {} = {}>(
7266
props: GridOptions<TData>,
7367
gridRef?: ForwardedRef<AgGridRef<TData, TContext>>
7468
): ReactNode {
@@ -94,15 +88,9 @@ export const AgGrid: AgGridWithRef = forwardRef(function AgGrid<
9488
<Box component="div" className={theme.agGridTheme} sx={style}>
9589
<AgGridReact<TData>
9690
ref={agGridRef}
97-
localeText={
98-
messages[intl.locale] ??
99-
messages[intl.defaultLocale] ??
100-
undefined
101-
}
91+
localeText={messages[intl.locale] ?? messages[intl.defaultLocale] ?? undefined}
10292
{...props} //destruct props to optimize react props change detection
103-
debug={
104-
import.meta.env.VITE_DEBUG_AGGRID === 'true' || props.debug
105-
}
93+
debug={import.meta.env.VITE_DEBUG_AGGRID === 'true' || props.debug}
10694
reactiveCustomComponents //AG Grid: Using custom components without `reactiveCustomComponents = true` is deprecated.
10795
/>
10896
</Box>

0 commit comments

Comments
 (0)