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

fix: 🐛 don't show actions if Discover app is disabled #73017

Merged
merged 3 commits into from
Jul 23, 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
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,16 @@ export abstract class AbstractExploreDataAction<Context extends { embeddable?: I
public async isCompatible({ embeddable }: Context): Promise<boolean> {
if (!embeddable) return false;

const { core, plugins } = this.params.start();
const { capabilities } = core.application;

if (capabilities.discover && !capabilities.discover.show) return false;
if (!plugins.discover.urlGenerator) return false;
const isDashboardOnlyMode = !!this.params
.start()
.plugins.kibanaLegacy?.dashboardConfig.getHideWriteControls();
if (isDashboardOnlyMode) return false;

if (!this.params.start().plugins.discover.urlGenerator) return false;
if (!shared.hasExactlyOneIndexPattern(embeddable)) return false;
if (embeddable.getInput().viewMode !== ViewMode.VIEW) return false;
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,19 @@ describe('"Explore underlying data" panel action', () => {

expect(isCompatible).toBe(false);
});

test('returns false if Discover app is disabled', async () => {
const { action, context, core } = setup();

core.application.capabilities = { ...core.application.capabilities };
(core.application.capabilities as any).discover = {
show: false,
};

const isCompatible = await action.isCompatible(context);

expect(isCompatible).toBe(false);
});
});

describe('getHref()', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,19 @@ describe('"Explore underlying data" panel action', () => {

expect(isCompatible).toBe(false);
});

test('returns false if Discover app is disabled', async () => {
const { action, context, core } = setup();

core.application.capabilities = { ...core.application.capabilities };
(core.application.capabilities as any).discover = {
show: false,
};

const isCompatible = await action.isCompatible(context);

expect(isCompatible).toBe(false);
});
});

describe('getHref()', () => {
Expand Down