Skip to content

Commit

Permalink
Merge branch 'chore/siem-deep-equal' of github.com:patrykkopycinski/k…
Browse files Browse the repository at this point in the history
…ibana into chore/siem-deep-equal
  • Loading branch information
patrykkopycinski committed Feb 6, 2020
2 parents 839f609 + 876805e commit aa2dca1
Show file tree
Hide file tree
Showing 65 changed files with 815 additions and 844 deletions.
1 change: 1 addition & 0 deletions src/optimize/base_optimizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ export default class BaseOptimizer {
profile: this.profile || false,

output: {
futureEmitAssets: true, // TODO: remove on webpack 5
path: this.uiBundles.getWorkingDir(),
filename: '[name].bundle.js',
sourceMapFilename: '[file].map',
Expand Down
1 change: 1 addition & 0 deletions src/optimize/dynamic_dll_plugin/dll_config_model.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ function generateDLL(config) {
entry: dllEntry,
context: dllContext,
output: {
futureEmitAssets: true, // TODO: remove on webpack 5
filename: dllBundleFilename,
path: dllOutputPath,
publicPath: dllPublicPath,
Expand Down
55 changes: 30 additions & 25 deletions x-pack/legacy/plugins/siem/public/app/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ import euiDarkVars from '@elastic/eui/dist/eui_theme_dark.json';
import euiLightVars from '@elastic/eui/dist/eui_theme_light.json';
import { BehaviorSubject } from 'rxjs';
import { pluck } from 'rxjs/operators';
import { I18nContext } from 'ui/i18n';

import { KibanaContextProvider, useUiSetting$ } from '../lib/kibana';
import { KibanaContextProvider, useKibana, useUiSetting$ } from '../lib/kibana';
import { Storage } from '../../../../../../src/plugins/kibana_utils/public';

import { DEFAULT_DARK_MODE } from '../../common/constants';
Expand All @@ -27,7 +26,7 @@ import { compose } from '../lib/compose/kibana_compose';
import { AppFrontendLibs, AppApolloClient } from '../lib/lib';
import { CoreStart, StartPlugins } from '../plugin';
import { PageRouter } from '../routes';
import { createStore } from '../store';
import { createStore, createInitialState } from '../store';
import { GlobalToaster, ManageGlobalToaster } from '../components/toasters';
import { MlCapabilitiesProvider } from '../components/ml/permissions/ml_capabilities_provider';

Expand All @@ -46,33 +45,30 @@ const AppPluginRootComponent: React.FC<AppPluginRootComponentProps> = ({
apolloClient,
history,
}) => (
<EuiErrorBoundary>
<I18nContext>
<ManageGlobalToaster>
<ReduxStoreProvider store={store}>
<ApolloProvider client={apolloClient}>
<ApolloClientContext.Provider value={apolloClient}>
<ThemeProvider theme={theme}>
<MlCapabilitiesProvider>
<PageRouter history={history} />
</MlCapabilitiesProvider>
</ThemeProvider>
<ErrorToastDispatcher />
<GlobalToaster />
</ApolloClientContext.Provider>
</ApolloProvider>
</ReduxStoreProvider>
</ManageGlobalToaster>
</I18nContext>
</EuiErrorBoundary>
<ManageGlobalToaster>
<ReduxStoreProvider store={store}>
<ApolloProvider client={apolloClient}>
<ApolloClientContext.Provider value={apolloClient}>
<ThemeProvider theme={theme}>
<MlCapabilitiesProvider>
<PageRouter history={history} />
</MlCapabilitiesProvider>
</ThemeProvider>
<ErrorToastDispatcher />
<GlobalToaster />
</ApolloClientContext.Provider>
</ApolloProvider>
</ReduxStoreProvider>
</ManageGlobalToaster>
);

const AppPluginRoot = memo(AppPluginRootComponent);

const StartAppComponent: FC<AppFrontendLibs> = libs => {
const { i18n } = useKibana().services;
const history = createHashHistory();
const libs$ = new BehaviorSubject(libs);
const store = createStore(undefined, libs$.pipe(pluck('apolloClient')));
const store = createStore(createInitialState(), libs$.pipe(pluck('apolloClient')));
const [darkMode] = useUiSetting$<boolean>(DEFAULT_DARK_MODE);
const theme = useMemo(
() => ({
Expand All @@ -83,7 +79,16 @@ const StartAppComponent: FC<AppFrontendLibs> = libs => {
);

return (
<AppPluginRoot store={store} apolloClient={libs.apolloClient} history={history} theme={theme} />
<EuiErrorBoundary>
<i18n.Context>
<AppPluginRoot
store={store}
apolloClient={libs.apolloClient}
history={history}
theme={theme}
/>
</i18n.Context>
</EuiErrorBoundary>
);
};

Expand All @@ -103,7 +108,7 @@ const SiemAppComponent: React.FC<SiemAppComponentProps> = ({ core, plugins }) =>
...plugins,
}}
>
<StartApp {...compose()} />
<StartApp {...compose(core)} />
</KibanaContextProvider>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { getOr, get, isNull, isNumber } from 'lodash/fp';

import { AutoSizer } from '../auto_sizer';
import { ChartPlaceHolder } from './chart_place_holder';
import { useTimeZone } from '../../hooks';
import { useTimeZone } from '../../lib/kibana';
import {
chartDefaultSettings,
ChartSeriesConfigs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Chart, BarSeries, Axis, Position, ScaleType, Settings } from '@elastic/
import { getOr, get, isNumber } from 'lodash/fp';
import deepmerge from 'deepmerge';

import { useTimeZone } from '../../hooks';
import { useTimeZone } from '../../lib/kibana';
import { AutoSizer } from '../auto_sizer';
import { ChartPlaceHolder } from './chart_place_holder';
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ import { useIndexPatterns } from '../../hooks/use_index_patterns';
import { EmbeddedMapComponent } from './embedded_map';
import { SetQuery } from './types';

jest.mock('../search_bar', () => ({
siemFilterManager: {
addFilters: jest.fn(),
},
}));

const mockUseIndexPatterns = useIndexPatterns as jest.Mock;
jest.mock('../../hooks/use_index_patterns');
mockUseIndexPatterns.mockImplementation(() => [true, []]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
import { EuiButton, EuiCode, EuiEmptyPrompt } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import React from 'react';
import chrome from 'ui/chrome';

import { useKibana } from '../../lib/kibana';
import { useKibana, useBasePath } from '../../lib/kibana';
import * as i18n from './translations';

export const IndexPatternsMissingPromptComponent = () => {
const docLinks = useKibana().services.docLinks;
const { docLinks } = useKibana().services;
const kibanaBasePath = `${useBasePath()}/app/kibana`;

return (
<EuiEmptyPrompt
Expand All @@ -29,7 +29,7 @@ export const IndexPatternsMissingPromptComponent = () => {
values={{
defaultIndex: (
<a
href={`${chrome.getBasePath()}/app/kibana#/management/kibana/settings`}
href={`${kibanaBasePath}#/management/kibana/settings`}
rel="noopener noreferrer"
target="_blank"
>
Expand Down Expand Up @@ -61,7 +61,7 @@ export const IndexPatternsMissingPromptComponent = () => {
}
actions={
<EuiButton
href={`${chrome.getBasePath()}/app/kibana#/management/kibana/index_patterns`}
href={`${kibanaBasePath}#/management/kibana/index_patterns`}
color="primary"
target="_blank"
fill
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ import React from 'react';
import { MapToolTipComponent } from './map_tool_tip';
import { MapFeature } from '../types';

jest.mock('../../search_bar', () => ({
siemFilterManager: {
addFilters: jest.fn(),
},
}));

describe('MapToolTip', () => {
test('placeholder component renders correctly against snapshot', () => {
const wrapper = shallow(<MapToolTipComponent />);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ import { HostDetailsLink, IPDetailsLink } from '../../links';
import { useMountAppended } from '../../../utils/use_mount_appended';
import { FlowTarget } from '../../../graphql/types';

jest.mock('../../search_bar', () => ({
siemFilterManager: {
addFilters: jest.fn(),
},
}));

describe('PointToolTipContent', () => {
const mount = useMountAppended();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
import { mount, shallow } from 'enzyme';
import React from 'react';

import { useDateFormat, useTimeZone } from '../../hooks';
import { useDateFormat, useTimeZone } from '../../lib/kibana';

import { TestProviders } from '../../mock';
import { getEmptyString, getEmptyValue } from '../empty_value';
import { PreferenceFormattedDate, FormattedDate, FormattedRelativePreferenceDate } from '.';

jest.mock('../../hooks');
jest.mock('../../lib/kibana');
const mockUseDateFormat = useDateFormat as jest.Mock;
const mockUseTimeZone = useTimeZone as jest.Mock;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ import moment from 'moment-timezone';
import React from 'react';
import { FormattedRelative } from '@kbn/i18n/react';

import { useDateFormat, useTimeZone } from '../../hooks';
import { useDateFormat, useTimeZone, useUiSetting$ } from '../../lib/kibana';
import { getOrEmptyTagFromValue } from '../empty_value';
import { useUiSetting$ } from '../../lib/kibana';
import { LocalizedDateTooltip } from '../localized_date_tooltip';
import { getMaybeDate } from './maybe_date';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
*/

import React, { useEffect } from 'react';
import chrome from 'ui/chrome';
import { i18n } from '@kbn/i18n';
import { documentationLinks } from 'ui/documentation_links';
import { useKibana } from '../../lib/kibana';

export const HelpMenu = React.memo(() => {
const { chrome, docLinks } = useKibana().services;

useEffect(() => {
chrome.helpExtension.set({
chrome.setHelpExtension({
appName: i18n.translate('xpack.siem.chrome.help.appName', {
defaultMessage: 'SIEM',
}),
Expand All @@ -20,7 +21,7 @@ export const HelpMenu = React.memo(() => {
content: i18n.translate('xpack.siem.chrome.helpMenu.documentation', {
defaultMessage: 'SIEM documentation',
}),
href: documentationLinks.siem.guide,
href: docLinks.links.siem.guide,
iconType: 'documents',
linkType: 'custom',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ import { useStateToaster } from '../../toasters';
import { errorToToaster } from '../api/error_to_toaster';

import * as i18n from './translations';
import { useUiSetting$ } from '../../../lib/kibana';
import { useTimeZone, useUiSetting$ } from '../../../lib/kibana';
import { DEFAULT_ANOMALY_SCORE } from '../../../../common/constants';
import { useTimeZone } from '../../../hooks';

interface Args {
influencers?: InfluencerInput[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { npStart } from 'ui/new_platform';
import { Anomalies, InfluencerInput, CriteriaFields } from '../types';
import { throwIfNotOk } from '../../../hooks/api/api';
import { KibanaServices } from '../../../lib/kibana';

export interface Body {
jobIds: string[];
Expand All @@ -22,7 +22,7 @@ export interface Body {
}

export const anomaliesTableData = async (body: Body, signal: AbortSignal): Promise<Anomalies> => {
const response = await npStart.core.http.fetch<Anomalies>(
const response = await KibanaServices.get().http.fetch<Anomalies>(
'/api/ml/results/anomalies_table_data',
{
method: 'POST',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { npStart } from 'ui/new_platform';

import { InfluencerInput, MlCapabilities } from '../types';
import { throwIfNotOk } from '../../../hooks/api/api';
import { KibanaServices } from '../../../lib/kibana';

export interface Body {
jobIds: string[];
Expand All @@ -23,12 +22,15 @@ export interface Body {
}

export const getMlCapabilities = async (signal: AbortSignal): Promise<MlCapabilities> => {
const response = await npStart.core.http.fetch<MlCapabilities>('/api/ml/ml_capabilities', {
method: 'GET',
asResponse: true,
asSystemRequest: true,
signal,
});
const response = await KibanaServices.get().http.fetch<MlCapabilities>(
'/api/ml/ml_capabilities',
{
method: 'GET',
asResponse: true,
asSystemRequest: true,
signal,
}
);

await throwIfNotOk(response.response);
return response.body!;
Expand Down
Loading

0 comments on commit aa2dca1

Please sign in to comment.