Skip to content

Commit dcdec80

Browse files
author
Stacey Gammon
committed
Merge branch 'master' of github.com:elastic/kibana into 2020-02-26-action-types-2
2 parents 689dbc5 + ea43dce commit dcdec80

File tree

76 files changed

+730
-752
lines changed

Some content is hidden

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

76 files changed

+730
-752
lines changed

src/plugins/es_ui_shared/public/request/request.test.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
import sinon from 'sinon';
21-
import { sendRequest as sendRequestUnbound, useRequest as useRequestUnbound } from './request';
21+
// import { sendRequest as sendRequestUnbound, useRequest as useRequestUnbound } from './request';
2222

2323
import React from 'react';
2424
import { act } from 'react-dom/test-utils';
@@ -52,6 +52,11 @@ describe.skip('request lib', () => {
5252
let sendRequest;
5353
let useRequest;
5454

55+
/**
56+
*
57+
* commented out due to hooks being called regardless of skip
58+
* https://github.com/facebook/jest/issues/8379
59+
5560
beforeEach(() => {
5661
sendPost = sinon.stub();
5762
sendPost.withArgs(successRequest.path, successRequest.body).returns(successResponse);
@@ -67,6 +72,8 @@ describe.skip('request lib', () => {
6772
useRequest = useRequestUnbound.bind(null, httpClient);
6873
});
6974
75+
*/
76+
7077
describe('sendRequest function', () => {
7178
it('uses the provided path, method, and body to send the request', async () => {
7279
const response = await sendRequest({ ...successRequest });

test/functional/page_objects/visualize_page.ts

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ export function VisualizePageProvider({ getService, getPageObjects }: FtrProvide
7979
await this.waitForVisualizationSelectPage();
8080
}
8181

82+
public async hasVisType(type: string) {
83+
return await testSubjects.exists(`visType-${type}`);
84+
}
85+
8286
public async clickVisType(type: string) {
8387
await testSubjects.click(`visType-${type}`);
8488
await header.waitUntilLoadingHasFinished();
@@ -100,6 +104,10 @@ export function VisualizePageProvider({ getService, getPageObjects }: FtrProvide
100104
await this.clickVisType('region_map');
101105
}
102106

107+
public async hasRegionMap() {
108+
return await this.hasVisType('region_map');
109+
}
110+
103111
public async clickMarkdownWidget() {
104112
await this.clickVisType('markdown');
105113
}
@@ -120,6 +128,10 @@ export function VisualizePageProvider({ getService, getPageObjects }: FtrProvide
120128
await this.clickVisType('tile_map');
121129
}
122130

131+
public async hasTileMap() {
132+
return await this.hasVisType('tile_map');
133+
}
134+
123135
public async clickTagCloud() {
124136
await this.clickVisType('tagcloud');
125137
}
@@ -144,6 +156,18 @@ export function VisualizePageProvider({ getService, getPageObjects }: FtrProvide
144156
await this.clickVisType('input_control_vis');
145157
}
146158

159+
public async clickLensWidget() {
160+
await this.clickVisType('lens');
161+
}
162+
163+
public async clickMapsApp() {
164+
await this.clickVisType('maps');
165+
}
166+
167+
public async hasMapsApp() {
168+
return await this.hasVisType('maps');
169+
}
170+
147171
public async createSimpleMarkdownViz(vizName: string) {
148172
await this.gotoVisualizationLandingPage();
149173
await this.navigateToNewVisualization();
@@ -315,10 +339,6 @@ export function VisualizePageProvider({ getService, getPageObjects }: FtrProvide
315339
async () => (await globalNav.getLastBreadcrumb()) === vizName
316340
);
317341
}
318-
319-
public async clickLensWidget() {
320-
await this.clickVisType('lens');
321-
}
322342
}
323343

324344
return new VisualizePage();
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
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+
export { MlLicense, LicenseStatus, MINIMUM_FULL_LICENSE, MINIMUM_LICENSE } from './ml_license';
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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 { Observable, Subscription } from 'rxjs';
8+
import { ILicense, LICENSE_CHECK_STATE } from '../../../../../plugins/licensing/common/types';
9+
import { PLUGIN_ID } from '../constants/app';
10+
11+
export const MINIMUM_LICENSE = 'basic';
12+
export const MINIMUM_FULL_LICENSE = 'platinum';
13+
14+
export interface LicenseStatus {
15+
isValid: boolean;
16+
isSecurityEnabled: boolean;
17+
message?: string;
18+
}
19+
20+
export class MlLicense {
21+
private _licenseSubscription: Subscription | null = null;
22+
private _license: ILicense | null = null;
23+
private _isSecurityEnabled: boolean = false;
24+
private _hasLicenseExpired: boolean = false;
25+
private _isMlEnabled: boolean = false;
26+
private _isMinimumLicense: boolean = false;
27+
private _isFullLicense: boolean = false;
28+
private _initialized: boolean = false;
29+
30+
public setup(
31+
license$: Observable<ILicense>,
32+
postInitFunctions?: Array<(lic: MlLicense) => void>
33+
) {
34+
this._licenseSubscription = license$.subscribe(async license => {
35+
const { isEnabled: securityIsEnabled } = license.getFeature('security');
36+
37+
this._license = license;
38+
this._isSecurityEnabled = securityIsEnabled;
39+
this._hasLicenseExpired = this._license.status === 'expired';
40+
this._isMlEnabled = this._license.getFeature(PLUGIN_ID).isEnabled;
41+
this._isMinimumLicense =
42+
this._license.check(PLUGIN_ID, MINIMUM_LICENSE).state === LICENSE_CHECK_STATE.Valid;
43+
this._isFullLicense =
44+
this._license.check(PLUGIN_ID, MINIMUM_FULL_LICENSE).state === LICENSE_CHECK_STATE.Valid;
45+
46+
if (this._initialized === false && postInitFunctions !== undefined) {
47+
postInitFunctions.forEach(f => f(this));
48+
}
49+
this._initialized = true;
50+
});
51+
}
52+
53+
public unsubscribe() {
54+
if (this._licenseSubscription !== null) {
55+
this._licenseSubscription.unsubscribe();
56+
}
57+
}
58+
59+
public isSecurityEnabled() {
60+
return this._isSecurityEnabled;
61+
}
62+
63+
public hasLicenseExpired() {
64+
return this._hasLicenseExpired;
65+
}
66+
67+
public isMlEnabled() {
68+
return this._isMlEnabled;
69+
}
70+
71+
public isMinimumLicense() {
72+
return this._isMinimumLicense;
73+
}
74+
75+
public isFullLicense() {
76+
return this._isFullLicense;
77+
}
78+
}

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,18 @@ 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';
1617

1718
import { KibanaContextProvider } from '../../../../../../src/plugins/kibana_react/public';
1819
import { setDependencyCache, clearCache } from './util/dependency_cache';
20+
import { setLicenseCache } from './license';
1921

2022
import { MlRouter } from './routing';
2123

2224
export interface MlDependencies extends AppMountParameters {
2325
data: DataPublicPluginStart;
2426
security: SecurityPluginSetup;
27+
licensing: LicensingPluginSetup;
2528
__LEGACY: {
2629
XSRF: string;
2730
};
@@ -36,22 +39,26 @@ const App: FC<AppProps> = ({ coreStart, deps }) => {
3639
setDependencyCache({
3740
indexPatterns: deps.data.indexPatterns,
3841
timefilter: deps.data.query.timefilter,
42+
fieldFormats: deps.data.fieldFormats,
43+
autocomplete: deps.data.autocomplete,
3944
config: coreStart.uiSettings!,
4045
chrome: coreStart.chrome!,
4146
docLinks: coreStart.docLinks!,
4247
toastNotifications: coreStart.notifications.toasts,
4348
overlays: coreStart.overlays,
4449
recentlyAccessed: coreStart.chrome!.recentlyAccessed,
45-
fieldFormats: deps.data.fieldFormats,
46-
autocomplete: deps.data.autocomplete,
4750
basePath: coreStart.http.basePath,
4851
savedObjectsClient: coreStart.savedObjects.client,
4952
XSRF: deps.__LEGACY.XSRF,
5053
application: coreStart.application,
5154
http: coreStart.http,
5255
security: deps.security,
5356
});
57+
58+
const mlLicense = setLicenseCache(deps.licensing);
59+
5460
deps.onAppLeave(actions => {
61+
mlLicense.unsubscribe();
5562
clearCache();
5663
return actions.default();
5764
});

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/check_license', () => ({
14+
jest.mock('../../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: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,18 @@ export const MainTabs: FC<Props> = ({ tabId, disableLinks }) => {
8181
return (
8282
<EuiTabs display="condensed">
8383
{tabs.map((tab: Tab) => {
84-
const id = tab.id;
84+
const { id, disabled } = tab;
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-
return (
90+
91+
return disabled ? (
92+
<EuiTab key={`${id}-key`} className={'mlNavigationMenu__mainTab'} disabled={true}>
93+
{tab.name}
94+
</EuiTab>
95+
) : (
9196
<EuiLink
9297
data-test-subj={testSubject + (id === selectedTabId ? ' selected' : '')}
9398
href={`#/${defaultPathId}${fullGlobalStateString}`}
@@ -98,7 +103,6 @@ export const MainTabs: FC<Props> = ({ tabId, disableLinks }) => {
98103
className={'mlNavigationMenu__mainTab'}
99104
onClick={() => onSelectedTabChanged(id)}
100105
isSelected={id === selectedTabId}
101-
disabled={tab.disabled}
102106
>
103107
{tab.name}
104108
</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/check_license';
10+
import { isFullLicense } from '../../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/check_license';
25+
import { isFullLicense } from '../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/check_license';
12+
import { isFullLicense } from '../../../../license';
1313
import { checkPermission } from '../../../../privilege/check_privilege';
1414
import { mlNodesAvailable } from '../../../../ml_nodes_check/check_ml_nodes';
1515
import { useMlKibana } from '../../../../contexts/kibana';

0 commit comments

Comments
 (0)