Skip to content

Commit

Permalink
- PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-goldstein committed Apr 25, 2023
1 parent 5aba8b2 commit 177eed0
Show file tree
Hide file tree
Showing 14 changed files with 29 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,7 @@ const IndicesDetailsComponent: React.FC<Props> = ({
updatePatternIndexNames={updatePatternIndexNames}
updatePatternRollup={updatePatternRollup}
/>
{i !== patterns.length - 1 ? (
<EuiSpacer data-test-subj="bodyPatternSpacer" size="s" />
) : null}
{patterns[i + 1] && <EuiSpacer data-test-subj="bodyPatternSpacer" size="s" />}
</EuiFlexItem>
))}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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) => ({
Expand All @@ -75,7 +76,7 @@ export const getLegendItemsForPattern = ({
pattern: flattenedBucket.pattern,
sizeInBytes: flattenedBucket.sizeInBytes ?? 0,
}))
).reverse();
);

export const getLegendItems = ({
patterns,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, EcsMetadata>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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];
}, []);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 '.';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
* 2.0.
*/

import { repeat } from 'lodash/fp';

import {
ERRORS_MAY_OCCUR,
ERRORS_CALLOUT_SUMMARY,
Expand Down Expand Up @@ -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)}\``;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)} |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 = ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ const StorageTreemapComponent: React.FC<Props> = ({
<EuiFlexGroup data-test-subj="storageTreemap" gutterSize="none">
<ChartFlexItem grow={true} $maxChartHeight={maxChartHeight} $minChartHeight={minChartHeight}>
{flattenedBuckets.length === 0 ? (
<NoData reason="" />
<NoData />
) : (
<Chart>
<Settings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interface Props {

const NoDataComponent: React.FC<Props> = ({ reason }) => (
<EuiFlexGroup alignItems="center" gutterSize="none">
<EuiFlexItem grow={true}>
<EuiFlexItem grow>
<NoDataLabel color="subdued" data-test-subj="noDataLabel" size="xs">
{i18n.NO_DATA_LABEL}
</NoDataLabel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down

0 comments on commit 177eed0

Please sign in to comment.