Skip to content

Commit

Permalink
- PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-goldstein committed Jul 12, 2022
1 parent 49d27fe commit 848f8da
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,22 @@ describe('layers', () => {

expect(getGroupFromPath(datumWithUndefinedPath)).toBeUndefined();
});

it('returns undefined when path is an empty array', () => {
expect(
getGroupFromPath({
path: [],
})
).toBeUndefined();
});

it('returns undefined when path is an array with only one value', () => {
expect(
getGroupFromPath({
path: [{ index: 0, value: '__null_small_multiples_key__' }],
})
).toBeUndefined();
});
});

describe('getLayersOneDimension', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,11 @@ const AlertsTreemapPanelComponent: React.FC<Props> = ({
hasBorder
height={isPanelExpanded ? height : COLLAPSED_HEIGHT}
$overflowY="auto"
$toggleStatus={true}
$toggleStatus
>
<HeaderSection
alignHeader={alignHeader}
hideSubtitle={true}
hideSubtitle
id={uniqueQueryId}
outerDirection="row"
showInspectButton={chartOptionsContextMenu == null}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,21 @@

import { useCallback, useEffect, useState } from 'react';

import { useKibana } from '../../lib/kibana';
import { APP_ID } from '../../../../common/constants';

import { useKibana } from '../../lib/kibana';
interface Props<T> {
defaultValue: T;
isInvalidDefault?: (value: T) => boolean;
key: string;
plugin: string;
plugin?: string;
}

/** Reads and writes settings from local storage */
export const useLocalStorage = <T,>({
defaultValue,
key,
plugin,
plugin = APP_ID,
isInvalidDefault,
}: Props<T>): [T, (value: T) => void] => {
const { storage } = useKibana().services;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
getSettingKey,
isDefaultWhenEmptyString,
} from '../../../../../common/components/local_storage/helpers';
import { APP_ID } from '../../../../../../common/constants';

import {
ALERTS_PAGE,
ALERT_VIEW_SELECTION_SETTING_NAME,
Expand Down Expand Up @@ -39,7 +39,6 @@ export const useAlertsLocalStorage = (): AlertsSettings => {
page: ALERTS_PAGE,
setting: ALERT_VIEW_SELECTION_SETTING_NAME,
}),
plugin: APP_ID,
isInvalidDefault: isDefaultWhenEmptyString,
});

Expand All @@ -50,7 +49,6 @@ export const useAlertsLocalStorage = (): AlertsSettings => {
page: ALERTS_PAGE,
setting: EXPAND_SETTING_NAME,
}),
plugin: APP_ID,
});

const [riskChartStackBy0, setRiskChartStackBy0] = useLocalStorage<string>({
Expand All @@ -60,7 +58,6 @@ export const useAlertsLocalStorage = (): AlertsSettings => {
page: ALERTS_PAGE,
setting: STACK_BY_0_SETTING_NAME,
}),
plugin: APP_ID,
isInvalidDefault: isDefaultWhenEmptyString,
});

Expand All @@ -71,7 +68,6 @@ export const useAlertsLocalStorage = (): AlertsSettings => {
page: ALERTS_PAGE,
setting: STACK_BY_1_SETTING_NAME,
}),
plugin: APP_ID,
});

const [countTableStackBy0, setCountTableStackBy0] = useLocalStorage<string>({
Expand All @@ -81,7 +77,6 @@ export const useAlertsLocalStorage = (): AlertsSettings => {
page: ALERTS_PAGE,
setting: STACK_BY_0_SETTING_NAME,
}),
plugin: APP_ID,
isInvalidDefault: isDefaultWhenEmptyString,
});

Expand All @@ -92,7 +87,6 @@ export const useAlertsLocalStorage = (): AlertsSettings => {
page: ALERTS_PAGE,
setting: STACK_BY_1_SETTING_NAME,
}),
plugin: APP_ID,
});

const [trendChartStackBy, setTrendChartStackBy] = useLocalStorage<string>({
Expand All @@ -102,7 +96,6 @@ export const useAlertsLocalStorage = (): AlertsSettings => {
page: ALERTS_PAGE,
setting: STACK_BY_SETTING_NAME,
}),
plugin: APP_ID,
isInvalidDefault: isDefaultWhenEmptyString,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ const ChartPanelsComponent: React.FC<Props> = ({
stackByField0={riskChartStackBy0}
stackByField1={riskChartStackBy1}
title={title}
riskSubAggregationField="signal.rule.risk_score" // TODO: 'kibana.alert.rule.risk_score' returns no values
riskSubAggregationField="kibana.alert.risk_score"
runtimeMappings={runtimeMappings}
/>
)}
Expand Down

0 comments on commit 848f8da

Please sign in to comment.