Skip to content

Commit

Permalink
[frontend] fetch creators on observable creation (#8686) (#9056)
Browse files Browse the repository at this point in the history
  • Loading branch information
delemaf authored Nov 26, 2024
1 parent 0e8d34b commit 5d3920d
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ const BulkRelationDialog : FunctionComponent<BulkRelationDialogProps> = ({
paginationKey={paginationKey}
handleClose={handleCloseObjectCreateEntityForm}
type={missingEntity.key}
contextual
contextual={true}
isFromBulkRelation
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,6 @@ const ContainerAddStixCoreObjectsInLine: FunctionComponent<ContainerAddStixCoreO
speeddial={true}
open={openCreateObservable}
handleClose={() => setOpenCreateObservable(false)}
type={undefined}
onCompleted={undefined}
isFromBulkRelation={undefined}
/>
</>);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -843,12 +843,6 @@ const StixCoreRelationshipCreationFromEntity: FunctionComponent<StixCoreRelation
inputValue={searchTerm}
paginationKey="Pagination_stixCoreObjects"
paginationOptions={searchPaginationOptions}
open={undefined}
handleClose={undefined}
type={undefined}
speeddial={undefined}
onCompleted={undefined}
isFromBulkRelation={undefined}
/>
)}
{targetEntities.length === 0 && !isOnlySDOs && !isOnlySCOs && (
Expand Down Expand Up @@ -908,9 +902,6 @@ const StixCoreRelationshipCreationFromEntity: FunctionComponent<StixCoreRelation
speeddial={true}
open={openCreateObservable}
handleClose={handleCloseCreateObservable}
type={undefined}
onCompleted={undefined}
isFromBulkRelation={undefined}
/>
</>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,6 @@ const StixNestedRefRelationshipCreationFromEntity = ({
speeddial={true}
open={openCreateObservable}
handleClose={handleCloseCreateObservable}
type={undefined}
/>
</>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,7 @@ const StixCyberObservables: FunctionComponent = () => {
paginationOptions={queryPaginationOptions}
contextual={false}
open={false}
handleClose={undefined}
onCompleted={undefined}
isFromBulkRelation={undefined}
type={undefined}
display={undefined}
speeddial={false}
inputValue={undefined}
controlledDialStyles={{ marginLeft: 1 }}
/>
</Security>
Expand All @@ -172,13 +166,7 @@ const StixCyberObservables: FunctionComponent = () => {
paginationOptions={queryPaginationOptions}
contextual={false}
open={false}
handleClose={undefined}
onCompleted={undefined}
isFromBulkRelation={undefined}
type={undefined}
display={undefined}
speeddial={false}
inputValue={undefined}
/>
</Security>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import List from '@mui/material/List';
import ListItemText from '@mui/material/ListItemText';
import makeStyles from '@mui/styles/makeStyles';
import { ListItemButton } from '@mui/material';
import PropTypes from 'prop-types';
import { useTheme } from '@mui/styles';
import useHelper from '../../../../utils/hooks/useHelper';
import { handleErrorInForm, QueryRenderer } from '../../../../relay/environment';
Expand Down Expand Up @@ -195,6 +196,10 @@ const stixCyberObservableMutation = graphql`
entity_type
}
}
creators {
id,
name,
}
objectMarking {
id
definition_type
Expand Down Expand Up @@ -271,9 +276,9 @@ const StixCyberObservableCreation = ({
inputValue,
paginationKey,
paginationOptions,
controlledDialStyles = {},
defaultCreatedBy = null,
defaultMarkingDefinitions = null,
controlledDialStyles,
defaultCreatedBy,
defaultMarkingDefinitions,
isFromBulkRelation,
onCompleted,
}) => {
Expand Down Expand Up @@ -493,9 +498,7 @@ const StixCyberObservableCreation = ({
const baseCreatedBy = defaultCreatedBy
? { value: defaultCreatedBy.id, label: defaultCreatedBy.name }
: undefined;
const baseMarkingDefinitions = (
defaultMarkingDefinitions ?? []
).map((n) => convertMarking(n));
const baseMarkingDefinitions = defaultMarkingDefinitions.map((n) => convertMarking(n));
const initialValues = {
x_opencti_description: '',
x_opencti_score: 50,
Expand Down Expand Up @@ -1011,4 +1014,42 @@ const StixCyberObservableCreation = ({
return renderClassic();
};

StixCyberObservableCreation.propTypes = {
contextual: PropTypes.bool.isRequired,
open: PropTypes.bool,
handleClose: PropTypes.func,
type: PropTypes.string,
display: PropTypes.bool,
speeddial: PropTypes.bool,
inputValue: PropTypes.string,
paginationKey: PropTypes.string,
paginationOptions: PropTypes.any,
controlledDialStyles: PropTypes.object,
defaultCreatedBy: PropTypes.oneOfType([
PropTypes.shape({
id: PropTypes.string.isRequired,
name: PropTypes.string.isRequired,
}),
PropTypes.oneOf([undefined]),
]),
defaultMarkingDefinitions: PropTypes.arrayOf(
PropTypes.shape({
id: PropTypes.string.isRequired,
name: PropTypes.string.isRequired,
}),
),
isFromBulkRelation: PropTypes.bool,
onCompleted: PropTypes.func,
};

StixCyberObservableCreation.defaultProps = {
open: false,
display: false,
speeddial: false,
isFromBulkRelation: false,
defaultMarkingDefinitions: [],
paginationOptions: [],
controlledDialStyles: {},
};

export default StixCyberObservableCreation;
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,6 @@ AddPersonaThreatActorIndividualProps
<StixCyberObservableCreation
contextual={false}
type="Persona"
open={undefined}
handleClose={undefined}
onCompleted={undefined}
display={undefined}
speeddial={undefined}
isFromBulkRelation={undefined}
inputValue={search}
paginationOptions={{ search, types: ['Persona'] }}
paginationKey="Pagination_stixCyberObservables"
Expand Down

0 comments on commit 5d3920d

Please sign in to comment.