Skip to content

Commit

Permalink
[frontend] fix history filters in activity tab (#6293)
Browse files Browse the repository at this point in the history
  • Loading branch information
marieflorescontact committed Mar 13, 2024
1 parent 0f4dcce commit dea383c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,6 @@ class StixCoreObjectHistory extends Component {
filters: {
mode: 'and',
filters: [
{
key: 'context_data.id',
values: [stixCoreObjectId],
operator: 'wildcard',
},
{
key: 'event_type',
values: ['create', 'delete', 'mutation'], // retro-compatibility
Expand All @@ -142,6 +137,20 @@ class StixCoreObjectHistory extends Component {
},
],
filterGroups: [],
},
{
mode: 'or',
filters: [
{
key: 'context_data.from_id',
values: [stixCoreObjectId],
},
{
key: 'context_data.to_id',
values: [stixCoreObjectId],
},
],
filterGroups: [],
}],
},
first: 20,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ENTITY_TYPE_USER } from './internalObject';
import { ABSTRACT_STIX_CORE_OBJECT } from './general';
import { ABSTRACT_BASIC_OBJECT, ABSTRACT_BASIC_RELATIONSHIP } from './general';

export const shortMapping = {
type: 'text',
Expand Down Expand Up @@ -70,13 +70,14 @@ export const id: AttributeDefinition = {
name: 'id',
label: 'Id',
type: 'string',
format: 'short',
format: 'id',
update: false,
mandatoryType: 'no',
multiple: false,
editDefault: false,
upsert: false,
isFilterable: false,
entityTypes: [ABSTRACT_BASIC_OBJECT, ABSTRACT_BASIC_RELATIONSHIP]
};

export const internalId: AttributeDefinition = {
Expand All @@ -90,7 +91,7 @@ export const internalId: AttributeDefinition = {
multiple: false,
upsert: false,
isFilterable: false,
entityTypes: [ABSTRACT_STIX_CORE_OBJECT]
entityTypes: [ABSTRACT_BASIC_OBJECT, ABSTRACT_BASIC_RELATIONSHIP]
};

export const creators: AttributeDefinition = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { describe, expect, it } from 'vitest';
import { generateFilterKeysSchema } from '../../../src/domain/filterKeysSchema';
import {
ABSTRACT_BASIC_OBJECT,
ABSTRACT_STIX_CORE_OBJECT,
ABSTRACT_STIX_CORE_RELATIONSHIP,
ABSTRACT_STIX_CYBER_OBSERVABLE,
Expand Down Expand Up @@ -133,8 +134,8 @@ describe('Filter keys schema generation testing', async () => {
expect(filterDefinition?.filterKey).toEqual('fromId');
expect(filterDefinition?.type).toEqual('id');
expect(filterDefinition?.label).toEqual('Source entity');
expect(filterDefinition?.elementsForFilterValuesSearch.length).toEqual(1);
expect(filterDefinition?.elementsForFilterValuesSearch[0]).toEqual(ABSTRACT_STIX_CORE_OBJECT);
expect(filterDefinition?.elementsForFilterValuesSearch.length).toEqual(2);
expect(filterDefinition?.elementsForFilterValuesSearch[0]).toEqual(ABSTRACT_BASIC_OBJECT);
// 'toTypes' for relationships
filterDefinition = filterKeysSchema.get(ABSTRACT_STIX_CORE_RELATIONSHIP)?.get('toTypes');
expect(filterDefinition?.filterKey).toEqual('toTypes');
Expand Down

0 comments on commit dea383c

Please sign in to comment.