mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
* [SIEM] Migrating frontend services to NP (#52783) * Remove legacy index_patterns import We'd already brought in the new interface in a previous commit; this was just used as an unnecessary type assertion. * Update snapshots following new docLink mocks * Remove unused manual mocks These are not picked up by jest; calling jest.mock('lib/compose/kibana_core') has the same effect whether or not these files exist. * WIP: Use kibana core mock everywhere we're doing it manually The timeline tests are the last place we're explicitly mocking useKibanaCore; removing the mocks cause tests to hang. I think hey're relying on the side effects of importing the mock/ui_settings file, but I'll figure that out next. * Replace ui/documentation_links with core NP service In most instances, this meant using the useContext hook with our NP core context. This also updates our mocks to leverage the factory so graciously provided by platform. There are a few failing tests, mostly due to links being previously undefined in tests. * Use new mocks on timeline test that doesn't hang The rest of these do, though. * Remove remaining uses of mockUiSettings in useKibanaCore mocks These have to be evaluated immediately so that we always return the same core object. Otherwise we get stuck in a loop between render/useEffect/setState due to the savedObjects client being different on each invocation. * Invoke platform's mock factory at mock time Previously, we were invoking it any time someone called `useKibanaCore`, getting a new object back each time. This both caused some bugs (looping with useEffect) and was not representative of how the actual hook worked. This also moves that invokation into the mock function, along with shaping the mocked module so that we don't have to do it in every call to jest.mock. * WIP: migrating to use kibana_react's provider and helpers We're re-exporting these locally to have more control around mocking them (until platform implements that). This breaks everything that was using the old mocks. Will fix. * WIP: Migrating to use kibana_react Instead of our homegrown hooks we can use these utilities instead. Unfortunately kibana_react doesn't yet have mocks, so we had to implement that ourselves. Luckily, we already had local mocks for the settings service. This migrates to a the new format. For clarity and consistency, we also re-export new platform's mocks here and use them to populate our kibana_react mocks. We started by migrating the UiSettings service to new platform, and let that drive the rest. With the mocks in place for kibana_react, removing the usage of useKibanaCore was a natural step as well. The next step is removing the usage of chrome.getUiSettingsClient with our useUiSetting$ hook, and with that (and maybe some config setup; I'm seeing errors at runtime), we should be ready to start migrating other services. * Bind a copy of kibana at mock creation We were previously returning a new copy any time e.g. useKibana was called, which is not the contract that consumers are expecting. and in fact caused looping with components employing useEffect etc. * Remove internal context providers and last usage We're now using kibana_react fully. * Fix tests failing due to wrong mocks Remaining failures are either due to a date format issue, or something being rendered differently. Those are up next. Still haven't touched use of chrome.getUiSettingsClient, that's after. * Fix test failures related to date formatting * mocks missing UI Setting (DEFAULT_TIMEZONE_BROWSER) which is required by our formatted_date utilities * mock timepicker ranges in the one test that uses it (SuperDatePicker) * Remove unnecessary and/or redundant mocks Since our TestProvider now mocks new platform, the only tests that should need to mock uiSettings related stuff (e.g. timezone preferences) would be the tests that (directly or no) use kibana_react to get it. * Refactor kibana_react mocks * adds a mock for the non-observable useUiSetting * removes the unmockable HOC withKibana * Replace usage of chrome.getUiSettingsClient with useUiSetting We're opting for the non-observable behavior here because I believe that's more analagous. There are a few remaining usages in non-react code. Tests are still using the mocks, those'll be removed next. * Remove ui_settings mocks Now that we're not using this hook there's no need for the mocks. Tests are green. * Remove siem's UI settings hook We're now using the ones provided by kibana_react. * Use withKibana HOC on our component classes React was kind enough to remind me that I can't put hooks in classes. Whoops. * Set defaults for some unknown UI settings The service claims not to know about these settings we're retrieving. Until I can figure out where they should come from, we're going to initialize them with what seem to be the defaults at plugin initialization. * Remove old hooks These have now been replaced with kibana_react's equivalents. * Fix type error on usage of useKibana hook This is one of the few places where we're using another plugin, which are not present in the default typings due to their opt-in nature. * Fix type error on ML call The indexPattern we get back is actually an array. The endpoint seems to handle this just fine (at least, it doesn't blow up), but once we started retrieving a typed value this error surfaced. * Export a 'bound' version of the useKibana function Rather than having to type this on each invocation. This requires us to define which plugins we depend on, which is a good thing. * Instantiate our mock function We aren't using these right now I didn't notice, but that wasn't the right reference. * Fix test that relies on unmocked service Our QueryBar component relies very (very, very) indirectly on a storage service that does not exist in New Platform, nor its corresponding mocks. To get it passing for now, we're just gonna pretend like it's there. * Remove use of ui/chrome in our charts Replaces with hooks that accomplish the same. * Remove last use of chrome.getUiSettingsClient This function is itself a hook, so we should be good here. * Remove unnecessary non-null assertions Now that we're using our typed version of the useKibana hook, typescript knows that these services will be available (once we actually enforce that in our kibana.json, of course). * Fix chart tests These rely on a kibana hook now, so we need to mock it out for these renders lest we blow up when the context isn't there. * Replace missing mock I deleted this in a previous commit, thinking it unneeded. However, getHostDetailsBreadcrumbs ultimately asks for some default date parameters for the timerange boundaries. * Add back tests for our theming hook * Style: cleanup * Remove unneeded default UI Settings values We were previously getting errors due to these values not being known to the client, but it looks like that was either fixed upstream, or a temporary issue caused by some improper context setup. * Simplify kibana_react mocks Let's leave JSX out of it. Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> * Update references to now-deleted hooks These hooks were deleted on a recent branch, but new usages were merged to master in the meantime. * Fix remaining uses of hooks/chrome that were not merge conflicts * Use HOC on class component Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
parent
3beace99eb
commit
63e1e750dd
166 changed files with 852 additions and 1126 deletions
|
@ -15,6 +15,12 @@ import template from './template.html';
|
|||
|
||||
export const ROOT_ELEMENT_ID = 'react-siem-root';
|
||||
|
||||
export type StartCore = LegacyCoreStart;
|
||||
export type StartPlugins = Required<
|
||||
Pick<PluginsStart, 'data' | 'embeddable' | 'inspector' | 'uiActions'>
|
||||
>;
|
||||
export type StartServices = StartCore & StartPlugins;
|
||||
|
||||
export class Plugin {
|
||||
constructor(
|
||||
// @ts-ignore this is added to satisfy the New Platform typing constraint,
|
||||
|
@ -25,7 +31,7 @@ export class Plugin {
|
|||
this.chrome = chrome;
|
||||
}
|
||||
|
||||
public start(core: LegacyCoreStart, plugins: PluginsStart) {
|
||||
public start(core: StartCore, plugins: StartPlugins) {
|
||||
// @ts-ignore improper type description
|
||||
this.chrome.setRootTemplate(template);
|
||||
const checkForRoot = () => {
|
||||
|
|
|
@ -9,8 +9,6 @@ import React, { memo, FC } from 'react';
|
|||
import { ApolloProvider } from 'react-apollo';
|
||||
import { Provider as ReduxStoreProvider } from 'react-redux';
|
||||
import { ThemeProvider } from 'styled-components';
|
||||
import { LegacyCoreStart } from 'kibana/public';
|
||||
import { PluginsStart } from 'ui/new_platform/new_platform';
|
||||
|
||||
import { EuiErrorBoundary } from '@elastic/eui';
|
||||
import euiDarkVars from '@elastic/eui/dist/eui_theme_dark.json';
|
||||
|
@ -19,16 +17,14 @@ import { BehaviorSubject } from 'rxjs';
|
|||
import { pluck } from 'rxjs/operators';
|
||||
import { I18nContext } from 'ui/i18n';
|
||||
|
||||
import { KibanaContextProvider } from '../../../../../../src/plugins/kibana_react/public';
|
||||
import { KibanaContextProvider, useUiSetting$ } from '../lib/kibana';
|
||||
import { Storage } from '../../../../../../src/plugins/kibana_utils/public';
|
||||
|
||||
import { DEFAULT_DARK_MODE } from '../../common/constants';
|
||||
import { ErrorToastDispatcher } from '../components/error_toast_dispatcher';
|
||||
import { compose } from '../lib/compose/kibana_compose';
|
||||
import { AppFrontendLibs } from '../lib/lib';
|
||||
import { KibanaCoreContextProvider } from '../lib/compose/kibana_core';
|
||||
import { KibanaPluginsContextProvider } from '../lib/compose/kibana_plugins';
|
||||
import { useKibanaUiSetting } from '../lib/settings/use_kibana_ui_setting';
|
||||
import { StartCore, StartPlugins } from './plugin';
|
||||
import { PageRouter } from '../routes';
|
||||
import { createStore } from '../store/store';
|
||||
import { GlobalToaster, ManageGlobalToaster } from '../components/toasters';
|
||||
|
@ -44,7 +40,7 @@ const StartApp: FC<AppFrontendLibs> = memo(libs => {
|
|||
const store = createStore(undefined, libs$.pipe(pluck('apolloClient')));
|
||||
|
||||
const AppPluginRoot = memo(() => {
|
||||
const [darkMode] = useKibanaUiSetting(DEFAULT_DARK_MODE);
|
||||
const [darkMode] = useUiSetting$<boolean>(DEFAULT_DARK_MODE);
|
||||
return (
|
||||
<EuiErrorBoundary>
|
||||
<I18nContext>
|
||||
|
@ -77,21 +73,15 @@ const StartApp: FC<AppFrontendLibs> = memo(libs => {
|
|||
|
||||
export const ROOT_ELEMENT_ID = 'react-siem-root';
|
||||
|
||||
export const SiemApp = memo<{ core: LegacyCoreStart; plugins: PluginsStart }>(
|
||||
({ core, plugins }) => (
|
||||
<KibanaContextProvider
|
||||
services={{
|
||||
appName: 'siem',
|
||||
data: plugins.data,
|
||||
storage: new Storage(localStorage),
|
||||
...core,
|
||||
}}
|
||||
>
|
||||
<KibanaCoreContextProvider core={core}>
|
||||
<KibanaPluginsContextProvider plugins={plugins}>
|
||||
<StartApp {...compose()} />
|
||||
</KibanaPluginsContextProvider>
|
||||
</KibanaCoreContextProvider>
|
||||
</KibanaContextProvider>
|
||||
)
|
||||
);
|
||||
export const SiemApp = memo<{ core: StartCore; plugins: StartPlugins }>(({ core, plugins }) => (
|
||||
<KibanaContextProvider
|
||||
services={{
|
||||
appName: 'siem',
|
||||
data: plugins.data,
|
||||
storage: new Storage(localStorage),
|
||||
...core,
|
||||
}}
|
||||
>
|
||||
<StartApp {...compose()} />
|
||||
</KibanaContextProvider>
|
||||
));
|
||||
|
|
|
@ -12,8 +12,6 @@ import { useMountAppended } from '../../utils/use_mount_appended';
|
|||
|
||||
import { Bytes } from '.';
|
||||
|
||||
jest.mock('../../lib/settings/use_kibana_ui_setting');
|
||||
|
||||
describe('Bytes', () => {
|
||||
const mount = useMountAppended();
|
||||
|
||||
|
|
|
@ -11,6 +11,8 @@ import { AreaChartBaseComponent, AreaChartComponent } from './areachart';
|
|||
import { ChartSeriesData } from './common';
|
||||
import { ScaleType, AreaSeries, Axis } from '@elastic/charts';
|
||||
|
||||
jest.mock('../../lib/kibana');
|
||||
|
||||
const customHeight = '100px';
|
||||
const customWidth = '120px';
|
||||
const chartDataSets = [
|
||||
|
|
|
@ -21,7 +21,6 @@ import { getOr, get, isNull, isNumber } from 'lodash/fp';
|
|||
import { AutoSizer } from '../auto_sizer';
|
||||
import { ChartPlaceHolder } from './chart_place_holder';
|
||||
import {
|
||||
browserTimezone,
|
||||
chartDefaultSettings,
|
||||
ChartSeriesConfigs,
|
||||
ChartSeriesData,
|
||||
|
@ -29,6 +28,8 @@ import {
|
|||
getChartWidth,
|
||||
getSeriesStyle,
|
||||
WrappedByAutoSizer,
|
||||
useTheme,
|
||||
useBrowserTimeZone,
|
||||
} from './common';
|
||||
|
||||
// custom series styles: https://ela.st/areachart-styling
|
||||
|
@ -72,12 +73,15 @@ export const AreaChartBaseComponent = ({
|
|||
height: string | null | undefined;
|
||||
configs?: ChartSeriesConfigs | undefined;
|
||||
}) => {
|
||||
const theme = useTheme();
|
||||
const timeZone = useBrowserTimeZone();
|
||||
const xTickFormatter = get('configs.axis.xTickFormatter', chartConfigs);
|
||||
const yTickFormatter = get('configs.axis.yTickFormatter', chartConfigs);
|
||||
const xAxisId = getAxisId(`group-${data[0].key}-x`);
|
||||
const yAxisId = getAxisId(`group-${data[0].key}-y`);
|
||||
const settings = {
|
||||
...chartDefaultSettings,
|
||||
theme,
|
||||
...get('configs.settings', chartConfigs),
|
||||
};
|
||||
return chartConfigs.width && chartConfigs.height ? (
|
||||
|
@ -95,7 +99,7 @@ export const AreaChartBaseComponent = ({
|
|||
data={series.value || undefined}
|
||||
xScaleType={getOr(ScaleType.Linear, 'configs.series.xScaleType', chartConfigs)}
|
||||
yScaleType={getOr(ScaleType.Linear, 'configs.series.yScaleType', chartConfigs)}
|
||||
timeZone={browserTimezone}
|
||||
timeZone={timeZone}
|
||||
xAccessor="x"
|
||||
yAccessors={['y']}
|
||||
areaSeriesStyle={getSeriesLineStyle()}
|
||||
|
|
|
@ -11,6 +11,8 @@ import { BarChartBaseComponent, BarChartComponent } from './barchart';
|
|||
import { ChartSeriesData } from './common';
|
||||
import { BarSeries, ScaleType, Axis } from '@elastic/charts';
|
||||
|
||||
jest.mock('../../lib/kibana');
|
||||
|
||||
const customHeight = '100px';
|
||||
const customWidth = '120px';
|
||||
const chartDataSets = [
|
||||
|
|
|
@ -19,16 +19,17 @@ import { getOr, get, isNumber } from 'lodash/fp';
|
|||
import { AutoSizer } from '../auto_sizer';
|
||||
import { ChartPlaceHolder } from './chart_place_holder';
|
||||
import {
|
||||
browserTimezone,
|
||||
chartDefaultSettings,
|
||||
ChartSeriesConfigs,
|
||||
ChartSeriesData,
|
||||
checkIfAllValuesAreZero,
|
||||
getSeriesStyle,
|
||||
getChartHeight,
|
||||
getChartWidth,
|
||||
getSeriesStyle,
|
||||
SeriesType,
|
||||
WrappedByAutoSizer,
|
||||
useBrowserTimeZone,
|
||||
useTheme,
|
||||
} from './common';
|
||||
|
||||
const checkIfAllTheDataInTheSeriesAreValid = (series: ChartSeriesData): series is ChartSeriesData =>
|
||||
|
@ -53,6 +54,8 @@ export const BarChartBaseComponent = ({
|
|||
height: string | null | undefined;
|
||||
configs?: ChartSeriesConfigs | undefined;
|
||||
}) => {
|
||||
const theme = useTheme();
|
||||
const timeZone = useBrowserTimeZone();
|
||||
const xTickFormatter = get('configs.axis.xTickFormatter', chartConfigs);
|
||||
const yTickFormatter = get('configs.axis.yTickFormatter', chartConfigs);
|
||||
const tickSize = getOr(0, 'configs.axis.tickSize', chartConfigs);
|
||||
|
@ -60,6 +63,7 @@ export const BarChartBaseComponent = ({
|
|||
const yAxisId = getAxisId(`stat-items-barchart-${data[0].key}-y`);
|
||||
const settings = {
|
||||
...chartDefaultSettings,
|
||||
theme,
|
||||
...get('configs.settings', chartConfigs),
|
||||
};
|
||||
|
||||
|
@ -79,7 +83,7 @@ export const BarChartBaseComponent = ({
|
|||
yScaleType={getOr(ScaleType.Linear, 'configs.series.yScaleType', chartConfigs)}
|
||||
xAccessor="x"
|
||||
yAccessors={['y']}
|
||||
timeZone={browserTimezone}
|
||||
timeZone={timeZone}
|
||||
splitSeriesAccessors={['g']}
|
||||
data={series.value!}
|
||||
stackAccessors={get('configs.series.stackAccessors', chartConfigs)}
|
||||
|
|
|
@ -5,23 +5,27 @@
|
|||
*/
|
||||
import { shallow } from 'enzyme';
|
||||
import React from 'react';
|
||||
import { renderHook } from '@testing-library/react-hooks';
|
||||
|
||||
import { useUiSetting } from '../../lib/kibana';
|
||||
import {
|
||||
checkIfAllValuesAreZero,
|
||||
defaultChartHeight,
|
||||
getChartHeight,
|
||||
getChartWidth,
|
||||
getSeriesStyle,
|
||||
getTheme,
|
||||
SeriesType,
|
||||
WrappedByAutoSizer,
|
||||
ChartSeriesData,
|
||||
useTheme,
|
||||
} from './common';
|
||||
import { mergeWithDefaultTheme, LIGHT_THEME } from '@elastic/charts';
|
||||
|
||||
jest.mock('../../lib/kibana');
|
||||
|
||||
jest.mock('@elastic/charts', () => {
|
||||
return {
|
||||
...jest.requireActual('@elastic/charts'),
|
||||
getSpecId: jest.fn(() => {}),
|
||||
mergeWithDefaultTheme: jest.fn(),
|
||||
};
|
||||
});
|
||||
|
||||
|
@ -57,21 +61,6 @@ describe('getSeriesStyle', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('getTheme', () => {
|
||||
it('should merge custom theme with default theme', () => {
|
||||
const defaultTheme = {
|
||||
chartMargins: { bottom: 0, left: 0, right: 0, top: 4 },
|
||||
chartPaddings: { bottom: 0, left: 0, right: 0, top: 0 },
|
||||
scales: {
|
||||
barsPadding: 0.05,
|
||||
},
|
||||
};
|
||||
getTheme();
|
||||
expect((mergeWithDefaultTheme as jest.Mock).mock.calls[0][0]).toMatchObject(defaultTheme);
|
||||
expect((mergeWithDefaultTheme as jest.Mock).mock.calls[0][1]).toEqual(LIGHT_THEME);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getChartHeight', () => {
|
||||
it('should render customHeight', () => {
|
||||
const height = getChartHeight(10, 100);
|
||||
|
@ -197,4 +186,23 @@ describe('checkIfAllValuesAreZero', () => {
|
|||
expect(result).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('useTheme', () => {
|
||||
it('merges our spacing with the default theme', () => {
|
||||
const { result } = renderHook(() => useTheme());
|
||||
|
||||
expect(result.current).toEqual(
|
||||
expect.objectContaining({ chartMargins: expect.objectContaining({ top: 4, bottom: 0 }) })
|
||||
);
|
||||
});
|
||||
|
||||
it('returns a different theme depending on user settings', () => {
|
||||
const { result: defaultResult } = renderHook(() => useTheme());
|
||||
(useUiSetting as jest.Mock).mockImplementation(() => true);
|
||||
|
||||
const { result: darkResult } = renderHook(() => useTheme());
|
||||
|
||||
expect(defaultResult.current).not.toMatchObject(darkResult.current);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import chrome from 'ui/chrome';
|
||||
import {
|
||||
CustomSeriesColorsMap,
|
||||
DARK_THEME,
|
||||
|
@ -21,6 +20,7 @@ import {
|
|||
} from '@elastic/charts';
|
||||
import moment from 'moment-timezone';
|
||||
import styled from 'styled-components';
|
||||
import { useUiSetting } from '../../lib/kibana';
|
||||
import { DEFAULT_DATE_FORMAT_TZ, DEFAULT_DARK_MODE } from '../../../common/constants';
|
||||
|
||||
export const defaultChartHeight = '100%';
|
||||
|
@ -95,27 +95,28 @@ export const getSeriesStyle = (
|
|||
};
|
||||
|
||||
// Apply margins and paddings: https://ela.st/charts-spacing
|
||||
export const getTheme = () => {
|
||||
const theme: PartialTheme = {
|
||||
chartMargins: {
|
||||
left: 0,
|
||||
right: 0,
|
||||
// Apply some paddings to the top to avoid chopping the y tick https://ela.st/chopping-edge
|
||||
top: 4,
|
||||
bottom: 0,
|
||||
},
|
||||
chartPaddings: {
|
||||
left: 0,
|
||||
right: 0,
|
||||
top: 0,
|
||||
bottom: 0,
|
||||
},
|
||||
scales: {
|
||||
barsPadding: 0.05,
|
||||
},
|
||||
};
|
||||
const isDarkMode: boolean = chrome.getUiSettingsClient().get(DEFAULT_DARK_MODE);
|
||||
const theme: PartialTheme = {
|
||||
chartMargins: {
|
||||
left: 0,
|
||||
right: 0,
|
||||
// Apply some paddings to the top to avoid chopping the y tick https://ela.st/chopping-edge
|
||||
top: 4,
|
||||
bottom: 0,
|
||||
},
|
||||
chartPaddings: {
|
||||
left: 0,
|
||||
right: 0,
|
||||
top: 0,
|
||||
bottom: 0,
|
||||
},
|
||||
scales: {
|
||||
barsPadding: 0.05,
|
||||
},
|
||||
};
|
||||
export const useTheme = () => {
|
||||
const isDarkMode = useUiSetting<boolean>(DEFAULT_DARK_MODE);
|
||||
const defaultTheme = isDarkMode ? DARK_THEME : LIGHT_THEME;
|
||||
|
||||
return mergeWithDefaultTheme(theme, defaultTheme);
|
||||
};
|
||||
|
||||
|
@ -126,11 +127,12 @@ export const chartDefaultSettings = {
|
|||
showLegend: false,
|
||||
showLegendDisplayValue: false,
|
||||
debug: false,
|
||||
theme: getTheme(),
|
||||
};
|
||||
|
||||
const kibanaTimezone: string = chrome.getUiSettingsClient().get(DEFAULT_DATE_FORMAT_TZ);
|
||||
export const browserTimezone = kibanaTimezone === 'Browser' ? moment.tz.guess() : kibanaTimezone;
|
||||
export const useBrowserTimeZone = () => {
|
||||
const kibanaTimezone = useUiSetting<string>(DEFAULT_DATE_FORMAT_TZ);
|
||||
return kibanaTimezone === 'Browser' ? moment.tz.guess() : kibanaTimezone;
|
||||
};
|
||||
|
||||
export const getChartHeight = (customHeight?: number, autoSizerHeight?: number): string => {
|
||||
const height = customHeight || autoSizerHeight;
|
||||
|
|
|
@ -9,7 +9,6 @@ import { mount, shallow } from 'enzyme';
|
|||
import toJson from 'enzyme-to-json';
|
||||
import React from 'react';
|
||||
|
||||
import '../../../mock/ui_settings';
|
||||
import { TestProviders } from '../../../mock';
|
||||
import {
|
||||
UtilityBar,
|
||||
|
@ -19,8 +18,6 @@ import {
|
|||
UtilityBarText,
|
||||
} from './index';
|
||||
|
||||
jest.mock('../../../lib/settings/use_kibana_ui_setting');
|
||||
|
||||
describe('UtilityBar', () => {
|
||||
test('it renders', () => {
|
||||
const wrapper = shallow(
|
||||
|
|
|
@ -8,12 +8,9 @@ import { mount, shallow } from 'enzyme';
|
|||
import toJson from 'enzyme-to-json';
|
||||
import React from 'react';
|
||||
|
||||
import '../../../mock/ui_settings';
|
||||
import { TestProviders } from '../../../mock';
|
||||
import { UtilityBarAction } from './index';
|
||||
|
||||
jest.mock('../../../lib/settings/use_kibana_ui_setting');
|
||||
|
||||
describe('UtilityBarAction', () => {
|
||||
test('it renders', () => {
|
||||
const wrapper = shallow(
|
||||
|
|
|
@ -8,12 +8,9 @@ import { shallow } from 'enzyme';
|
|||
import toJson from 'enzyme-to-json';
|
||||
import React from 'react';
|
||||
|
||||
import '../../../mock/ui_settings';
|
||||
import { TestProviders } from '../../../mock';
|
||||
import { UtilityBarGroup, UtilityBarText } from './index';
|
||||
|
||||
jest.mock('../../../lib/settings/use_kibana_ui_setting');
|
||||
|
||||
describe('UtilityBarGroup', () => {
|
||||
test('it renders', () => {
|
||||
const wrapper = shallow(
|
||||
|
|
|
@ -8,12 +8,9 @@ import { shallow } from 'enzyme';
|
|||
import toJson from 'enzyme-to-json';
|
||||
import React from 'react';
|
||||
|
||||
import '../../../mock/ui_settings';
|
||||
import { TestProviders } from '../../../mock';
|
||||
import { UtilityBarGroup, UtilityBarSection, UtilityBarText } from './index';
|
||||
|
||||
jest.mock('../../../lib/settings/use_kibana_ui_setting');
|
||||
|
||||
describe('UtilityBarSection', () => {
|
||||
test('it renders', () => {
|
||||
const wrapper = shallow(
|
||||
|
|
|
@ -8,12 +8,9 @@ import { shallow } from 'enzyme';
|
|||
import toJson from 'enzyme-to-json';
|
||||
import React from 'react';
|
||||
|
||||
import '../../../mock/ui_settings';
|
||||
import { TestProviders } from '../../../mock';
|
||||
import { UtilityBarText } from './index';
|
||||
|
||||
jest.mock('../../../lib/settings/use_kibana_ui_setting');
|
||||
|
||||
describe('UtilityBarText', () => {
|
||||
test('it renders', () => {
|
||||
const wrapper = shallow(
|
||||
|
|
|
@ -9,7 +9,7 @@ exports[`EmbeddedMapComponent renders correctly against snapshot 1`] = `
|
|||
size="xs"
|
||||
>
|
||||
<EuiLink
|
||||
href="undefinedguide/en/siem/guide/undefined/conf-map-ui.html"
|
||||
href="https://www.elastic.co/guide/en/siem/guide/mocked-test-branch/conf-map-ui.html"
|
||||
target="_blank"
|
||||
>
|
||||
Map configuration help
|
||||
|
|
|
@ -21,7 +21,7 @@ exports[`IndexPatternsMissingPrompt renders correctly against snapshot 1`] = `
|
|||
values={
|
||||
Object {
|
||||
"beats": <a
|
||||
href="https://www.elastic.coguide/en/beats/libbeat/current/getting-started.html"
|
||||
href="https://www.elastic.co/guide/en/beats/libbeat/mocked-test-branch/getting-started.html"
|
||||
rel="noopener noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
|
|
|
@ -8,11 +8,8 @@ import { shallow } from 'enzyme';
|
|||
import toJson from 'enzyme-to-json';
|
||||
import React from 'react';
|
||||
|
||||
import '../../mock/ui_settings';
|
||||
import { Embeddable } from './embeddable';
|
||||
|
||||
jest.mock('../../lib/settings/use_kibana_ui_setting');
|
||||
|
||||
describe('Embeddable', () => {
|
||||
test('it renders', () => {
|
||||
const wrapper = shallow(
|
||||
|
|
|
@ -8,12 +8,9 @@ import { mount, shallow } from 'enzyme';
|
|||
import toJson from 'enzyme-to-json';
|
||||
import React from 'react';
|
||||
|
||||
import '../../mock/ui_settings';
|
||||
import { TestProviders } from '../../mock';
|
||||
import { EmbeddableHeader } from './embeddable_header';
|
||||
|
||||
jest.mock('../../lib/settings/use_kibana_ui_setting');
|
||||
|
||||
describe('EmbeddableHeader', () => {
|
||||
test('it renders', () => {
|
||||
const wrapper = shallow(<EmbeddableHeader title="Test title" />);
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
import { shallow } from 'enzyme';
|
||||
import toJson from 'enzyme-to-json';
|
||||
import * as React from 'react';
|
||||
|
||||
import { useIndexPatterns } from '../../hooks/use_index_patterns';
|
||||
import { EmbeddedMapComponent } from './embedded_map';
|
||||
import { SetQuery } from './types';
|
||||
import { useKibanaCore } from '../../lib/compose/kibana_core';
|
||||
import { useIndexPatterns } from '../../hooks/use_index_patterns';
|
||||
|
||||
jest.mock('../search_bar', () => ({
|
||||
siemFilterManager: {
|
||||
|
@ -22,22 +22,7 @@ const mockUseIndexPatterns = useIndexPatterns as jest.Mock;
|
|||
jest.mock('../../hooks/use_index_patterns');
|
||||
mockUseIndexPatterns.mockImplementation(() => [true, []]);
|
||||
|
||||
const mockUseKibanaCore = useKibanaCore as jest.Mock;
|
||||
jest.mock('../../lib/compose/kibana_core');
|
||||
mockUseKibanaCore.mockImplementation(() => ({
|
||||
uiSettings: {
|
||||
get$: () => 'world',
|
||||
},
|
||||
injectedMetadata: {
|
||||
getKibanaVersion: () => '8.0.0',
|
||||
},
|
||||
}));
|
||||
|
||||
jest.mock('../../lib/compose/kibana_plugins');
|
||||
|
||||
jest.mock('ui/vis/lib/timezone', () => ({
|
||||
timezoneProvider: () => () => 'America/New_York',
|
||||
}));
|
||||
jest.mock('../../lib/kibana');
|
||||
|
||||
describe('EmbeddedMapComponent', () => {
|
||||
let setQuery: SetQuery;
|
||||
|
|
|
@ -8,16 +8,12 @@ import { EuiLink, EuiText } from '@elastic/eui';
|
|||
import React, { useEffect, useState } from 'react';
|
||||
import { createPortalNode, InPortal } from 'react-reverse-portal';
|
||||
import styled, { css } from 'styled-components';
|
||||
import { ELASTIC_WEBSITE_URL, DOC_LINK_VERSION } from 'ui/documentation_links';
|
||||
|
||||
import { EmbeddablePanel } from '../../../../../../../src/legacy/core_plugins/embeddable_api/public/np_ready/public';
|
||||
import { start } from '../../../../../../../src/legacy/core_plugins/embeddable_api/public/np_ready/public/legacy';
|
||||
import { DEFAULT_INDEX_KEY } from '../../../common/constants';
|
||||
import { getIndexPatternTitleIdMapping } from '../../hooks/api/helpers';
|
||||
import { useIndexPatterns } from '../../hooks/use_index_patterns';
|
||||
import { useKibanaCore } from '../../lib/compose/kibana_core';
|
||||
import { useKibanaPlugins } from '../../lib/compose/kibana_plugins';
|
||||
import { useKibanaUiSetting } from '../../lib/settings/use_kibana_ui_setting';
|
||||
import { Loader } from '../loader';
|
||||
import { useStateToaster } from '../toasters';
|
||||
import { Embeddable } from './embeddable';
|
||||
|
@ -28,6 +24,7 @@ import { MapToolTip } from './map_tool_tip/map_tool_tip';
|
|||
import * as i18n from './translations';
|
||||
import { MapEmbeddable, SetQuery } from './types';
|
||||
import { Query, esFilters } from '../../../../../../../src/plugins/data/public';
|
||||
import { useKibana, useUiSetting$ } from '../../lib/kibana';
|
||||
import {
|
||||
SavedObjectFinderProps,
|
||||
SavedObjectFinderUi,
|
||||
|
@ -96,7 +93,7 @@ export const EmbeddedMapComponent = ({
|
|||
|
||||
const [, dispatchToaster] = useStateToaster();
|
||||
const [loadingKibanaIndexPatterns, kibanaIndexPatterns] = useIndexPatterns();
|
||||
const [siemDefaultIndices] = useKibanaUiSetting(DEFAULT_INDEX_KEY);
|
||||
const [siemDefaultIndices] = useUiSetting$<string[]>(DEFAULT_INDEX_KEY);
|
||||
|
||||
// This portalNode provided by react-reverse-portal allows us re-parent the MapToolTip within our
|
||||
// own component tree instead of the embeddables (default). This is necessary to have access to
|
||||
|
@ -104,8 +101,7 @@ export const EmbeddedMapComponent = ({
|
|||
// Search InPortal/OutPortal for implementation touch points
|
||||
const portalNode = React.useMemo(() => createPortalNode(), []);
|
||||
|
||||
const plugins = useKibanaPlugins();
|
||||
const core = useKibanaCore();
|
||||
const { services } = useKibana();
|
||||
|
||||
// Initial Load useEffect
|
||||
useEffect(() => {
|
||||
|
@ -131,7 +127,7 @@ export const EmbeddedMapComponent = ({
|
|||
endDate,
|
||||
setQuery,
|
||||
portalNode,
|
||||
plugins.embeddable
|
||||
services.embeddable
|
||||
);
|
||||
if (isSubscribed) {
|
||||
setEmbeddable(embeddableObject);
|
||||
|
@ -180,7 +176,11 @@ export const EmbeddedMapComponent = ({
|
|||
}, [startDate, endDate]);
|
||||
|
||||
const SavedObjectFinder = (props: SavedObjectFinderProps) => (
|
||||
<SavedObjectFinderUi {...props} savedObjects={core.savedObjects} uiSettings={core.uiSettings} />
|
||||
<SavedObjectFinderUi
|
||||
{...props}
|
||||
savedObjects={services.savedObjects}
|
||||
uiSettings={services.uiSettings}
|
||||
/>
|
||||
);
|
||||
|
||||
return isError ? null : (
|
||||
|
@ -188,7 +188,7 @@ export const EmbeddedMapComponent = ({
|
|||
<EmbeddableHeader title={i18n.EMBEDDABLE_HEADER_TITLE}>
|
||||
<EuiText size="xs">
|
||||
<EuiLink
|
||||
href={`${ELASTIC_WEBSITE_URL}guide/en/siem/guide/${DOC_LINK_VERSION}/conf-map-ui.html`}
|
||||
href={`${services.docLinks.ELASTIC_WEBSITE_URL}guide/en/siem/guide/${services.docLinks.DOC_LINK_VERSION}/conf-map-ui.html`}
|
||||
target="_blank"
|
||||
>
|
||||
{i18n.EMBEDDABLE_HEADER_HELP}
|
||||
|
@ -205,12 +205,12 @@ export const EmbeddedMapComponent = ({
|
|||
<EmbeddablePanel
|
||||
data-test-subj="embeddable-panel"
|
||||
embeddable={embeddable}
|
||||
getActions={plugins.uiActions.getTriggerCompatibleActions}
|
||||
getActions={services.uiActions.getTriggerCompatibleActions}
|
||||
getEmbeddableFactory={start.getEmbeddableFactory}
|
||||
getAllEmbeddableFactories={start.getEmbeddableFactories}
|
||||
notifications={core.notifications}
|
||||
overlays={core.overlays}
|
||||
inspector={plugins.inspector}
|
||||
notifications={services.notifications}
|
||||
overlays={services.overlays}
|
||||
inspector={services.inspector}
|
||||
SavedObjectFinder={SavedObjectFinder}
|
||||
/>
|
||||
) : !isLoading && isIndexError ? (
|
||||
|
|
|
@ -9,7 +9,6 @@ import { createUiNewPlatformMock } from 'ui/new_platform/__mocks__/helpers';
|
|||
import { createPortalNode } from 'react-reverse-portal';
|
||||
|
||||
jest.mock('ui/new_platform');
|
||||
jest.mock('../../lib/settings/use_kibana_ui_setting');
|
||||
|
||||
jest.mock('uuid', () => {
|
||||
return {
|
||||
|
|
|
@ -7,12 +7,10 @@
|
|||
import { shallow } from 'enzyme';
|
||||
import toJson from 'enzyme-to-json';
|
||||
import * as React from 'react';
|
||||
|
||||
import { IndexPatternsMissingPromptComponent } from './index_patterns_missing_prompt';
|
||||
|
||||
jest.mock('ui/documentation_links', () => ({
|
||||
ELASTIC_WEBSITE_URL: 'https://www.elastic.co',
|
||||
DOC_LINK_VERSION: 'current',
|
||||
}));
|
||||
jest.mock('../../lib/kibana');
|
||||
|
||||
describe('IndexPatternsMissingPrompt', () => {
|
||||
test('renders correctly against snapshot', () => {
|
||||
|
|
|
@ -8,66 +8,70 @@ import { EuiButton, EuiCode, EuiEmptyPrompt } from '@elastic/eui';
|
|||
import { FormattedMessage } from '@kbn/i18n/react';
|
||||
import * as React from 'react';
|
||||
import chrome from 'ui/chrome';
|
||||
import { ELASTIC_WEBSITE_URL, DOC_LINK_VERSION } from 'ui/documentation_links';
|
||||
|
||||
import { useKibana } from '../../lib/kibana';
|
||||
import * as i18n from './translations';
|
||||
|
||||
export const IndexPatternsMissingPromptComponent = () => (
|
||||
<EuiEmptyPrompt
|
||||
iconType="gisApp"
|
||||
title={<h2>{i18n.ERROR_TITLE}</h2>}
|
||||
titleSize="xs"
|
||||
body={
|
||||
<>
|
||||
<p>
|
||||
<FormattedMessage
|
||||
defaultMessage="To display map data, you must define SIEM indices ({defaultIndex}) and Kibana index patterns with identical names or glob patterns. When using {beats}, you can run the {setup} command on your hosts to automatically create the index patterns. For example: {example}."
|
||||
id="xpack.siem.components.embeddables.indexPatternsMissingPrompt.errorDescription1"
|
||||
values={{
|
||||
defaultIndex: (
|
||||
<a
|
||||
href={`${chrome.getBasePath()}/app/kibana#/management/kibana/settings`}
|
||||
rel="noopener noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
{'siem:defaultIndex'}
|
||||
</a>
|
||||
),
|
||||
beats: (
|
||||
<a
|
||||
href={`${ELASTIC_WEBSITE_URL}guide/en/beats/libbeat/${DOC_LINK_VERSION}/getting-started.html`}
|
||||
rel="noopener noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
{'beats'}
|
||||
</a>
|
||||
),
|
||||
setup: <EuiCode>{'setup'}</EuiCode>,
|
||||
example: <EuiCode>{'./packetbeat setup'}</EuiCode>,
|
||||
}}
|
||||
/>
|
||||
</p>
|
||||
export const IndexPatternsMissingPromptComponent = () => {
|
||||
const docLinks = useKibana().services.docLinks;
|
||||
|
||||
<p>
|
||||
<FormattedMessage
|
||||
defaultMessage="You can also configure index patterns manually in Kibana."
|
||||
id="xpack.siem.components.embeddables.indexPatternsMissingPrompt.errorDescription2"
|
||||
/>
|
||||
</p>
|
||||
</>
|
||||
}
|
||||
actions={
|
||||
<EuiButton
|
||||
href={`${chrome.getBasePath()}/app/kibana#/management/kibana/index_patterns`}
|
||||
color="primary"
|
||||
target="_blank"
|
||||
fill
|
||||
>
|
||||
{i18n.ERROR_BUTTON}
|
||||
</EuiButton>
|
||||
}
|
||||
/>
|
||||
);
|
||||
return (
|
||||
<EuiEmptyPrompt
|
||||
iconType="gisApp"
|
||||
title={<h2>{i18n.ERROR_TITLE}</h2>}
|
||||
titleSize="xs"
|
||||
body={
|
||||
<>
|
||||
<p>
|
||||
<FormattedMessage
|
||||
defaultMessage="To display map data, you must define SIEM indices ({defaultIndex}) and Kibana index patterns with identical names or glob patterns. When using {beats}, you can run the {setup} command on your hosts to automatically create the index patterns. For example: {example}."
|
||||
id="xpack.siem.components.embeddables.indexPatternsMissingPrompt.errorDescription1"
|
||||
values={{
|
||||
defaultIndex: (
|
||||
<a
|
||||
href={`${chrome.getBasePath()}/app/kibana#/management/kibana/settings`}
|
||||
rel="noopener noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
{'siem:defaultIndex'}
|
||||
</a>
|
||||
),
|
||||
beats: (
|
||||
<a
|
||||
href={`${docLinks.ELASTIC_WEBSITE_URL}guide/en/beats/libbeat/${docLinks.DOC_LINK_VERSION}/getting-started.html`}
|
||||
rel="noopener noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
{'beats'}
|
||||
</a>
|
||||
),
|
||||
setup: <EuiCode>{'setup'}</EuiCode>,
|
||||
example: <EuiCode>{'./packetbeat setup'}</EuiCode>,
|
||||
}}
|
||||
/>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<FormattedMessage
|
||||
defaultMessage="You can also configure index patterns manually in Kibana."
|
||||
id="xpack.siem.components.embeddables.indexPatternsMissingPrompt.errorDescription2"
|
||||
/>
|
||||
</p>
|
||||
</>
|
||||
}
|
||||
actions={
|
||||
<EuiButton
|
||||
href={`${chrome.getBasePath()}/app/kibana#/management/kibana/index_patterns`}
|
||||
color="primary"
|
||||
target="_blank"
|
||||
fill
|
||||
>
|
||||
{i18n.ERROR_BUTTON}
|
||||
</EuiButton>
|
||||
}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
IndexPatternsMissingPromptComponent.displayName = 'IndexPatternsMissingPromptComponent';
|
||||
|
||||
|
|
|
@ -16,8 +16,6 @@ import { mockBrowserFields } from '../../containers/source/mock';
|
|||
import { defaultHeaders } from '../../mock/header';
|
||||
import { useMountAppended } from '../../utils/use_mount_appended';
|
||||
|
||||
jest.mock('../../lib/settings/use_kibana_ui_setting');
|
||||
|
||||
describe('EventDetails', () => {
|
||||
const mount = useMountAppended();
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ import { mockBrowserFields } from '../../containers/source/mock';
|
|||
import { defaultHeaders } from '../../mock/header';
|
||||
import { useMountAppended } from '../../utils/use_mount_appended';
|
||||
|
||||
jest.mock('../../lib/settings/use_kibana_ui_setting');
|
||||
jest.mock('../../lib/kibana');
|
||||
|
||||
describe('EventFieldsBrowser', () => {
|
||||
const mount = useMountAppended();
|
||||
|
|
|
@ -8,25 +8,17 @@ import React from 'react';
|
|||
import { MockedProvider } from 'react-apollo/test-utils';
|
||||
|
||||
import { mockIndexPattern, TestProviders } from '../../mock';
|
||||
import { mockUiSettings } from '../../mock/ui_settings';
|
||||
import { wait } from '../../lib/helpers';
|
||||
|
||||
import { mockEventViewerResponse } from './mock';
|
||||
import { StatefulEventsViewer } from '.';
|
||||
import { defaultHeaders } from './default_headers';
|
||||
import { useKibanaCore } from '../../lib/compose/kibana_core';
|
||||
import { useFetchIndexPatterns } from '../../containers/detection_engine/rules/fetch_index_patterns';
|
||||
import { mockBrowserFields } from '../../containers/source/mock';
|
||||
import { eventsDefaultModel } from './default_model';
|
||||
import { useMountAppended } from '../../utils/use_mount_appended';
|
||||
|
||||
jest.mock('../../lib/settings/use_kibana_ui_setting');
|
||||
|
||||
const mockUseKibanaCore = useKibanaCore as jest.Mock;
|
||||
jest.mock('../../lib/compose/kibana_core');
|
||||
mockUseKibanaCore.mockImplementation(() => ({
|
||||
uiSettings: mockUiSettings,
|
||||
}));
|
||||
jest.mock('../../lib/kibana');
|
||||
|
||||
const mockUseFetchIndexPatterns: jest.Mock = useFetchIndexPatterns as jest.Mock;
|
||||
jest.mock('../../containers/detection_engine/rules/fetch_index_patterns');
|
||||
|
|
|
@ -12,7 +12,7 @@ import styled from 'styled-components';
|
|||
import { BrowserFields } from '../../containers/source';
|
||||
import { TimelineQuery } from '../../containers/timeline';
|
||||
import { Direction } from '../../graphql/types';
|
||||
import { useKibanaCore } from '../../lib/compose/kibana_core';
|
||||
import { useKibana } from '../../lib/kibana';
|
||||
import { KqlMode } from '../../store/timeline/model';
|
||||
import { AutoSizer } from '../auto_sizer';
|
||||
import { HeaderSection } from '../header_section';
|
||||
|
@ -93,9 +93,9 @@ export const EventsViewer = React.memo<Props>(
|
|||
utilityBar,
|
||||
}) => {
|
||||
const columnsHeader = isEmpty(columns) ? defaultHeaders : columns;
|
||||
const core = useKibanaCore();
|
||||
const kibana = useKibana();
|
||||
const combinedQueries = combineQueries({
|
||||
config: esQuery.getEsQueryConfig(core.uiSettings),
|
||||
config: esQuery.getEsQueryConfig(kibana.services.uiSettings),
|
||||
dataProviders,
|
||||
indexPattern,
|
||||
browserFields,
|
||||
|
|
|
@ -7,10 +7,8 @@
|
|||
import React from 'react';
|
||||
import { MockedProvider } from 'react-apollo/test-utils';
|
||||
|
||||
import { useKibanaCore } from '../../lib/compose/kibana_core';
|
||||
import { wait } from '../../lib/helpers';
|
||||
import { mockIndexPattern, TestProviders } from '../../mock';
|
||||
import { mockUiSettings } from '../../mock/ui_settings';
|
||||
import { useMountAppended } from '../../utils/use_mount_appended';
|
||||
|
||||
import { mockEventViewerResponse } from './mock';
|
||||
|
@ -19,13 +17,7 @@ import { useFetchIndexPatterns } from '../../containers/detection_engine/rules/f
|
|||
import { mockBrowserFields } from '../../containers/source/mock';
|
||||
import { eventsDefaultModel } from './default_model';
|
||||
|
||||
jest.mock('../../lib/settings/use_kibana_ui_setting');
|
||||
|
||||
const mockUseKibanaCore = useKibanaCore as jest.Mock;
|
||||
jest.mock('../../lib/compose/kibana_core');
|
||||
mockUseKibanaCore.mockImplementation(() => ({
|
||||
uiSettings: mockUiSettings,
|
||||
}));
|
||||
jest.mock('../../lib/kibana');
|
||||
|
||||
const mockUseFetchIndexPatterns: jest.Mock = useFetchIndexPatterns as jest.Mock;
|
||||
jest.mock('../../containers/detection_engine/rules/fetch_index_patterns');
|
||||
|
|
|
@ -8,7 +8,6 @@ import { isEqual } from 'lodash/fp';
|
|||
import React, { useCallback, useEffect, useState } from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import { ActionCreator } from 'typescript-fsa';
|
||||
import chrome from 'ui/chrome';
|
||||
import { inputsModel, inputsSelectors, State, timelineSelectors } from '../../store';
|
||||
import { inputsActions, timelineActions } from '../../store/actions';
|
||||
import { KqlMode, SubsetTimelineModel, TimelineModel } from '../../store/timeline/model';
|
||||
|
@ -18,6 +17,7 @@ import { Sort } from '../timeline/body/sort';
|
|||
import { OnChangeItemsPerPage } from '../timeline/events';
|
||||
import { esFilters, Query } from '../../../../../../../src/plugins/data/public';
|
||||
|
||||
import { useUiSetting } from '../../lib/kibana';
|
||||
import { EventsViewer } from './events_viewer';
|
||||
import { InputsModelId } from '../../store/inputs/constants';
|
||||
import { useFetchIndexPatterns } from '../../containers/detection_engine/rules/fetch_index_patterns';
|
||||
|
@ -116,7 +116,7 @@ const StatefulEventsViewerComponent = React.memo<Props>(
|
|||
}) => {
|
||||
const [showInspect, setShowInspect] = useState(false);
|
||||
const [{ browserFields, indexPatterns }] = useFetchIndexPatterns(
|
||||
defaultIndices ?? chrome.getUiSettingsClient().get(DEFAULT_INDEX_KEY)
|
||||
defaultIndices ?? useUiSetting<string[]>(DEFAULT_INDEX_KEY)
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
|
|
|
@ -20,8 +20,6 @@ import { FlyoutButton } from './button';
|
|||
const testFlyoutHeight = 980;
|
||||
const usersViewing = ['elastic'];
|
||||
|
||||
jest.mock('../../lib/settings/use_kibana_ui_setting');
|
||||
|
||||
describe('Flyout', () => {
|
||||
const state: State = mockGlobalState;
|
||||
|
||||
|
|
|
@ -8,26 +8,15 @@ import { mount, shallow } from 'enzyme';
|
|||
import toJson from 'enzyme-to-json';
|
||||
import * as React from 'react';
|
||||
|
||||
import { flyoutHeaderHeight } from '../';
|
||||
import { useKibanaCore } from '../../../lib/compose/kibana_core';
|
||||
import { TestProviders } from '../../../mock';
|
||||
import { mockUiSettings } from '../../../mock/ui_settings';
|
||||
import { flyoutHeaderHeight } from '..';
|
||||
import { Pane } from '.';
|
||||
|
||||
const testFlyoutHeight = 980;
|
||||
const testWidth = 640;
|
||||
const usersViewing = ['elastic'];
|
||||
|
||||
const mockUseKibanaCore = useKibanaCore as jest.Mock;
|
||||
jest.mock('ui/new_platform');
|
||||
jest.mock('../../../lib/compose/kibana_core');
|
||||
mockUseKibanaCore.mockImplementation(() => ({
|
||||
uiSettings: mockUiSettings,
|
||||
}));
|
||||
|
||||
jest.mock('ui/vis/lib/timezone', () => ({
|
||||
timezoneProvider: () => () => 'America/New_York',
|
||||
}));
|
||||
jest.mock('../../../lib/kibana');
|
||||
|
||||
describe('Pane', () => {
|
||||
test('renders correctly against snapshot', () => {
|
||||
|
|
|
@ -8,27 +8,25 @@ import { mount, shallow } from 'enzyme';
|
|||
import toJson from 'enzyme-to-json';
|
||||
import * as React from 'react';
|
||||
|
||||
import { useKibanaUiSetting } from '../../lib/settings/use_kibana_ui_setting';
|
||||
import { mockFrameworks, getMockKibanaUiSetting } from '../../mock';
|
||||
import { useUiSetting$ } from '../../lib/kibana';
|
||||
|
||||
import { PreferenceFormattedBytesComponent } from '.';
|
||||
|
||||
const mockUseKibanaUiSetting: jest.Mock = useKibanaUiSetting as jest.Mock;
|
||||
jest.mock('../../lib/settings/use_kibana_ui_setting', () => ({
|
||||
useKibanaUiSetting: jest.fn(),
|
||||
}));
|
||||
jest.mock('../../lib/kibana');
|
||||
const mockUseUiSetting$ = useUiSetting$ as jest.Mock;
|
||||
|
||||
describe('formatted_bytes', () => {
|
||||
describe('PreferenceFormattedBytes', () => {
|
||||
describe('rendering', () => {
|
||||
beforeEach(() => {
|
||||
mockUseKibanaUiSetting.mockClear();
|
||||
mockUseUiSetting$.mockClear();
|
||||
});
|
||||
|
||||
const bytes = '2806422';
|
||||
|
||||
test('renders correctly against snapshot', () => {
|
||||
mockUseKibanaUiSetting.mockImplementation(
|
||||
mockUseUiSetting$.mockImplementation(
|
||||
getMockKibanaUiSetting(mockFrameworks.default_browser)
|
||||
);
|
||||
const wrapper = shallow(<PreferenceFormattedBytesComponent value={bytes} />);
|
||||
|
@ -36,13 +34,13 @@ describe('formatted_bytes', () => {
|
|||
});
|
||||
|
||||
test('it renders bytes to hardcoded format when no configuration exists', () => {
|
||||
mockUseKibanaUiSetting.mockImplementation(() => [null]);
|
||||
mockUseUiSetting$.mockImplementation(() => [null]);
|
||||
const wrapper = mount(<PreferenceFormattedBytesComponent value={bytes} />);
|
||||
expect(wrapper.text()).toEqual('2.7MB');
|
||||
});
|
||||
|
||||
test('it renders bytes according to the default format', () => {
|
||||
mockUseKibanaUiSetting.mockImplementation(
|
||||
mockUseUiSetting$.mockImplementation(
|
||||
getMockKibanaUiSetting(mockFrameworks.default_browser)
|
||||
);
|
||||
const wrapper = mount(<PreferenceFormattedBytesComponent value={bytes} />);
|
||||
|
@ -50,7 +48,7 @@ describe('formatted_bytes', () => {
|
|||
});
|
||||
|
||||
test('it renders bytes supplied as a number according to the default format', () => {
|
||||
mockUseKibanaUiSetting.mockImplementation(
|
||||
mockUseUiSetting$.mockImplementation(
|
||||
getMockKibanaUiSetting(mockFrameworks.default_browser)
|
||||
);
|
||||
const wrapper = mount(<PreferenceFormattedBytesComponent value={+bytes} />);
|
||||
|
@ -58,9 +56,7 @@ describe('formatted_bytes', () => {
|
|||
});
|
||||
|
||||
test('it renders bytes according to new format', () => {
|
||||
mockUseKibanaUiSetting.mockImplementation(
|
||||
getMockKibanaUiSetting(mockFrameworks.bytes_short)
|
||||
);
|
||||
mockUseUiSetting$.mockImplementation(getMockKibanaUiSetting(mockFrameworks.bytes_short));
|
||||
const wrapper = mount(<PreferenceFormattedBytesComponent value={bytes} />);
|
||||
expect(wrapper.text()).toEqual('3MB');
|
||||
});
|
||||
|
|
|
@ -8,10 +8,10 @@ import * as React from 'react';
|
|||
import numeral from '@elastic/numeral';
|
||||
|
||||
import { DEFAULT_BYTES_FORMAT } from '../../../common/constants';
|
||||
import { useKibanaUiSetting } from '../../lib/settings/use_kibana_ui_setting';
|
||||
import { useUiSetting$ } from '../../lib/kibana';
|
||||
|
||||
export const PreferenceFormattedBytesComponent = ({ value }: { value: string | number }) => {
|
||||
const [bytesFormat] = useKibanaUiSetting(DEFAULT_BYTES_FORMAT);
|
||||
const [bytesFormat] = useUiSetting$<string>(DEFAULT_BYTES_FORMAT);
|
||||
return (
|
||||
<>{bytesFormat ? numeral(value).format(bytesFormat) : numeral(value).format('0,0.[0]b')}</>
|
||||
);
|
||||
|
|
|
@ -9,24 +9,18 @@ import toJson from 'enzyme-to-json';
|
|||
import moment from 'moment-timezone';
|
||||
import * as React from 'react';
|
||||
|
||||
import { useKibanaUiSetting } from '../../lib/settings/use_kibana_ui_setting';
|
||||
import { useUiSetting$ } from '../../lib/kibana';
|
||||
|
||||
import { mockFrameworks, TestProviders, MockFrameworks, getMockKibanaUiSetting } from '../../mock';
|
||||
|
||||
import { PreferenceFormattedDate, FormattedDate, FormattedRelativePreferenceDate } from '.';
|
||||
import { getEmptyString, getEmptyValue } from '../empty_value';
|
||||
import { PreferenceFormattedDate, FormattedDate, FormattedRelativePreferenceDate } from '.';
|
||||
|
||||
const mockUseKibanaUiSetting: jest.Mock = useKibanaUiSetting as jest.Mock;
|
||||
jest.mock('../../lib/settings/use_kibana_ui_setting', () => ({
|
||||
useKibanaUiSetting: jest.fn(),
|
||||
}));
|
||||
jest.mock('../../lib/kibana');
|
||||
const mockUseUiSetting$ = useUiSetting$ as jest.Mock;
|
||||
|
||||
describe('formatted_date', () => {
|
||||
describe('PreferenceFormattedDate', () => {
|
||||
describe('rendering', () => {
|
||||
beforeEach(() => {
|
||||
mockUseKibanaUiSetting.mockClear();
|
||||
});
|
||||
const isoDateString = '2019-02-25T22:27:05.000Z';
|
||||
const isoDate = new Date(isoDateString);
|
||||
const configFormattedDateString = (dateString: string, config: MockFrameworks): string =>
|
||||
|
@ -38,21 +32,19 @@ describe('formatted_date', () => {
|
|||
.format(config.dateFormat);
|
||||
|
||||
test('renders correctly against snapshot', () => {
|
||||
mockUseKibanaUiSetting.mockImplementation(() => [null]);
|
||||
mockUseUiSetting$.mockImplementation(() => [null]);
|
||||
const wrapper = mount(<PreferenceFormattedDate value={isoDate} />);
|
||||
expect(toJson(wrapper)).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('it renders the UTC ISO8601 date string supplied when no configuration exists', () => {
|
||||
mockUseKibanaUiSetting.mockImplementation(() => [null]);
|
||||
mockUseUiSetting$.mockImplementation(() => [null]);
|
||||
const wrapper = mount(<PreferenceFormattedDate value={isoDate} />);
|
||||
expect(wrapper.text()).toEqual(isoDateString);
|
||||
});
|
||||
|
||||
test('it renders the UTC ISO8601 date supplied when the default configuration exists', () => {
|
||||
mockUseKibanaUiSetting.mockImplementation(
|
||||
getMockKibanaUiSetting(mockFrameworks.default_UTC)
|
||||
);
|
||||
mockUseUiSetting$.mockImplementation(getMockKibanaUiSetting(mockFrameworks.default_UTC));
|
||||
|
||||
const wrapper = mount(<PreferenceFormattedDate value={isoDate} />);
|
||||
expect(wrapper.text()).toEqual(
|
||||
|
@ -61,7 +53,7 @@ describe('formatted_date', () => {
|
|||
});
|
||||
|
||||
test('it renders the correct tz when the default browser configuration exists', () => {
|
||||
mockUseKibanaUiSetting.mockImplementation(
|
||||
mockUseUiSetting$.mockImplementation(
|
||||
getMockKibanaUiSetting(mockFrameworks.default_browser)
|
||||
);
|
||||
const wrapper = mount(<PreferenceFormattedDate value={isoDate} />);
|
||||
|
@ -71,9 +63,7 @@ describe('formatted_date', () => {
|
|||
});
|
||||
|
||||
test('it renders the correct tz when a non-UTC configuration exists', () => {
|
||||
mockUseKibanaUiSetting.mockImplementation(
|
||||
getMockKibanaUiSetting(mockFrameworks.default_MT)
|
||||
);
|
||||
mockUseUiSetting$.mockImplementation(getMockKibanaUiSetting(mockFrameworks.default_MT));
|
||||
const wrapper = mount(<PreferenceFormattedDate value={isoDate} />);
|
||||
expect(wrapper.text()).toEqual(
|
||||
configFormattedDateString(isoDateString, mockFrameworks.default_MT)
|
||||
|
@ -84,30 +74,20 @@ describe('formatted_date', () => {
|
|||
|
||||
describe('FormattedDate', () => {
|
||||
describe('rendering', () => {
|
||||
beforeEach(() => {
|
||||
mockUseKibanaUiSetting.mockClear();
|
||||
});
|
||||
|
||||
test('it renders against a numeric epoch', () => {
|
||||
mockUseKibanaUiSetting.mockImplementation(
|
||||
getMockKibanaUiSetting(mockFrameworks.default_UTC)
|
||||
);
|
||||
mockUseUiSetting$.mockImplementation(getMockKibanaUiSetting(mockFrameworks.default_UTC));
|
||||
const wrapper = mount(<FormattedDate fieldName="@timestamp" value={1559079339000} />);
|
||||
expect(wrapper.text()).toEqual('May 28, 2019 @ 21:35:39.000');
|
||||
});
|
||||
|
||||
test('it renders against a string epoch', () => {
|
||||
mockUseKibanaUiSetting.mockImplementation(
|
||||
getMockKibanaUiSetting(mockFrameworks.default_UTC)
|
||||
);
|
||||
mockUseUiSetting$.mockImplementation(getMockKibanaUiSetting(mockFrameworks.default_UTC));
|
||||
const wrapper = mount(<FormattedDate fieldName="@timestamp" value={'1559079339000'} />);
|
||||
expect(wrapper.text()).toEqual('May 28, 2019 @ 21:35:39.000');
|
||||
});
|
||||
|
||||
test('it renders against a ISO string', () => {
|
||||
mockUseKibanaUiSetting.mockImplementation(
|
||||
getMockKibanaUiSetting(mockFrameworks.default_UTC)
|
||||
);
|
||||
mockUseUiSetting$.mockImplementation(getMockKibanaUiSetting(mockFrameworks.default_UTC));
|
||||
const wrapper = mount(
|
||||
<FormattedDate fieldName="@timestamp" value={'2019-05-28T22:04:49.957Z'} />
|
||||
);
|
||||
|
@ -115,9 +95,7 @@ describe('formatted_date', () => {
|
|||
});
|
||||
|
||||
test('it renders against an empty string as an empty string placeholder', () => {
|
||||
mockUseKibanaUiSetting.mockImplementation(
|
||||
getMockKibanaUiSetting(mockFrameworks.default_UTC)
|
||||
);
|
||||
mockUseUiSetting$.mockImplementation(getMockKibanaUiSetting(mockFrameworks.default_UTC));
|
||||
const wrapper = mount(
|
||||
<TestProviders>
|
||||
<FormattedDate fieldName="@timestamp" value={''} />
|
||||
|
@ -127,9 +105,7 @@ describe('formatted_date', () => {
|
|||
});
|
||||
|
||||
test('it renders against an null as a EMPTY_VALUE', () => {
|
||||
mockUseKibanaUiSetting.mockImplementation(
|
||||
getMockKibanaUiSetting(mockFrameworks.default_UTC)
|
||||
);
|
||||
mockUseUiSetting$.mockImplementation(getMockKibanaUiSetting(mockFrameworks.default_UTC));
|
||||
const wrapper = mount(
|
||||
<TestProviders>
|
||||
<FormattedDate fieldName="@timestamp" value={null} />
|
||||
|
@ -139,9 +115,7 @@ describe('formatted_date', () => {
|
|||
});
|
||||
|
||||
test('it renders against an undefined as a EMPTY_VALUE', () => {
|
||||
mockUseKibanaUiSetting.mockImplementation(
|
||||
getMockKibanaUiSetting(mockFrameworks.default_UTC)
|
||||
);
|
||||
mockUseUiSetting$.mockImplementation(getMockKibanaUiSetting(mockFrameworks.default_UTC));
|
||||
const wrapper = mount(
|
||||
<TestProviders>
|
||||
<FormattedDate fieldName="@timestamp" value={undefined} />
|
||||
|
@ -151,9 +125,7 @@ describe('formatted_date', () => {
|
|||
});
|
||||
|
||||
test('it renders against an invalid date time as just the string its self', () => {
|
||||
mockUseKibanaUiSetting.mockImplementation(
|
||||
getMockKibanaUiSetting(mockFrameworks.default_UTC)
|
||||
);
|
||||
mockUseUiSetting$.mockImplementation(getMockKibanaUiSetting(mockFrameworks.default_UTC));
|
||||
const wrapper = mount(
|
||||
<TestProviders>
|
||||
<FormattedDate fieldName="@timestamp" value={'Rebecca Evan Braden'} />
|
||||
|
|
|
@ -8,20 +8,21 @@ import moment from 'moment-timezone';
|
|||
import * as React from 'react';
|
||||
import { FormattedRelative } from '@kbn/i18n/react';
|
||||
|
||||
import { useUiSetting$ } from '../../lib/kibana';
|
||||
|
||||
import {
|
||||
DEFAULT_DATE_FORMAT,
|
||||
DEFAULT_DATE_FORMAT_TZ,
|
||||
DEFAULT_TIMEZONE_BROWSER,
|
||||
} from '../../../common/constants';
|
||||
import { useKibanaUiSetting } from '../../lib/settings/use_kibana_ui_setting';
|
||||
import { getOrEmptyTagFromValue } from '../empty_value';
|
||||
import { LocalizedDateTooltip } from '../localized_date_tooltip';
|
||||
import { getMaybeDate } from './maybe_date';
|
||||
|
||||
export const PreferenceFormattedDate = React.memo<{ value: Date }>(({ value }) => {
|
||||
const [dateFormat] = useKibanaUiSetting(DEFAULT_DATE_FORMAT);
|
||||
const [dateFormatTz] = useKibanaUiSetting(DEFAULT_DATE_FORMAT_TZ);
|
||||
const [timezone] = useKibanaUiSetting(DEFAULT_TIMEZONE_BROWSER);
|
||||
const [dateFormat] = useUiSetting$<string>(DEFAULT_DATE_FORMAT);
|
||||
const [dateFormatTz] = useUiSetting$<string>(DEFAULT_DATE_FORMAT_TZ);
|
||||
const [timezone] = useUiSetting$<string>(DEFAULT_TIMEZONE_BROWSER);
|
||||
|
||||
return (
|
||||
<>
|
||||
|
|
|
@ -9,10 +9,9 @@ import toJson from 'enzyme-to-json';
|
|||
import React from 'react';
|
||||
|
||||
import '../../mock/match_media';
|
||||
import '../../mock/ui_settings';
|
||||
import { HeaderGlobal } from './index';
|
||||
|
||||
jest.mock('../../lib/settings/use_kibana_ui_setting');
|
||||
jest.mock('ui/new_platform');
|
||||
|
||||
// Test will fail because we will to need to mock some core services to make the test work
|
||||
// For now let's forget about SiemSearchBar
|
||||
|
|
|
@ -10,12 +10,9 @@ import toJson from 'enzyme-to-json';
|
|||
import React from 'react';
|
||||
|
||||
import { TestProviders } from '../../mock';
|
||||
import '../../mock/ui_settings';
|
||||
import { HeaderPage } from './index';
|
||||
import { useMountAppended } from '../../utils/use_mount_appended';
|
||||
|
||||
jest.mock('../../lib/settings/use_kibana_ui_setting');
|
||||
|
||||
describe('HeaderPage', () => {
|
||||
const mount = useMountAppended();
|
||||
|
||||
|
|
|
@ -10,11 +10,8 @@ import toJson from 'enzyme-to-json';
|
|||
import React from 'react';
|
||||
|
||||
import { TestProviders } from '../../mock';
|
||||
import '../../mock/ui_settings';
|
||||
import { HeaderSection } from './index';
|
||||
|
||||
jest.mock('../../lib/settings/use_kibana_ui_setting');
|
||||
|
||||
describe('HeaderSection', () => {
|
||||
test('it renders', () => {
|
||||
const wrapper = shallow(<HeaderSection title="Test title" />);
|
||||
|
|
|
@ -13,7 +13,6 @@ import { mockLastEventTimeQuery } from '../../containers/events/last_event_time/
|
|||
import { useMountAppended } from '../../utils/use_mount_appended';
|
||||
import { useLastEventTimeQuery } from '../../containers/events/last_event_time';
|
||||
import { TestProviders } from '../../mock';
|
||||
import '../../mock/ui_settings';
|
||||
|
||||
import { LastEventTime } from '.';
|
||||
|
||||
|
|
|
@ -9,11 +9,8 @@ import toJson from 'enzyme-to-json';
|
|||
import React from 'react';
|
||||
|
||||
import { TestProviders } from '../../mock';
|
||||
import '../../mock/ui_settings';
|
||||
import { LinkIcon } from './index';
|
||||
|
||||
jest.mock('../../lib/settings/use_kibana_ui_setting');
|
||||
|
||||
describe('LinkIcon', () => {
|
||||
test('it renders', () => {
|
||||
const wrapper = shallow(
|
||||
|
|
|
@ -9,12 +9,7 @@ import * as React from 'react';
|
|||
|
||||
import { MatrixHistogram } from '.';
|
||||
|
||||
jest.mock('@elastic/eui', () => {
|
||||
return {
|
||||
EuiPanel: (children: JSX.Element) => <>{children}</>,
|
||||
EuiLoadingContent: () => <div className="euiLoadingContent" />,
|
||||
};
|
||||
});
|
||||
jest.mock('../../lib/kibana');
|
||||
|
||||
jest.mock('../loader', () => {
|
||||
return {
|
||||
|
@ -22,10 +17,6 @@ jest.mock('../loader', () => {
|
|||
};
|
||||
});
|
||||
|
||||
jest.mock('../../lib/settings/use_kibana_ui_setting', () => {
|
||||
return { useKibanaUiSetting: () => [false] };
|
||||
});
|
||||
|
||||
jest.mock('../header_section', () => {
|
||||
return {
|
||||
HeaderSection: () => <div className="headerSection" />,
|
||||
|
|
|
@ -14,7 +14,7 @@ import { BarChart } from '../charts/barchart';
|
|||
import { HeaderSection } from '../header_section';
|
||||
import { ChartSeriesData } from '../charts/common';
|
||||
import { DEFAULT_DARK_MODE } from '../../../common/constants';
|
||||
import { useKibanaUiSetting } from '../../lib/settings/use_kibana_ui_setting';
|
||||
import { useUiSetting$ } from '../../lib/kibana';
|
||||
import { Loader } from '../loader';
|
||||
import { Panel } from '../panel';
|
||||
import { getBarchartConfigs, getCustomChartData } from './utils';
|
||||
|
@ -45,7 +45,7 @@ export const MatrixHistogram = ({
|
|||
showLegend,
|
||||
});
|
||||
const [showInspect, setShowInspect] = useState(false);
|
||||
const [darkMode] = useKibanaUiSetting(DEFAULT_DARK_MODE);
|
||||
const [darkMode] = useUiSetting$<boolean>(DEFAULT_DARK_MODE);
|
||||
const [loadingInitial, setLoadingInitial] = useState(false);
|
||||
|
||||
const barChartData: ChartSeriesData[] = getCustomChartData(data, mapping);
|
||||
|
|
|
@ -14,7 +14,7 @@ import { useStateToaster } from '../../toasters';
|
|||
import { errorToToaster } from '../api/error_to_toaster';
|
||||
|
||||
import * as i18n from './translations';
|
||||
import { useKibanaUiSetting } from '../../../lib/settings/use_kibana_ui_setting';
|
||||
import { useUiSetting$ } from '../../../lib/kibana';
|
||||
import {
|
||||
DEFAULT_ANOMALY_SCORE,
|
||||
DEFAULT_TIMEZONE_BROWSER,
|
||||
|
@ -67,9 +67,9 @@ export const useAnomaliesTableData = ({
|
|||
const capabilities = useContext(MlCapabilitiesContext);
|
||||
const userPermissions = hasMlUserPermissions(capabilities);
|
||||
const [, dispatchToaster] = useStateToaster();
|
||||
const [timezone] = useKibanaUiSetting(DEFAULT_TIMEZONE_BROWSER);
|
||||
const [anomalyScore] = useKibanaUiSetting(DEFAULT_ANOMALY_SCORE);
|
||||
const [kbnVersion] = useKibanaUiSetting(DEFAULT_KBN_VERSION);
|
||||
const [timezone] = useUiSetting$<string>(DEFAULT_TIMEZONE_BROWSER);
|
||||
const [anomalyScore] = useUiSetting$<number>(DEFAULT_ANOMALY_SCORE);
|
||||
const [kbnVersion] = useUiSetting$<string>(DEFAULT_KBN_VERSION);
|
||||
|
||||
const siemJobIds = siemJobs.filter(job => job.isInstalled).map(job => job.id);
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import { getMlCapabilities } from '../api/get_ml_capabilities';
|
|||
import { emptyMlCapabilities } from '../empty_ml_capabilities';
|
||||
import { errorToToaster } from '../api/error_to_toaster';
|
||||
import { useStateToaster } from '../../toasters';
|
||||
import { useKibanaUiSetting } from '../../../lib/settings/use_kibana_ui_setting';
|
||||
import { useUiSetting$ } from '../../../lib/kibana';
|
||||
import { DEFAULT_KBN_VERSION } from '../../../../common/constants';
|
||||
|
||||
import * as i18n from './translations';
|
||||
|
@ -36,7 +36,7 @@ export const MlCapabilitiesProvider = React.memo<{ children: JSX.Element }>(({ c
|
|||
emptyMlCapabilitiesProvider
|
||||
);
|
||||
const [, dispatchToaster] = useStateToaster();
|
||||
const [kbnVersion] = useKibanaUiSetting(DEFAULT_KBN_VERSION);
|
||||
const [kbnVersion] = useUiSetting$<string>(DEFAULT_KBN_VERSION);
|
||||
|
||||
useEffect(() => {
|
||||
let isSubscribed = true;
|
||||
|
|
|
@ -17,8 +17,6 @@ import { Anomalies } from '../types';
|
|||
const endDate: number = new Date('3000-01-01T00:00:00.000Z').valueOf();
|
||||
const narrowDateRange = jest.fn();
|
||||
|
||||
jest.mock('../../../lib/settings/use_kibana_ui_setting');
|
||||
|
||||
describe('anomaly_scores', () => {
|
||||
let anomalies: Anomalies = cloneDeep(mockAnomalies);
|
||||
const mount = useMountAppended();
|
||||
|
|
|
@ -18,8 +18,6 @@ import { useMountAppended } from '../../../utils/use_mount_appended';
|
|||
const endDate: number = new Date('3000-01-01T00:00:00.000Z').valueOf();
|
||||
const narrowDateRange = jest.fn();
|
||||
|
||||
jest.mock('../../../lib/settings/use_kibana_ui_setting');
|
||||
|
||||
describe('anomaly_scores', () => {
|
||||
let anomalies: Anomalies = cloneDeep(mockAnomalies);
|
||||
const mount = useMountAppended();
|
||||
|
|
|
@ -12,7 +12,7 @@ import { createDescriptionList } from './create_description_list';
|
|||
import { EuiDescriptionList } from '@elastic/eui';
|
||||
import { Anomaly } from '../types';
|
||||
|
||||
jest.mock('../../../lib/settings/use_kibana_ui_setting');
|
||||
jest.mock('../../../lib/kibana');
|
||||
|
||||
const endDate: number = new Date('3000-01-01T00:00:00.000Z').valueOf();
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ import { hasMlUserPermissions } from '../../ml/permissions/has_ml_user_permissio
|
|||
import { MlCapabilitiesContext } from '../../ml/permissions/ml_capabilities_provider';
|
||||
import { useStateToaster } from '../../toasters';
|
||||
import { errorToToaster } from '../../ml/api/error_to_toaster';
|
||||
import { useKibanaUiSetting } from '../../../lib/settings/use_kibana_ui_setting';
|
||||
import { useUiSetting$ } from '../../../lib/kibana';
|
||||
import { DEFAULT_INDEX_KEY, DEFAULT_KBN_VERSION } from '../../../../common/constants';
|
||||
|
||||
import * as i18n from './translations';
|
||||
|
@ -33,8 +33,8 @@ export const useSiemJobs = (refetchData: boolean): Return => {
|
|||
const [loading, setLoading] = useState(true);
|
||||
const capabilities = useContext(MlCapabilitiesContext);
|
||||
const userPermissions = hasMlUserPermissions(capabilities);
|
||||
const [siemDefaultIndex] = useKibanaUiSetting(DEFAULT_INDEX_KEY);
|
||||
const [kbnVersion] = useKibanaUiSetting(DEFAULT_KBN_VERSION);
|
||||
const [siemDefaultIndex] = useUiSetting$<string[]>(DEFAULT_INDEX_KEY);
|
||||
const [kbnVersion] = useUiSetting$<string>(DEFAULT_KBN_VERSION);
|
||||
const [, dispatchToaster] = useStateToaster();
|
||||
|
||||
useEffect(() => {
|
||||
|
|
|
@ -9,7 +9,8 @@ import { mountWithIntl } from 'test_utils/enzyme_helpers';
|
|||
|
||||
import { MlPopover } from './ml_popover';
|
||||
|
||||
jest.mock('../../lib/settings/use_kibana_ui_setting');
|
||||
jest.mock('ui/new_platform');
|
||||
jest.mock('../../lib/kibana');
|
||||
|
||||
jest.mock('../ml/permissions/has_ml_admin_permissions', () => ({
|
||||
hasMlAdminPermissions: () => true,
|
||||
|
|
|
@ -9,10 +9,9 @@ import { FormattedMessage } from '@kbn/i18n/react';
|
|||
import moment from 'moment';
|
||||
import React, { useContext, useReducer, useState } from 'react';
|
||||
import styled from 'styled-components';
|
||||
import { DOC_LINK_VERSION, ELASTIC_WEBSITE_URL } from 'ui/documentation_links';
|
||||
|
||||
import { DEFAULT_KBN_VERSION } from '../../../common/constants';
|
||||
import { useKibanaUiSetting } from '../../lib/settings/use_kibana_ui_setting';
|
||||
import { useKibana, useUiSetting$ } from '../../lib/kibana';
|
||||
import { METRIC_TYPE, TELEMETRY_EVENT, trackUiAction as track } from '../../lib/track_usage';
|
||||
import { errorToToaster } from '../ml/api/error_to_toaster';
|
||||
import { hasMlAdminPermissions } from '../ml/permissions/has_ml_admin_permissions';
|
||||
|
@ -98,10 +97,11 @@ export const MlPopover = React.memo(() => {
|
|||
|
||||
const [isPopoverOpen, setIsPopoverOpen] = useState(false);
|
||||
const [filterProperties, setFilterProperties] = useState(defaultFilterProps);
|
||||
const [kbnVersion] = useKibanaUiSetting(DEFAULT_KBN_VERSION);
|
||||
const [kbnVersion] = useUiSetting$<string>(DEFAULT_KBN_VERSION);
|
||||
const [isLoadingSiemJobs, siemJobs] = useSiemJobs(refreshToggle);
|
||||
const [, dispatchToaster] = useStateToaster();
|
||||
const capabilities = useContext(MlCapabilitiesContext);
|
||||
const docLinks = useKibana().services.docLinks;
|
||||
|
||||
// Enable/Disable Job & Datafeed -- passed to JobsTable for use as callback on JobSwitch
|
||||
const enableDatafeed = async (job: SiemJob, latestTimestampMs: number, enable: boolean) => {
|
||||
|
@ -226,7 +226,7 @@ export const MlPopover = React.memo(() => {
|
|||
values={{
|
||||
mlDocs: (
|
||||
<a
|
||||
href={`${ELASTIC_WEBSITE_URL}guide/en/siem/guide/${DOC_LINK_VERSION}/machine-learning.html`}
|
||||
href={`${docLinks.ELASTIC_WEBSITE_URL}guide/en/siem/guide/${docLinks.DOC_LINK_VERSION}/machine-learning.html`}
|
||||
rel="noopener noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
|
|
|
@ -13,7 +13,7 @@ export interface Group {
|
|||
}
|
||||
|
||||
export interface CheckRecognizerProps {
|
||||
indexPatternName: string;
|
||||
indexPatternName: string[];
|
||||
kbnVersion: string;
|
||||
signal: AbortSignal;
|
||||
}
|
||||
|
|
|
@ -57,8 +57,6 @@ import {
|
|||
} from '../source_destination/field_names';
|
||||
import { useMountAppended } from '../../utils/use_mount_appended';
|
||||
|
||||
jest.mock('../../lib/settings/use_kibana_ui_setting');
|
||||
|
||||
const getNetflowInstance = () => (
|
||||
<Netflow
|
||||
contextId="test"
|
||||
|
|
|
@ -19,7 +19,7 @@ import { StatefulOpenTimeline } from '.';
|
|||
import { NotePreviews } from './note_previews';
|
||||
import { OPEN_TIMELINE_CLASS_NAME } from './helpers';
|
||||
|
||||
jest.mock('../../lib/settings/use_kibana_ui_setting');
|
||||
jest.mock('../../lib/kibana');
|
||||
|
||||
describe('StatefulOpenTimeline', () => {
|
||||
const theme = () => ({ eui: euiDarkVars, darkMode: true });
|
||||
|
|
|
@ -17,7 +17,7 @@ import { mockTimelineResults } from '../../mock/timeline_results';
|
|||
import { OpenTimeline } from './open_timeline';
|
||||
import { DEFAULT_SORT_DIRECTION, DEFAULT_SORT_FIELD } from './constants';
|
||||
|
||||
jest.mock('../../lib/settings/use_kibana_ui_setting');
|
||||
jest.mock('../../lib/kibana');
|
||||
|
||||
describe('OpenTimeline', () => {
|
||||
const theme = () => ({ eui: euiDarkVars, darkMode: true });
|
||||
|
|
|
@ -16,7 +16,7 @@ import { mockOpenTimelineQueryResults } from '../../../mock/timeline_results';
|
|||
|
||||
import { OpenTimelineModal } from '.';
|
||||
|
||||
jest.mock('../../../lib/settings/use_kibana_ui_setting');
|
||||
jest.mock('../../../lib/kibana');
|
||||
jest.mock('../../../utils/apollo_context', () => ({
|
||||
useApolloClient: () => ({}),
|
||||
}));
|
||||
|
|
|
@ -17,7 +17,7 @@ import { mockTimelineResults } from '../../../mock/timeline_results';
|
|||
import { OpenTimelineModalBody } from './open_timeline_modal_body';
|
||||
import { DEFAULT_SORT_DIRECTION, DEFAULT_SORT_FIELD } from '../constants';
|
||||
|
||||
jest.mock('../../../lib/settings/use_kibana_ui_setting');
|
||||
jest.mock('../../../lib/kibana');
|
||||
|
||||
describe('OpenTimelineModal', () => {
|
||||
const theme = () => ({ eui: euiDarkVars, darkMode: true });
|
||||
|
|
|
@ -17,8 +17,6 @@ import * as i18n from '../translations';
|
|||
|
||||
import { OpenTimelineModalButton } from './open_timeline_modal_button';
|
||||
|
||||
jest.mock('../../../lib/settings/use_kibana_ui_setting');
|
||||
|
||||
describe('OpenTimelineModalButton', () => {
|
||||
const theme = () => ({ eui: euiDarkVars, darkMode: true });
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ import { OpenTimelineResult } from '../types';
|
|||
import { TimelinesTable } from '.';
|
||||
import { DEFAULT_SORT_DIRECTION, DEFAULT_SORT_FIELD } from '../constants';
|
||||
|
||||
jest.mock('../../../lib/settings/use_kibana_ui_setting');
|
||||
jest.mock('../../../lib/kibana');
|
||||
|
||||
describe('#getActionsColumns', () => {
|
||||
const theme = () => ({ eui: euiDarkVars, darkMode: true });
|
||||
|
|
|
@ -21,7 +21,7 @@ import { TimelinesTable } from '.';
|
|||
import * as i18n from '../translations';
|
||||
import { DEFAULT_SORT_DIRECTION, DEFAULT_SORT_FIELD } from '../constants';
|
||||
|
||||
jest.mock('../../../lib/settings/use_kibana_ui_setting');
|
||||
jest.mock('../../../lib/kibana');
|
||||
|
||||
describe('#getCommonColumns', () => {
|
||||
const theme = () => ({ eui: euiDarkVars, darkMode: true });
|
||||
|
|
|
@ -20,7 +20,7 @@ import { TimelinesTable } from '.';
|
|||
import * as i18n from '../translations';
|
||||
import { DEFAULT_SORT_DIRECTION, DEFAULT_SORT_FIELD } from '../constants';
|
||||
|
||||
jest.mock('../../../lib/settings/use_kibana_ui_setting');
|
||||
jest.mock('../../../lib/kibana');
|
||||
|
||||
describe('#getExtendedColumns', () => {
|
||||
const theme = () => ({ eui: euiDarkVars, darkMode: true });
|
||||
|
|
|
@ -16,7 +16,7 @@ import { TimelinesTable } from '.';
|
|||
import { OpenTimelineResult } from '../types';
|
||||
import { DEFAULT_SORT_DIRECTION, DEFAULT_SORT_FIELD } from '../constants';
|
||||
|
||||
jest.mock('../../../lib/settings/use_kibana_ui_setting');
|
||||
jest.mock('../../../lib/kibana');
|
||||
|
||||
describe('#getActionsColumns', () => {
|
||||
const theme = () => ({ eui: euiDarkVars, darkMode: true });
|
||||
|
|
|
@ -18,7 +18,7 @@ import { TimelinesTable, TimelinesTableProps } from '.';
|
|||
import * as i18n from '../translations';
|
||||
import { DEFAULT_SORT_DIRECTION, DEFAULT_SORT_FIELD } from '../constants';
|
||||
|
||||
jest.mock('../../../lib/settings/use_kibana_ui_setting');
|
||||
jest.mock('../../../lib/kibana');
|
||||
|
||||
describe('TimelinesTable', () => {
|
||||
const theme = () => ({ eui: euiDarkVars, darkMode: true });
|
||||
|
|
|
@ -8,12 +8,9 @@ import { shallow } from 'enzyme';
|
|||
import toJson from 'enzyme-to-json';
|
||||
import React from 'react';
|
||||
|
||||
import '../../../../mock/ui_settings';
|
||||
import { TestProviders } from '../../../../mock';
|
||||
import { HistogramSignals } from './index';
|
||||
|
||||
jest.mock('../../../../lib/settings/use_kibana_ui_setting');
|
||||
|
||||
describe('HistogramSignals', () => {
|
||||
test('it renders', () => {
|
||||
const wrapper = shallow(
|
||||
|
|
|
@ -12,26 +12,25 @@ import { render, act } from '@testing-library/react';
|
|||
import { mockFirstLastSeenHostQuery } from '../../../../containers/hosts/first_last_seen/mock';
|
||||
import { wait } from '../../../../lib/helpers';
|
||||
import { TestProviders } from '../../../../mock';
|
||||
import '../../../../mock/ui_settings';
|
||||
|
||||
import { FirstLastSeenHost, FirstLastSeenHostType } from '.';
|
||||
|
||||
jest.mock('../../../../lib/settings/use_kibana_ui_setting');
|
||||
|
||||
// Suppress warnings about "react-apollo" until we migrate to apollo@3
|
||||
/* eslint-disable no-console */
|
||||
const originalError = console.error;
|
||||
beforeAll(() => {
|
||||
console.error = jest.fn();
|
||||
});
|
||||
afterAll(() => {
|
||||
console.error = originalError;
|
||||
});
|
||||
jest.mock('../../../../lib/kibana');
|
||||
|
||||
describe('FirstLastSeen Component', () => {
|
||||
const firstSeen = 'Apr 8, 2019 @ 16:09:40.692';
|
||||
const lastSeen = 'Apr 8, 2019 @ 18:35:45.064';
|
||||
|
||||
// Suppress warnings about "react-apollo" until we migrate to apollo@3
|
||||
/* eslint-disable no-console */
|
||||
const originalError = console.error;
|
||||
beforeAll(() => {
|
||||
console.error = jest.fn();
|
||||
});
|
||||
afterAll(() => {
|
||||
console.error = originalError;
|
||||
});
|
||||
|
||||
test('Loading', async () => {
|
||||
const { container } = render(
|
||||
<TestProviders>
|
||||
|
|
|
@ -12,7 +12,7 @@ import React, { useContext, useState, useCallback } from 'react';
|
|||
|
||||
import { DEFAULT_DARK_MODE } from '../../../../../common/constants';
|
||||
import { DescriptionList } from '../../../../../common/utility_types';
|
||||
import { useKibanaUiSetting } from '../../../../lib/settings/use_kibana_ui_setting';
|
||||
import { useUiSetting$ } from '../../../../lib/kibana';
|
||||
import { getEmptyTagValue } from '../../../empty_value';
|
||||
import { DefaultFieldRenderer, hostIdRenderer } from '../../../field_renderers/field_renderers';
|
||||
import { InspectButton } from '../../../inspect';
|
||||
|
@ -59,7 +59,7 @@ export const HostOverview = React.memo<HostSummaryProps>(
|
|||
const [showInspect, setShowInspect] = useState(false);
|
||||
const capabilities = useContext(MlCapabilitiesContext);
|
||||
const userPermissions = hasMlUserPermissions(capabilities);
|
||||
const [darkMode] = useKibanaUiSetting(DEFAULT_DARK_MODE);
|
||||
const [darkMode] = useUiSetting$<boolean>(DEFAULT_DARK_MODE);
|
||||
|
||||
const getDefaultRenderer = (fieldName: string, fieldData: HostItem) => (
|
||||
<DefaultFieldRenderer
|
||||
|
|
|
@ -17,19 +17,11 @@ import {
|
|||
TestProviders,
|
||||
} from '../../../../mock';
|
||||
import { useMountAppended } from '../../../../utils/use_mount_appended';
|
||||
import { mockUiSettings } from '../../../../mock/ui_settings';
|
||||
import { useKibanaCore } from '../../../../lib/compose/kibana_core';
|
||||
import { createStore, hostsModel, State } from '../../../../store';
|
||||
import { HostsTableType } from '../../../../store/hosts/model';
|
||||
import { HostsTable } from './index';
|
||||
import { mockData } from './mock';
|
||||
|
||||
const mockUseKibanaCore = useKibanaCore as jest.Mock;
|
||||
jest.mock('../../../../lib/compose/kibana_core');
|
||||
mockUseKibanaCore.mockImplementation(() => ({
|
||||
uiSettings: mockUiSettings,
|
||||
}));
|
||||
|
||||
// Test will fail because we will to need to mock some core services to make the test work
|
||||
// For now let's forget about SiemSearchBar and QueryBar
|
||||
jest.mock('../../../search_bar', () => ({
|
||||
|
|
|
@ -11,7 +11,7 @@ import React, { useContext, useState, useCallback } from 'react';
|
|||
|
||||
import { DEFAULT_DARK_MODE } from '../../../../../common/constants';
|
||||
import { DescriptionList } from '../../../../../common/utility_types';
|
||||
import { useKibanaUiSetting } from '../../../../lib/settings/use_kibana_ui_setting';
|
||||
import { useUiSetting$ } from '../../../../lib/kibana';
|
||||
import { FlowTarget, IpOverviewData, Overview } from '../../../../graphql/types';
|
||||
import { networkModel } from '../../../../store';
|
||||
import { getEmptyTagValue } from '../../../empty_value';
|
||||
|
@ -74,7 +74,7 @@ export const IpOverview = React.memo<IpOverviewProps>(
|
|||
const [showInspect, setShowInspect] = useState(false);
|
||||
const capabilities = useContext(MlCapabilitiesContext);
|
||||
const userPermissions = hasMlUserPermissions(capabilities);
|
||||
const [darkMode] = useKibanaUiSetting(DEFAULT_DARK_MODE);
|
||||
const [darkMode] = useUiSetting$<boolean>(DEFAULT_DARK_MODE);
|
||||
const typeData: Overview = data[flowTarget]!;
|
||||
const column: DescriptionList[] = [
|
||||
{
|
||||
|
|
|
@ -18,8 +18,6 @@ import { useMountAppended } from '../../../../utils/use_mount_appended';
|
|||
import { NetworkDnsTable } from '.';
|
||||
import { mockData } from './mock';
|
||||
|
||||
jest.mock('../../../../lib/settings/use_kibana_ui_setting');
|
||||
|
||||
describe('NetworkTopNFlow Table Component', () => {
|
||||
const loadPage = jest.fn();
|
||||
const state: State = mockGlobalState;
|
||||
|
|
|
@ -18,8 +18,6 @@ import { createStore, networkModel, State } from '../../../../store';
|
|||
import { NetworkHttpTable } from '.';
|
||||
import { mockData } from './mock';
|
||||
|
||||
jest.mock('../../../../lib/settings/use_kibana_ui_setting');
|
||||
|
||||
describe('NetworkHttp Table Component', () => {
|
||||
const loadPage = jest.fn();
|
||||
const state: State = mockGlobalState;
|
||||
|
|
|
@ -24,7 +24,6 @@ import { createStore, networkModel, State } from '../../../../store';
|
|||
import { NetworkTopCountriesTable } from '.';
|
||||
import { mockData } from './mock';
|
||||
|
||||
jest.mock('../../../../lib/settings/use_kibana_ui_setting');
|
||||
describe('NetworkTopCountries Table Component', () => {
|
||||
const loadPage = jest.fn();
|
||||
const state: State = mockGlobalState;
|
||||
|
|
|
@ -24,8 +24,6 @@ import { createStore, networkModel, State } from '../../../../store';
|
|||
import { NetworkTopNFlowTable } from '.';
|
||||
import { mockData } from './mock';
|
||||
|
||||
jest.mock('../../../../lib/settings/use_kibana_ui_setting');
|
||||
|
||||
describe('NetworkTopNFlow Table Component', () => {
|
||||
const loadPage = jest.fn();
|
||||
const state: State = mockGlobalState;
|
||||
|
|
|
@ -18,8 +18,6 @@ import { createStore, networkModel, State } from '../../../../store';
|
|||
import { TlsTable } from '.';
|
||||
import { mockTlsData } from './mock';
|
||||
|
||||
jest.mock('../../../../lib/settings/use_kibana_ui_setting');
|
||||
|
||||
describe('Tls Table Component', () => {
|
||||
const loadPage = jest.fn();
|
||||
const state: State = mockGlobalState;
|
||||
|
|
|
@ -19,8 +19,6 @@ import { createStore, networkModel, State } from '../../../../store';
|
|||
import { UsersTable } from '.';
|
||||
import { mockUsersData } from './mock';
|
||||
|
||||
jest.mock('../../../../lib/settings/use_kibana_ui_setting');
|
||||
|
||||
jest.mock('../../../search_bar', () => ({
|
||||
siemFilterManager: {
|
||||
addFilters: jest.fn(),
|
||||
|
|
|
@ -8,11 +8,8 @@ import { shallow } from 'enzyme';
|
|||
import toJson from 'enzyme-to-json';
|
||||
import React from 'react';
|
||||
|
||||
import '../../mock/ui_settings';
|
||||
import { ProgressInline } from './index';
|
||||
|
||||
jest.mock('../../lib/settings/use_kibana_ui_setting');
|
||||
|
||||
describe('ProgressInline', () => {
|
||||
test('it renders', () => {
|
||||
const wrapper = shallow(
|
||||
|
|
|
@ -7,23 +7,16 @@
|
|||
import { mount } from 'enzyme';
|
||||
import React from 'react';
|
||||
|
||||
import { FilterManager, SearchBar } from '../../../../../../../src/plugins/data/public';
|
||||
import { uiSettingsServiceMock } from '../../../../../../../src/core/public/ui_settings/ui_settings_service.mock';
|
||||
import { useKibanaCore } from '../../lib/compose/kibana_core';
|
||||
import { TestProviders, mockIndexPattern } from '../../mock';
|
||||
import { QueryBar, QueryBarComponentProps } from '.';
|
||||
import { createKibanaCoreStartMock } from '../../mock/kibana_core';
|
||||
import { DEFAULT_FROM, DEFAULT_TO } from '../../../common/constants';
|
||||
import { mockUiSettings } from '../../mock/ui_settings';
|
||||
import { FilterManager, SearchBar } from '../../../../../../../src/plugins/data/public';
|
||||
import { QueryBar, QueryBarComponentProps } from '.';
|
||||
import { createKibanaContextProviderMock } from '../../mock/kibana_react';
|
||||
|
||||
jest.mock('ui/new_platform');
|
||||
jest.mock('../../lib/kibana');
|
||||
|
||||
const mockUseKibanaCore = useKibanaCore as jest.Mock;
|
||||
const mockUiSettingsForFilterManager = uiSettingsServiceMock.createSetupContract();
|
||||
jest.mock('../../lib/compose/kibana_core');
|
||||
mockUseKibanaCore.mockImplementation(() => ({
|
||||
uiSettings: mockUiSettings,
|
||||
savedObjects: {},
|
||||
}));
|
||||
const mockUiSettingsForFilterManager = createKibanaCoreStartMock().uiSettings;
|
||||
|
||||
describe('QueryBar ', () => {
|
||||
// We are doing that because we need to wrapped this component with redux
|
||||
|
@ -196,9 +189,13 @@ describe('QueryBar ', () => {
|
|||
|
||||
describe('#onQueryChange', () => {
|
||||
test(' is the only reference that changed when filterQueryDraft props get updated', () => {
|
||||
const KibanaWithStorageProvider = createKibanaContextProviderMock();
|
||||
|
||||
const Proxy = (props: QueryBarComponentProps) => (
|
||||
<TestProviders>
|
||||
<QueryBar {...props} />
|
||||
<KibanaWithStorageProvider services={{ storage: { get: jest.fn() } }}>
|
||||
<QueryBar {...props} />
|
||||
</KibanaWithStorageProvider>
|
||||
</TestProviders>
|
||||
);
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
import { isEqual } from 'lodash/fp';
|
||||
import React, { memo, useState, useEffect, useMemo, useCallback } from 'react';
|
||||
import { IndexPattern } from 'ui/index_patterns';
|
||||
|
||||
import {
|
||||
esFilters,
|
||||
|
@ -118,7 +117,7 @@ export const QueryBar = memo<QueryBarComponentProps>(
|
|||
);
|
||||
|
||||
const CustomButton = <>{null}</>;
|
||||
const indexPatterns = useMemo(() => [indexPattern as IndexPattern], [indexPattern]);
|
||||
const indexPatterns = useMemo(() => [indexPattern], [indexPattern]);
|
||||
|
||||
const searchBarProps = savedQuery != null ? { savedQuery } : {};
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@ import { connect } from 'react-redux';
|
|||
import { Dispatch } from 'redux';
|
||||
import { Subscription } from 'rxjs';
|
||||
import styled from 'styled-components';
|
||||
import { IndexPattern } from 'ui/index_patterns';
|
||||
import { IIndexPattern } from 'src/plugins/data/public';
|
||||
import { SavedQuery } from 'src/legacy/core_plugins/data/public';
|
||||
|
||||
|
@ -254,7 +253,7 @@ const SearchBarComponent = memo<SiemSearchBarProps & SiemSearchBarRedux & SiemSe
|
|||
subscriptions.unsubscribe();
|
||||
};
|
||||
}, []);
|
||||
const indexPatterns = useMemo(() => [indexPattern as IndexPattern], [indexPattern]);
|
||||
const indexPatterns = useMemo(() => [indexPattern], [indexPattern]);
|
||||
return (
|
||||
<SearchBarContainer data-test-subj={`${id}DatePicker`}>
|
||||
<SearchBar
|
||||
|
|
|
@ -47,8 +47,6 @@ import {
|
|||
NETWORK_TRANSPORT_FIELD_NAME,
|
||||
} from './field_names';
|
||||
|
||||
jest.mock('../../lib/settings/use_kibana_ui_setting');
|
||||
|
||||
const getSourceDestinationInstance = () => (
|
||||
<SourceDestination
|
||||
contextId="test"
|
||||
|
|
|
@ -35,8 +35,6 @@ import {
|
|||
SOURCE_GEO_REGION_NAME_FIELD_NAME,
|
||||
} from './geo_fields';
|
||||
|
||||
jest.mock('../../lib/settings/use_kibana_ui_setting');
|
||||
|
||||
describe('SourceDestinationIp', () => {
|
||||
const mount = useMountAppended();
|
||||
|
||||
|
|
|
@ -8,12 +8,9 @@ import { mount, shallow } from 'enzyme';
|
|||
import toJson from 'enzyme-to-json';
|
||||
import React from 'react';
|
||||
|
||||
import '../../mock/ui_settings';
|
||||
import { TestProviders } from '../../mock';
|
||||
import { Subtitle } from './index';
|
||||
|
||||
jest.mock('../../lib/settings/use_kibana_ui_setting');
|
||||
|
||||
describe('Subtitle', () => {
|
||||
test('it renders', () => {
|
||||
const wrapper = shallow(<Subtitle items="Test subtitle" />);
|
||||
|
|
|
@ -8,13 +8,69 @@ import { mount } from 'enzyme';
|
|||
import * as React from 'react';
|
||||
import { Provider as ReduxStoreProvider } from 'react-redux';
|
||||
|
||||
import { useUiSetting$ } from '../../lib/kibana';
|
||||
import { apolloClientObservable, mockGlobalState } from '../../mock';
|
||||
import { createUseUiSetting$Mock } from '../../mock/kibana_react';
|
||||
import { createStore, State } from '../../store';
|
||||
|
||||
import { SuperDatePicker, makeMapStateToProps } from '.';
|
||||
import { cloneDeep } from 'lodash/fp';
|
||||
import { DEFAULT_TIMEPICKER_QUICK_RANGES } from '../../../common/constants';
|
||||
|
||||
jest.mock('../../lib/settings/use_kibana_ui_setting');
|
||||
jest.mock('../../lib/kibana');
|
||||
const mockUseUiSetting$ = useUiSetting$ as jest.Mock;
|
||||
const timepickerRanges = [
|
||||
{
|
||||
from: 'now/d',
|
||||
to: 'now/d',
|
||||
display: 'Today',
|
||||
},
|
||||
{
|
||||
from: 'now/w',
|
||||
to: 'now/w',
|
||||
display: 'This week',
|
||||
},
|
||||
{
|
||||
from: 'now-15m',
|
||||
to: 'now',
|
||||
display: 'Last 15 minutes',
|
||||
},
|
||||
{
|
||||
from: 'now-30m',
|
||||
to: 'now',
|
||||
display: 'Last 30 minutes',
|
||||
},
|
||||
{
|
||||
from: 'now-1h',
|
||||
to: 'now',
|
||||
display: 'Last 1 hour',
|
||||
},
|
||||
{
|
||||
from: 'now-24h',
|
||||
to: 'now',
|
||||
display: 'Last 24 hours',
|
||||
},
|
||||
{
|
||||
from: 'now-7d',
|
||||
to: 'now',
|
||||
display: 'Last 7 days',
|
||||
},
|
||||
{
|
||||
from: 'now-30d',
|
||||
to: 'now',
|
||||
display: 'Last 30 days',
|
||||
},
|
||||
{
|
||||
from: 'now-90d',
|
||||
to: 'now',
|
||||
display: 'Last 90 days',
|
||||
},
|
||||
{
|
||||
from: 'now-1y',
|
||||
to: 'now',
|
||||
display: 'Last 1 year',
|
||||
},
|
||||
];
|
||||
|
||||
describe('SIEM Super Date Picker', () => {
|
||||
describe('#SuperDatePicker', () => {
|
||||
|
@ -24,6 +80,13 @@ describe('SIEM Super Date Picker', () => {
|
|||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
store = createStore(state, apolloClientObservable);
|
||||
mockUseUiSetting$.mockImplementation((key, defaultValue) => {
|
||||
const useUiSetting$Mock = createUseUiSetting$Mock();
|
||||
|
||||
return key === DEFAULT_TIMEPICKER_QUICK_RANGES
|
||||
? [timepickerRanges, jest.fn()]
|
||||
: useUiSetting$Mock(key, defaultValue);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Pick Relative Date', () => {
|
||||
|
|
|
@ -18,7 +18,7 @@ import { connect } from 'react-redux';
|
|||
import { Dispatch } from 'redux';
|
||||
|
||||
import { DEFAULT_TIMEPICKER_QUICK_RANGES } from '../../../common/constants';
|
||||
import { useKibanaUiSetting } from '../../lib/settings/use_kibana_ui_setting';
|
||||
import { useUiSetting$ } from '../../lib/kibana';
|
||||
import { inputsModel, State } from '../../store';
|
||||
import { inputsActions, timelineActions } from '../../store/actions';
|
||||
import { InputsModelId } from '../../store/inputs/constants';
|
||||
|
@ -38,6 +38,12 @@ import { InputsRange, Policy } from '../../store/inputs/model';
|
|||
|
||||
const MAX_RECENTLY_USED_RANGES = 9;
|
||||
|
||||
interface Range {
|
||||
from: string;
|
||||
to: string;
|
||||
display: string;
|
||||
}
|
||||
|
||||
interface SuperDatePickerStateRedux {
|
||||
duration: number;
|
||||
end: number;
|
||||
|
@ -196,10 +202,10 @@ export const SuperDatePickerComponent = React.memo<SuperDatePickerProps>(
|
|||
const endDate = kind === 'relative' ? toStr : new Date(end).toISOString();
|
||||
const startDate = kind === 'relative' ? fromStr : new Date(start).toISOString();
|
||||
|
||||
const [quickRanges] = useKibanaUiSetting(DEFAULT_TIMEPICKER_QUICK_RANGES);
|
||||
const [quickRanges] = useUiSetting$<Range[]>(DEFAULT_TIMEPICKER_QUICK_RANGES);
|
||||
const commonlyUsedRanges = isEmpty(quickRanges)
|
||||
? []
|
||||
: quickRanges.map(({ from, to, display }: { from: string; to: string; display: string }) => ({
|
||||
: quickRanges.map(({ from, to, display }) => ({
|
||||
start: from,
|
||||
end: to,
|
||||
label: display,
|
||||
|
|
|
@ -17,8 +17,6 @@ import { Sort } from './sort';
|
|||
import { wait } from '../../../lib/helpers';
|
||||
import { useMountAppended } from '../../../utils/use_mount_appended';
|
||||
|
||||
jest.mock('../../../lib/settings/use_kibana_ui_setting');
|
||||
|
||||
const testBodyHeight = 700;
|
||||
const mockGetNotesByIds = (eventId: string[]) => [];
|
||||
const mockSort: Sort = {
|
||||
|
|
|
@ -18,7 +18,7 @@ import { useMountAppended } from '../../../../utils/use_mount_appended';
|
|||
import { FormattedFieldValue } from './formatted_field';
|
||||
import { HOST_NAME_FIELD_NAME } from './constants';
|
||||
|
||||
jest.mock('../../../../lib/settings/use_kibana_ui_setting');
|
||||
jest.mock('../../../../lib/kibana');
|
||||
|
||||
describe('Events', () => {
|
||||
const theme = () => ({ eui: euiDarkVars, darkMode: true });
|
||||
|
|
|
@ -25,8 +25,6 @@ export const justIdAndTimestamp: Ecs = {
|
|||
timestamp: '2018-11-12T19:03:25.936Z',
|
||||
};
|
||||
|
||||
jest.mock('../../../../../lib/settings/use_kibana_ui_setting');
|
||||
|
||||
describe('netflowRowRenderer', () => {
|
||||
const mount = useMountAppended();
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ import { useMountAppended } from '../../../../utils/use_mount_appended';
|
|||
import { plainColumnRenderer } from './plain_column_renderer';
|
||||
import { getValues, deleteItemIdx, findItem } from './helpers';
|
||||
|
||||
jest.mock('../../../../lib/settings/use_kibana_ui_setting');
|
||||
jest.mock('../../../../lib/kibana');
|
||||
|
||||
const mockFramework = mockFrameworks.default_UTC;
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ import {
|
|||
} from './generic_row_renderer';
|
||||
import * as i18n from './translations';
|
||||
|
||||
jest.mock('../../../../../lib/settings/use_kibana_ui_setting');
|
||||
jest.mock('../../../../../lib/kibana');
|
||||
|
||||
describe('GenericRowRenderer', () => {
|
||||
const mount = useMountAppended();
|
||||
|
|
|
@ -9,21 +9,14 @@ import toJson from 'enzyme-to-json';
|
|||
import * as React from 'react';
|
||||
|
||||
import { Direction } from '../../../graphql/types';
|
||||
import { useKibanaCore } from '../../../lib/compose/kibana_core';
|
||||
import { mockIndexPattern } from '../../../mock';
|
||||
import { TestProviders } from '../../../mock/test_providers';
|
||||
import { mockUiSettings } from '../../../mock/ui_settings';
|
||||
import { mockDataProviders } from '../data_providers/mock/mock_data_providers';
|
||||
import { useMountAppended } from '../../../utils/use_mount_appended';
|
||||
|
||||
import { TimelineHeaderComponent } from '.';
|
||||
|
||||
const mockUseKibanaCore = useKibanaCore as jest.Mock;
|
||||
jest.mock('../../../lib/compose/kibana_core');
|
||||
mockUseKibanaCore.mockImplementation(() => ({
|
||||
uiSettings: mockUiSettings,
|
||||
savedObjects: {},
|
||||
}));
|
||||
jest.mock('../../../lib/kibana');
|
||||
|
||||
describe('Header', () => {
|
||||
const indexPattern = mockIndexPattern;
|
||||
|
|
|
@ -8,22 +8,12 @@ import { mount } from 'enzyme';
|
|||
import * as React from 'react';
|
||||
import { Provider as ReduxStoreProvider } from 'react-redux';
|
||||
|
||||
import { useKibanaCore } from '../../../lib/compose/kibana_core';
|
||||
import { mockGlobalState, apolloClientObservable } from '../../../mock';
|
||||
import { mockUiSettings } from '../../../mock/ui_settings';
|
||||
import { createStore, State } from '../../../store';
|
||||
|
||||
import { Properties, showDescriptionThreshold, showNotesThreshold } from '.';
|
||||
|
||||
const mockUseKibanaCore = useKibanaCore as jest.Mock;
|
||||
jest.mock('../../../lib/compose/kibana_core');
|
||||
mockUseKibanaCore.mockImplementation(() => ({
|
||||
uiSettings: mockUiSettings,
|
||||
}));
|
||||
|
||||
jest.mock('ui/vis/lib/timezone', () => ({
|
||||
timezoneProvider: () => () => 'America/New_York',
|
||||
}));
|
||||
jest.mock('../../../lib/kibana');
|
||||
|
||||
describe('Properties', () => {
|
||||
const usersViewing = ['elastic'];
|
||||
|
|
|
@ -9,22 +9,15 @@ import React from 'react';
|
|||
|
||||
import { DEFAULT_FROM, DEFAULT_TO } from '../../../../common/constants';
|
||||
import { mockBrowserFields } from '../../../containers/source/mock';
|
||||
import { useKibanaCore } from '../../../lib/compose/kibana_core';
|
||||
import { convertKueryToElasticSearchQuery } from '../../../lib/keury';
|
||||
import { mockIndexPattern, TestProviders } from '../../../mock';
|
||||
import { mockUiSettings } from '../../../mock/ui_settings';
|
||||
import { QueryBar } from '../../query_bar';
|
||||
import { mockDataProviders } from '../data_providers/mock/mock_data_providers';
|
||||
import { buildGlobalQuery } from '../helpers';
|
||||
|
||||
import { QueryBarTimeline, QueryBarTimelineComponentProps, getDataProviderFilter } from './index';
|
||||
|
||||
const mockUseKibanaCore = useKibanaCore as jest.Mock;
|
||||
jest.mock('../../../lib/compose/kibana_core');
|
||||
mockUseKibanaCore.mockImplementation(() => ({
|
||||
uiSettings: mockUiSettings,
|
||||
savedObjects: {},
|
||||
}));
|
||||
jest.mock('../../../lib/kibana');
|
||||
|
||||
describe('Timeline QueryBar ', () => {
|
||||
// We are doing that because we need to wrapped this component with redux
|
||||
|
|
|
@ -19,7 +19,7 @@ import {
|
|||
|
||||
import { BrowserFields } from '../../../containers/source';
|
||||
import { convertKueryToElasticSearchQuery } from '../../../lib/keury';
|
||||
import { useKibanaCore } from '../../../lib/compose/kibana_core';
|
||||
import { useKibana } from '../../../lib/kibana';
|
||||
import { KueryFilterQuery, KueryFilterQueryKind } from '../../../store';
|
||||
import { KqlMode } from '../../../store/timeline/model';
|
||||
import { useSavedQueryServices } from '../../../utils/saved_query_services';
|
||||
|
@ -92,8 +92,8 @@ export const QueryBarTimeline = memo<QueryBarTimelineComponentProps>(
|
|||
const [dataProvidersDsl, setDataProvidersDsl] = useState<string>(
|
||||
convertKueryToElasticSearchQuery(buildGlobalQuery(dataProviders, browserFields), indexPattern)
|
||||
);
|
||||
const core = useKibanaCore();
|
||||
const [filterManager] = useState<FilterManager>(new FilterManager(core.uiSettings));
|
||||
const kibana = useKibana();
|
||||
const [filterManager] = useState<FilterManager>(new FilterManager(kibana.services.uiSettings));
|
||||
|
||||
const savedQueryServices = useSavedQueryServices();
|
||||
|
||||
|
|
|
@ -12,10 +12,8 @@ import { MockedProvider } from 'react-apollo/test-utils';
|
|||
import { timelineQuery } from '../../containers/timeline/index.gql_query';
|
||||
import { mockBrowserFields } from '../../containers/source/mock';
|
||||
import { Direction } from '../../graphql/types';
|
||||
import { useKibanaCore } from '../../lib/compose/kibana_core';
|
||||
import { defaultHeaders, mockTimelineData, mockIndexPattern } from '../../mock';
|
||||
import { TestProviders } from '../../mock/test_providers';
|
||||
import { mockUiSettings } from '../../mock/ui_settings';
|
||||
import { flyoutHeaderHeight } from '../flyout';
|
||||
|
||||
import {
|
||||
|
@ -30,12 +28,7 @@ import { useMountAppended } from '../../utils/use_mount_appended';
|
|||
|
||||
const testFlyoutHeight = 980;
|
||||
|
||||
const mockUseKibanaCore = useKibanaCore as jest.Mock;
|
||||
jest.mock('../../lib/compose/kibana_core');
|
||||
mockUseKibanaCore.mockImplementation(() => ({
|
||||
uiSettings: mockUiSettings,
|
||||
savedObjects: {},
|
||||
}));
|
||||
jest.mock('../../lib/kibana');
|
||||
|
||||
describe('Timeline', () => {
|
||||
const sort: Sort = {
|
||||
|
|
|
@ -12,7 +12,7 @@ import styled from 'styled-components';
|
|||
import { BrowserFields } from '../../containers/source';
|
||||
import { TimelineQuery } from '../../containers/timeline';
|
||||
import { Direction } from '../../graphql/types';
|
||||
import { useKibanaCore } from '../../lib/compose/kibana_core';
|
||||
import { useKibana } from '../../lib/kibana';
|
||||
import { KqlMode } from '../../store/timeline/model';
|
||||
import { AutoSizer } from '../auto_sizer';
|
||||
import { ColumnHeader } from './body/column_headers/column_header';
|
||||
|
@ -113,9 +113,9 @@ export const TimelineComponent = ({
|
|||
sort,
|
||||
toggleColumn,
|
||||
}: Props) => {
|
||||
const core = useKibanaCore();
|
||||
const kibana = useKibana();
|
||||
const combinedQueries = combineQueries({
|
||||
config: esQuery.getEsQueryConfig(core.uiSettings),
|
||||
config: esQuery.getEsQueryConfig(kibana.services.uiSettings),
|
||||
dataProviders,
|
||||
indexPattern,
|
||||
browserFields,
|
||||
|
|
|
@ -9,11 +9,8 @@ import toJson from 'enzyme-to-json';
|
|||
import React from 'react';
|
||||
|
||||
import { TestProviders } from '../../mock';
|
||||
import '../../mock/ui_settings';
|
||||
import { WrapperPage } from './index';
|
||||
|
||||
jest.mock('../../lib/settings/use_kibana_ui_setting');
|
||||
|
||||
describe('WrapperPage', () => {
|
||||
test('it renders', () => {
|
||||
const wrapper = shallow(
|
||||
|
|
|
@ -8,10 +8,11 @@ import { getOr } from 'lodash/fp';
|
|||
import React from 'react';
|
||||
import { Query } from 'react-apollo';
|
||||
import { connect } from 'react-redux';
|
||||
import { compose } from 'redux';
|
||||
|
||||
import chrome from 'ui/chrome';
|
||||
import { DEFAULT_INDEX_KEY } from '../../../../common/constants';
|
||||
import { inputsModel, State, inputsSelectors, hostsModel } from '../../../store';
|
||||
import { withKibana, WithKibanaProps } from '../../../lib/kibana';
|
||||
import { createFilter, getDefaultFetchPolicy } from '../../helpers';
|
||||
import { QueryTemplate, QueryTemplateProps } from '../../query_template';
|
||||
|
||||
|
@ -40,7 +41,7 @@ export interface AlertsOverTimeComponentReduxProps {
|
|||
isInspected: boolean;
|
||||
}
|
||||
|
||||
type AlertsOverTimeProps = OwnProps & AlertsOverTimeComponentReduxProps;
|
||||
type AlertsOverTimeProps = OwnProps & AlertsOverTimeComponentReduxProps & WithKibanaProps;
|
||||
|
||||
class AlertsOverTimeComponentQuery extends QueryTemplate<
|
||||
AlertsOverTimeProps,
|
||||
|
@ -54,6 +55,7 @@ class AlertsOverTimeComponentQuery extends QueryTemplate<
|
|||
filterQuery,
|
||||
id = ID,
|
||||
isInspected,
|
||||
kibana,
|
||||
sourceId,
|
||||
startDate,
|
||||
} = this.props;
|
||||
|
@ -70,7 +72,7 @@ class AlertsOverTimeComponentQuery extends QueryTemplate<
|
|||
from: startDate!,
|
||||
to: endDate!,
|
||||
},
|
||||
defaultIndex: chrome.getUiSettingsClient().get(DEFAULT_INDEX_KEY),
|
||||
defaultIndex: kibana.services.uiSettings.get<string[]>(DEFAULT_INDEX_KEY),
|
||||
inspect: isInspected,
|
||||
}}
|
||||
>
|
||||
|
@ -105,4 +107,7 @@ const makeMapStateToProps = () => {
|
|||
return mapStateToProps;
|
||||
};
|
||||
|
||||
export const AlertsOverTimeQuery = connect(makeMapStateToProps)(AlertsOverTimeComponentQuery);
|
||||
export const AlertsOverTimeQuery = compose<React.ComponentClass<OwnProps>>(
|
||||
connect(makeMapStateToProps),
|
||||
withKibana
|
||||
)(AlertsOverTimeComponentQuery);
|
||||
|
|
|
@ -12,7 +12,7 @@ import { AnomaliesOverTimeHistogram } from '../../../components/anomalies_over_t
|
|||
import { AnomaliesOverTimeQuery } from '../anomalies_over_time';
|
||||
import { getAnomaliesFilterQuery } from './utils';
|
||||
import { useSiemJobs } from '../../../components/ml_popover/hooks/use_siem_jobs';
|
||||
import { useKibanaUiSetting } from '../../../lib/settings/use_kibana_ui_setting';
|
||||
import { useUiSetting$ } from '../../../lib/kibana';
|
||||
import { DEFAULT_ANOMALY_SCORE } from '../../../../common/constants';
|
||||
|
||||
const AnomaliesOverTimeManage = manageQuery(AnomaliesOverTimeHistogram);
|
||||
|
@ -33,7 +33,7 @@ export const AnomaliesQueryTabBody = ({
|
|||
ip,
|
||||
}: AnomaliesQueryTabBodyProps) => {
|
||||
const [siemJobsLoading, siemJobs] = useSiemJobs(true);
|
||||
const [anomalyScore] = useKibanaUiSetting(DEFAULT_ANOMALY_SCORE);
|
||||
const [anomalyScore] = useUiSetting$<number>(DEFAULT_ANOMALY_SCORE);
|
||||
|
||||
const mergedFilterQuery = getAnomaliesFilterQuery(
|
||||
filterQuery,
|
||||
|
|
|
@ -8,10 +8,11 @@ import { getOr } from 'lodash/fp';
|
|||
import React from 'react';
|
||||
import { Query } from 'react-apollo';
|
||||
import { connect } from 'react-redux';
|
||||
import { compose } from 'redux';
|
||||
|
||||
import chrome from 'ui/chrome';
|
||||
import { DEFAULT_INDEX_KEY } from '../../../../common/constants';
|
||||
import { inputsModel, State, inputsSelectors, hostsModel } from '../../../store';
|
||||
import { withKibana, WithKibanaProps } from '../../../lib/kibana';
|
||||
import { createFilter, getDefaultFetchPolicy } from '../../helpers';
|
||||
import { QueryTemplate, QueryTemplateProps } from '../../query_template';
|
||||
|
||||
|
@ -43,7 +44,9 @@ export interface AuthenticationsOverTimeComponentReduxProps {
|
|||
isInspected: boolean;
|
||||
}
|
||||
|
||||
type AuthenticationsOverTimeProps = OwnProps & AuthenticationsOverTimeComponentReduxProps;
|
||||
type AuthenticationsOverTimeProps = OwnProps &
|
||||
AuthenticationsOverTimeComponentReduxProps &
|
||||
WithKibanaProps;
|
||||
|
||||
class AuthenticationsOverTimeComponentQuery extends QueryTemplate<
|
||||
AuthenticationsOverTimeProps,
|
||||
|
@ -56,6 +59,7 @@ class AuthenticationsOverTimeComponentQuery extends QueryTemplate<
|
|||
filterQuery,
|
||||
id = ID,
|
||||
isInspected,
|
||||
kibana,
|
||||
sourceId,
|
||||
startDate,
|
||||
endDate,
|
||||
|
@ -73,7 +77,7 @@ class AuthenticationsOverTimeComponentQuery extends QueryTemplate<
|
|||
from: startDate!,
|
||||
to: endDate!,
|
||||
},
|
||||
defaultIndex: chrome.getUiSettingsClient().get(DEFAULT_INDEX_KEY),
|
||||
defaultIndex: kibana.services.uiSettings.get<string[]>(DEFAULT_INDEX_KEY),
|
||||
inspect: isInspected,
|
||||
}}
|
||||
>
|
||||
|
@ -108,6 +112,7 @@ const makeMapStateToProps = () => {
|
|||
return mapStateToProps;
|
||||
};
|
||||
|
||||
export const AuthenticationsOverTimeQuery = connect(makeMapStateToProps)(
|
||||
AuthenticationsOverTimeComponentQuery
|
||||
);
|
||||
export const AuthenticationsOverTimeQuery = compose<React.ComponentClass<OwnProps>>(
|
||||
connect(makeMapStateToProps),
|
||||
withKibana
|
||||
)(AuthenticationsOverTimeComponentQuery);
|
||||
|
|
|
@ -8,8 +8,8 @@ import { getOr } from 'lodash/fp';
|
|||
import React from 'react';
|
||||
import { Query } from 'react-apollo';
|
||||
import { connect } from 'react-redux';
|
||||
import { compose } from 'redux';
|
||||
|
||||
import chrome from 'ui/chrome';
|
||||
import { DEFAULT_INDEX_KEY } from '../../../common/constants';
|
||||
import {
|
||||
AuthenticationsEdges,
|
||||
|
@ -19,6 +19,7 @@ import {
|
|||
import { hostsModel, hostsSelectors, inputsModel, State, inputsSelectors } from '../../store';
|
||||
import { createFilter, getDefaultFetchPolicy } from '../helpers';
|
||||
import { generateTablePaginationOptions } from '../../components/paginated_table/helpers';
|
||||
import { withKibana, WithKibanaProps } from '../../lib/kibana';
|
||||
import { QueryTemplatePaginated, QueryTemplatePaginatedProps } from '../query_template_paginated';
|
||||
|
||||
import { authenticationsQuery } from './index.gql_query';
|
||||
|
@ -48,7 +49,7 @@ export interface AuthenticationsComponentReduxProps {
|
|||
limit: number;
|
||||
}
|
||||
|
||||
type AuthenticationsProps = OwnProps & AuthenticationsComponentReduxProps;
|
||||
type AuthenticationsProps = OwnProps & AuthenticationsComponentReduxProps & WithKibanaProps;
|
||||
|
||||
class AuthenticationsComponentQuery extends QueryTemplatePaginated<
|
||||
AuthenticationsProps,
|
||||
|
@ -63,6 +64,7 @@ class AuthenticationsComponentQuery extends QueryTemplatePaginated<
|
|||
filterQuery,
|
||||
id = ID,
|
||||
isInspected,
|
||||
kibana,
|
||||
limit,
|
||||
skip,
|
||||
sourceId,
|
||||
|
@ -77,7 +79,7 @@ class AuthenticationsComponentQuery extends QueryTemplatePaginated<
|
|||
},
|
||||
pagination: generateTablePaginationOptions(activePage, limit),
|
||||
filterQuery: createFilter(filterQuery),
|
||||
defaultIndex: chrome.getUiSettingsClient().get(DEFAULT_INDEX_KEY),
|
||||
defaultIndex: kibana.services.uiSettings.get<string[]>(DEFAULT_INDEX_KEY),
|
||||
inspect: isInspected,
|
||||
};
|
||||
return (
|
||||
|
@ -142,4 +144,7 @@ const makeMapStateToProps = () => {
|
|||
return mapStateToProps;
|
||||
};
|
||||
|
||||
export const AuthenticationsQuery = connect(makeMapStateToProps)(AuthenticationsComponentQuery);
|
||||
export const AuthenticationsQuery = compose<React.ComponentClass<OwnProps>>(
|
||||
connect(makeMapStateToProps),
|
||||
withKibana
|
||||
)(AuthenticationsComponentQuery);
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
import { useEffect, useState, Dispatch } from 'react';
|
||||
|
||||
import { useKibanaUiSetting } from '../../../lib/settings/use_kibana_ui_setting';
|
||||
import { useUiSetting$ } from '../../../lib/kibana';
|
||||
import { DEFAULT_KBN_VERSION } from '../../../../common/constants';
|
||||
import { useStateToaster } from '../../../components/toasters';
|
||||
import { errorToToaster } from '../../../components/ml/api/error_to_toaster';
|
||||
|
@ -26,7 +26,7 @@ export const usePersistRule = (): Return => {
|
|||
const [rule, setRule] = useState<NewRule | null>(null);
|
||||
const [isSaved, setIsSaved] = useState(false);
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [kbnVersion] = useKibanaUiSetting(DEFAULT_KBN_VERSION);
|
||||
const [kbnVersion] = useUiSetting$<string>(DEFAULT_KBN_VERSION);
|
||||
const [, dispatchToaster] = useStateToaster();
|
||||
|
||||
useEffect(() => {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
import { useKibanaUiSetting } from '../../../lib/settings/use_kibana_ui_setting';
|
||||
import { useUiSetting$ } from '../../../lib/kibana';
|
||||
import { DEFAULT_KBN_VERSION } from '../../../../common/constants';
|
||||
import { useStateToaster } from '../../../components/toasters';
|
||||
import { errorToToaster } from '../../../components/ml/api/error_to_toaster';
|
||||
|
@ -25,7 +25,7 @@ type Return = [boolean, Rule | null];
|
|||
export const useRule = (id: string | undefined): Return => {
|
||||
const [rule, setRule] = useState<Rule | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [kbnVersion] = useKibanaUiSetting(DEFAULT_KBN_VERSION);
|
||||
const [kbnVersion] = useUiSetting$<string>(DEFAULT_KBN_VERSION);
|
||||
const [, dispatchToaster] = useStateToaster();
|
||||
|
||||
useEffect(() => {
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue