Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[frontend] Mandatory file for Artifact creation (#8794) #10075

Merged
merged 2 commits into from
Feb 26, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,11 @@ const StixCyberObservableCreation = ({
is: (a, b, c, d) => !a && !b && !c && !d,
then: () => Yup.string().required(t_i18n('MD5, SHA-1, SHA-256, SHA-512, or name is required')),
}),
file: Yup.mixed().when([], {
is: () => status.type === 'Artifact',
then: () => Yup.mixed().required(t_i18n('This field is required')),
otherwise: () => Yup.mixed().nullable(),
}),
};

requiredOneOfFields = [
Expand Down Expand Up @@ -628,6 +633,7 @@ const StixCyberObservableCreation = ({
setFieldValue,
values,
resetForm,
errors,
}) => (
<>
{bulkConf && (
Expand Down Expand Up @@ -848,10 +854,9 @@ const StixCyberObservableCreation = ({
setFieldValue={setFieldValue}
values={values.externalReferences}
/>
<Field
component={CustomFileUploader}
name="file"
<CustomFileUploader
setFieldValue={setFieldValue}
formikErrors={errors}
disabled={bulkConf && bulkSelectedKey && splitMultilines(values[bulkSelectedKey]).length > 1}
noFileSelectedLabel={bulkConf && bulkSelectedKey && splitMultilines(values[bulkSelectedKey]).length > 1
? t_i18n('File upload not allowed in bulk creation')
Expand Down