Skip to content

Commit 49f7046

Browse files
authored
Handle access rights. (#426)
Signed-off-by: AAJELLAL <[email protected]>
1 parent 6753fd0 commit 49f7046

14 files changed

+35
-302
lines changed

src/components/dialogs/access-rights-dialog.jsx

Lines changed: 0 additions & 132 deletions
This file was deleted.

src/components/dialogs/create-directory-dialog.jsx

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ import Button from '@mui/material/Button';
1414
import PropTypes from 'prop-types';
1515
import React from 'react';
1616
import Alert from '@mui/material/Alert';
17-
import FormControl from '@mui/material/FormControl';
18-
import RadioGroup from '@mui/material/RadioGroup';
19-
import FormControlLabel from '@mui/material/FormControlLabel';
20-
import Radio from '@mui/material/Radio';
2117
import { ElementType } from '@gridsuite/commons-ui';
2218
import { useNameField } from './field-hook';
2319
import { CancelButton } from '@gridsuite/commons-ui';
@@ -38,8 +34,6 @@ export const CreateDirectoryDialog = ({
3834
parentDirectory,
3935
error,
4036
}) => {
41-
const [isPrivate, setIsPrivate] = React.useState(true);
42-
4337
const [name, nameField, nameError, nameOk] = useNameField({
4438
label: 'nameProperty',
4539
autoFocus: true,
@@ -56,11 +50,7 @@ export const CreateDirectoryDialog = ({
5650
};
5751

5852
const handleClick = () => {
59-
onClick(name, isPrivate);
60-
};
61-
62-
const handleChange = (event) => {
63-
setIsPrivate(event.target.value);
53+
onClick(name);
6454
};
6555

6656
const canCreate = () => {
@@ -77,26 +67,6 @@ export const CreateDirectoryDialog = ({
7767
<DialogTitle>{title}</DialogTitle>
7868
<DialogContent>
7969
{nameField}
80-
<FormControl>
81-
<RadioGroup
82-
aria-label=""
83-
name="DirectoryAccessRights"
84-
value={isPrivate + ''}
85-
onChange={handleChange}
86-
row
87-
>
88-
<FormControlLabel
89-
value="false"
90-
control={<Radio />}
91-
label={<FormattedMessage id="public" />}
92-
/>
93-
<FormControlLabel
94-
value="true"
95-
control={<Radio />}
96-
label={<FormattedMessage id="private" />}
97-
/>
98-
</RadioGroup>
99-
</FormControl>
10070
<br />
10171
{nameError && <Alert severity="error">{nameError}</Alert>}
10272
{error !== '' && <Alert severity="error">{error}</Alert>}

src/components/dialogs/delete-dialog.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ const DeleteDialog = ({
5050
const openRef = useRef(null);
5151

5252
useEffect(() => {
53-
if (open && !openRef.current) {
53+
if ((open && !openRef.current) || error !== '') {
5454
setItemState(items);
5555
setLoadingState(false);
5656
}
5757
openRef.current = open;
58-
}, [open, items]);
58+
}, [open, items, error]);
5959

6060
const handleClose = (_, reasonOfClose) => {
6161
if (

src/components/directory-tree-view.jsx

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,11 @@
88
import React, { useCallback, useEffect, useRef } from 'react';
99

1010
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
11-
import LockIcon from '@mui/icons-material/Lock';
1211
import ChevronRightIcon from '@mui/icons-material/ChevronRight';
1312
import Typography from '@mui/material/Typography';
1413
import Tooltip from '@mui/material/Tooltip';
1514
import Zoom from '@mui/material/Zoom';
1615

17-
import { FormattedMessage } from 'react-intl';
18-
1916
import { useDispatch, useSelector } from 'react-redux';
2017
import { setSelectedDirectory } from '../redux/actions';
2118
import CustomTreeItem from './custom-tree-item';
@@ -176,20 +173,6 @@ const DirectoryTreeView = ({
176173
handleContextMenuClick(e, node.elementUuid)
177174
}
178175
>
179-
{node.accessRights?.isPrivate ? (
180-
<Tooltip
181-
TransitionComponent={Zoom}
182-
disableFocusListener
183-
disableTouchListener
184-
enterDelay={1000}
185-
enterNextDelay={1000}
186-
title={<FormattedMessage id="private" />}
187-
placement="bottom"
188-
arrow
189-
>
190-
<LockIcon sx={styles.icon} />
191-
</Tooltip>
192-
) : null}
193176
<Tooltip
194177
TransitionComponent={Zoom}
195178
disableFocusListener

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ const ContentContextualMenu = (props) => {
273273
onClose();
274274
setOpenDialog(DialogsId.NONE);
275275
setHideMenu(false);
276+
setDeleteError('');
276277
}, [onClose, setOpenDialog]);
277278

278279
const handleCloseExportDialog = useCallback(() => {
@@ -283,12 +284,14 @@ const ContentContextualMenu = (props) => {
283284
const [deleteError, setDeleteError] = useState('');
284285
const handleDeleteElements = useCallback(
285286
(elementsUuids) => {
287+
setDeleteError('');
286288
deleteElements(elementsUuids, selectedDirectory.elementUuid)
289+
.then(() => handleCloseDialog())
290+
//show the error message and don't close the dialog
287291
.catch((error) => {
288292
setDeleteError(error.message);
289293
handleLastError(error.message);
290-
})
291-
.finally(() => handleCloseDialog());
294+
});
292295
},
293296
[selectedDirectory?.elementUuid, handleCloseDialog, handleLastError]
294297
);

0 commit comments

Comments
 (0)