Skip to content

Commit

Permalink
[frontend] add representative in stream, playbook, triggers (#6799)
Browse files Browse the repository at this point in the history
  • Loading branch information
Archidoit committed May 10, 2024
1 parent 5d035a8 commit 1226ba7
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -457,14 +457,14 @@ const PlaybookAddComponentsContent = ({
<Filters
helpers={helpers}
availableFilterKeys={stixFilters}
searchContext={{ entityTypes: ['Stix-Core-Object', 'stix-core-relationship'] }}
searchContext={{ entityTypes: ['Stix-Core-Object', 'stix-core-relationship', 'Stix-Filtering'] }}
/>
</Box>
<div className="clearfix" />
<FilterIconButton
filters={filters}
helpers={helpers}
entityTypes={['Stix-Core-Object', 'stix-core-relationship']}
entityTypes={['Stix-Core-Object', 'stix-core-relationship', 'Stix-Filtering']}
styleNumber={2}
redirection
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,15 @@ const StreamCollectionCreation: FunctionComponent<StreamCollectionCreationProps>
<Filters
availableFilterKeys={stixFilters}
helpers={helpers}
searchContext={{ entityTypes: ['Stix-Core-Object', 'stix-core-relationship'] }}
searchContext={{ entityTypes: ['Stix-Core-Object', 'stix-core-relationship', 'Stix-Filtering'] }}
/>
</Box>
<FilterIconButton
filters={filters}
helpers={helpers}
styleNumber={2}
redirection
entityTypes={['Stix-Core-Object', 'stix-core-relationship', 'Stix-Filtering']}
/>
<div className={classes.buttons}>
<Button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,15 @@ const StreamCollectionEditionContainer: FunctionComponent<{ streamCollection: St
<Filters
availableFilterKeys={stixFilters}
helpers={helpers}
searchContext={{ entityTypes: ['Stix-Core-Object', 'stix-core-relationship'] }}
searchContext={{ entityTypes: ['Stix-Core-Object', 'stix-core-relationship', 'Stix-Filtering'] }}
/>
</Box>
<FilterIconButton
filters={filters}
styleNumber={2}
helpers={helpers}
redirection
entityTypes={['Stix-Core-Object', 'stix-core-relationship', 'Stix-Filtering']}
/>
</Form>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ TriggerEditionOverviewProps
&& <Filters
availableFilterKeys={stixFilters}
helpers={helpers}
searchContext={{ entityTypes: ['Stix-Core-Object', 'stix-core-relationship'] }}
searchContext={{ entityTypes: ['Stix-Core-Object', 'stix-core-relationship', 'Stix-Filtering'] }}
/>)}
</Box>

Expand All @@ -443,7 +443,8 @@ TriggerEditionOverviewProps
filters={filters}
helpers={helpers}
redirection
/>}
entityTypes={['Stix-Core-Object', 'stix-core-relationship', 'Stix-Filtering']}
/>}
</span>
)}
</Form>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ const TriggerLiveCreation: FunctionComponent<TriggerLiveCreationProps> = ({
&& <Filters
availableFilterKeys={stixFilters}
helpers={helpers}
searchContext={{ entityTypes: ['Stix-Core-Object', 'stix-core-relationship'] }}
searchContext={{ entityTypes: ['Stix-Core-Object', 'stix-core-relationship', 'Stix-Filtering'] }}
/>
)}
</Box>
Expand Down Expand Up @@ -297,6 +297,7 @@ const TriggerLiveCreation: FunctionComponent<TriggerLiveCreationProps> = ({
filters={filters}
helpers={helpers}
redirection
entityTypes={['Stix-Core-Object', 'stix-core-relationship', 'Stix-Filtering']}
/>
}

Expand Down
16 changes: 13 additions & 3 deletions opencti-platform/opencti-graphql/src/domain/filterKeysSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
MEMBERS_GROUP_FILTER,
MEMBERS_ORGANIZATION_FILTER,
MEMBERS_USER_FILTER,
OBJECT_CONTAINS_FILTER,
OBJECT_CONTAINS_FILTER, REPRESENTATIVE_FILTER,
TYPE_FILTER,
WORKFLOW_FILTER
} from '../utils/filtering/filtering-constants';
Expand Down Expand Up @@ -376,15 +376,16 @@ export const generateFilterKeysSchema = async () => {
const context = executionContext('filterKeysSchema');
const settings = await getEntityFromCache<BasicStoreSettings>(context, SYSTEM_USER, ENTITY_TYPE_SETTINGS);
const isNotEnterpriseEdition = isEmptyField(settings.enterprise_edition);
// A. build filterKeysSchema map
// A. build filterKeysSchema map for each entity type
const registeredTypes = schemaAttributesDefinition.getRegisteredTypes();
registeredTypes.forEach((type) => {
const filterDefinitionsMap: Map<string, FilterDefinition> = new Map(); // map that will contain the filterKeys schema for the entity type
completeFilterDefinitionsMapForTypeAndSubtypes(filterDefinitionsMap, type);
handleRemoveSpecialKeysFromFilterDefinitionsMap(filterDefinitionsMap, type, isNotEnterpriseEdition);
filterKeysSchema.set(type, filterDefinitionsMap);
});
// B. add connectedToId special key (for instance triggers)
// B. add special types
// connectedToId special key (for instance triggers)
filterKeysSchema.set('Instance', new Map([[CONNECTED_TO_INSTANCE_FILTER, {
filterKey: CONNECTED_TO_INSTANCE_FILTER,
type: 'id',
Expand All @@ -393,6 +394,15 @@ export const generateFilterKeysSchema = async () => {
subEntityTypes: [],
elementsForFilterValuesSearch: [ABSTRACT_STIX_CORE_OBJECT],
}]]));
// representative (for streams, triggers, playbooks)
filterKeysSchema.set('Stix-Filtering', new Map([[REPRESENTATIVE_FILTER, {
filterKey: REPRESENTATIVE_FILTER,
type: 'string',
label: 'Representative',
multiple: true,
subEntityTypes: [],
elementsForFilterValuesSearch: [],
}]]));
// C. transform the filterKeysSchema map in { key, values }[]
const flattenFilterKeysSchema: { entity_type: string, filters_schema: { filterDefinition: FilterDefinition, filterKey: string }[] }[] = [];
filterKeysSchema.forEach((filtersMap, entity_type) => {
Expand Down

0 comments on commit 1226ba7

Please sign in to comment.