mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
* [APM] Fix crash when ml is disabled * Remove unused props from interface
This commit is contained in:
parent
41ae42adb0
commit
d6b89fe76f
6 changed files with 31 additions and 28 deletions
|
@ -14,6 +14,7 @@ import { i18n } from '@kbn/i18n';
|
|||
import { memoize } from 'lodash';
|
||||
import React, { Fragment } from 'react';
|
||||
import { InternalCoreStart } from 'src/core/public';
|
||||
import { idx } from '@kbn/elastic-idx';
|
||||
import { IUrlParams } from '../../../../context/UrlParamsContext/types';
|
||||
import { LicenseContext } from '../../../../context/LicenseContext';
|
||||
import { MachineLearningFlyout } from './MachineLearningFlyout';
|
||||
|
@ -33,7 +34,7 @@ export class ServiceIntegrations extends React.Component<Props, State> {
|
|||
static contextType = CoreContext;
|
||||
public state: State = { isPopoverOpen: false, activeFlyout: null };
|
||||
|
||||
public getPanelItems = memoize((mlAvailable: boolean) => {
|
||||
public getPanelItems = memoize((mlAvailable: boolean | undefined) => {
|
||||
let panelItems: EuiContextMenuPanelItemDescriptor[] = [];
|
||||
if (mlAvailable) {
|
||||
panelItems = panelItems.concat(this.getMLPanelItems());
|
||||
|
@ -147,7 +148,9 @@ export class ServiceIntegrations extends React.Component<Props, State> {
|
|||
panels={[
|
||||
{
|
||||
id: 0,
|
||||
items: this.getPanelItems(license.features.ml.is_available)
|
||||
items: this.getPanelItems(
|
||||
idx(license, _ => _.features.ml.is_available)
|
||||
)
|
||||
}
|
||||
]}
|
||||
/>
|
||||
|
|
|
@ -18,6 +18,7 @@ import { Location } from 'history';
|
|||
import React, { Component } from 'react';
|
||||
import { isEmpty, flatten } from 'lodash';
|
||||
import styled from 'styled-components';
|
||||
import { idx } from '@kbn/elastic-idx';
|
||||
import { NOT_AVAILABLE_LABEL } from '../../../../../common/i18n';
|
||||
import { Coordinate, TimeSeries } from '../../../../../typings/timeseries';
|
||||
import { ITransactionChartData } from '../../../../selectors/chartSelectors';
|
||||
|
@ -87,7 +88,7 @@ export class TransactionCharts extends Component<TransactionChartProps> {
|
|||
: NOT_AVAILABLE_LABEL;
|
||||
};
|
||||
|
||||
public renderMLHeader(hasValidMlLicense: boolean) {
|
||||
public renderMLHeader(hasValidMlLicense: boolean | undefined) {
|
||||
const { hasMLJob } = this.props;
|
||||
if (!hasValidMlLicense || !hasMLJob) {
|
||||
return null;
|
||||
|
@ -161,7 +162,9 @@ export class TransactionCharts extends Component<TransactionChartProps> {
|
|||
</EuiFlexItem>
|
||||
<LicenseContext.Consumer>
|
||||
{license =>
|
||||
this.renderMLHeader(license.features.ml.is_available)
|
||||
this.renderMLHeader(
|
||||
idx(license, _ => _.features.ml.is_available)
|
||||
)
|
||||
}
|
||||
</LicenseContext.Consumer>
|
||||
</EuiFlexGroup>
|
||||
|
|
|
@ -5,15 +5,14 @@
|
|||
*/
|
||||
import React from 'react';
|
||||
import { FETCH_STATUS, useFetcher } from '../../hooks/useFetcher';
|
||||
import { loadLicense } from '../../services/rest/xpack';
|
||||
import { loadLicense, LicenseApiResponse } from '../../services/rest/xpack';
|
||||
import { InvalidLicenseNotification } from './InvalidLicenseNotification';
|
||||
|
||||
const initialLicense = {
|
||||
features: {
|
||||
watcher: { is_available: false },
|
||||
ml: { is_available: false }
|
||||
},
|
||||
license: { is_active: false }
|
||||
const initialLicense: LicenseApiResponse = {
|
||||
features: {},
|
||||
license: {
|
||||
is_active: false
|
||||
}
|
||||
};
|
||||
export const LicenseContext = React.createContext(initialLicense);
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
import React, { useContext, useEffect, useState, useMemo } from 'react';
|
||||
import { toastNotifications } from 'ui/notify';
|
||||
import { idx } from '@kbn/elastic-idx/target';
|
||||
import { idx } from '@kbn/elastic-idx';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { LoadingIndicatorContext } from '../context/LoadingIndicatorContext';
|
||||
import { useComponentId } from './useComponentId';
|
||||
|
|
|
@ -9,30 +9,28 @@ import { callApi } from './callApi';
|
|||
|
||||
export interface LicenseApiResponse {
|
||||
license: {
|
||||
expiry_date_in_millis: number;
|
||||
is_active: boolean;
|
||||
type: string;
|
||||
};
|
||||
features: {
|
||||
beats_management: StringMap;
|
||||
graph: StringMap;
|
||||
grokdebugger: StringMap;
|
||||
index_management: StringMap;
|
||||
logstash: StringMap;
|
||||
ml: {
|
||||
beats_management?: StringMap;
|
||||
graph?: StringMap;
|
||||
grokdebugger?: StringMap;
|
||||
index_management?: StringMap;
|
||||
logstash?: StringMap;
|
||||
ml?: {
|
||||
is_available: boolean;
|
||||
license_type: number;
|
||||
has_expired: boolean;
|
||||
enable_links: boolean;
|
||||
show_links: boolean;
|
||||
};
|
||||
reporting: StringMap;
|
||||
rollup: StringMap;
|
||||
searchprofiler: StringMap;
|
||||
security: StringMap;
|
||||
spaces: StringMap;
|
||||
tilemap: StringMap;
|
||||
watcher: {
|
||||
reporting?: StringMap;
|
||||
rollup?: StringMap;
|
||||
searchprofiler?: StringMap;
|
||||
security?: StringMap;
|
||||
spaces?: StringMap;
|
||||
tilemap?: StringMap;
|
||||
watcher?: {
|
||||
is_available: boolean;
|
||||
enable_links: boolean;
|
||||
show_links: boolean;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
import { ESFilter } from 'elasticsearch';
|
||||
import { Server } from 'hapi';
|
||||
import { idx } from '@kbn/elastic-idx/target';
|
||||
import { idx } from '@kbn/elastic-idx';
|
||||
import { toElasticsearchQuery, fromKueryExpression } from '@kbn/es-query';
|
||||
import { ISavedObject } from '../../../../public/services/rest/savedObjects';
|
||||
import { StaticIndexPattern } from '../../../../../../../../src/legacy/core_plugins/data/public';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue