Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add filter by value to document details fields #7081

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
48b25d7
Refactor filter button actions in DocViewer
guidomodarelli Oct 7, 2024
c9f9a32
Add Doc Viewer styles and import to Doc Viewer component
guidomodarelli Oct 7, 2024
334b845
Refactor cell filter actions to use 'field' instead of 'columnId'
guidomodarelli Oct 7, 2024
3433625
Refactor filtering logic in DocViewer component
guidomodarelli Oct 7, 2024
71f1ba9
Add onFilterHandler to DocViewer component
guidomodarelli Oct 7, 2024
344df6d
Add onFilter handler to various components
guidomodarelli Oct 7, 2024
bc93d2f
Refactor RequirementFlyout component for readability
guidomodarelli Oct 7, 2024
44db0fc
Add filter functionality to inventory vulnerabilities dashboard
guidomodarelli Oct 8, 2024
6b5a363
Remove unused code related to doc viewer in WazuhDataGrid
guidomodarelli Oct 8, 2024
d6eb863
Add setFilters function to FileDetails and RequirementFlyout
guidomodarelli Oct 8, 2024
7f3f738
Refactor doc-viewer styles for button display
guidomodarelli Oct 8, 2024
a45fb43
Add filter state management to data grid and drilldown panels
guidomodarelli Oct 8, 2024
64dfcd1
Fix Prettier issue
guidomodarelli Oct 8, 2024
0b92f0b
Add filter by value to document details fields
guidomodarelli Oct 8, 2024
72cead5
Update defaultColumns to defaultTableColumns in WazuhDataGrid
guidomodarelli Oct 8, 2024
92787ce
Add filter functionality for document viewer
guidomodarelli Oct 8, 2024
119332c
Swap the order of arguments in filter action test
guidomodarelli Oct 8, 2024
9612879
Merge branch '4.10.0' into enhancement/7080-add-filter-by-value-to-do…
guidomodarelli Oct 10, 2024
c20b626
Merge branch '4.10.0' into enhancement/7080-add-filter-by-value-to-do…
guidomodarelli Oct 14, 2024
daf4529
Merge branch '4.10.0' into enhancement/7080-add-filter-by-value-to-do…
guidomodarelli Oct 14, 2024
3d563be
Merge branch '4.10.0' into enhancement/7080-add-filter-by-value-to-do…
guidomodarelli Oct 17, 2024
84cb708
Rename button icons to EuiButtonIcon component
guidomodarelli Oct 17, 2024
8b2bffc
Update component import paths and class names
guidomodarelli Oct 17, 2024
13bd581
Update doc-viewer styles for wzDocViewer classes
guidomodarelli Oct 17, 2024
81862f9
Refactor adding filters to handle array values efficiently
guidomodarelli Oct 17, 2024
f7871be
Add onClose callback to onFilter function in DocViewer
guidomodarelli Oct 17, 2024
8364cc1
Refactor DocumentViewTableAndJson component props
guidomodarelli Oct 17, 2024
d09836a
Refactor technique row details component props type
guidomodarelli Oct 17, 2024
0ee73ff
Add setFilters function to TechniqueRowDetails component
guidomodarelli Oct 17, 2024
ce6badc
Refactor closeFlyoutHandler in DashboardTH component
guidomodarelli Oct 17, 2024
cff23c5
Add closeFlyoutHandler function for flyout onClose event
guidomodarelli Oct 17, 2024
da5411a
Merge branch '4.10.0' into enhancement/7080-add-filter-by-value-to-do…
guidomodarelli Oct 17, 2024
2ddb2d4
Fix Prettier issue
guidomodarelli Oct 17, 2024
2ab5e94
Merge branch '4.10.0' into enhancement/7080-add-filter-by-value-to-do…
guidomodarelli Oct 18, 2024
9516d55
fix: add guard clause for undefined value in filter cell actions
guidomodarelli Oct 21, 2024
24eedda
Merge branch '4.10.0' into enhancement/7080-add-filter-by-value-to-do…
asteriscos Oct 22, 2024
a1f8e72
feat: add FilterStateStore enum and update state management in Patter…
guidomodarelli Oct 22, 2024
bfad495
fix: update onFilter function to accept more specific FILTER_OPERATOR…
guidomodarelli Oct 22, 2024
ec96ca7
feat: add isNullish utility function and update exports in util index…
guidomodarelli Oct 22, 2024
6d3307f
fix: refactor onFilterCellActions to use isNullish for improved handl…
guidomodarelli Oct 22, 2024
21e1038
fix: refactor onFilterCellActions import path for improved structure …
guidomodarelli Oct 22, 2024
3822411
fix: update onFilterCellActions to accept number type in values for e…
guidomodarelli Oct 22, 2024
2c2de22
test: add unit tests for onFilterCellActions to verify filtering with…
guidomodarelli Oct 22, 2024
70ad2e7
test: simplify onFilterCellActions tests by removing unused filters a…
guidomodarelli Oct 22, 2024
6f00f93
test: enhance onFilterCellActions tests by clarifying filter addition…
guidomodarelli Oct 22, 2024
30ed18a
test: refactor buildFilter usage in onFilterCellActions tests for imp…
guidomodarelli Oct 22, 2024
5e639ab
test: improve onFilterCellActions tests with clearer descriptions for…
guidomodarelli Oct 22, 2024
fe06973
test: add tests for single filter actions with string values and 'is'…
guidomodarelli Oct 22, 2024
3e7555d
test: add tests for multiple filters with 'is' and 'is not' operators…
guidomodarelli Oct 22, 2024
17c0db5
test: add test for onFilterCellActions with undefined value to ensure…
guidomodarelli Oct 22, 2024
5c0ea1c
test: update filter negate logic and add test for 'is not' operator w…
guidomodarelli Oct 22, 2024
d1757f2
Fix Prettier issue
guidomodarelli Oct 22, 2024
741029b
test: refactor filter creation logic in onFilterCellActions tests for…
guidomodarelli Oct 22, 2024
638da8d
test: unify key usage in filter tests in onFilterCellActions for clea…
guidomodarelli Oct 22, 2024
48205ed
test: add filter logic tests for boolean values in onFilterCellAction…
guidomodarelli Oct 22, 2024
4233592
test: update filter tests in onFilterCellActions to clarify handling …
guidomodarelli Oct 22, 2024
e88e502
test: improve clarity in filter cell action tests by specifying value…
guidomodarelli Oct 22, 2024
fd9a9e8
test: refine value type definition in onFilterCellActions to enhance …
guidomodarelli Oct 22, 2024
1e54b41
Merge branch '4.10.0' into enhancement/7080-add-filter-by-value-to-do…
guidomodarelli Oct 24, 2024
d4fe110
Merge branch '4.10.0' into enhancement/7080-add-filter-by-value-to-do…
asteriscos Oct 24, 2024
9954031
Refactor drilldown components to simplify destructuring of props, rem…
guidomodarelli Oct 25, 2024
ad190ba
Remove unused `filters` and `setFilters` props from OfficePanel for c…
guidomodarelli Oct 25, 2024
53a2ca5
Merge branch '4.10.0' into enhancement/7080-add-filter-by-value-to-do…
guidomodarelli Oct 25, 2024
4d96145
Merge branch '4.10.0' into enhancement/7080-add-filter-by-value-to-do…
guidomodarelli Oct 28, 2024
b28fd9d
Fix typos in export button label across data grid components
guidomodarelli Oct 28, 2024
c6fb420
Merge branch '4.10.0' into enhancement/7080-add-filter-by-value-to-do…
asteriscos Oct 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ All notable changes to the Wazuh app project will be documented in this file.
- Added an "Agents management" menu and moved the sections: "Endpoint Groups" and "Endpoint Summary" which changed its name to "Summary".[#7112](https://github.com/wazuh/wazuh-dashboard-plugins/pull/7112)
- Added ability to filter from File Integrity Monitoring registry inventory [#7119](https://github.com/wazuh/wazuh-dashboard-plugins/pull/7119)
- Added new field columns and ability to select the visible fields in the File Integrity Monitoring Files and Registry tables [#7119](https://github.com/wazuh/wazuh-dashboard-plugins/pull/7119)
- Added filter by value to document details fields [#7081](https://github.com/wazuh/wazuh-dashboard-plugins/pull/7081)

### Changed

Expand Down
5 changes: 5 additions & 0 deletions plugins/main/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -530,3 +530,8 @@ export const OSD_URL_STATE_STORAGE_ID = 'state:storeInSessionStorage';

export const APP_STATE_URL_KEY = '_a';
export const GLOBAL_STATE_URL_KEY = '_g';

export enum FilterStateStore {
APP_STATE = 'appState',
GLOBAL_STATE = 'globalState',
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import { RedirectAppLinks } from '../../../../../../../src/plugins/opensearch_da
import TechniqueRowDetails from '../../../overview/mitre/framework/components/techniques/components/flyout-technique/technique-row-details';
import { DATA_SOURCE_FILTER_CONTROLLED_CLUSTER_MANAGER } from '../../../../../common/constants';
import NavigationService from '../../../../react-services/navigation-service';
import { setFilters } from '../../../common/search-bar/set-filters';

export class FileDetails extends Component {
props!: {
Expand Down Expand Up @@ -586,6 +587,8 @@ export class FileDetails extends Component {

this.discoverFilterManager.addFilters(newFilter);
}}
filters={[]}
setFilters={setFilters(this.discoverFilterManager)}
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe('cell-filter-actions', () => {
fireEvent.click(component);

expect(onFilter).toHaveBeenCalledTimes(1);
expect(onFilter).toHaveBeenCalledWith(TEST_COLUMN_ID, TEST_VALUE, 'is');
expect(onFilter).toHaveBeenCalledWith(TEST_COLUMN_ID, 'is', TEST_VALUE);
});
});

Expand Down Expand Up @@ -102,8 +102,8 @@ describe('cell-filter-actions', () => {
expect(onFilter).toHaveBeenCalledTimes(1);
expect(onFilter).toHaveBeenCalledWith(
TEST_COLUMN_ID,
TEST_VALUE,
'is not',
TEST_VALUE,
);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,30 @@ export const filterIsAction = (
rows: any[],
pageSize: number,
onFilter: (
columndId: string,
value: any,
field: string,
operation: FILTER_OPERATOR.IS | FILTER_OPERATOR.IS_NOT,
value?: any,
) => void,
) => {
return ({
rowIndex,
columnId,
columnId: field,
Component,
}: EuiDataGridColumnCellActionProps) => {
const filterForValueText = i18n.translate('discover.filterForValue', {
defaultMessage: 'Filter for value',
});
const filterForValueLabel = i18n.translate('discover.filterForValueLabel', {
defaultMessage: 'Filter for value: {value}',
values: { value: columnId },
values: { value: field },
});

const handleClick = () => {
const row = rows[rowIndex % pageSize];
const flattened = indexPattern.flattenHit(row);

if (flattened) {
onFilter(columnId, flattened[columnId], FILTER_OPERATOR.IS);
onFilter(field, FILTER_OPERATOR.IS, flattened[field]);
}
};

Expand All @@ -61,26 +61,30 @@ export const filterIsNotAction =
rows: any[],
pageSize: number,
onFilter: (
columndId: string,
value: any,
field: string,
operation: FILTER_OPERATOR.IS | FILTER_OPERATOR.IS_NOT,
value?: any,
) => void,
) =>
({ rowIndex, columnId, Component }: EuiDataGridColumnCellActionProps) => {
({
rowIndex,
columnId: field,
Component,
}: EuiDataGridColumnCellActionProps) => {
const filterOutValueText = i18n.translate('discover.filterOutValue', {
defaultMessage: 'Filter out value',
});
const filterOutValueLabel = i18n.translate('discover.filterOutValueLabel', {
defaultMessage: 'Filter out value: {value}',
values: { value: columnId },
values: { value: field },
});

const handleClick = () => {
const row = rows[rowIndex % pageSize];
const flattened = indexPattern.flattenHit(row);

if (flattened) {
onFilter(columnId, flattened[columnId], FILTER_OPERATOR.IS_NOT);
onFilter(field, FILTER_OPERATOR.IS_NOT, flattened[field]);
}
};

Expand All @@ -103,9 +107,9 @@ export function cellFilterActions(
rows: any[],
pageSize: number,
onFilter: (
columndId: string,
value: any,
field: string,
operation: FILTER_OPERATOR.IS | FILTER_OPERATOR.IS_NOT,
value: any,
) => void,
) {
if (!field.filterable) return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ import {
export const MAX_ENTRIES_PER_QUERY = 10000;
import { tDataGridColumn } from './use-data-grid';
import { cellFilterActions } from './cell-filter-actions';
import {
FILTER_OPERATOR,
PatternDataSourceFilterManager,
} from '../data-source/pattern/pattern-data-source-filter-manager';
import { onFilterCellActions } from './filter-cell-actions';

type ParseData<T> =
| {
Expand Down Expand Up @@ -192,26 +189,6 @@ export const exportSearchToCSV = async (
}
};

const onFilterCellActions = (
indexPatternId: string,
filters: Filter[],
setFilters: (filters: Filter[]) => void,
) => {
return (
columndId: string,
value: any,
operation: FILTER_OPERATOR.IS | FILTER_OPERATOR.IS_NOT,
) => {
const newFilter = PatternDataSourceFilterManager.createFilter(
operation,
columndId,
value,
indexPatternId,
);
setFilters([...filters, newFilter]);
};
};

const mapToDataGridColumn = (
field: IFieldType,
indexPattern: IndexPattern,
Expand Down
Loading
Loading