-
Notifications
You must be signed in to change notification settings - Fork 932
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[frontend] Popover removal - Locations
Co-authored-by: Bonsai8863 <131906254+Bonsai8863@users.noreply.github.com> Co-authored-by: Marie Flores <73853856+marieflorescontact@users.noreply.github.com>
- Loading branch information
1 parent
0b78e70
commit e44e755
Showing
24 changed files
with
881 additions
and
320 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
...ront/src/private/components/locations/administrative_areas/AdministrativeAreaDeletion.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import React from 'react'; | ||
import Button from '@mui/material/Button'; | ||
import Dialog from '@mui/material/Dialog'; | ||
import DialogActions from '@mui/material/DialogActions'; | ||
import DialogContent from '@mui/material/DialogContent'; | ||
import DialogContentText from '@mui/material/DialogContentText'; | ||
import { graphql } from 'react-relay'; | ||
import { useNavigate } from 'react-router-dom'; | ||
import { useFormatter } from '../../../../components/i18n'; | ||
import Security from '../../../../utils/Security'; | ||
import Transition from '../../../../components/Transition'; | ||
import { KNOWLEDGE_KNUPDATE_KNDELETE } from '../../../../utils/hooks/useGranted'; | ||
import useDeletion from '../../../../utils/hooks/useDeletion'; | ||
import useApiMutation from '../../../../utils/hooks/useApiMutation'; | ||
|
||
const AdministrativeAreaDeletionDeleteMutation = graphql` | ||
mutation AdministrativeAreaDeletionDeleteMutation($id: ID!) { | ||
administrativeAreaDelete(id: $id) | ||
} | ||
`; | ||
|
||
const AdministrativeAreaDeletion = ({ id }: { id: string }) => { | ||
const { t_i18n } = useFormatter(); | ||
const navigate = useNavigate(); | ||
const deleteSuccessMessage = t_i18n('', { | ||
id: '... successfully deleted', | ||
values: { entity_type: t_i18n('entity_Administrative-Area') }, | ||
}); | ||
const [commit] = useApiMutation( | ||
AdministrativeAreaDeletionDeleteMutation, | ||
undefined, | ||
{ successMessage: deleteSuccessMessage }, | ||
); | ||
const handleClose = () => {}; | ||
const { | ||
deleting, | ||
handleOpenDelete, | ||
displayDelete, | ||
handleCloseDelete, | ||
setDeleting, | ||
} = useDeletion({ handleClose }); | ||
const submitDelete = () => { | ||
setDeleting(true); | ||
commit({ | ||
variables: { | ||
id, | ||
}, | ||
onCompleted: () => { | ||
setDeleting(false); | ||
handleClose(); | ||
navigate('/dashboard/locations/administrative_areas'); | ||
}, | ||
}); | ||
}; | ||
return ( | ||
<> | ||
<Security needs={[KNOWLEDGE_KNUPDATE_KNDELETE]}> | ||
<Button | ||
color="error" | ||
variant="contained" | ||
onClick={handleOpenDelete} | ||
disabled={deleting} | ||
sx={{ marginTop: 2 }} | ||
> | ||
{t_i18n('Delete')} | ||
</Button> | ||
</Security> | ||
<Dialog | ||
PaperProps={{ elevation: 1 }} | ||
open={displayDelete} | ||
keepMounted={true} | ||
TransitionComponent={Transition} | ||
onClose={handleCloseDelete} | ||
> | ||
<DialogContent> | ||
<DialogContentText> | ||
{t_i18n('Do you want to delete this area?')} | ||
</DialogContentText> | ||
</DialogContent> | ||
<DialogActions> | ||
<Button onClick={handleCloseDelete} disabled={deleting}> | ||
{t_i18n('Cancel')} | ||
</Button> | ||
<Button color="secondary" onClick={submitDelete} disabled={deleting}> | ||
{t_i18n('Delete')} | ||
</Button> | ||
</DialogActions> | ||
</Dialog> | ||
</> | ||
); | ||
}; | ||
|
||
export default AdministrativeAreaDeletion; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
opencti-platform/opencti-front/src/private/components/locations/cities/CityDeletion.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import React from 'react'; | ||
import Button from '@mui/material/Button'; | ||
import Dialog from '@mui/material/Dialog'; | ||
import DialogActions from '@mui/material/DialogActions'; | ||
import DialogContent from '@mui/material/DialogContent'; | ||
import DialogContentText from '@mui/material/DialogContentText'; | ||
import { graphql } from 'react-relay'; | ||
import { useNavigate } from 'react-router-dom'; | ||
import { useFormatter } from '../../../../components/i18n'; | ||
import Security from '../../../../utils/Security'; | ||
import Transition from '../../../../components/Transition'; | ||
import { KNOWLEDGE_KNUPDATE_KNDELETE } from '../../../../utils/hooks/useGranted'; | ||
import useDeletion from '../../../../utils/hooks/useDeletion'; | ||
import useApiMutation from '../../../../utils/hooks/useApiMutation'; | ||
|
||
const CityDeletionDeleteMutation = graphql` | ||
mutation CityDeletionDeleteMutation($id: ID!) { | ||
cityEdit(id: $id) { | ||
delete | ||
} | ||
} | ||
`; | ||
|
||
const CityDeletion = ({ id }: { id: string }) => { | ||
const { t_i18n } = useFormatter(); | ||
const navigate = useNavigate(); | ||
const deleteSuccessMessage = t_i18n('', { | ||
id: '... successfully deleted', | ||
values: { entity_type: t_i18n('entity_City') }, | ||
}); | ||
const [commit] = useApiMutation( | ||
CityDeletionDeleteMutation, | ||
undefined, | ||
{ successMessage: deleteSuccessMessage }, | ||
); | ||
const handleClose = () => { }; | ||
const { | ||
deleting, | ||
handleOpenDelete, | ||
displayDelete, | ||
handleCloseDelete, | ||
setDeleting, | ||
} = useDeletion({ handleClose }); | ||
|
||
const submitDelete = () => { | ||
setDeleting(true); | ||
commit({ | ||
variables: { | ||
id, | ||
}, | ||
onCompleted: () => { | ||
setDeleting(false); | ||
handleClose(); | ||
navigate('/dashboard/locations/cities'); | ||
}, | ||
}); | ||
}; | ||
return ( | ||
<div style={{ margin: 0 }}> | ||
<Security needs={[KNOWLEDGE_KNUPDATE_KNDELETE]}> | ||
<Button | ||
color="error" | ||
variant="contained" | ||
onClick={handleOpenDelete} | ||
disabled={deleting} | ||
sx={{ marginTop: 2 }} | ||
> | ||
{t_i18n('Delete')} | ||
</Button> | ||
</Security> | ||
<Dialog | ||
PaperProps={{ elevation: 1 }} | ||
open={displayDelete} | ||
keepMounted={true} | ||
TransitionComponent={Transition} | ||
onClose={handleCloseDelete} | ||
> | ||
<DialogContent> | ||
<DialogContentText> | ||
{t_i18n('Do you want to delete this city?')} | ||
</DialogContentText> | ||
</DialogContent> | ||
<DialogActions> | ||
<Button onClick={handleCloseDelete} disabled={deleting}> | ||
{t_i18n('Cancel')} | ||
</Button> | ||
<Button color="secondary" onClick={submitDelete} disabled={deleting}> | ||
{t_i18n('Delete')} | ||
</Button> | ||
</DialogActions> | ||
</Dialog> | ||
</div> | ||
); | ||
}; | ||
|
||
export default CityDeletion; |
Oops, something went wrong.