mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[Lens] Displays the Explore field in Discover button if the capabilities are correct (#142332)
This commit is contained in:
parent
764fe0ae43
commit
ab90104024
3 changed files with 36 additions and 3 deletions
|
@ -54,6 +54,11 @@ const mockedServices = {
|
|||
getRedirectUrl: jest.fn(() => 'discover_url'),
|
||||
},
|
||||
} as unknown as DiscoverStart,
|
||||
application: {
|
||||
capabilities: {
|
||||
discover: { save: true, saveQuery: true, show: true },
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const InnerFieldItemWrapper: React.FC<FieldItemProps> = (props) => {
|
||||
|
@ -460,4 +465,30 @@ describe('IndexPattern Field Item', () => {
|
|||
);
|
||||
expect(exploreInDiscoverBtn.length).toBe(0);
|
||||
});
|
||||
|
||||
it('should not display Explore in discover button if discover capabilities show is false', async () => {
|
||||
const services = {
|
||||
...mockedServices,
|
||||
application: {
|
||||
capabilities: {
|
||||
discover: { save: false, saveQuery: false, show: false },
|
||||
},
|
||||
},
|
||||
};
|
||||
const wrapper = await mountWithIntl(
|
||||
<KibanaContextProvider services={services}>
|
||||
<InnerFieldItem {...defaultProps} />
|
||||
</KibanaContextProvider>
|
||||
);
|
||||
|
||||
await clickField(wrapper, 'bytes');
|
||||
|
||||
await wrapper.update();
|
||||
|
||||
const exploreInDiscoverBtn = findTestSubject(
|
||||
wrapper,
|
||||
'lnsFieldListPanel-exploreInDiscover-bytes'
|
||||
);
|
||||
expect(exploreInDiscoverBtn.length).toBe(0);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -370,8 +370,7 @@ function FieldItemPopoverContents(props: FieldItemProps) {
|
|||
[indexPattern],
|
||||
getEsQueryConfig(services.uiSettings)
|
||||
);
|
||||
|
||||
if (!services.discover) {
|
||||
if (!services.discover || !services.application.capabilities.discover.show) {
|
||||
return;
|
||||
}
|
||||
return services.discover.locator!.getRedirectUrl({
|
||||
|
|
|
@ -494,7 +494,10 @@ export interface DatasourceDataPanelProps<T = unknown> {
|
|||
dragDropContext: DragContextState;
|
||||
setState: StateSetter<T, { applyImmediately?: boolean }>;
|
||||
showNoDataPopover: () => void;
|
||||
core: Pick<CoreStart, 'http' | 'notifications' | 'uiSettings' | 'overlays' | 'theme'>;
|
||||
core: Pick<
|
||||
CoreStart,
|
||||
'http' | 'notifications' | 'uiSettings' | 'overlays' | 'theme' | 'application'
|
||||
>;
|
||||
query: Query;
|
||||
dateRange: DateRange;
|
||||
filters: Filter[];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue