[Uptime] Only register route in side nav if uptime show capability is true (#101709)

This commit is contained in:
Shahzad 2021-06-09 17:37:26 +02:00 committed by GitHub
parent 75ad61ae0f
commit 96c684c4ec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -12,7 +12,8 @@ import {
PluginInitializerContext,
AppMountParameters,
} from 'kibana/public';
import { of } from 'rxjs';
import { from } from 'rxjs';
import { map } from 'rxjs/operators';
import { i18n } from '@kbn/i18n';
import { DEFAULT_APP_CATEGORIES } from '../../../../../src/core/public';
import {
@ -104,32 +105,41 @@ export class UptimePlugin
});
plugins.observability.navigation.registerSections(
of([
{
label: 'Uptime',
sortKey: 200,
entries: [
{
label: i18n.translate('xpack.uptime.overview.heading', {
defaultMessage: 'Monitoring overview',
}),
app: 'uptime',
path: '/',
matchFullPath: true,
ignoreTrailingSlash: true,
},
{
label: i18n.translate('xpack.uptime.certificatesPage.heading', {
defaultMessage: 'TLS Certificates',
}),
app: 'uptime',
path: '/certificates',
matchFullPath: true,
},
],
},
])
from(core.getStartServices()).pipe(
map(([coreStart]) => {
if (coreStart.application.capabilities.uptime.show) {
return [
{
label: 'Uptime',
sortKey: 200,
entries: [
{
label: i18n.translate('xpack.uptime.overview.heading', {
defaultMessage: 'Monitoring overview',
}),
app: 'uptime',
path: '/',
matchFullPath: true,
ignoreTrailingSlash: true,
},
{
label: i18n.translate('xpack.uptime.certificatesPage.heading', {
defaultMessage: 'TLS Certificates',
}),
app: 'uptime',
path: '/certificates',
matchFullPath: true,
},
],
},
];
}
return [];
})
)
);
core.application.register({
id: PLUGIN.ID,
euiIconType: 'logoObservability',