mirror of
https://github.com/elastic/kibana.git
synced 2025-04-25 02:09:32 -04:00
fix: 🐛 don't show actions if Discover app is disabled (#73017)
* fix: 🐛 don't show actions if Discover app is disabled
* style: collapse ifs
This commit is contained in:
parent
49782f9348
commit
304445f007
3 changed files with 31 additions and 1 deletions
|
@ -49,12 +49,16 @@ export abstract class AbstractExploreDataAction<Context extends { embeddable?: I
|
||||||
public async isCompatible({ embeddable }: Context): Promise<boolean> {
|
public async isCompatible({ embeddable }: Context): Promise<boolean> {
|
||||||
if (!embeddable) return false;
|
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
|
const isDashboardOnlyMode = !!this.params
|
||||||
.start()
|
.start()
|
||||||
.plugins.kibanaLegacy?.dashboardConfig.getHideWriteControls();
|
.plugins.kibanaLegacy?.dashboardConfig.getHideWriteControls();
|
||||||
if (isDashboardOnlyMode) return false;
|
if (isDashboardOnlyMode) return false;
|
||||||
|
|
||||||
if (!this.params.start().plugins.discover.urlGenerator) return false;
|
|
||||||
if (!shared.hasExactlyOneIndexPattern(embeddable)) return false;
|
if (!shared.hasExactlyOneIndexPattern(embeddable)) return false;
|
||||||
if (embeddable.getInput().viewMode !== ViewMode.VIEW) return false;
|
if (embeddable.getInput().viewMode !== ViewMode.VIEW) return false;
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -196,6 +196,19 @@ describe('"Explore underlying data" panel action', () => {
|
||||||
|
|
||||||
expect(isCompatible).toBe(false);
|
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()', () => {
|
describe('getHref()', () => {
|
||||||
|
|
|
@ -179,6 +179,19 @@ describe('"Explore underlying data" panel action', () => {
|
||||||
|
|
||||||
expect(isCompatible).toBe(false);
|
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()', () => {
|
describe('getHref()', () => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue