From 177eed0370d63607b936f30aea1bdb138252e49e Mon Sep 17 00:00:00 2001 From: Andrew Macri Date: Mon, 24 Apr 2023 18:49:32 -0600 Subject: [PATCH] - PR feedback --- .../indices_details/index.tsx | 4 +--- .../storage_details/helpers.ts | 9 +++++---- .../check_all/check_index.test.ts | 2 +- .../summary_actions/check_all/helpers.ts | 4 ++-- .../summary_actions/check_all/index.test.tsx | 2 +- .../index_properties/index.test.tsx | 2 +- .../index_properties/markdown/helpers.test.ts | 2 +- .../index_properties/markdown/helpers.ts | 16 ++++++++++------ .../data_quality_panel/pattern/helpers.test.ts | 4 ++-- .../data_quality_panel/pattern/helpers.ts | 8 ++------ .../data_quality_panel/storage_treemap/index.tsx | 2 +- .../storage_treemap/no_data/index.tsx | 2 +- .../mock_unallowed_values.ts} | 0 .../use_unallowed_values/helpers.test.ts | 2 +- 14 files changed, 29 insertions(+), 30 deletions(-) rename x-pack/packages/kbn-ecs-data-quality-dashboard/impl/data_quality/mock/{uallowed_values/mock_uallowed_values.ts => unallowed_values/mock_unallowed_values.ts} (100%) diff --git a/x-pack/packages/kbn-ecs-data-quality-dashboard/impl/data_quality/data_quality_panel/body/data_quality_details/indices_details/index.tsx b/x-pack/packages/kbn-ecs-data-quality-dashboard/impl/data_quality/data_quality_panel/body/data_quality_details/indices_details/index.tsx index f36a7a9c56dddb..9b59a78430e1c1 100644 --- a/x-pack/packages/kbn-ecs-data-quality-dashboard/impl/data_quality/data_quality_panel/body/data_quality_details/indices_details/index.tsx +++ b/x-pack/packages/kbn-ecs-data-quality-dashboard/impl/data_quality/data_quality_panel/body/data_quality_details/indices_details/index.tsx @@ -99,9 +99,7 @@ const IndicesDetailsComponent: React.FC = ({ updatePatternIndexNames={updatePatternIndexNames} updatePatternRollup={updatePatternRollup} /> - {i !== patterns.length - 1 ? ( - - ) : null} + {patterns[i + 1] && } ))} diff --git a/x-pack/packages/kbn-ecs-data-quality-dashboard/impl/data_quality/data_quality_panel/body/data_quality_details/storage_details/helpers.ts b/x-pack/packages/kbn-ecs-data-quality-dashboard/impl/data_quality/data_quality_panel/body/data_quality_details/storage_details/helpers.ts index 66cf6a560e0bf8..09ed53402a89fd 100644 --- a/x-pack/packages/kbn-ecs-data-quality-dashboard/impl/data_quality/data_quality_panel/body/data_quality_details/storage_details/helpers.ts +++ b/x-pack/packages/kbn-ecs-data-quality-dashboard/impl/data_quality/data_quality_panel/body/data_quality_details/storage_details/helpers.ts @@ -7,7 +7,7 @@ import type { Datum, Key, ArrayNode } from '@elastic/charts'; import { euiThemeVars } from '@kbn/ui-theme'; -import { sortBy } from 'lodash/fp'; +import { orderBy } from 'lodash/fp'; import { getSizeInBytes } from '../../../../helpers'; import { getIlmPhase } from '../../../pattern/helpers'; @@ -64,8 +64,9 @@ export const getLegendItemsForPattern = ({ pattern: string; flattenedBuckets: FlattenedBucket[]; }): LegendItem[] => - sortBy( - 'sizeInBytes', + orderBy( + ['sizeInBytes'], + ['desc'], flattenedBuckets .filter((x) => x.pattern === pattern) .map((flattenedBucket) => ({ @@ -75,7 +76,7 @@ export const getLegendItemsForPattern = ({ pattern: flattenedBucket.pattern, sizeInBytes: flattenedBucket.sizeInBytes ?? 0, })) - ).reverse(); + ); export const getLegendItems = ({ patterns, diff --git a/x-pack/packages/kbn-ecs-data-quality-dashboard/impl/data_quality/data_quality_panel/data_quality_summary/summary_actions/check_all/check_index.test.ts b/x-pack/packages/kbn-ecs-data-quality-dashboard/impl/data_quality/data_quality_panel/data_quality_summary/summary_actions/check_all/check_index.test.ts index 4713efde02c713..fd457193a9c6fe 100644 --- a/x-pack/packages/kbn-ecs-data-quality-dashboard/impl/data_quality/data_quality_panel/data_quality_summary/summary_actions/check_all/check_index.test.ts +++ b/x-pack/packages/kbn-ecs-data-quality-dashboard/impl/data_quality/data_quality_panel/data_quality_summary/summary_actions/check_all/check_index.test.ts @@ -10,7 +10,7 @@ import { EcsFlat, EcsVersion } from '@kbn/ecs'; import { checkIndex, EMPTY_PARTITIONED_FIELD_METADATA } from './check_index'; import { EMPTY_STAT } from '../../../../helpers'; import { mockMappingsResponse } from '../../../../mock/mappings_response/mock_mappings_response'; -import { mockUnallowedValuesResponse } from '../../../../mock/uallowed_values/mock_uallowed_values'; +import { mockUnallowedValuesResponse } from '../../../../mock/unallowed_values/mock_unallowed_values'; import { EcsMetadata, UnallowedValueRequestItem } from '../../../../types'; const ecsMetadata = EcsFlat as unknown as Record; diff --git a/x-pack/packages/kbn-ecs-data-quality-dashboard/impl/data_quality/data_quality_panel/data_quality_summary/summary_actions/check_all/helpers.ts b/x-pack/packages/kbn-ecs-data-quality-dashboard/impl/data_quality/data_quality_panel/data_quality_summary/summary_actions/check_all/helpers.ts index 84e22a33a890c4..30f314c73ea3bc 100644 --- a/x-pack/packages/kbn-ecs-data-quality-dashboard/impl/data_quality/data_quality_panel/data_quality_summary/summary_actions/check_all/helpers.ts +++ b/x-pack/packages/kbn-ecs-data-quality-dashboard/impl/data_quality/data_quality_panel/data_quality_summary/summary_actions/check_all/helpers.ts @@ -6,7 +6,7 @@ */ import type { IndicesStatsIndicesStats } from '@elastic/elasticsearch/lib/api/types'; -import { sortBy } from 'lodash/fp'; +import { orderBy } from 'lodash/fp'; import { getDocsCount } from '../../../../helpers'; import type { IndexToCheck, PatternRollup } from '../../../../types'; @@ -41,7 +41,7 @@ export const getAllIndicesToCheck = ( getIndexToCheck({ indexName, pattern }) ); - const sortedIndicesToCheck = sortBy('indexName', indicesToCheck).reverse(); + const sortedIndicesToCheck = orderBy(['indexName'], ['desc'], indicesToCheck); return [...acc, ...sortedIndicesToCheck]; }, []); diff --git a/x-pack/packages/kbn-ecs-data-quality-dashboard/impl/data_quality/data_quality_panel/data_quality_summary/summary_actions/check_all/index.test.tsx b/x-pack/packages/kbn-ecs-data-quality-dashboard/impl/data_quality/data_quality_panel/data_quality_summary/summary_actions/check_all/index.test.tsx index 01d7b52489d732..f2aa7a2666c33d 100644 --- a/x-pack/packages/kbn-ecs-data-quality-dashboard/impl/data_quality/data_quality_panel/data_quality_summary/summary_actions/check_all/index.test.tsx +++ b/x-pack/packages/kbn-ecs-data-quality-dashboard/impl/data_quality/data_quality_panel/data_quality_summary/summary_actions/check_all/index.test.tsx @@ -12,7 +12,7 @@ import React from 'react'; import { mockMappingsResponse } from '../../../../mock/mappings_response/mock_mappings_response'; import { TestProviders } from '../../../../mock/test_providers/test_providers'; -import { mockUnallowedValuesResponse } from '../../../../mock/uallowed_values/mock_uallowed_values'; +import { mockUnallowedValuesResponse } from '../../../../mock/unallowed_values/mock_unallowed_values'; import { CANCEL, CHECK_ALL } from '../../../../translations'; import { OnCheckCompleted, diff --git a/x-pack/packages/kbn-ecs-data-quality-dashboard/impl/data_quality/data_quality_panel/index_properties/index.test.tsx b/x-pack/packages/kbn-ecs-data-quality-dashboard/impl/data_quality/data_quality_panel/index_properties/index.test.tsx index 69f66b3d794dbc..b6914daef0e7da 100644 --- a/x-pack/packages/kbn-ecs-data-quality-dashboard/impl/data_quality/data_quality_panel/index_properties/index.test.tsx +++ b/x-pack/packages/kbn-ecs-data-quality-dashboard/impl/data_quality/data_quality_panel/index_properties/index.test.tsx @@ -14,7 +14,7 @@ import { EMPTY_STAT } from '../../helpers'; import { mockMappingsResponse } from '../../mock/mappings_response/mock_mappings_response'; import { auditbeatWithAllResults } from '../../mock/pattern_rollup/mock_auditbeat_pattern_rollup'; import { TestProviders } from '../../mock/test_providers/test_providers'; -import { mockUnallowedValuesResponse } from '../../mock/uallowed_values/mock_uallowed_values'; +import { mockUnallowedValuesResponse } from '../../mock/unallowed_values/mock_unallowed_values'; import { LOADING_MAPPINGS, LOADING_UNALLOWED_VALUES } from './translations'; import { UnallowedValueRequestItem } from '../../types'; import { IndexProperties, Props } from '.'; diff --git a/x-pack/packages/kbn-ecs-data-quality-dashboard/impl/data_quality/data_quality_panel/index_properties/markdown/helpers.test.ts b/x-pack/packages/kbn-ecs-data-quality-dashboard/impl/data_quality/data_quality_panel/index_properties/markdown/helpers.test.ts index a3bdde69912741..b51a49ecc89dfa 100644 --- a/x-pack/packages/kbn-ecs-data-quality-dashboard/impl/data_quality/data_quality_panel/index_properties/markdown/helpers.test.ts +++ b/x-pack/packages/kbn-ecs-data-quality-dashboard/impl/data_quality/data_quality_panel/index_properties/markdown/helpers.test.ts @@ -150,7 +150,7 @@ describe('helpers', () => { const content = '0123456789'; // content.length === 10 const expected = '------------'; // expected.length === 12 - expect(getHeaderSeparator(content.length)).toEqual(expected); + expect(getHeaderSeparator(content)).toEqual(expected); }); }); diff --git a/x-pack/packages/kbn-ecs-data-quality-dashboard/impl/data_quality/data_quality_panel/index_properties/markdown/helpers.ts b/x-pack/packages/kbn-ecs-data-quality-dashboard/impl/data_quality/data_quality_panel/index_properties/markdown/helpers.ts index 890bfb613a4111..32424dff66883c 100644 --- a/x-pack/packages/kbn-ecs-data-quality-dashboard/impl/data_quality/data_quality_panel/index_properties/markdown/helpers.ts +++ b/x-pack/packages/kbn-ecs-data-quality-dashboard/impl/data_quality/data_quality_panel/index_properties/markdown/helpers.ts @@ -5,8 +5,6 @@ * 2.0. */ -import { repeat } from 'lodash/fp'; - import { ERRORS_MAY_OCCUR, ERRORS_CALLOUT_SUMMARY, @@ -66,11 +64,11 @@ export const escape = (content: string | undefined): string | undefined => export const escapePreserveNewlines = (content: string | undefined): string | undefined => content != null ? content.replaceAll('|', '\\|') : content; -export const getHeaderSeparator = (headerLength: number): string => repeat(headerLength + 2, '-'); +export const getHeaderSeparator = (headerText: string): string => '-'.repeat(headerText.length + 2); // 2 extra, for the spaces on both sides of the column name export const getMarkdownTableHeader = (headerNames: string[]) => ` | ${headerNames.map((name) => `${escape(name)} | `).join('')} -|${headerNames.map((name) => `${getHeaderSeparator(name.length)}|`).join('')}`; +|${headerNames.map((name) => `${getHeaderSeparator(name)}|`).join('')}`; export const getCodeFormattedValue = (value: string | undefined) => `\`${escape(value ?? EMPTY_PLACEHOLDER)}\``; @@ -220,7 +218,11 @@ export const getResultEmoji = (incompatible: number | undefined): string => { export const getSummaryTableMarkdownHeader = (): string => `| ${RESULT} | ${INDEX} | ${DOCS} | ${INCOMPATIBLE_FIELDS} | ${ILM_PHASE} | ${SIZE} | -|--------|-------|------|---------------------|-----------|------|`; +|${getHeaderSeparator(RESULT)}|${getHeaderSeparator(INDEX)}|${getHeaderSeparator( + DOCS + )}|${getHeaderSeparator(INCOMPATIBLE_FIELDS)}|${getHeaderSeparator( + ILM_PHASE + )}|${getHeaderSeparator(SIZE)}|`; export const getSummaryTableMarkdownRow = ({ docsCount, @@ -301,7 +303,9 @@ export const getStatsRollupMarkdownComment = ({ sizeInBytes: number | undefined; }): string => `| ${INCOMPATIBLE_FIELDS} | ${INDICES_CHECKED} | ${INDICES} | ${SIZE} | ${DOCS} | -|---------------------|-----------------|---------|------|------| +|${getHeaderSeparator(INCOMPATIBLE_FIELDS)}|${getHeaderSeparator( + INDICES_CHECKED + )}|${getHeaderSeparator(INDICES)}|${getHeaderSeparator(SIZE)}|${getHeaderSeparator(DOCS)}| | ${incompatible ?? EMPTY_STAT} | ${indicesChecked ?? EMPTY_STAT} | ${ indices ?? EMPTY_STAT } | ${formatBytes(sizeInBytes)} | ${formatNumber(docsCount)} | diff --git a/x-pack/packages/kbn-ecs-data-quality-dashboard/impl/data_quality/data_quality_panel/pattern/helpers.test.ts b/x-pack/packages/kbn-ecs-data-quality-dashboard/impl/data_quality/data_quality_panel/pattern/helpers.test.ts index 2fd33f6fec3ea2..c40f6a73ffa03e 100644 --- a/x-pack/packages/kbn-ecs-data-quality-dashboard/impl/data_quality/data_quality_panel/pattern/helpers.test.ts +++ b/x-pack/packages/kbn-ecs-data-quality-dashboard/impl/data_quality/data_quality_panel/pattern/helpers.test.ts @@ -377,7 +377,7 @@ describe('helpers', () => { docsCount: 0, ilmPhase: undefined, incompatible: undefined, - indexName: 'auditbeat-custom-index-1', + indexName: '.ds-packetbeat-8.6.1-2023.02.04-000001', pattern: 'auditbeat-*', patternDocsCount: 4, sizeInBytes: 0, @@ -395,7 +395,7 @@ describe('helpers', () => { docsCount: 0, ilmPhase: undefined, incompatible: undefined, - indexName: '.ds-packetbeat-8.6.1-2023.02.04-000001', + indexName: 'auditbeat-custom-index-1', pattern: 'auditbeat-*', patternDocsCount: 4, sizeInBytes: 0, diff --git a/x-pack/packages/kbn-ecs-data-quality-dashboard/impl/data_quality/data_quality_panel/pattern/helpers.ts b/x-pack/packages/kbn-ecs-data-quality-dashboard/impl/data_quality/data_quality_panel/pattern/helpers.ts index 674f81a5770034..40d0bbfb262932 100644 --- a/x-pack/packages/kbn-ecs-data-quality-dashboard/impl/data_quality/data_quality_panel/pattern/helpers.ts +++ b/x-pack/packages/kbn-ecs-data-quality-dashboard/impl/data_quality/data_quality_panel/pattern/helpers.ts @@ -9,7 +9,7 @@ import type { IlmExplainLifecycleLifecycleExplain, IndicesStatsIndicesStats, } from '@elastic/elasticsearch/lib/api/types'; -import { sortBy } from 'lodash/fp'; +import { orderBy } from 'lodash/fp'; import type { IndexSummaryTableItem } from '../summary_table/helpers'; import type { @@ -168,11 +168,7 @@ export const getSummaryTableItems = ({ sizeInBytes: getSizeInBytes({ stats, indexName }), })); - if (sortByDirection === 'desc') { - return sortBy(sortByColumn, summaryTableItems).reverse(); - } else { - return sortBy(sortByColumn, summaryTableItems); - } + return orderBy([sortByColumn], [sortByDirection], summaryTableItems); }; export const shouldCreateIndexNames = ({ diff --git a/x-pack/packages/kbn-ecs-data-quality-dashboard/impl/data_quality/data_quality_panel/storage_treemap/index.tsx b/x-pack/packages/kbn-ecs-data-quality-dashboard/impl/data_quality/data_quality_panel/storage_treemap/index.tsx index fcb86b54692595..b42cd6072ad820 100644 --- a/x-pack/packages/kbn-ecs-data-quality-dashboard/impl/data_quality/data_quality_panel/storage_treemap/index.tsx +++ b/x-pack/packages/kbn-ecs-data-quality-dashboard/impl/data_quality/data_quality_panel/storage_treemap/index.tsx @@ -147,7 +147,7 @@ const StorageTreemapComponent: React.FC = ({ {flattenedBuckets.length === 0 ? ( - + ) : ( = ({ reason }) => ( - + {i18n.NO_DATA_LABEL} diff --git a/x-pack/packages/kbn-ecs-data-quality-dashboard/impl/data_quality/mock/uallowed_values/mock_uallowed_values.ts b/x-pack/packages/kbn-ecs-data-quality-dashboard/impl/data_quality/mock/unallowed_values/mock_unallowed_values.ts similarity index 100% rename from x-pack/packages/kbn-ecs-data-quality-dashboard/impl/data_quality/mock/uallowed_values/mock_uallowed_values.ts rename to x-pack/packages/kbn-ecs-data-quality-dashboard/impl/data_quality/mock/unallowed_values/mock_unallowed_values.ts diff --git a/x-pack/packages/kbn-ecs-data-quality-dashboard/impl/data_quality/use_unallowed_values/helpers.test.ts b/x-pack/packages/kbn-ecs-data-quality-dashboard/impl/data_quality/use_unallowed_values/helpers.test.ts index b7566e17cc1ff4..2f80ba5e2cc7a5 100644 --- a/x-pack/packages/kbn-ecs-data-quality-dashboard/impl/data_quality/use_unallowed_values/helpers.test.ts +++ b/x-pack/packages/kbn-ecs-data-quality-dashboard/impl/data_quality/use_unallowed_values/helpers.test.ts @@ -13,7 +13,7 @@ import { getUnallowedValues, isBucket, } from './helpers'; -import { mockUnallowedValuesResponse } from '../mock/uallowed_values/mock_uallowed_values'; +import { mockUnallowedValuesResponse } from '../mock/unallowed_values/mock_unallowed_values'; import { UnallowedValueRequestItem, UnallowedValueSearchResult } from '../types'; describe('helpers', () => {