From 5588903da0e8d68ec0ee2e9271581adffd82fb8d Mon Sep 17 00:00:00 2001 From: Laurent Bonnet Date: Fri, 13 Sep 2024 14:37:42 +0200 Subject: [PATCH] [frontend] make TAI personas always visible to be able to add some --- .../src/components/FieldOrEmpty.tsx | 2 +- .../StixCyberObservableCreation.jsx | 2 + .../ThreatActorGroupLocation.jsx | 96 +++++++++---------- .../AddIndividualsThreatActorIndividual.tsx | 24 ++--- .../AddPersonasThreatActorIndividual.tsx | 25 ++--- .../ThreatActorIndividualDetailsChips.tsx | 73 +++++++------- .../ThreatActorIndividualLocation.jsx | 2 +- 7 files changed, 103 insertions(+), 121 deletions(-) diff --git a/opencti-platform/opencti-front/src/components/FieldOrEmpty.tsx b/opencti-platform/opencti-front/src/components/FieldOrEmpty.tsx index 632009c9481f..1dd899f96659 100644 --- a/opencti-platform/opencti-front/src/components/FieldOrEmpty.tsx +++ b/opencti-platform/opencti-front/src/components/FieldOrEmpty.tsx @@ -6,7 +6,7 @@ interface FieldOrEmptyProps { children: React.ReactNode; } -const FieldOrEmpty = ({ source, children }: FieldOrEmptyProps) => { +const FieldOrEmpty = ({ source, children }: FieldOrEmptyProps) => { return <>{isNotEmptyField(source) ? children : '-'}; // render the children if source is defined }; export default FieldOrEmpty; diff --git a/opencti-platform/opencti-front/src/private/components/observations/stix_cyber_observables/StixCyberObservableCreation.jsx b/opencti-platform/opencti-front/src/private/components/observations/stix_cyber_observables/StixCyberObservableCreation.jsx index 0cd3e0f90e58..c4c84bbc9f9c 100644 --- a/opencti-platform/opencti-front/src/private/components/observations/stix_cyber_observables/StixCyberObservableCreation.jsx +++ b/opencti-platform/opencti-front/src/private/components/observations/stix_cyber_observables/StixCyberObservableCreation.jsx @@ -270,6 +270,7 @@ const StixCyberObservableCreation = ({ inputValue, paginationKey, paginationOptions, + controlledDialStyles = {}, defaultCreatedBy = null, defaultMarkingDefinitions = null, isFromBulkRelation, @@ -901,6 +902,7 @@ const StixCyberObservableCreation = ({ entityType={type ?? 'Observable'} onOpen={handleOpen} onClose={() => {}} + style={controlledDialStyles} /> :
- - {threatActorGroup.locations.edges.length === 0 && ( - - - - )} - {threatActorGroup.locations.edges.map((locationEdge) => { - const { types } = locationEdge; - const location = locationEdge.node; - const link = resolveLink(location.entity_type); - const flag = location.entity_type === 'Country' + + + {threatActorGroup.locations.edges.map((locationEdge) => { + const { types } = locationEdge; + const location = locationEdge.node; + const link = resolveLink(location.entity_type); + const flag = location.entity_type === 'Country' && R.head( (location.x_opencti_aliases ?? []).filter( (n) => n?.length === 2, ), ); - return ( - - + return ( + - {flag ? ( - {location.name} - ) : ( - - )} + + {flag ? ( + {location.name} + ) : ( + + )} + - - - {types.includes('manual') ? ( - - - this.removeLocation(locationEdge)} - size="large" - > - - - - - ) : } - - ); - })} - + + {types.includes('manual') ? ( + + + this.removeLocation(locationEdge)} + size="large" + > + + + + + ) : } + + ); + })} + + ); } diff --git a/opencti-platform/opencti-front/src/private/components/threats/threat_actors_individual/AddIndividualsThreatActorIndividual.tsx b/opencti-platform/opencti-front/src/private/components/threats/threat_actors_individual/AddIndividualsThreatActorIndividual.tsx index 77f3ad2c63b2..d61fe4c1d24c 100644 --- a/opencti-platform/opencti-front/src/private/components/threats/threat_actors_individual/AddIndividualsThreatActorIndividual.tsx +++ b/opencti-platform/opencti-front/src/private/components/threats/threat_actors_individual/AddIndividualsThreatActorIndividual.tsx @@ -35,25 +35,15 @@ AddIndividualsThreatActorIndividualProps count: 50, }, ); - const getRelationships = () => { - const relations = []; - for (const { node } of threatActorIndividual.stixCoreRelationships?.edges ?? []) { - const { relationship_type } = node ?? {}; - if (relationship_type === 'impersonates') relations.push(node); - } - return relations; - }; return (
- {(getRelationships().length > 0) && ( - - - - )} + + + { - const relations = []; - for (const { node } of threatActorIndividual.stixCoreRelationships?.edges ?? []) { - const { relationship_type } = node ?? {}; - if (relationship_type === 'known-as') relations.push(node); - } - return relations; - }; - return (
- {(getRelationships().length > 0) && ( - - - - )} + + + 0 ? { marginBottom: '20px' } : {}}> -
- {(nodes.length > 0) && ( - - {title} - )} - } + return ( +
+
- - -
-
- {(nodes.length > 0) && ( - nodes.map(({ id, to }) => ( - - )) - )} -
); + + +
+
+ + { + nodes.map(({ id, to }) => ( + + )) + } + +
+ ); }; export default ThreatActorIndividualDetailsChips; diff --git a/opencti-platform/opencti-front/src/private/components/threats/threat_actors_individual/ThreatActorIndividualLocation.jsx b/opencti-platform/opencti-front/src/private/components/threats/threat_actors_individual/ThreatActorIndividualLocation.jsx index 38841e9587a8..563ef891864b 100644 --- a/opencti-platform/opencti-front/src/private/components/threats/threat_actors_individual/ThreatActorIndividualLocation.jsx +++ b/opencti-platform/opencti-front/src/private/components/threats/threat_actors_individual/ThreatActorIndividualLocation.jsx @@ -63,7 +63,7 @@ class ThreatActorIndividualLocationsComponent extends Component { />
- + {threatActorIndividual.locations.edges.map((locationEdge) => { const { types } = locationEdge;