Skip to content

Commit

Permalink
Move max item per query to global location
Browse files Browse the repository at this point in the history
  • Loading branch information
Machi3mfl committed Jun 26, 2024
1 parent 339c840 commit 7f29967
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -10,7 +11,6 @@ type tDiscoverDataGridAdditionalControlsProps = {
maxEntriesPerQuery?: number;
};

export const MAX_ENTRIES_PER_QUERY = 10000;

const DiscoverDataGridAdditionalControls = (props: tDiscoverDataGridAdditionalControlsProps) => {
const {
Expand All @@ -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
}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down Expand Up @@ -254,8 +255,8 @@ const WazuhFlyoutDiscoverComponent = (props: WazuhDiscoverProps) => {
indexPattern,
})
) : (
<DocDetails doc={doc} item={item} indexPattern={indexPattern} />
);
<DocDetails doc={doc} item={item} indexPattern={indexPattern} />
);
};

const parsedItems = useMemo(() => {
Expand All @@ -278,13 +279,13 @@ const WazuhFlyoutDiscoverComponent = (props: WazuhDiscoverProps) => {
{isDataSourceLoading ? (
<LoadingSpinner />
) : (
<WzSearchBar
appName='wazuh-discover-search-bar'
{...searchBarProps}
useDefaultBehaviors={false}
hideFixedFilters
/>
)}
<WzSearchBar
appName='wazuh-discover-search-bar'
{...searchBarProps}
useDefaultBehaviors={false}
hideFixedFilters
/>
)}
{!isDataSourceLoading && results?.hits?.total === 0 ? (
<DiscoverNoResults timeFieldName={timeField} queryLanguage={''} />
) : null}
Expand All @@ -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',
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,16 +214,16 @@ const DashboardTH: React.FC = () => {
{isDataSourceLoading && !dataSource ? (
<LoadingSpinner />
) : (
<WzSearchBar
appName='th-searchbar'
{...searchBarProps}
fixedFilters={fixedFilters}
showDatePicker={true}
showQueryInput={true}
showQueryBar={true}
showSaveQuery={true}
/>
)}
<WzSearchBar
appName='th-searchbar'
{...searchBarProps}
fixedFilters={fixedFilters}
showDatePicker={true}
showQueryInput={true}
showQueryBar={true}
showSaveQuery={true}
/>
)}
{!isDataSourceLoading && dataSource && results?.hits?.total === 0 ? (
<DiscoverNoResults />
) : null}
Expand Down Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -182,16 +182,16 @@ const InventoryVulsComponent = () => {
{isDataSourceLoading ? (
<LoadingSpinner />
) : (
<WzSearchBar
appName='inventory-vuls'
{...searchBarProps}
fixedFilters={fixedFilters}
showDatePicker={false}
showQueryInput={true}
showQueryBar={true}
showSaveQuery={true}
/>
)}
<WzSearchBar
appName='inventory-vuls'
{...searchBarProps}
fixedFilters={fixedFilters}
showDatePicker={false}
showQueryInput={true}
showQueryBar={true}
showSaveQuery={true}
/>
)}
{!isDataSourceLoading && results?.hits?.total === 0 ? (
<DiscoverNoResults />
) : null}
Expand All @@ -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',
Expand Down

0 comments on commit 7f29967

Please sign in to comment.