Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.x] [Observability] landing page always being displayed (#71494) #71658

Merged
merged 1 commit into from
Jul 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion x-pack/plugins/observability/public/data_handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ export function getDataHandler<T extends ObservabilityApp>(appName: T) {
export async function fetchHasData() {
const apps: ObservabilityApp[] = ['apm', 'uptime', 'infra_logs', 'infra_metrics'];
const promises = apps.map((app) => getDataHandler(app)?.hasData());
const [apm, uptime, logs, metrics] = await Promise.all(promises);
const [apm, uptime, logs, metrics] = await Promise.allSettled(promises);
return { apm, uptime, infra_logs: logs, infra_metrics: metrics };
}
6 changes: 5 additions & 1 deletion x-pack/plugins/observability/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ import {
DEFAULT_APP_CATEGORIES,
Plugin as PluginClass,
PluginInitializerContext,
CoreStart,
} from '../../../../src/core/public';
import { registerDataHandler } from './data_handler';
import { toggleOverviewLinkInNav } from './toggle_overview_link_in_nav';

export interface ObservabilityPluginSetup {
dashboard: { register: typeof registerDataHandler };
Expand Down Expand Up @@ -43,5 +45,7 @@ export class Plugin implements PluginClass<ObservabilityPluginSetup, Observabili
dashboard: { register: registerDataHandler },
};
}
public start() {}
public start(core: CoreStart) {
toggleOverviewLinkInNav(core);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { CoreStart } from 'kibana/public';

import { toggleOverviewLinkInNav } from './toggle_overview_link_in_nav';

describe('toggleOverviewLinkInNav', () => {
const update = jest.fn();
afterEach(() => {
update.mockClear();
});
it('hides overview menu', () => {
const core = ({
application: {
capabilities: {
navLinks: {
apm: false,
logs: false,
metrics: false,
uptime: false,
},
},
},
chrome: { navLinks: { update } },
} as unknown) as CoreStart;
toggleOverviewLinkInNav(core);
expect(update).toHaveBeenCalledWith('observability-overview', { hidden: true });
});
it('shows overview menu', () => {
const core = ({
application: {
capabilities: {
navLinks: {
apm: true,
logs: false,
metrics: false,
uptime: false,
},
},
},
chrome: { navLinks: { update } },
} as unknown) as CoreStart;
toggleOverviewLinkInNav(core);
expect(update).not.toHaveBeenCalled();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { CoreStart } from 'kibana/public';

export function toggleOverviewLinkInNav(core: CoreStart) {
const { apm, logs, metrics, uptime } = core.application.capabilities.navLinks;
const someVisible = Object.values({ apm, logs, metrics, uptime }).some((visible) => visible);
if (!someVisible) {
core.chrome.navLinks.update('observability-overview', { hidden: true });
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {

it('shows management navlink', async () => {
const navLinks = (await appsMenu.readLinks()).map((link) => link.text);
expect(navLinks).to.contain('Stack Management');
expect(navLinks).to.eql(['Stack Management']);
});

it(`allows settings to be changed`, async () => {
Expand Down Expand Up @@ -125,7 +125,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {

it('shows Management navlink', async () => {
const navLinks = (await appsMenu.readLinks()).map((link) => link.text);
expect(navLinks).to.contain('Stack Management');
expect(navLinks).to.eql(['Stack Management']);
});

it(`does not allow settings to be changed`, async () => {
Expand Down Expand Up @@ -176,7 +176,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {

it('shows Management navlink', async () => {
const navLinks = (await appsMenu.readLinks()).map((link) => link.text);
expect(navLinks).to.contain('Stack Management');
expect(navLinks).to.eql(['Discover', 'Stack Management']);
});

it(`does not allow navigation to advanced settings; redirects to management home`, async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {

it('shows apm navlink', async () => {
const navLinks = await appsMenu.readLinks();
expect(navLinks.map((link) => link.text)).to.contain('APM');
expect(navLinks.map((link) => link.text)).to.eql(['Overview', 'APM', 'Stack Management']);
});

it('can navigate to APM app', async () => {
Expand Down Expand Up @@ -109,7 +109,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {

it('shows apm navlink', async () => {
const navLinks = (await appsMenu.readLinks()).map((link) => link.text);
expect(navLinks).to.contain('APM');
expect(navLinks).to.eql(['Overview', 'APM', 'Stack Management']);
});

it('can navigate to APM app', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {

it('shows canvas navlink', async () => {
const navLinks = (await appsMenu.readLinks()).map((link) => link.text);
expect(navLinks).to.contain('Canvas');
expect(navLinks).to.eql(['Canvas', 'Stack Management']);
});

it(`landing page shows "Create new workpad" button`, async () => {
Expand Down Expand Up @@ -142,7 +142,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {

it('shows canvas navlink', async () => {
const navLinks = (await appsMenu.readLinks()).map((link) => link.text);
expect(navLinks).to.contain('Canvas');
expect(navLinks).to.eql(['Canvas', 'Stack Management']);
});

it(`landing page shows disabled "Create new workpad" button`, async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {

it('shows Dev Tools navlink', async () => {
const navLinks = await appsMenu.readLinks();
expect(navLinks.map((link) => link.text)).to.contain('Dev Tools');
expect(navLinks.map((link) => link.text)).to.eql(['Dev Tools', 'Stack Management']);
});

describe('console', () => {
Expand Down Expand Up @@ -144,7 +144,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {

it(`shows 'Dev Tools' navlink`, async () => {
const navLinks = (await appsMenu.readLinks()).map((link) => link.text);
expect(navLinks).to.contain('Dev Tools');
expect(navLinks).to.eql(['Dev Tools', 'Stack Management']);
});

describe('console', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {

it('shows discover navlink', async () => {
const navLinks = await appsMenu.readLinks();
expect(navLinks.map((link) => link.text)).to.contain('Discover');
expect(navLinks.map((link) => link.text)).to.eql(['Discover', 'Stack Management']);
});

it('shows save button', async () => {
Expand Down Expand Up @@ -169,7 +169,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {

it('shows discover navlink', async () => {
const navLinks = (await appsMenu.readLinks()).map((link) => link.text);
expect(navLinks).to.contain('Discover');
expect(navLinks).to.eql(['Discover', 'Stack Management']);
});

it(`doesn't show save button`, async () => {
Expand Down Expand Up @@ -260,7 +260,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {

it('shows discover navlink', async () => {
const navLinks = (await appsMenu.readLinks()).map((link) => link.text);
expect(navLinks).to.contain('Discover');
expect(navLinks).to.eql(['Discover', 'Stack Management']);
});

it(`doesn't show save button`, async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {

it('shows graph navlink', async () => {
const navLinks = await appsMenu.readLinks();
expect(navLinks.map((link) => link.text)).to.contain('Graph');
expect(navLinks.map((link) => link.text)).to.eql(['Graph', 'Stack Management']);
});

it('landing page shows "Create new graph" button', async () => {
Expand Down Expand Up @@ -127,7 +127,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {

it('shows graph navlink', async () => {
const navLinks = (await appsMenu.readLinks()).map((link) => link.text);
expect(navLinks).to.contain('Graph');
expect(navLinks).to.eql(['Graph', 'Stack Management']);
});

it('does not show a "Create new Workspace" button', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {

it('shows management navlink', async () => {
const navLinks = (await appsMenu.readLinks()).map((link) => link.text);
expect(navLinks).to.contain('Stack Management');
expect(navLinks).to.eql(['Stack Management']);
});

it(`index pattern listing shows create button`, async () => {
Expand Down Expand Up @@ -125,7 +125,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {

it('shows management navlink', async () => {
const navLinks = (await appsMenu.readLinks()).map((link) => link.text);
expect(navLinks).to.contain('Stack Management');
expect(navLinks).to.eql(['Stack Management']);
});

it(`index pattern listing doesn't show create button`, async () => {
Expand Down Expand Up @@ -177,7 +177,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {

it('shows Management navlink', async () => {
const navLinks = (await appsMenu.readLinks()).map((link) => link.text);
expect(navLinks).to.contain('Stack Management');
expect(navLinks).to.eql(['Discover', 'Stack Management']);
});

it(`doesn't show Index Patterns in management side-nav`, async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {

it('shows metrics navlink', async () => {
const navLinks = (await appsMenu.readLinks()).map((link) => link.text);
expect(navLinks).to.contain('Metrics');
expect(navLinks).to.eql(['Overview', 'Metrics', 'Stack Management']);
});

describe('infrastructure landing page without data', () => {
Expand Down Expand Up @@ -177,7 +177,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {

it('shows metrics navlink', async () => {
const navLinks = (await appsMenu.readLinks()).map((link) => link.text);
expect(navLinks).to.contain('Metrics');
expect(navLinks).to.eql(['Overview', 'Metrics', 'Stack Management']);
});

describe('infrastructure landing page without data', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {

it('shows logs navlink', async () => {
const navLinks = (await appsMenu.readLinks()).map((link) => link.text);
expect(navLinks).to.contain('Logs');
expect(navLinks).to.eql(['Overview', 'Logs', 'Stack Management']);
});

describe('logs landing page without data', () => {
Expand Down Expand Up @@ -121,7 +121,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {

it('shows logs navlink', async () => {
const navLinks = (await appsMenu.readLinks()).map((link) => link.text);
expect(navLinks).to.contain('Logs');
expect(navLinks).to.eql(['Overview', 'Logs', 'Stack Management']);
});

describe('logs landing page without data', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {

it('shows maps navlink', async () => {
const navLinks = (await appsMenu.readLinks()).map((link) => link.text);
expect(navLinks).to.contain('Maps');
expect(navLinks).to.eql(['Maps', 'Stack Management']);
});

it(`allows a map to be created`, async () => {
Expand Down Expand Up @@ -153,7 +153,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {

it('shows Maps navlink', async () => {
const navLinks = (await appsMenu.readLinks()).map((link) => link.text);
expect(navLinks).to.contain('Maps');
expect(navLinks).to.eql(['Maps', 'Stack Management']);
});

it(`does not show create new button`, async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {

it('shows timelion navlink', async () => {
const navLinks = (await appsMenu.readLinks()).map((link) => link.text);
expect(navLinks).to.contain('Timelion');
expect(navLinks).to.eql(['Timelion', 'Stack Management']);
});

it(`allows a timelion sheet to be created`, async () => {
Expand Down Expand Up @@ -112,7 +112,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {

it('shows timelion navlink', async () => {
const navLinks = (await appsMenu.readLinks()).map((link) => link.text);
expect(navLinks).to.contain('Timelion');
expect(navLinks).to.eql(['Timelion', 'Stack Management']);
});

it(`does not allow a timelion sheet to be created`, async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {

it('shows uptime navlink', async () => {
const navLinks = await appsMenu.readLinks();
expect(navLinks.map((link) => link.text)).to.contain('Uptime');
expect(navLinks.map((link) => link.text)).to.eql([
'Overview',
'Uptime',
'Stack Management',
]);
});

it('can navigate to Uptime app', async () => {
Expand Down Expand Up @@ -115,7 +119,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {

it('shows uptime navlink', async () => {
const navLinks = (await appsMenu.readLinks()).map((link) => link.text);
expect(navLinks).to.contain('Uptime');
expect(navLinks).to.eql(['Overview', 'Uptime', 'Stack Management']);
});

it('can navigate to Uptime app', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {

it('shows visualize navlink', async () => {
const navLinks = (await appsMenu.readLinks()).map((link) => link.text);
expect(navLinks).to.contain('Visualize');
expect(navLinks).to.eql(['Visualize', 'Stack Management']);
});

it(`landing page shows "Create new Visualization" button`, async () => {
Expand Down Expand Up @@ -201,7 +201,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {

it('shows visualize navlink', async () => {
const navLinks = (await appsMenu.readLinks()).map((link) => link.text);
expect(navLinks).to.contain('Visualize');
expect(navLinks).to.eql(['Visualize', 'Stack Management']);
});

it(`landing page shows "Create new Visualization" button`, async () => {
Expand Down Expand Up @@ -316,7 +316,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {

it('shows visualize navlink', async () => {
const navLinks = (await appsMenu.readLinks()).map((link) => link.text);
expect(navLinks).to.contain('Visualize');
expect(navLinks).to.eql(['Visualize', 'Stack Management']);
});

it(`landing page shows "Create new Visualization" button`, async () => {
Expand Down