mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 01:13:23 -04:00
Don't register management section if capabilities are not granted (#90782)
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
4ee5f094ce
commit
9778060ae8
5 changed files with 48 additions and 30 deletions
|
@ -7,7 +7,7 @@
|
|||
|
||||
export { UNIQUENESS_ENFORCING_TYPES } from './configuration_blocks';
|
||||
export { INDEX_NAMES } from './index_names';
|
||||
export { PLUGIN } from './plugin';
|
||||
export { PLUGIN, MANAGEMENT_SECTION } from './plugin';
|
||||
export { LICENSES, REQUIRED_LICENSES, REQUIRED_ROLES } from './security';
|
||||
export { TABLE_CONFIG } from './table';
|
||||
export const BASE_PATH = '/management/ingest/beats_management';
|
||||
|
|
|
@ -9,3 +9,4 @@ export const PLUGIN = {
|
|||
ID: 'beats_management',
|
||||
};
|
||||
export const CONFIG_PREFIX = 'xpack.beats';
|
||||
export const MANAGEMENT_SECTION = 'beats_management';
|
||||
|
|
|
@ -15,11 +15,18 @@ import { CoreSetup } from '../../../../src/core/public';
|
|||
import { DataPublicPluginStart } from '../../../../src/plugins/data/public';
|
||||
import { LicensingPluginSetup } from '../../licensing/public';
|
||||
import { BeatsManagementConfigType } from '../common';
|
||||
import { MANAGEMENT_SECTION } from '../common/constants';
|
||||
|
||||
async function startApp(libs: FrontendLibs, core: CoreSetup<StartDeps>) {
|
||||
await libs.framework.waitUntilFrameworkReady();
|
||||
const [startServices] = await Promise.all([
|
||||
core.getStartServices(),
|
||||
libs.framework.waitUntilFrameworkReady(),
|
||||
]);
|
||||
|
||||
if (libs.framework.licenseIsAtLeast('standard')) {
|
||||
const capabilities = startServices[0].application.capabilities;
|
||||
const hasBeatsCapability = capabilities.management.ingest?.[MANAGEMENT_SECTION] ?? false;
|
||||
|
||||
if (libs.framework.licenseIsAtLeast('standard') && hasBeatsCapability) {
|
||||
const mount = async (params: any) => {
|
||||
const [coreStart, pluginsStart] = await core.getStartServices();
|
||||
setServices(coreStart, pluginsStart, params);
|
||||
|
|
|
@ -11,6 +11,7 @@ import { PathReporter } from 'io-ts/lib/PathReporter';
|
|||
import { isLeft } from 'fp-ts/lib/Either';
|
||||
import { first } from 'rxjs/operators';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { MANAGEMENT_SECTION } from '../../../../common/constants';
|
||||
import { SecurityPluginSetup } from '../../../../../security/public';
|
||||
import { BufferedKibanaServiceCall, KibanaAdapterServiceRefs, KibanaUIConfig } from '../../types';
|
||||
import {
|
||||
|
@ -107,7 +108,7 @@ export class KibanaFrameworkAdapter implements FrameworkAdapter {
|
|||
public registerManagementUI(mount: RegisterManagementAppArgs['mount']) {
|
||||
const section = this.management.sections.section.ingest;
|
||||
section.registerApp({
|
||||
id: 'beats_management',
|
||||
id: MANAGEMENT_SECTION,
|
||||
title: i18n.translate('xpack.beatsManagement.centralManagementLinkLabel', {
|
||||
defaultMessage: 'Beats Central Management',
|
||||
}),
|
||||
|
|
|
@ -6,11 +6,11 @@
|
|||
*/
|
||||
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { Subscription } from 'rxjs';
|
||||
import { Subscription, Subject, combineLatest } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { once } from 'lodash';
|
||||
|
||||
import { CoreSetup, CoreStart, Plugin } from 'src/core/public';
|
||||
import { Capabilities, CoreSetup, CoreStart, Plugin } from 'src/core/public';
|
||||
import {
|
||||
HomePublicPluginSetup,
|
||||
FeatureCatalogueCategory,
|
||||
|
@ -30,6 +30,7 @@ interface SetupDeps {
|
|||
|
||||
export class LogstashPlugin implements Plugin<void, void, SetupDeps> {
|
||||
private licenseSubscription?: Subscription;
|
||||
private capabilities$ = new Subject<Capabilities>();
|
||||
|
||||
public setup(core: CoreSetup, plugins: SetupDeps) {
|
||||
const logstashLicense$ = plugins.licensing.license$.pipe(
|
||||
|
@ -51,35 +52,43 @@ export class LogstashPlugin implements Plugin<void, void, SetupDeps> {
|
|||
},
|
||||
});
|
||||
|
||||
this.licenseSubscription = logstashLicense$.subscribe((license: any) => {
|
||||
if (license.enableLinks) {
|
||||
managementApp.enable();
|
||||
} else {
|
||||
managementApp.disable();
|
||||
}
|
||||
this.licenseSubscription = combineLatest([logstashLicense$, this.capabilities$]).subscribe(
|
||||
([license, capabilities]) => {
|
||||
const shouldShow = license.enableLinks && capabilities.management.ingest.pipelines === true;
|
||||
if (shouldShow) {
|
||||
managementApp.enable();
|
||||
} else {
|
||||
managementApp.disable();
|
||||
}
|
||||
|
||||
if (plugins.home && license.enableLinks) {
|
||||
// Ensure that we don't register the feature more than once
|
||||
once(() => {
|
||||
plugins.home!.featureCatalogue.register({
|
||||
id: 'management_logstash',
|
||||
title: i18n.translate('xpack.logstash.homeFeature.logstashPipelinesTitle', {
|
||||
defaultMessage: 'Logstash Pipelines',
|
||||
}),
|
||||
description: i18n.translate('xpack.logstash.homeFeature.logstashPipelinesDescription', {
|
||||
defaultMessage: 'Create, delete, update, and clone data ingestion pipelines.',
|
||||
}),
|
||||
icon: 'pipelineApp',
|
||||
path: '/app/management/ingest/pipelines',
|
||||
showOnHomePage: false,
|
||||
category: FeatureCatalogueCategory.ADMIN,
|
||||
if (plugins.home && shouldShow) {
|
||||
// Ensure that we don't register the feature more than once
|
||||
once(() => {
|
||||
plugins.home!.featureCatalogue.register({
|
||||
id: 'management_logstash',
|
||||
title: i18n.translate('xpack.logstash.homeFeature.logstashPipelinesTitle', {
|
||||
defaultMessage: 'Logstash Pipelines',
|
||||
}),
|
||||
description: i18n.translate(
|
||||
'xpack.logstash.homeFeature.logstashPipelinesDescription',
|
||||
{
|
||||
defaultMessage: 'Create, delete, update, and clone data ingestion pipelines.',
|
||||
}
|
||||
),
|
||||
icon: 'pipelineApp',
|
||||
path: '/app/management/ingest/pipelines',
|
||||
showOnHomePage: false,
|
||||
category: FeatureCatalogueCategory.ADMIN,
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
);
|
||||
}
|
||||
|
||||
public start(core: CoreStart) {}
|
||||
public start(core: CoreStart) {
|
||||
this.capabilities$.next(core.application.capabilities);
|
||||
}
|
||||
|
||||
public stop() {
|
||||
if (this.licenseSubscription) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue