-
Notifications
You must be signed in to change notification settings - Fork 799
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[frontend/backend] Marking definitions for uploaded files (#5823)
- Loading branch information
1 parent
1610481
commit 09fb80e
Showing
23 changed files
with
349 additions
and
216 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
77 changes: 77 additions & 0 deletions
77
...orm/opencti-front/src/private/components/common/files/FileImportMarkingSelectionPopup.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,77 @@ | ||
import { Formik } from 'formik'; | ||
import Dialog from '@mui/material/Dialog'; | ||
import DialogTitle from '@mui/material/DialogTitle'; | ||
import DialogContent from '@mui/material/DialogContent'; | ||
import DialogActions from '@mui/material/DialogActions'; | ||
import React from 'react'; | ||
import ObjectMarkingField from '@components/common/form/ObjectMarkingField'; | ||
import Button from '@mui/material/Button'; | ||
import { Option } from '@components/common/form/ReferenceField'; | ||
import { useFormatter } from '../../../../components/i18n'; | ||
import { fieldSpacingContainerStyle } from '../../../../utils/field'; | ||
|
||
type FileImportMarkingSelectionPopupProps = { | ||
closePopup: () => void; | ||
handleUpload: (fileMarkings: string[]) => void; | ||
isOpen: boolean | ||
}; | ||
|
||
export type SubmittedMarkingsType = { | ||
fileMarkings: Option[]; | ||
}; | ||
|
||
const FileImportMarkingSelectionPopup = ({ closePopup, handleUpload, isOpen }: FileImportMarkingSelectionPopupProps) => { | ||
const { t_i18n } = useFormatter(); | ||
|
||
const handleSubmit = (values: SubmittedMarkingsType) => { | ||
const fileMarkings = values.fileMarkings.map(({ value }) => value); | ||
closePopup(); | ||
handleUpload(fileMarkings); | ||
}; | ||
|
||
return ( | ||
<> | ||
<Formik | ||
enableReinitialize={true} | ||
initialValues={{ | ||
fileMarkings: [], | ||
}} | ||
onSubmit={handleSubmit} | ||
> | ||
{({ resetForm, submitForm }) => ( | ||
<Dialog open={isOpen} fullWidth={true} PaperProps={{ elevation: 1 }} onClose={() => { | ||
resetForm(); | ||
closePopup(); | ||
}} | ||
> | ||
<DialogTitle>{t_i18n('Select file marking definitions')}</DialogTitle> | ||
<DialogContent> | ||
<ObjectMarkingField | ||
name="fileMarkings" | ||
label={t_i18n('File marking definition levels')} | ||
style={fieldSpacingContainerStyle} | ||
/> | ||
</DialogContent> | ||
<DialogActions> | ||
<Button onClick={() => { | ||
resetForm(); | ||
closePopup(); | ||
}} | ||
> | ||
{t_i18n('Cancel')} | ||
</Button> | ||
<Button | ||
color="secondary" | ||
onClick={submitForm} | ||
> | ||
{t_i18n('Validate')} | ||
</Button> | ||
</DialogActions> | ||
</Dialog> | ||
)} | ||
</Formik> | ||
</> | ||
); | ||
}; | ||
|
||
export default FileImportMarkingSelectionPopup; |
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
Oops, something went wrong.