Skip to content

Commit c6b8399

Browse files
authored
First page : rootDirectory creation (#416)
*First Root directory creation --------- Signed-off-by: maissa SOUISSI <[email protected]>
1 parent d288663 commit c6b8399

File tree

7 files changed

+115
-2
lines changed

7 files changed

+115
-2
lines changed

src/components/directory-content.jsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ import CriteriaBasedEditionDialog from './dialogs/contingency-list/edition/crite
5252
import ExplicitNamingEditionDialog from './dialogs/contingency-list/edition/explicit-naming/explicit-naming-edition-dialog';
5353
import ScriptEditionDialog from './dialogs/contingency-list/edition/script/script-edition-dialog';
5454
import { noSelectionForCopy } from 'utils/constants';
55+
import NoContentDirectory from './no-content-directory';
5556
import { useParameterState } from './dialogs/parameters-dialog';
5657
import { PARAM_LANGUAGE } from '../utils/config-params';
5758

@@ -117,6 +118,7 @@ const initialMousePosition = {
117118
};
118119

119120
const DirectoryContent = () => {
121+
const treeData = useSelector((state) => state.treeData);
120122
const { snackError } = useSnackMessage();
121123
const dispatch = useDispatch();
122124

@@ -840,6 +842,9 @@ const DirectoryContent = () => {
840842
})),
841843
[childrenMetadata, currentChildren, getElementTypeTranslation]
842844
);
845+
const handleOpenDialog = useCallback(() => {
846+
setOpenDialog(constants.DialogsId.ADD_ROOT_DIRECTORY);
847+
}, []);
843848

844849
const renderLoadingContent = () => {
845850
return (
@@ -968,8 +973,12 @@ const DirectoryContent = () => {
968973
}
969974

970975
// If no selection or currentChildren = null (first time) render nothing
971-
// TODO : Make a beautiful page here
972976
if (!currentChildren || !selectedDirectory) {
977+
if (treeData.rootDirectories.length === 0 && treeData.initialized) {
978+
return (
979+
<NoContentDirectory handleOpenDialog={handleOpenDialog} />
980+
);
981+
}
973982
return;
974983
}
975984

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* Copyright (c) 2024, RTE (http://www.rte-france.com)
3+
* This Source Code Form is subject to the terms of the Mozilla Public
4+
* License, v. 2.0. If a copy of the MPL was not distributed with this
5+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
*/
7+
import React, { FC, ReactNode } from 'react';
8+
import { Box, useTheme } from '@mui/material';
9+
10+
interface CircleIconProps {
11+
size: number;
12+
iconStyles?: (theme: any) => React.CSSProperties; // Adjust this type based on your theme type
13+
children: ReactNode;
14+
}
15+
16+
const CircleIcon: FC<CircleIconProps> = ({ size, iconStyles, children }) => {
17+
const theme = useTheme();
18+
const circleStyles: React.CSSProperties = {
19+
display: 'flex',
20+
justifyContent: 'center',
21+
alignItems: 'center',
22+
width: size,
23+
height: size,
24+
borderRadius: size / 2,
25+
...(iconStyles && iconStyles(theme)),
26+
};
27+
28+
return <Box sx={circleStyles}>{children}</Box>;
29+
};
30+
31+
export default CircleIcon;
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/**
2+
* Copyright (c) 2024, RTE (http://www.rte-france.com)
3+
* This Source Code Form is subject to the terms of the Mozilla Public
4+
* License, v. 2.0. If a copy of the MPL was not distributed with this
5+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
*/
7+
8+
import React from 'react';
9+
import { Box, Button } from '@mui/material';
10+
import { FormattedMessage } from 'react-intl';
11+
import CircleIcon from './icons/circleIcon';
12+
import CreateNewFolderOutlinedIcon from '@mui/icons-material/CreateNewFolderOutlined';
13+
14+
const CIRCLE_SIZE = 200;
15+
16+
const stylesIcon = {
17+
circle: (theme: any) => ({
18+
backgroundColor: theme.row.primary,
19+
}),
20+
};
21+
22+
interface NoContentDirectoryProps {
23+
handleOpenDialog: () => void;
24+
}
25+
26+
const NoContentDirectory: React.FC<NoContentDirectoryProps> = ({
27+
handleOpenDialog,
28+
}) => {
29+
const styles = {
30+
noContentContainer: (theme: any) => ({
31+
display: 'flex',
32+
flexDirection: 'column',
33+
alignItems: 'center',
34+
marginTop: theme.spacing(20),
35+
}),
36+
noContentText: (theme: any) => ({
37+
color: theme.row.primary,
38+
textAlign: 'center',
39+
marginTop: theme.spacing(1),
40+
}),
41+
noContentButton: {
42+
borderRadius: '30px',
43+
},
44+
iconSize: {
45+
fontSize: CIRCLE_SIZE / 2,
46+
},
47+
};
48+
49+
return (
50+
<Box sx={styles.noContentContainer}>
51+
<CircleIcon size={CIRCLE_SIZE} iconStyles={stylesIcon.circle}>
52+
<CreateNewFolderOutlinedIcon sx={styles.iconSize} />
53+
</CircleIcon>
54+
<Box sx={styles.noContentText}>
55+
<h1>
56+
<FormattedMessage id={'createFirstDir'} />
57+
</h1>
58+
<Button
59+
variant="contained"
60+
sx={styles.noContentButton}
61+
onClick={handleOpenDialog}
62+
>
63+
<FormattedMessage id={'createFolder'} />
64+
</Button>
65+
</Box>
66+
</Box>
67+
);
68+
};
69+
70+
export default NoContentDirectory;

src/components/tree-views-container.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ const TreeViewsContainer = () => {
287287
setTreeData({
288288
rootDirectories: nrs,
289289
mapData: mdr,
290+
initialized: true,
290291
})
291292
);
292293
})

src/redux/reducer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ const initialState = {
6161
selectedFile: null,
6262
uploadingElements: {},
6363
directoryUpdated: { force: 0, eventData: {} },
64-
treeData: { mapData: {}, rootDirectories: [] },
64+
treeData: { mapData: {}, rootDirectories: [], initialized: false },
6565
selectionForCopy: {
6666
sourceItemUuid: null,
6767
typeItem: null,

src/translations/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"private": "private",
1818
"public": "public",
1919
"emptyDir": "Empty directory",
20+
"createFirstDir": "Create your first directory",
2021
"ID": "ID",
2122
"createNewStudy": "Create a study",
2223
"studyCreationError": "Error when creating study: {studyName}",

src/translations/fr.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"private": "privé",
1818
"public": "public",
1919
"emptyDir": "Dossier vide",
20+
"createFirstDir": "Créer votre premier dossier",
2021
"ID": "ID",
2122
"createNewStudy": "Créer une étude",
2223
"studyCreationError": "Erreur lors de la création de l'étude: {studyName}",

0 commit comments

Comments
 (0)