Skip to content

Commit

Permalink
some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ValentinBouzinFiligran committed Sep 11, 2024
1 parent 915146c commit d0713ee
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ const EntityRelationshipCard : FunctionComponent<EntityRelationshipCardProps> =
color: theme.palette.text?.primary,
textAlign: 'center',
fontSize: 12,
overflow: 'hidden',
textOverflow: 'ellipsis',
padding: '0 8px',
}}
>
{t_i18n(entityName)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,12 @@ const BulkRelationDialog : FunctionComponent<BulkRelationDialogProps> = ({
}, [bulkEntityList]);

const getDefaultEntityType = () => {
if (targetObjectTypes.length === 1 && targetObjectTypes.includes('Stix-Cyber-Observable')) {
const foundObservableType = entityList
.filter((obs) => obs.isObservable)
.sort((a, b) => (a.toEntitytype < b.toEntitytype ? -1 : 1))[0];
return foundObservableType ?? entityList[0];
}
const selectedEntityType = targetObjectTypes[0];
const foundEntityType = entityList.find((item) => item.toEntitytype === selectedEntityType);
return foundEntityType ?? entityList[0];
Expand Down Expand Up @@ -373,7 +379,7 @@ const BulkRelationDialog : FunctionComponent<BulkRelationDialogProps> = ({
const handleSubmit = async () => {
setIsSubmitting(true);
for (const bulkEntity of bulkEntityList) {
const foundEntityType = bulkEntity.entityTypeList?.find(({ entity_type }) => entity_type === bulkEntity.selectedEntityType.toEntitytype);
const foundEntityType = bulkEntity.entityTypeList && bulkEntity.entityTypeList.find((entity) => entity.entity_type === bulkEntity.selectedEntityType.toEntitytype);
if (!foundEntityType) return;
const finalValues = {
relationship_type: selectedRelationType,
Expand Down Expand Up @@ -472,7 +478,7 @@ const BulkRelationDialog : FunctionComponent<BulkRelationDialogProps> = ({
</Box>
<Box id="relationArrow" sx={{ display: 'flex', justifyContent: 'center', padding: '0 20px', flexDirection: 'column', minWidth: '200px' }}>
<Select disabled={isSubmitting} onChange={handleChangeSelectedRelationType} value={selectedRelationType}>
{relationListArray.map((relation) => (
{relationListArray.sort((a, b) => (a < b ? -1 : 1)).map((relation) => (
<MenuItem key={relation} value={relation}>
{t_i18n(`relationship_${relation}`)}
</MenuItem>
Expand Down Expand Up @@ -500,7 +506,7 @@ const BulkRelationDialog : FunctionComponent<BulkRelationDialogProps> = ({
value={getTextAreaValue()}
onChange={handleChangeTextArea}
multiline
minRows={10}
minRows={textAreaValue.length > 10 ? textAreaValue.length + 1 : 10}
placeholder={t_i18n('Type or copy paste data in this area.')}
variant="outlined"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ export const stixCoreRelationshipCreationFromEntityStixCoreObjectsLinesFragment
standard_id
entity_type
created_at
representative {
main
}
createdBy {
... on Identity {
name
Expand Down Expand Up @@ -729,7 +732,7 @@ const StixCoreRelationshipCreationFromEntity: FunctionComponent<StixCoreRelation
const newTargetEntities: TargetEntity[] = Object.values(selectedElements).map((item) => ({
id: item.id,
entity_type: item.entity_type ?? '',
name: item.name ?? item.observable_value ?? '',
name: item.name ?? item.observable_value ?? String(item.representative?.main ?? '') ?? '',
}));
setTargetEntities(newTargetEntities);
}, [selectedElements]);
Expand Down
2 changes: 2 additions & 0 deletions opencti-platform/opencti-front/src/utils/Relation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export interface RelationsDataFromEntity {
export interface RelationsToEntity {
toEntitytype: string; // TODO rename to toDomainAndObserble or anything that says both of them.
legitRelations: string[];
isObservable?: boolean;
}

/**
Expand Down Expand Up @@ -131,6 +132,7 @@ export const getRelationsFromOneEntityToAny = (
entityList.push({
toEntitytype: schema.scos[i].id,
legitRelations: [DEFAULT_RELATION],
isObservable: true,
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ type UseEntityToggleType = {
name?: string | null,
observable_value?: string | null,
entity_type?: string | null
representative?: {
main: string;
};
};

const useEntityToggle = <T extends UseEntityToggleType>(
Expand Down

0 comments on commit d0713ee

Please sign in to comment.