Skip to content

Commit

Permalink
[7.7] Hide APM alerting menu if alerting plugin is disabled (#61907) (#…
Browse files Browse the repository at this point in the history
…62374)

* Hide APM alerting menu if alerting plugin is disabled (#61907)

* Hide APM alerting menu if alerting plugin is disabled

Checks for presence of plugin and does not display the link if the plugin is disabled.

Use `xpack.alerting.enabled: false` in config/kibana.dev.yml to try it.

Fixes #61048.

* Remove duplicate import

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
  • Loading branch information
smith and elasticmachine authored Apr 6, 2020
1 parent b9c999a commit eaeac31
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ export function ServiceDetails({ tab }: Props) {
const canSaveAlerts = !!plugin.core.application.capabilities.apm[
'alerting:save'
];
const isAlertingPluginEnabled = 'alerting' in plugin.plugins;

const isAlertingAvailable = canReadAlerts || canSaveAlerts;
const isAlertingAvailable =
isAlertingPluginEnabled && (canReadAlerts || canSaveAlerts);

return (
<div>
Expand Down
28 changes: 15 additions & 13 deletions x-pack/legacy/plugins/apm/public/new-platform/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,49 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { ApmRoute } from '@elastic/apm-rum-react';
import { i18n } from '@kbn/i18n';
import React from 'react';
import ReactDOM from 'react-dom';
import { Route, Router, Switch } from 'react-router-dom';
import { ApmRoute } from '@elastic/apm-rum-react';
import styled from 'styled-components';
import { i18n } from '@kbn/i18n';
import { AlertType } from '../../../../../plugins/apm/common/alert_types';
import {
CoreSetup,
CoreStart,
Plugin,
PluginInitializerContext
} from '../../../../../../src/core/public';
import { featureCatalogueEntry } from './featureCatalogueEntry';
import { DataPublicPluginSetup } from '../../../../../../src/plugins/data/public';
import { HomePublicPluginSetup } from '../../../../../../src/plugins/home/public';
import { KibanaContextProvider } from '../../../../../../src/plugins/kibana_react/public';
import { PluginSetupContract as AlertingPluginPublicSetup } from '../../../../../plugins/alerting/public';
import { AlertType } from '../../../../../plugins/apm/common/alert_types';
import { LicensingPluginSetup } from '../../../../../plugins/licensing/public';
import {
AlertsContextProvider,
TriggersAndActionsUIPublicPluginSetup
} from '../../../../../plugins/triggers_actions_ui/public';
import { APMIndicesPermission } from '../components/app/APMIndicesPermission';
import { routes } from '../components/app/Main/route_config';
import { ScrollToTopOnPathChange } from '../components/app/Main/ScrollToTopOnPathChange';
import { UpdateBreadcrumbs } from '../components/app/Main/UpdateBreadcrumbs';
import { ErrorRateAlertTrigger } from '../components/shared/ErrorRateAlertTrigger';
import { TransactionDurationAlertTrigger } from '../components/shared/TransactionDurationAlertTrigger';
import { ApmPluginContext } from '../context/ApmPluginContext';
import { LicenseProvider } from '../context/LicenseContext';
import { LoadingIndicatorProvider } from '../context/LoadingIndicatorContext';
import { LocationProvider } from '../context/LocationContext';
import { MatchedRouteProvider } from '../context/MatchedRouteContext';
import { UrlParamsProvider } from '../context/UrlParamsContext';
import { createCallApmApi } from '../services/rest/createCallApmApi';
import { createStaticIndexPattern } from '../services/rest/index_pattern';
import { px, unit, units } from '../style/variables';
import { history } from '../utils/history';
import { featureCatalogueEntry } from './featureCatalogueEntry';
import { getConfigFromInjectedMetadata } from './getConfigFromInjectedMetadata';
import { setHelpExtension } from './setHelpExtension';
import { toggleAppLinkInNav } from './toggleAppLinkInNav';
import { setReadonlyBadge } from './updateBadge';
import { KibanaContextProvider } from '../../../../../../src/plugins/kibana_react/public';
import { APMIndicesPermission } from '../components/app/APMIndicesPermission';
import {
TriggersAndActionsUIPublicPluginSetup,
AlertsContextProvider
} from '../../../../../plugins/triggers_actions_ui/public';
import { ErrorRateAlertTrigger } from '../components/shared/ErrorRateAlertTrigger';
import { TransactionDurationAlertTrigger } from '../components/shared/TransactionDurationAlertTrigger';
import { createCallApmApi } from '../services/rest/createCallApmApi';

export const REACT_APP_ROOT_ID = 'react-apm-root';

Expand Down Expand Up @@ -75,6 +76,7 @@ export type ApmPluginSetup = void;
export type ApmPluginStart = void;

export interface ApmPluginSetupDeps {
alerting?: AlertingPluginPublicSetup;
data: DataPublicPluginSetup;
home: HomePublicPluginSetup;
licensing: LicensingPluginSetup;
Expand Down

0 comments on commit eaeac31

Please sign in to comment.