diff --git a/x-pack/legacy/plugins/ml/public/settings/__snapshots__/settings.test.js.snap b/x-pack/legacy/plugins/ml/public/settings/__snapshots__/settings.test.js.snap
deleted file mode 100644
index 9305677b04372..0000000000000
--- a/x-pack/legacy/plugins/ml/public/settings/__snapshots__/settings.test.js.snap
+++ /dev/null
@@ -1,76 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`Settings Renders settings page 1`] = `
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-`;
diff --git a/x-pack/legacy/plugins/ml/public/settings/calendars/edit/__snapshots__/new_calendar.test.js.snap b/x-pack/legacy/plugins/ml/public/settings/calendars/edit/__snapshots__/new_calendar.test.js.snap
index 52c91e0159103..9a48bb551dcde 100644
--- a/x-pack/legacy/plugins/ml/public/settings/calendars/edit/__snapshots__/new_calendar.test.js.snap
+++ b/x-pack/legacy/plugins/ml/public/settings/calendars/edit/__snapshots__/new_calendar.test.js.snap
@@ -1,40 +1,45 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`NewCalendar Renders new calendar form 1`] = `
-
-
+
+
-
-
-
+
+
+
+
+
`;
diff --git a/x-pack/legacy/plugins/ml/public/settings/calendars/edit/directive.js b/x-pack/legacy/plugins/ml/public/settings/calendars/edit/directive.js
index ca9d86a6572a7..2d5427f091def 100644
--- a/x-pack/legacy/plugins/ml/public/settings/calendars/edit/directive.js
+++ b/x-pack/legacy/plugins/ml/public/settings/calendars/edit/directive.js
@@ -17,13 +17,16 @@ import { checkGetJobsPrivilege, checkPermission } from '../../../privilege/check
import { checkMlNodesAvailable } from '../../../ml_nodes_check/check_ml_nodes';
import { getCreateCalendarBreadcrumbs, getEditCalendarBreadcrumbs } from '../../breadcrumbs';
+import chrome from 'ui/chrome';
import uiRoutes from 'ui/routes';
-
+import { timefilter } from 'ui/timefilter';
+import { timeHistory } from 'ui/timefilter/time_history';
import { I18nContext } from 'ui/i18n';
+import { NavigationMenuContext } from '../../../util/context_utils';
+
const template = `
-
`;
@@ -63,7 +66,9 @@ module.directive('mlNewCalendar', function ($route) {
ReactDOM.render(
- {React.createElement(NewCalendar, props)}
+
+
+
,
element[0]
);
diff --git a/x-pack/legacy/plugins/ml/public/settings/calendars/edit/new_calendar.js b/x-pack/legacy/plugins/ml/public/settings/calendars/edit/new_calendar.js
index 91d70e4890cb4..307fbf564be20 100644
--- a/x-pack/legacy/plugins/ml/public/settings/calendars/edit/new_calendar.js
+++ b/x-pack/legacy/plugins/ml/public/settings/calendars/edit/new_calendar.js
@@ -6,11 +6,11 @@
-import React, {
- Component
-} from 'react';
+import React, { Component, Fragment } from 'react';
import { PropTypes } from 'prop-types';
+import { injectI18n } from '@kbn/i18n/react';
+
import {
EuiPage,
EuiPageContent,
@@ -18,14 +18,16 @@ import {
} from '@elastic/eui';
import chrome from 'ui/chrome';
+import { toastNotifications } from 'ui/notify';
+
+import { NavigationMenu } from '../../../components/navigation_menu/navigation_menu';
+
import { getCalendarSettingsData, validateCalendarId } from './utils';
import { CalendarForm } from './calendar_form/';
import { NewEventModal } from './new_event_modal/';
import { ImportModal } from './import_modal';
import { ml } from '../../../services/ml_api_service';
-import { toastNotifications } from 'ui/notify';
-import { injectI18n } from '@kbn/i18n/react';
export const NewCalendar = injectI18n(class NewCalendar extends Component {
static propTypes = {
@@ -333,39 +335,42 @@ export const NewCalendar = injectI18n(class NewCalendar extends Component {
}
return (
-
-
-
-
- {modal}
-
+
+
+
+
+
+
+ {modal}
+
+
);
}
});
diff --git a/x-pack/legacy/plugins/ml/public/settings/calendars/edit/new_calendar.test.js b/x-pack/legacy/plugins/ml/public/settings/calendars/edit/new_calendar.test.js
index 3bf7a8ade705b..52ca426b9bd80 100644
--- a/x-pack/legacy/plugins/ml/public/settings/calendars/edit/new_calendar.test.js
+++ b/x-pack/legacy/plugins/ml/public/settings/calendars/edit/new_calendar.test.js
@@ -4,13 +4,15 @@
* you may not use this file except in compliance with the Elastic License.
*/
-
-
+jest.mock('../../../components/navigation_menu/navigation_menu', () => ({
+ NavigationMenu: () =>
+}));
jest.mock('../../../privilege/check_privilege', () => ({
checkPermission: () => true
}));
jest.mock('../../../license/check_license', () => ({
- hasLicenseExpired: () => false
+ hasLicenseExpired: () => false,
+ isFullLicense: () => false
}));
jest.mock('../../../privilege/get_privileges', () => ({
getPrivileges: () => {}
@@ -18,9 +20,6 @@ jest.mock('../../../privilege/get_privileges', () => ({
jest.mock('../../../ml_nodes_check/check_ml_nodes', () => ({
mlNodesAvailable: () => true
}));
-jest.mock('ui/chrome', () => ({
- getBasePath: jest.fn()
-}));
jest.mock('../../../services/ml_api_service', () => ({
ml: {
calendars: () => {
diff --git a/x-pack/legacy/plugins/ml/public/settings/calendars/list/__snapshots__/calendars_list.test.js.snap b/x-pack/legacy/plugins/ml/public/settings/calendars/list/__snapshots__/calendars_list.test.js.snap
index d582c96b410cf..40f67b5043c86 100644
--- a/x-pack/legacy/plugins/ml/public/settings/calendars/list/__snapshots__/calendars_list.test.js.snap
+++ b/x-pack/legacy/plugins/ml/public/settings/calendars/list/__snapshots__/calendars_list.test.js.snap
@@ -1,69 +1,74 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`CalendarsList Renders calendar list with calendars 1`] = `
-
-
+
+
-
-
-
-
+
+
+
+
+
+
`;
diff --git a/x-pack/legacy/plugins/ml/public/settings/calendars/list/calendars_list.js b/x-pack/legacy/plugins/ml/public/settings/calendars/list/calendars_list.js
index c24147b8123b8..0b5657b62ebf3 100644
--- a/x-pack/legacy/plugins/ml/public/settings/calendars/list/calendars_list.js
+++ b/x-pack/legacy/plugins/ml/public/settings/calendars/list/calendars_list.js
@@ -6,9 +6,7 @@
-import React, {
- Component
-} from 'react';
+import React, { Component, Fragment } from 'react';
import { PropTypes } from 'prop-types';
import {
@@ -19,6 +17,7 @@ import {
EUI_MODAL_CONFIRM_BUTTON,
} from '@elastic/eui';
+import { NavigationMenu } from '../../../components/navigation_menu/navigation_menu';
import { CalendarsListHeader } from './header';
import { CalendarsListTable } from './table/';
import { ml } from '../../../services/ml_api_service';
@@ -147,29 +146,32 @@ export const CalendarsList = injectI18n(class CalendarsList extends Component {
}
return (
-
-
-
- 0}
- />
-
- {destroyModal}
-
+
+
+
+
+
+ 0}
+ />
+
+ {destroyModal}
+
+
);
}
});
diff --git a/x-pack/legacy/plugins/ml/public/settings/calendars/list/calendars_list.test.js b/x-pack/legacy/plugins/ml/public/settings/calendars/list/calendars_list.test.js
index af6f0272b78d7..84211597f313c 100644
--- a/x-pack/legacy/plugins/ml/public/settings/calendars/list/calendars_list.test.js
+++ b/x-pack/legacy/plugins/ml/public/settings/calendars/list/calendars_list.test.js
@@ -4,13 +4,21 @@
* you may not use this file except in compliance with the Elastic License.
*/
+import { shallowWithIntl, mountWithIntl } from 'test_utils/enzyme_helpers';
+import React from 'react';
+import { ml } from '../../../services/ml_api_service';
+import { CalendarsList } from './calendars_list';
+jest.mock('../../../components/navigation_menu/navigation_menu', () => ({
+ NavigationMenu: () =>
+}));
jest.mock('../../../privilege/check_privilege', () => ({
checkPermission: () => true
}));
jest.mock('../../../license/check_license', () => ({
- hasLicenseExpired: () => false
+ hasLicenseExpired: () => false,
+ isFullLicense: () => false
}));
jest.mock('../../../privilege/get_privileges', () => ({
getPrivileges: () => {}
@@ -18,9 +26,6 @@ jest.mock('../../../privilege/get_privileges', () => ({
jest.mock('../../../ml_nodes_check/check_ml_nodes', () => ({
mlNodesAvailable: () => true
}));
-jest.mock('ui/chrome', () => ({
- getBasePath: jest.fn()
-}));
jest.mock('../../../services/ml_api_service', () => ({
ml: {
calendars: () => {
@@ -30,12 +35,6 @@ jest.mock('../../../services/ml_api_service', () => ({
}
}));
-import { shallowWithIntl, mountWithIntl } from 'test_utils/enzyme_helpers';
-import React from 'react';
-import { ml } from '../../../services/ml_api_service';
-
-import { CalendarsList } from './calendars_list';
-
const testingState = {
loading: false,
calendars: [
diff --git a/x-pack/legacy/plugins/ml/public/settings/calendars/list/directive.js b/x-pack/legacy/plugins/ml/public/settings/calendars/list/directive.js
index 3d72eb7912ac6..4f16433b987d5 100644
--- a/x-pack/legacy/plugins/ml/public/settings/calendars/list/directive.js
+++ b/x-pack/legacy/plugins/ml/public/settings/calendars/list/directive.js
@@ -4,7 +4,6 @@
* you may not use this file except in compliance with the Elastic License.
*/
-
import 'ngreact';
import React from 'react';
import ReactDOM from 'react-dom';
@@ -17,27 +16,28 @@ import { checkGetJobsPrivilege, checkPermission } from '../../../privilege/check
import { getMlNodeCount } from '../../../ml_nodes_check/check_ml_nodes';
import { getCalendarManagementBreadcrumbs } from '../../breadcrumbs';
+import chrome from 'ui/chrome';
import uiRoutes from 'ui/routes';
-
+import { timefilter } from 'ui/timefilter';
+import { timeHistory } from 'ui/timefilter/time_history';
import { I18nContext } from 'ui/i18n';
+import { NavigationMenuContext } from '../../../util/context_utils';
+
const template = `
-
`;
-uiRoutes
- .when('/settings/calendars_list', {
- template,
- k7Breadcrumbs: getCalendarManagementBreadcrumbs,
- resolve: {
- CheckLicense: checkFullLicense,
- privileges: checkGetJobsPrivilege,
- mlNodeCount: getMlNodeCount,
- }
- });
-
+uiRoutes.when('/settings/calendars_list', {
+ template,
+ k7Breadcrumbs: getCalendarManagementBreadcrumbs,
+ resolve: {
+ CheckLicense: checkFullLicense,
+ privileges: checkGetJobsPrivilege,
+ mlNodeCount: getMlNodeCount,
+ },
+});
import { CalendarsList } from './calendars_list';
@@ -54,10 +54,12 @@ module.directive('mlCalendarsList', function () {
ReactDOM.render(
- {React.createElement(CalendarsList, props)}
+
+
+
,
element[0]
);
- }
+ },
};
});
diff --git a/x-pack/legacy/plugins/ml/public/settings/filter_lists/edit/__snapshots__/edit_filter_list.test.js.snap b/x-pack/legacy/plugins/ml/public/settings/filter_lists/edit/__snapshots__/edit_filter_list.test.js.snap
index 43464755a4b79..e19c61350f8c7 100644
--- a/x-pack/legacy/plugins/ml/public/settings/filter_lists/edit/__snapshots__/edit_filter_list.test.js.snap
+++ b/x-pack/legacy/plugins/ml/public/settings/filter_lists/edit/__snapshots__/edit_filter_list.test.js.snap
@@ -1,852 +1,892 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`EditFilterList adds new items to filter list 1`] = `
-
-
+
+
-
-
-
-
-
-
+
+
+
+
-
-
-
-
-
-
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
`;
exports[`EditFilterList renders after selecting an item and deleting it 1`] = `
-
-
+
+
-
-
-
-
-
-
+
+
+
+
-
-
-
-
-
-
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
`;
exports[`EditFilterList renders after selecting an item and deleting it 2`] = `
-
-
+
+
-
-
-
-
-
-
+
+
+
+
-
-
-
-
-
-
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
`;
exports[`EditFilterList renders the edit page for a new filter list and updates ID 1`] = `
-
-
+
+
-
-
-
-
-
-
+
+
+
+
-
-
-
-
-
-
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
`;
exports[`EditFilterList renders the edit page for a new filter list and updates ID 2`] = `
-
-
+
+
-
-
-
-
-
-
+
+
+
+
-
-
-
-
-
-
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
`;
exports[`EditFilterList renders the edit page for an existing filter list and updates description 1`] = `
-
-
+
+
-
-
-
-
-
-
+
+
+
+
-
-
-
-
-
-
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
`;
exports[`EditFilterList renders the edit page for an existing filter list and updates description 2`] = `
-
-
+
+
-
-
-
-
-
-
+
+
+
+
-
-
-
-
-
-
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
`;
exports[`EditFilterList updates the items per page 1`] = `
-
-
+
+
-
-
-
-
-
-
+
+
+
+
-
-
-
-
-
-
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
`;
diff --git a/x-pack/legacy/plugins/ml/public/settings/filter_lists/edit/directive.js b/x-pack/legacy/plugins/ml/public/settings/filter_lists/edit/directive.js
index e51d700eb90e6..af3ba07d1b655 100644
--- a/x-pack/legacy/plugins/ml/public/settings/filter_lists/edit/directive.js
+++ b/x-pack/legacy/plugins/ml/public/settings/filter_lists/edit/directive.js
@@ -9,8 +9,6 @@ import 'ngreact';
import React from 'react';
import ReactDOM from 'react-dom';
-import { I18nContext } from 'ui/i18n';
-
import { uiModules } from 'ui/modules';
const module = uiModules.get('apps/ml', ['react']);
@@ -20,11 +18,16 @@ import { checkGetJobsPrivilege, checkPermission } from 'plugins/ml/privilege/che
import { getMlNodeCount } from 'plugins/ml/ml_nodes_check/check_ml_nodes';
import { EditFilterList } from './edit_filter_list';
+import chrome from 'ui/chrome';
import uiRoutes from 'ui/routes';
+import { timefilter } from 'ui/timefilter';
+import { timeHistory } from 'ui/timefilter/time_history';
+import { I18nContext } from 'ui/i18n';
+
+import { NavigationMenuContext } from '../../../util/context_utils';
const template = `
-
`;
@@ -62,7 +65,9 @@ module.directive('mlEditFilterList', function ($route) {
ReactDOM.render(
- {React.createElement(EditFilterList, props)}
+
+
+
,
element[0]
);
diff --git a/x-pack/legacy/plugins/ml/public/settings/filter_lists/edit/edit_filter_list.js b/x-pack/legacy/plugins/ml/public/settings/filter_lists/edit/edit_filter_list.js
index 81b12dc78b987..2a27dd0fc9774 100644
--- a/x-pack/legacy/plugins/ml/public/settings/filter_lists/edit/edit_filter_list.js
+++ b/x-pack/legacy/plugins/ml/public/settings/filter_lists/edit/edit_filter_list.js
@@ -11,9 +11,7 @@
*/
import PropTypes from 'prop-types';
-import React, {
- Component
-} from 'react';
+import React, { Component, Fragment } from 'react';
import {
EuiButton,
@@ -33,6 +31,7 @@ import { toastNotifications } from 'ui/notify';
import { EditFilterListHeader } from './header';
import { EditFilterListToolbar } from './toolbar';
import { ItemsGrid } from '../../../components/items_grid';
+import { NavigationMenu } from '../../../components/navigation_menu/navigation_menu';
import {
isValidFilterListId,
saveFilterList
@@ -309,71 +308,74 @@ export const EditFilterList = injectI18n(class extends Component {
const totalItemCount = (items !== undefined) ? items.length : 0;
return (
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+ }
+ fill
+ >
+
+
+
+
+
+
+
);
}
});
diff --git a/x-pack/legacy/plugins/ml/public/settings/filter_lists/edit/edit_filter_list.test.js b/x-pack/legacy/plugins/ml/public/settings/filter_lists/edit/edit_filter_list.test.js
index 75d6d34f0a586..035913d5dc465 100644
--- a/x-pack/legacy/plugins/ml/public/settings/filter_lists/edit/edit_filter_list.test.js
+++ b/x-pack/legacy/plugins/ml/public/settings/filter_lists/edit/edit_filter_list.test.js
@@ -4,6 +4,10 @@
* you may not use this file except in compliance with the Elastic License.
*/
+jest.mock('../../../components/navigation_menu/navigation_menu', () => ({
+ NavigationMenu: () =>
+}));
+
// Define the required mocks used for loading, saving and validating the filter list.
jest.mock('./utils', () => ({
isValidFilterListId: () => true,
@@ -19,7 +23,7 @@ const mockTestFilter = {
items: ['google.com', 'google.co.uk', 'elastic.co', 'youtube.com'],
used_by: {
detectors: ['high info content'],
- jobs: ['dns_exfiltration']
+ jobs: ['dns_exfiltration'],
},
};
jest.mock('../../../services/ml_api_service', () => ({
@@ -27,12 +31,11 @@ jest.mock('../../../services/ml_api_service', () => ({
filters: {
filters: () => {
return Promise.resolve(mockTestFilter);
- }
- }
- }
+ },
+ },
+ },
}));
-
import { shallowWithIntl } from 'test_utils/enzyme_helpers';
import React from 'react';
@@ -40,14 +43,11 @@ import { EditFilterList } from './edit_filter_list';
const props = {
canCreateFilter: true,
- canDeleteFilter: true
+ canDeleteFilter: true,
};
function prepareEditTest() {
-
- const wrapper = shallowWithIntl(
-
- );
+ const wrapper = shallowWithIntl(
);
// Cannot find a way to generate the snapshot after the Promise in the mock ml.filters
// has resolved.
@@ -61,11 +61,8 @@ function prepareEditTest() {
}
describe('EditFilterList', () => {
-
test('renders the edit page for a new filter list and updates ID', () => {
- const wrapper = shallowWithIntl(
-
- );
+ const wrapper = shallowWithIntl(
);
expect(wrapper).toMatchSnapshot();
const instance = wrapper.instance();
@@ -114,5 +111,4 @@ describe('EditFilterList', () => {
wrapper.update();
expect(wrapper).toMatchSnapshot();
});
-
});
diff --git a/x-pack/legacy/plugins/ml/public/settings/filter_lists/list/__snapshots__/filter_lists.test.js.snap b/x-pack/legacy/plugins/ml/public/settings/filter_lists/list/__snapshots__/filter_lists.test.js.snap
index b95a7966ad80d..129e9a0f83caa 100644
--- a/x-pack/legacy/plugins/ml/public/settings/filter_lists/list/__snapshots__/filter_lists.test.js.snap
+++ b/x-pack/legacy/plugins/ml/public/settings/filter_lists/list/__snapshots__/filter_lists.test.js.snap
@@ -1,41 +1,46 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Filter Lists renders a list of filters 1`] = `
-
-
+
+
-
-
+
+
-
-
+ ]
+ }
+ refreshFilterLists={[Function]}
+ selectedFilterLists={Array []}
+ setSelectedFilterLists={[Function]}
+ />
+
+
+
`;
diff --git a/x-pack/legacy/plugins/ml/public/settings/filter_lists/list/directive.js b/x-pack/legacy/plugins/ml/public/settings/filter_lists/list/directive.js
index f27f6e0609e26..95cdebf3518f7 100644
--- a/x-pack/legacy/plugins/ml/public/settings/filter_lists/list/directive.js
+++ b/x-pack/legacy/plugins/ml/public/settings/filter_lists/list/directive.js
@@ -9,8 +9,6 @@ import 'ngreact';
import React from 'react';
import ReactDOM from 'react-dom';
-import { I18nContext } from 'ui/i18n';
-
import { uiModules } from 'ui/modules';
const module = uiModules.get('apps/ml', ['react']);
@@ -20,11 +18,16 @@ import { checkGetJobsPrivilege, checkPermission } from 'plugins/ml/privilege/che
import { getMlNodeCount } from 'plugins/ml/ml_nodes_check/check_ml_nodes';
import { FilterLists } from './filter_lists';
+import chrome from 'ui/chrome';
import uiRoutes from 'ui/routes';
+import { timefilter } from 'ui/timefilter';
+import { timeHistory } from 'ui/timefilter/time_history';
+import { I18nContext } from 'ui/i18n';
+
+import { NavigationMenuContext } from '../../../util/context_utils';
const template = `
-
`;
@@ -52,7 +55,9 @@ module.directive('mlFilterLists', function () {
ReactDOM.render(
- {React.createElement(FilterLists, props)}
+
+
+
,
element[0]
);
diff --git a/x-pack/legacy/plugins/ml/public/settings/filter_lists/list/filter_lists.js b/x-pack/legacy/plugins/ml/public/settings/filter_lists/list/filter_lists.js
index f940e51d6f0ae..8ea2bb8929913 100644
--- a/x-pack/legacy/plugins/ml/public/settings/filter_lists/list/filter_lists.js
+++ b/x-pack/legacy/plugins/ml/public/settings/filter_lists/list/filter_lists.js
@@ -9,9 +9,7 @@
* React table for displaying a table of filter lists.
*/
-import React, {
- Component
-} from 'react';
+import React, { Component, Fragment } from 'react';
import { PropTypes } from 'prop-types';
import {
@@ -23,6 +21,8 @@ import { injectI18n } from '@kbn/i18n/react';
import { toastNotifications } from 'ui/notify';
+import { NavigationMenu } from '../../../components/navigation_menu/navigation_menu';
+
import { FilterListsHeader } from './header';
import { FilterListsTable } from './table';
import { ml } from '../../../services/ml_api_service';
@@ -88,26 +88,29 @@ export const FilterLists = injectI18n(class extends Component {
const { canCreateFilter, canDeleteFilter } = this.props;
return (
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
);
}
});
diff --git a/x-pack/legacy/plugins/ml/public/settings/filter_lists/list/filter_lists.test.js b/x-pack/legacy/plugins/ml/public/settings/filter_lists/list/filter_lists.test.js
index 2aa95f8604829..3c6a564ec92b4 100644
--- a/x-pack/legacy/plugins/ml/public/settings/filter_lists/list/filter_lists.test.js
+++ b/x-pack/legacy/plugins/ml/public/settings/filter_lists/list/filter_lists.test.js
@@ -4,9 +4,16 @@
* you may not use this file except in compliance with the Elastic License.
*/
+import { shallowWithIntl } from 'test_utils/enzyme_helpers';
+import React from 'react';
+
+import { FilterLists } from './filter_lists';
+jest.mock('../../../components/navigation_menu/navigation_menu', () => ({
+ NavigationMenu: () =>
+}));
jest.mock('../../../privilege/check_privilege', () => ({
- checkPermission: () => true
+ checkPermission: () => true,
}));
// Mock the call for loading the list of filters.
@@ -23,28 +30,19 @@ jest.mock('../../../services/ml_api_service', () => ({
filters: {
filtersStats: () => {
return Promise.resolve([mockTestFilter]);
- }
- }
- }
+ },
+ },
+ },
}));
-import { shallowWithIntl } from 'test_utils/enzyme_helpers';
-import React from 'react';
-
-import { FilterLists } from './filter_lists';
-
const props = {
canCreateFilter: true,
- canDeleteFilter: true
+ canDeleteFilter: true,
};
describe('Filter Lists', () => {
-
test('renders a list of filters', () => {
-
- const wrapper = shallowWithIntl(
-
- );
+ const wrapper = shallowWithIntl(
);
// Cannot find a way to generate the snapshot after the Promise in the mock ml.filters
// has resolved.
@@ -54,5 +52,4 @@ describe('Filter Lists', () => {
wrapper.update();
expect(wrapper).toMatchSnapshot();
});
-
});
diff --git a/x-pack/legacy/plugins/ml/public/settings/settings.js b/x-pack/legacy/plugins/ml/public/settings/settings.js
index ab4f807cae728..3e1b7d724f188 100644
--- a/x-pack/legacy/plugins/ml/public/settings/settings.js
+++ b/x-pack/legacy/plugins/ml/public/settings/settings.js
@@ -6,7 +6,7 @@
-import React from 'react';
+import React, { Fragment } from 'react';
import { PropTypes } from 'prop-types';
import {
@@ -20,67 +20,73 @@ import {
EuiTitle
} from '@elastic/eui';
-import chrome from 'ui/chrome';
-
import { FormattedMessage } from '@kbn/i18n/react';
+import { useNavigationMenuContext } from '../util/context_utils';
+import { NavigationMenu } from '../components/navigation_menu/navigation_menu';
+
export function Settings({
canGetFilters,
canGetCalendars
}) {
+ const basePath = useNavigationMenuContext().chrome.getBasePath();
+
return (
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
+
+
+
+
);
}
diff --git a/x-pack/legacy/plugins/ml/public/settings/settings.test.js b/x-pack/legacy/plugins/ml/public/settings/settings.test.js
index 0d5cc000854e1..3e7129bbc0718 100644
--- a/x-pack/legacy/plugins/ml/public/settings/settings.test.js
+++ b/x-pack/legacy/plugins/ml/public/settings/settings.test.js
@@ -4,46 +4,65 @@
* you may not use this file except in compliance with the Elastic License.
*/
-
-
-jest.mock('ui/chrome', () => ({
- getBasePath: jest.fn()
-}));
-
-import { shallowWithIntl, mountWithIntl } from 'test_utils/enzyme_helpers';
+import { mountWithIntl } from 'test_utils/enzyme_helpers';
+import PropTypes from 'prop-types';
import React from 'react';
+import * as ContextUtils from '../util/context_utils';
import { Settings } from './settings';
+const navigationMenuMock = ContextUtils.navigationMenuMock;
+const mountOptions = {
+ context: { NavigationMenuContext: navigationMenuMock },
+ childContextTypes: { NavigationMenuContext: PropTypes.object }
+};
+
+jest.mock('../components/navigation_menu/navigation_menu', () => ({
+ NavigationMenu: () =>
+}));
+jest.spyOn(ContextUtils, 'useNavigationMenuContext').mockImplementation(() => navigationMenuMock);
+
describe('Settings', () => {
+ test('Renders settings page with all buttons enabled.', () => {
+ const wrapper = mountWithIntl(
, mountOptions);
- test('Renders settings page', () => {
- const wrapper = shallowWithIntl(
-
- );
+ const filterButton = wrapper
+ .find('[data-test-subj="ml_filter_lists_button"]')
+ .find('EuiButtonEmpty');
+ expect(filterButton.prop('isDisabled')).toBe(false);
- expect(wrapper).toMatchSnapshot();
+ const calendarButton = wrapper
+ .find('[data-test-subj="ml_calendar_mng_button"]')
+ .find('EuiButtonEmpty');
+ expect(calendarButton.prop('isDisabled')).toBe(false);
});
test('Filter Lists button disabled if canGetFilters is false', () => {
- const wrapper = mountWithIntl(
-
- );
+ const wrapper = mountWithIntl(, mountOptions);
- const button = wrapper.find('[data-test-subj="ml_filter_lists_button"]');
- const filterButton = button.find('EuiButtonEmpty');
+ const filterButton = wrapper
+ .find('[data-test-subj="ml_filter_lists_button"]')
+ .find('EuiButtonEmpty');
expect(filterButton.prop('isDisabled')).toBe(true);
+
+ const calendarButton = wrapper
+ .find('[data-test-subj="ml_calendar_mng_button"]')
+ .find('EuiButtonEmpty');
+ expect(calendarButton.prop('isDisabled')).toBe(false);
});
test('Calendar management button disabled if canGetCalendars is false', () => {
- const wrapper = mountWithIntl(
-
- );
+ const wrapper = mountWithIntl(, mountOptions);
- const button = wrapper.find('[data-test-subj="ml_calendar_mng_button"]');
- const calendarButton = button.find('EuiButtonEmpty');
+ const filterButton = wrapper
+ .find('[data-test-subj="ml_filter_lists_button"]')
+ .find('EuiButtonEmpty');
+ expect(filterButton.prop('isDisabled')).toBe(false);
+
+ const calendarButton = wrapper
+ .find('[data-test-subj="ml_calendar_mng_button"]')
+ .find('EuiButtonEmpty');
expect(calendarButton.prop('isDisabled')).toBe(true);
});
-
});
diff --git a/x-pack/legacy/plugins/ml/public/settings/settings_directive.js b/x-pack/legacy/plugins/ml/public/settings/settings_directive.js
index 68ac533089558..ab03c548f53cd 100644
--- a/x-pack/legacy/plugins/ml/public/settings/settings_directive.js
+++ b/x-pack/legacy/plugins/ml/public/settings/settings_directive.js
@@ -15,15 +15,17 @@ const module = uiModules.get('apps/ml', ['react']);
import { checkFullLicense } from '../license/check_license';
import { checkGetJobsPrivilege, checkPermission } from '../privilege/check_privilege';
import { getMlNodeCount } from '../ml_nodes_check/check_ml_nodes';
+import { NavigationMenuContext } from '../util/context_utils';
import { getSettingsBreadcrumbs } from './breadcrumbs';
import { I18nContext } from 'ui/i18n';
+import chrome from 'ui/chrome';
import uiRoutes from 'ui/routes';
import { timefilter } from 'ui/timefilter';
+import { timeHistory } from 'ui/timefilter/time_history';
const template = `
-
`;
@@ -56,12 +58,9 @@ module.directive('mlSettings', function () {
ReactDOM.render(
- {React.createElement(
- Settings, {
- canGetFilters,
- canGetCalendars
- })
- }
+
+
+
,
element[0]
);
diff --git a/x-pack/legacy/plugins/ml/public/timeseriesexplorer/timeseriesexplorer.html b/x-pack/legacy/plugins/ml/public/timeseriesexplorer/timeseriesexplorer.html
index 880e8466e10bd..300832d05c741 100644
--- a/x-pack/legacy/plugins/ml/public/timeseriesexplorer/timeseriesexplorer.html
+++ b/x-pack/legacy/plugins/ml/public/timeseriesexplorer/timeseriesexplorer.html
@@ -1,4 +1,4 @@
-
+
diff --git a/x-pack/legacy/plugins/ml/public/util/context_utils.tsx b/x-pack/legacy/plugins/ml/public/util/context_utils.tsx
new file mode 100644
index 0000000000000..88d340bd6aa6b
--- /dev/null
+++ b/x-pack/legacy/plugins/ml/public/util/context_utils.tsx
@@ -0,0 +1,66 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License;
+ * you may not use this file except in compliance with the Elastic License.
+ */
+
+import React, { useContext } from 'react';
+
+import { Chrome } from 'ui/chrome';
+import { Timefilter } from 'ui/timefilter';
+import { TimeHistory } from 'ui/timefilter/time_history';
+
+export const ChromeContext = React.createContext({} as Chrome);
+export const TimefilterContext = React.createContext({} as Timefilter);
+export const TimeHistoryContext = React.createContext({} as TimeHistory);
+
+interface NavigationMenuContextValue {
+ chrome: Chrome;
+ timefilter: Timefilter;
+ timeHistory: TimeHistory;
+}
+export const NavigationMenuContext = React.createContext({
+ chrome: {} as Chrome,
+ timefilter: {} as Timefilter,
+ timeHistory: {} as TimeHistory,
+});
+
+export const useNavigationMenuContext = () => {
+ return useContext(NavigationMenuContext);
+};
+
+// testing mocks
+export const chromeMock = {
+ getBasePath: () => 'basePath',
+ getUiSettingsClient: () => {
+ return {
+ get: (key: string) => {
+ switch (key) {
+ case 'dateFormat':
+ case 'timepicker:timeDefaults':
+ return {};
+ case 'timepicker:refreshIntervalDefaults':
+ return { pause: false, value: 0 };
+ default:
+ throw new Error(`Unexpected config key: ${key}`);
+ }
+ },
+ };
+ },
+} as Chrome;
+
+export const timefilterMock = ({
+ getRefreshInterval: () => '30s',
+ getTime: () => ({ from: 0, to: 0 }),
+ on: (event: string, reload: () => void) => {},
+} as unknown) as Timefilter;
+
+export const timeHistoryMock = ({
+ get: () => [{ from: 0, to: 0 }],
+} as unknown) as TimeHistory;
+
+export const navigationMenuMock = {
+ chrome: chromeMock,
+ timefilter: timefilterMock,
+ timeHistory: timeHistoryMock,
+};