Skip to content

Commit 09c718d

Browse files
author
Aaron Caldwell
committed
Merge remote-tracking branch 'upstream/master' into np-move-file-upload-to-np
2 parents dc68a58 + d9a05af commit 09c718d

63 files changed

Lines changed: 716 additions & 536 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

x-pack/legacy/plugins/ml/common/license/index.ts

Lines changed: 0 additions & 7 deletions
This file was deleted.

x-pack/legacy/plugins/ml/common/license/ml_license.ts

Lines changed: 0 additions & 78 deletions
This file was deleted.

x-pack/legacy/plugins/ml/public/application/app.tsx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,15 @@ import { AppMountParameters, CoreStart } from 'kibana/public';
1313

1414
import { DataPublicPluginStart } from 'src/plugins/data/public';
1515
import { SecurityPluginSetup } from '../../../../../plugins/security/public';
16-
import { LicensingPluginSetup } from '../../../../../plugins/licensing/public';
1716

1817
import { KibanaContextProvider } from '../../../../../../src/plugins/kibana_react/public';
1918
import { setDependencyCache, clearCache } from './util/dependency_cache';
20-
import { setLicenseCache } from './license';
2119

2220
import { MlRouter } from './routing';
2321

2422
export interface MlDependencies extends AppMountParameters {
2523
data: DataPublicPluginStart;
2624
security: SecurityPluginSetup;
27-
licensing: LicensingPluginSetup;
2825
__LEGACY: {
2926
XSRF: string;
3027
};
@@ -39,26 +36,22 @@ const App: FC<AppProps> = ({ coreStart, deps }) => {
3936
setDependencyCache({
4037
indexPatterns: deps.data.indexPatterns,
4138
timefilter: deps.data.query.timefilter,
42-
fieldFormats: deps.data.fieldFormats,
43-
autocomplete: deps.data.autocomplete,
4439
config: coreStart.uiSettings!,
4540
chrome: coreStart.chrome!,
4641
docLinks: coreStart.docLinks!,
4742
toastNotifications: coreStart.notifications.toasts,
4843
overlays: coreStart.overlays,
4944
recentlyAccessed: coreStart.chrome!.recentlyAccessed,
45+
fieldFormats: deps.data.fieldFormats,
46+
autocomplete: deps.data.autocomplete,
5047
basePath: coreStart.http.basePath,
5148
savedObjectsClient: coreStart.savedObjects.client,
5249
XSRF: deps.__LEGACY.XSRF,
5350
application: coreStart.application,
5451
http: coreStart.http,
5552
security: deps.security,
5653
});
57-
58-
const mlLicense = setLicenseCache(deps.licensing);
59-
6054
deps.onAppLeave(actions => {
61-
mlLicense.unsubscribe();
6255
clearCache();
6356
return actions.default();
6457
});

x-pack/legacy/plugins/ml/public/application/components/anomalies_table/anomalies_table.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { getColumns } from './anomalies_table_columns';
1111
jest.mock('../../privilege/check_privilege', () => ({
1212
checkPermission: () => false,
1313
}));
14-
jest.mock('../../license', () => ({
14+
jest.mock('../../license/check_license', () => ({
1515
hasLicenseExpired: () => false,
1616
}));
1717
jest.mock('../../privilege/get_privileges', () => ({

x-pack/legacy/plugins/ml/public/application/components/navigation_menu/main_tabs.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,18 +81,13 @@ export const MainTabs: FC<Props> = ({ tabId, disableLinks }) => {
8181
return (
8282
<EuiTabs display="condensed">
8383
{tabs.map((tab: Tab) => {
84-
const { id, disabled } = tab;
84+
const id = tab.id;
8585
const testSubject = TAB_DATA[id].testSubject;
8686
const defaultPathId = TAB_DATA[id].pathId || id;
8787
// globalState (e.g. selected jobs and time range) should be retained when changing pages.
8888
// appState will not be considered.
8989
const fullGlobalStateString = globalState !== undefined ? `?_g=${encode(globalState)}` : '';
90-
91-
return disabled ? (
92-
<EuiTab key={`${id}-key`} className={'mlNavigationMenu__mainTab'} disabled={true}>
93-
{tab.name}
94-
</EuiTab>
95-
) : (
90+
return (
9691
<EuiLink
9792
data-test-subj={testSubject + (id === selectedTabId ? ' selected' : '')}
9893
href={`#/${defaultPathId}${fullGlobalStateString}`}
@@ -103,6 +98,7 @@ export const MainTabs: FC<Props> = ({ tabId, disableLinks }) => {
10398
className={'mlNavigationMenu__mainTab'}
10499
onClick={() => onSelectedTabChanged(id)}
105100
isSelected={id === selectedTabId}
101+
disabled={tab.disabled}
106102
>
107103
{tab.name}
108104
</EuiTab>

x-pack/legacy/plugins/ml/public/application/components/navigation_menu/navigation_menu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import React, { Fragment, FC } from 'react';
88
import { EuiFlexGroup, EuiFlexItem, EuiHorizontalRule } from '@elastic/eui';
99

10-
import { isFullLicense } from '../../license';
10+
import { isFullLicense } from '../../license/check_license';
1111

1212
import { TopNav } from './top_nav';
1313
import { MainTabs } from './main_tabs';

x-pack/legacy/plugins/ml/public/application/datavisualizer/datavisualizer_selector.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
import { i18n } from '@kbn/i18n';
2323

2424
import { FormattedMessage } from '@kbn/i18n/react';
25-
import { isFullLicense } from '../license';
25+
import { isFullLicense } from '../license/check_license';
2626
import { useTimefilter } from '../contexts/kibana';
2727

2828
import { NavigationMenu } from '../components/navigation_menu';

x-pack/legacy/plugins/ml/public/application/datavisualizer/file_based/components/results_links/results_links.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import moment from 'moment';
99
import { FormattedMessage } from '@kbn/i18n/react';
1010
import { EuiFlexGroup, EuiFlexItem, EuiCard, EuiIcon } from '@elastic/eui';
1111
import { ml } from '../../../../services/ml_api_service';
12-
import { isFullLicense } from '../../../../license';
12+
import { isFullLicense } from '../../../../license/check_license';
1313
import { checkPermission } from '../../../../privilege/check_privilege';
1414
import { mlNodesAvailable } from '../../../../ml_nodes_check/check_ml_nodes';
1515
import { useMlKibana } from '../../../../contexts/kibana';

x-pack/legacy/plugins/ml/public/application/datavisualizer/index_based/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import { SavedSearchSavedObject } from '../../../../common/types/kibana';
3131
import { NavigationMenu } from '../../components/navigation_menu';
3232
import { ML_JOB_FIELD_TYPES } from '../../../../common/constants/field_types';
3333
import { SEARCH_QUERY_LANGUAGE } from '../../../../common/constants/search';
34-
import { isFullLicense } from '../../license';
34+
import { isFullLicense } from '../../license/check_license';
3535
import { checkPermission } from '../../privilege/check_privilege';
3636
import { mlNodesAvailable } from '../../ml_nodes_check/check_ml_nodes';
3737
import { FullTimeRangeSelector } from '../../components/full_time_range_selector';
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
import expect from '@kbn/expect';
8+
import { xpackInfo } from '../../../../../xpack_main/public/services/xpack_info';
9+
import { LICENSE_STATUS_VALID } from '../../../../../../common/constants/license_status';
10+
import { xpackFeatureAvailable } from '../check_license';
11+
12+
const initialInfo = {
13+
features: {
14+
watcher: {
15+
status: LICENSE_STATUS_VALID,
16+
},
17+
},
18+
};
19+
20+
describe('ML - check license', () => {
21+
describe('xpackFeatureAvailable', () => {
22+
beforeEach(() => {
23+
xpackInfo.setAll(initialInfo);
24+
});
25+
26+
it('returns true for enabled feature', () => {
27+
const result = xpackFeatureAvailable('watcher');
28+
expect(result).to.be(true);
29+
});
30+
31+
it('returns false for disabled feature', () => {
32+
const result = xpackFeatureAvailable('noSuchFeature');
33+
expect(result).to.be(false);
34+
});
35+
});
36+
});

0 commit comments

Comments
 (0)