Skip to content

Commit

Permalink
[frontend] Entity type filter value selection in 'Add entities' panels (
Browse files Browse the repository at this point in the history
  • Loading branch information
Archidoit authored Nov 20, 2024
1 parent 50a5a8b commit ea72d44
Showing 1 changed file with 7 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import StixDomainObjectCreation from '../stix_domain_objects/StixDomainObjectCre
import StixCyberObservableCreation from '../../observations/stix_cyber_observables/StixCyberObservableCreation';
import useAuth from '../../../../utils/hooks/useAuth';
import ListLines from '../../../../components/list_lines/ListLines';
import { emptyFilterGroup } from '../../../../utils/filters/filtersUtils';
import { emptyFilterGroup, useBuildEntityTypeBasedFilterContext } from '../../../../utils/filters/filtersUtils';
import Drawer from '../drawer/Drawer';
import useAttributes from '../../../../utils/hooks/useAttributes';
import { usePaginationLocalStorage } from '../../../../utils/hooks/useLocalStorage';
Expand Down Expand Up @@ -87,19 +87,6 @@ const ContainerAddStixCoreObjects = (props) => {
platformModuleHelpers: { isRuntimeFieldEnable },
} = useAuth();

const targetEntityTypesFilterGroup = {
mode: 'and',
filterGroups: [],
filters: [
{
key: 'entity_type',
values: targetStixCoreObjectTypes,
operator: 'eq',
mode: 'or',
},
],
};

const isTypeDomainObject = (types) => {
return !types
|| types.some((r) => stixDomainObjectTypes.indexOf(r) >= 0)
Expand Down Expand Up @@ -143,10 +130,7 @@ const ContainerAddStixCoreObjects = (props) => {
searchTerm: '',
sortBy: '_score',
orderAsc: false,
filters: targetStixCoreObjectTypes
&& !(targetStixCoreObjectTypes.includes('Stix-Domain-Object') || targetStixCoreObjectTypes.includes('Stix-Cyber-Observable'))
? targetEntityTypesFilterGroup
: emptyFilterGroup,
filters: emptyFilterGroup,
types: [resolveAvailableTypes()],
},
true,
Expand All @@ -159,6 +143,7 @@ const ContainerAddStixCoreObjects = (props) => {
filters,
numberOfElements,
} = viewStorage;
const contextFilters = useBuildEntityTypeBasedFilterContext(targetStixCoreObjectTypes, filters);

const containerRef = useRef(null);
const keyword = mapping && (searchTerm ?? '').length === 0 ? selectedText : searchTerm;
Expand Down Expand Up @@ -350,6 +335,9 @@ const ContainerAddStixCoreObjects = (props) => {
disableExport={true}
availableEntityTypes={targetStixCoreObjectTypes}
entityTypes={targetStixCoreObjectTypes}
additionalFilterKeys={{
filterKeys: ['entity_type'],
}}
>
<QueryRenderer
query={containerAddStixCoreObjectsLinesQuery}
Expand Down Expand Up @@ -380,6 +368,7 @@ const ContainerAddStixCoreObjects = (props) => {
const searchPaginationOptions = removeEmptyFields({
...paginationOptionsNoCount,
search: keyword,
filters: contextFilters,
});
const renderButton = () => {
if (knowledgeGraph) {
Expand Down

0 comments on commit ea72d44

Please sign in to comment.