Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into np-move-file-uplo…
Browse files Browse the repository at this point in the history
…ad-to-np
  • Loading branch information
Aaron Caldwell committed Mar 3, 2020
2 parents dc68a58 + d9a05af commit 09c718d
Show file tree
Hide file tree
Showing 63 changed files with 716 additions and 536 deletions.
7 changes: 0 additions & 7 deletions x-pack/legacy/plugins/ml/common/license/index.ts

This file was deleted.

78 changes: 0 additions & 78 deletions x-pack/legacy/plugins/ml/common/license/ml_license.ts

This file was deleted.

11 changes: 2 additions & 9 deletions x-pack/legacy/plugins/ml/public/application/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,15 @@ import { AppMountParameters, CoreStart } from 'kibana/public';

import { DataPublicPluginStart } from 'src/plugins/data/public';
import { SecurityPluginSetup } from '../../../../../plugins/security/public';
import { LicensingPluginSetup } from '../../../../../plugins/licensing/public';

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

import { MlRouter } from './routing';

export interface MlDependencies extends AppMountParameters {
data: DataPublicPluginStart;
security: SecurityPluginSetup;
licensing: LicensingPluginSetup;
__LEGACY: {
XSRF: string;
};
Expand All @@ -39,26 +36,22 @@ const App: FC<AppProps> = ({ coreStart, deps }) => {
setDependencyCache({
indexPatterns: deps.data.indexPatterns,
timefilter: deps.data.query.timefilter,
fieldFormats: deps.data.fieldFormats,
autocomplete: deps.data.autocomplete,
config: coreStart.uiSettings!,
chrome: coreStart.chrome!,
docLinks: coreStart.docLinks!,
toastNotifications: coreStart.notifications.toasts,
overlays: coreStart.overlays,
recentlyAccessed: coreStart.chrome!.recentlyAccessed,
fieldFormats: deps.data.fieldFormats,
autocomplete: deps.data.autocomplete,
basePath: coreStart.http.basePath,
savedObjectsClient: coreStart.savedObjects.client,
XSRF: deps.__LEGACY.XSRF,
application: coreStart.application,
http: coreStart.http,
security: deps.security,
});

const mlLicense = setLicenseCache(deps.licensing);

deps.onAppLeave(actions => {
mlLicense.unsubscribe();
clearCache();
return actions.default();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { getColumns } from './anomalies_table_columns';
jest.mock('../../privilege/check_privilege', () => ({
checkPermission: () => false,
}));
jest.mock('../../license', () => ({
jest.mock('../../license/check_license', () => ({
hasLicenseExpired: () => false,
}));
jest.mock('../../privilege/get_privileges', () => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,13 @@ export const MainTabs: FC<Props> = ({ tabId, disableLinks }) => {
return (
<EuiTabs display="condensed">
{tabs.map((tab: Tab) => {
const { id, disabled } = tab;
const id = tab.id;
const testSubject = TAB_DATA[id].testSubject;
const defaultPathId = TAB_DATA[id].pathId || id;
// globalState (e.g. selected jobs and time range) should be retained when changing pages.
// appState will not be considered.
const fullGlobalStateString = globalState !== undefined ? `?_g=${encode(globalState)}` : '';

return disabled ? (
<EuiTab key={`${id}-key`} className={'mlNavigationMenu__mainTab'} disabled={true}>
{tab.name}
</EuiTab>
) : (
return (
<EuiLink
data-test-subj={testSubject + (id === selectedTabId ? ' selected' : '')}
href={`#/${defaultPathId}${fullGlobalStateString}`}
Expand All @@ -103,6 +98,7 @@ export const MainTabs: FC<Props> = ({ tabId, disableLinks }) => {
className={'mlNavigationMenu__mainTab'}
onClick={() => onSelectedTabChanged(id)}
isSelected={id === selectedTabId}
disabled={tab.disabled}
>
{tab.name}
</EuiTab>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import React, { Fragment, FC } from 'react';
import { EuiFlexGroup, EuiFlexItem, EuiHorizontalRule } from '@elastic/eui';

import { isFullLicense } from '../../license';
import { isFullLicense } from '../../license/check_license';

import { TopNav } from './top_nav';
import { MainTabs } from './main_tabs';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
import { i18n } from '@kbn/i18n';

import { FormattedMessage } from '@kbn/i18n/react';
import { isFullLicense } from '../license';
import { isFullLicense } from '../license/check_license';
import { useTimefilter } from '../contexts/kibana';

import { NavigationMenu } from '../components/navigation_menu';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import moment from 'moment';
import { FormattedMessage } from '@kbn/i18n/react';
import { EuiFlexGroup, EuiFlexItem, EuiCard, EuiIcon } from '@elastic/eui';
import { ml } from '../../../../services/ml_api_service';
import { isFullLicense } from '../../../../license';
import { isFullLicense } from '../../../../license/check_license';
import { checkPermission } from '../../../../privilege/check_privilege';
import { mlNodesAvailable } from '../../../../ml_nodes_check/check_ml_nodes';
import { useMlKibana } from '../../../../contexts/kibana';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import { SavedSearchSavedObject } from '../../../../common/types/kibana';
import { NavigationMenu } from '../../components/navigation_menu';
import { ML_JOB_FIELD_TYPES } from '../../../../common/constants/field_types';
import { SEARCH_QUERY_LANGUAGE } from '../../../../common/constants/search';
import { isFullLicense } from '../../license';
import { isFullLicense } from '../../license/check_license';
import { checkPermission } from '../../privilege/check_privilege';
import { mlNodesAvailable } from '../../ml_nodes_check/check_ml_nodes';
import { FullTimeRangeSelector } from '../../components/full_time_range_selector';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* 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 expect from '@kbn/expect';
import { xpackInfo } from '../../../../../xpack_main/public/services/xpack_info';
import { LICENSE_STATUS_VALID } from '../../../../../../common/constants/license_status';
import { xpackFeatureAvailable } from '../check_license';

const initialInfo = {
features: {
watcher: {
status: LICENSE_STATUS_VALID,
},
},
};

describe('ML - check license', () => {
describe('xpackFeatureAvailable', () => {
beforeEach(() => {
xpackInfo.setAll(initialInfo);
});

it('returns true for enabled feature', () => {
const result = xpackFeatureAvailable('watcher');
expect(result).to.be(true);
});

it('returns false for disabled feature', () => {
const result = xpackFeatureAvailable('noSuchFeature');
expect(result).to.be(false);
});
});
});
Loading

0 comments on commit 09c718d

Please sign in to comment.