Skip to content

Commit

Permalink
[Uptime] Only register route in side nav if uptime show capability is…
Browse files Browse the repository at this point in the history
… true (#101709)
  • Loading branch information
shahzad31 committed Jun 9, 2021
1 parent 75ad61a commit 96c684c
Showing 1 changed file with 36 additions and 26 deletions.
62 changes: 36 additions & 26 deletions x-pack/plugins/uptime/public/apps/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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',
Expand Down

0 comments on commit 96c684c

Please sign in to comment.