Skip to content

Commit

Permalink
[frontend] Fix add threat actor/intrusion set location: can't create …
Browse files Browse the repository at this point in the history
…a location + bad design (OpenCTI-Platform#4832)
  • Loading branch information
SarahBocognano authored and sbocahu committed Nov 27, 2023
1 parent 49cb79f commit a1cffcd
Show file tree
Hide file tree
Showing 9 changed files with 329 additions and 257 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,17 @@ interface MalwareAddInput {

interface MalwareFormProps {
updater: (store: RecordSourceSelectorProxy, key: string) => void
onClose?: () => void
onCompleted?: () => void
onReset?: () => void;
defaultCreatedBy?: { value: string, label: string }
defaultMarkingDefinitions?: { value: string, label: string }[]
defaultConfidence?: number;
}

export const MalwareCreationForm: FunctionComponent<MalwareFormProps> = ({
updater,
onClose,
onCompleted,
onReset,
defaultConfidence,
defaultCreatedBy,
defaultMarkingDefinitions,
Expand Down Expand Up @@ -148,8 +150,8 @@ export const MalwareCreationForm: FunctionComponent<MalwareFormProps> = ({
onCompleted: () => {
setSubmitting(false);
resetForm();
if (onClose) {
onClose();
if (onCompleted) {
onCompleted();
}
},
});
Expand Down Expand Up @@ -179,7 +181,7 @@ export const MalwareCreationForm: FunctionComponent<MalwareFormProps> = ({
initialValues={initialValues}
validationSchema={malwareValidator}
onSubmit={onSubmit}
onReset={() => onClose?.()}>
onReset={onReset}>
{({
submitForm,
handleReset,
Expand Down Expand Up @@ -305,11 +307,14 @@ const MalwareCreation = ({ paginationOptions }: { paginationOptions: MalwaresCar
);

return (
<Drawer
title={t('Create a malware')}
variant={DrawerVariant.create}
>
<MalwareCreationForm updater={updater} />
<Drawer title={t('Create a malware')} variant={DrawerVariant.create}>
{({ onClose }) => (
<MalwareCreationForm
updater={updater}
onReset={onClose}
onCompleted={onClose}
/>
)}
</Drawer>
);
};
Expand Down

This file was deleted.

0 comments on commit a1cffcd

Please sign in to comment.