From 7f29967dccee127fabad19be07d6fe3c1f2c403b Mon Sep 17 00:00:00 2001 From: Maximiliano Ibarra Date: Wed, 26 Jun 2024 08:24:20 -0300 Subject: [PATCH] Move max item per query to global location --- .../data-grid-additional-controls.tsx | 18 ++++++------ .../wazuh-discover/wz-flyout-discover.tsx | 23 +++++++-------- .../threat-hunting/dashboard/dashboard.tsx | 24 ++++++++-------- .../dashboards/inventory/inventory.tsx | 28 ++++++++++--------- 4 files changed, 50 insertions(+), 43 deletions(-) diff --git a/plugins/main/public/components/common/wazuh-discover/components/data-grid-additional-controls.tsx b/plugins/main/public/components/common/wazuh-discover/components/data-grid-additional-controls.tsx index 13f753313a..501c7cde79 100644 --- a/plugins/main/public/components/common/wazuh-discover/components/data-grid-additional-controls.tsx +++ b/plugins/main/public/components/common/wazuh-discover/components/data-grid-additional-controls.tsx @@ -2,6 +2,7 @@ import React from 'react'; import { EuiButtonEmpty } from '@elastic/eui'; import { HitsCounter } from '../../../../kibana-integrations/discover/application/components/hits_counter'; import { formatNumWithCommas } from '../../../../kibana-integrations/discover/application/helpers'; +import { MAX_ENTRIES_PER_QUERY } from '../../data-grid/data-grid-service'; type tDiscoverDataGridAdditionalControlsProps = { totalHits: number; @@ -10,7 +11,6 @@ type tDiscoverDataGridAdditionalControlsProps = { maxEntriesPerQuery?: number; }; -export const MAX_ENTRIES_PER_QUERY = 10000; const DiscoverDataGridAdditionalControls = (props: tDiscoverDataGridAdditionalControlsProps) => { const { @@ -32,13 +32,15 @@ const DiscoverDataGridAdditionalControls = (props: tDiscoverDataGridAdditionalCo tooltip={ totalHits && totalHits > maxEntriesPerQuery ? { - ariaLabel: 'Warning', - content: `The query results has exceeded the limit of 10,000 hits. To provide a better experience the table only shows the first ${formatNumWithCommas( - maxEntriesPerQuery - )} hits.`, - iconType: 'alert', - position: 'top', - } + ariaLabel: 'Warning', + content: `The query results has exceeded the limit of ${formatNumWithCommas( + maxEntriesPerQuery + )} hits. To provide a better experience the table only shows the first ${formatNumWithCommas( + maxEntriesPerQuery + )} hits.`, + iconType: 'alert', + position: 'top', + } : undefined } /> diff --git a/plugins/main/public/components/common/wazuh-discover/wz-flyout-discover.tsx b/plugins/main/public/components/common/wazuh-discover/wz-flyout-discover.tsx index 15237930bb..b0d66a2540 100644 --- a/plugins/main/public/components/common/wazuh-discover/wz-flyout-discover.tsx +++ b/plugins/main/public/components/common/wazuh-discover/wz-flyout-discover.tsx @@ -34,8 +34,9 @@ import { } from '../data-source'; import DocDetails from './components/doc-details'; import { WzSearchBar } from '../search-bar/search-bar'; +import { MAX_ENTRIES_PER_QUERY } from '../data-grid/data-grid-service' + -export const MAX_ENTRIES_PER_QUERY = 10000; export const MAX_ENTRIES_PER_QUERY_FORMATED = formatNumWithCommas( MAX_ENTRIES_PER_QUERY, ) @@ -254,8 +255,8 @@ const WazuhFlyoutDiscoverComponent = (props: WazuhDiscoverProps) => { indexPattern, }) ) : ( - - ); + + ); }; const parsedItems = useMemo(() => { @@ -278,13 +279,13 @@ const WazuhFlyoutDiscoverComponent = (props: WazuhDiscoverProps) => { {isDataSourceLoading ? ( ) : ( - - )} + + )} {!isDataSourceLoading && results?.hits?.total === 0 ? ( ) : null} @@ -304,7 +305,7 @@ const WazuhFlyoutDiscoverComponent = (props: WazuhDiscoverProps) => { results?.hits?.total > MAX_ENTRIES_PER_QUERY ? { ariaLabel: 'Warning', - content: `The query results has exceeded the limit of 10,000 hits. To provide a better experience the table only shows the first ${MAX_ENTRIES_PER_QUERY_FORMATED} hits.`, + content: `The query results has exceeded the limit of ${MAX_ENTRIES_PER_QUERY_FORMATED} hits. To provide a better experience the table only shows the first ${MAX_ENTRIES_PER_QUERY_FORMATED} hits.`, iconType: 'alert', position: 'top', } diff --git a/plugins/main/public/components/overview/threat-hunting/dashboard/dashboard.tsx b/plugins/main/public/components/overview/threat-hunting/dashboard/dashboard.tsx index 56ae5b644c..136efb1062 100644 --- a/plugins/main/public/components/overview/threat-hunting/dashboard/dashboard.tsx +++ b/plugins/main/public/components/overview/threat-hunting/dashboard/dashboard.tsx @@ -214,16 +214,16 @@ const DashboardTH: React.FC = () => { {isDataSourceLoading && !dataSource ? ( ) : ( - - )} + + )} {!isDataSourceLoading && dataSource && results?.hits?.total === 0 ? ( ) : null} @@ -298,7 +298,9 @@ const DashboardTH: React.FC = () => { results?.hits?.total > MAX_ENTRIES_PER_QUERY ? { ariaLabel: 'Warning', - content: `The query results has exceeded the limit of 10,000 hits. To provide a better experience the table only shows the first ${formatNumWithCommas( + content: `The query results has exceeded the limit of ${formatNumWithCommas( + MAX_ENTRIES_PER_QUERY, + )} hits. To provide a better experience the table only shows the first ${formatNumWithCommas( MAX_ENTRIES_PER_QUERY, )} hits.`, iconType: 'alert', diff --git a/plugins/main/public/components/overview/vulnerabilities/dashboards/inventory/inventory.tsx b/plugins/main/public/components/overview/vulnerabilities/dashboards/inventory/inventory.tsx index 0166b42426..3d977171fc 100644 --- a/plugins/main/public/components/overview/vulnerabilities/dashboards/inventory/inventory.tsx +++ b/plugins/main/public/components/overview/vulnerabilities/dashboards/inventory/inventory.tsx @@ -24,7 +24,8 @@ import { HttpError, } from '../../../../../react-services/error-management'; import './inventory.scss'; -import { MAX_ENTRIES_PER_QUERY, inventoryTableDefaultColumns } from './config'; +import { inventoryTableDefaultColumns } from './config'; +import { MAX_ENTRIES_PER_QUERY } from '../../../../common/data-grid/data-grid-service'; import { DiscoverNoResults } from '../../common/components/no_results'; import { LoadingSpinner } from '../../common/components/loading_spinner'; // common components/hooks @@ -36,7 +37,6 @@ import { exportSearchToCSV } from '../../../../common/data-grid/data-grid-servic import { compose } from 'redux'; import { withVulnerabilitiesStateDataSource } from '../../common/hocs/validate-vulnerabilities-states-index-pattern'; import { ModuleEnabledCheck } from '../../common/components/check-module-enabled'; - import { VulnerabilitiesDataSourceRepository, VulnerabilitiesDataSource, @@ -182,16 +182,16 @@ const InventoryVulsComponent = () => { {isDataSourceLoading ? ( ) : ( - - )} + + )} {!isDataSourceLoading && results?.hits?.total === 0 ? ( ) : null} @@ -217,7 +217,9 @@ const InventoryVulsComponent = () => { results?.hits?.total > MAX_ENTRIES_PER_QUERY ? { ariaLabel: 'Warning', - content: `The query results has exceeded the limit of 10,000 hits. To provide a better experience the table only shows the first ${formatNumWithCommas( + content: `The query results has exceeded the limit of ${formatNumWithCommas( + MAX_ENTRIES_PER_QUERY, + )} hits. To provide a better experience the table only shows the first ${formatNumWithCommas( MAX_ENTRIES_PER_QUERY, )} hits.`, iconType: 'alert',