diff --git a/opencti-platform/opencti-front/src/private/components/analysis/external_references/StixCoreObjectExternalReferencesLines.js b/opencti-platform/opencti-front/src/private/components/analysis/external_references/StixCoreObjectExternalReferencesLines.js
index fbffb6b93ca6..516717d95e85 100644
--- a/opencti-platform/opencti-front/src/private/components/analysis/external_references/StixCoreObjectExternalReferencesLines.js
+++ b/opencti-platform/opencti-front/src/private/components/analysis/external_references/StixCoreObjectExternalReferencesLines.js
@@ -20,9 +20,14 @@ import DialogActions from '@mui/material/DialogActions';
import { ExpandMoreOutlined, ExpandLessOutlined } from '@mui/icons-material';
import Slide from '@mui/material/Slide';
import { interval } from 'rxjs';
+import { Field, Form, Formik } from 'formik';
+import DialogTitle from '@mui/material/DialogTitle';
+import { includes } from 'ramda';
+import MenuItem from '@mui/material/MenuItem';
+import * as Yup from 'yup';
import inject18n from '../../../../components/i18n';
import { truncate } from '../../../../utils/String';
-import { commitMutation } from '../../../../relay/environment';
+import { commitMutation, MESSAGING$ } from '../../../../relay/environment';
import AddExternalReferences from './AddExternalReferences';
import { externalReferenceMutationRelationDelete } from './AddExternalReferencesLines';
import Security, {
@@ -35,6 +40,11 @@ import FileLine from '../../common/files/FileLine';
import { FIVE_SECONDS } from '../../../../utils/Time';
import FileUploader from '../../common/files/FileUploader';
import ExternalReferencePopover from './ExternalReferencePopover';
+import SelectField from '../../../../components/SelectField';
+import {
+ scopesConn,
+ stixCoreObjectFilesAndHistoryAskJobImportMutation,
+} from '../../common/stix_core_objects/StixCoreObjectFilesAndHistory';
const interval$ = interval(FIVE_SECONDS);
@@ -88,6 +98,10 @@ const Transition = React.forwardRef((props, ref) => (
));
Transition.displayName = 'TransitionSlide';
+const importValidation = (t) => Yup.object().shape({
+ connector_id: Yup.string().required(t('This field is required')),
+});
+
class StixCoreObjectExternalReferencesLinesContainer extends Component {
constructor(props) {
super(props);
@@ -98,6 +112,7 @@ class StixCoreObjectExternalReferencesLinesContainer extends Component {
removeExternalReference: null,
removing: false,
expanded: false,
+ fileToImport: null,
};
}
@@ -172,13 +187,43 @@ class StixCoreObjectExternalReferencesLinesContainer extends Component {
});
}
+ handleOpenImport(file) {
+ this.setState({ fileToImport: file });
+ }
+
+ handleCloseImport() {
+ this.setState({ fileToImport: null });
+ }
+
+ onSubmitImport(values, { setSubmitting, resetForm }) {
+ const { stixCoreObjectId } = this.props;
+ const { fileToImport } = this.state;
+ commitMutation({
+ mutation: stixCoreObjectFilesAndHistoryAskJobImportMutation,
+ variables: {
+ fileName: fileToImport.id,
+ connectorId: values.connector_id,
+ bypassEntityId: stixCoreObjectId,
+ },
+ onCompleted: () => {
+ setSubmitting(false);
+ resetForm();
+ this.handleCloseImport();
+ MESSAGING$.notifySuccess('Import successfully asked');
+ },
+ });
+ }
+
render() {
const { t, classes, stixCoreObjectId, data } = this.props;
- const { expanded } = this.state;
+ const { expanded, fileToImport } = this.state;
const externalReferencesEdges = data && data.stixCoreObject
? data.stixCoreObject.externalReferences.edges
: [];
const expandable = externalReferencesEdges.length > 7;
+ const importConnsPerFormat = data.connectorsForImport
+ ? scopesConn(data.connectorsForImport || [])
+ : {};
return (
@@ -272,9 +317,17 @@ class StixCoreObjectExternalReferencesLinesContainer extends Component {
))}
@@ -425,6 +478,67 @@ class StixCoreObjectExternalReferencesLinesContainer extends Component {
+
+ {({ submitForm, handleReset, isSubmitting }) => (
+
+ )}
+
);
}
@@ -508,6 +622,13 @@ const StixCoreObjectExternalReferencesLines = createPaginationContainer(
}
}
}
+ connectorsForImport {
+ id
+ name
+ active
+ connector_scope
+ updated_at
+ }
}
`,
},
diff --git a/opencti-platform/opencti-front/src/private/components/common/files/FileLine.js b/opencti-platform/opencti-front/src/private/components/common/files/FileLine.js
index 980d8bf551ea..869b85b460cd 100644
--- a/opencti-platform/opencti-front/src/private/components/common/files/FileLine.js
+++ b/opencti-platform/opencti-front/src/private/components/common/files/FileLine.js
@@ -143,6 +143,7 @@ class FileLineComponent extends Component {
directDownload,
handleOpenImport,
nested,
+ workNested,
} = this.props;
const { lastModifiedSinceMin, uploadStatus, metaData } = file;
const { messages, errors } = metaData;
@@ -266,7 +267,7 @@ class FileLineComponent extends Component {
)}
-
+