From 8abb24b49226480e928ce100c8b6f3d12bc260fa Mon Sep 17 00:00:00 2001 From: Gautier Bureau Date: Mon, 4 Apr 2022 11:52:56 +0200 Subject: [PATCH 1/3] Add dialog to delete network. Signed-off-by: Gautier Bureau --- src/components/2-molecules/AttachDialog.jsx | 28 +++++++++++++++++++++ src/redux/slices/Network.js | 26 +++++++++++++++++++ src/redux/slices/Script.js | 1 + src/rest/networkAPI.js | 12 +++++++++ 4 files changed, 67 insertions(+) diff --git a/src/components/2-molecules/AttachDialog.jsx b/src/components/2-molecules/AttachDialog.jsx index 029db08..887519f 100644 --- a/src/components/2-molecules/AttachDialog.jsx +++ b/src/components/2-molecules/AttachDialog.jsx @@ -14,8 +14,13 @@ import DialogTitle from '@material-ui/core/DialogTitle'; import PropTypes from 'prop-types'; import { Divider, Grid, Typography } from '@material-ui/core'; import Box from '@material-ui/core/Box'; +import ListItem from '@material-ui/core/ListItem'; +import ListItemText from '@material-ui/core/ListItemText'; +import List from '@material-ui/core/List'; import { useStyles } from './AttachDialogStyles'; import Autocomplete from '../1-atoms/Autocomplete'; +import { useDispatch } from 'react-redux'; +import { deleteNetwork as deleteMappingAction } from '../../redux/slices/Network'; const AttachDialog = (props) => { const { open, handleClose, attachWithFile, networks, attachWithId } = props; @@ -23,6 +28,8 @@ const AttachDialog = (props) => { const [networkId, setNetworkId] = useState(''); const classes = useStyles(); + const dispatch = useDispatch(); + const onChangeFile = (event) => { setFile(event.target.files[0]); }; @@ -42,6 +49,10 @@ const AttachDialog = (props) => { setNetworkId(''); }; + const deleteNetwork = (networkId) => { + dispatch(deleteMappingAction(networkId)); + }; + return ( { )} + + Delete a known network : + + {networks.map((network) => ( + deleteNetwork(network.networkId)} + > + + primary={`${network.networkName}`} + + + ))} + + +