[Lens] Displays the Explore field in Discover button if the capabilities are correct (#142332)

This commit is contained in:
Stratoula Kalafateli 2022-09-30 20:35:58 +03:00 committed by GitHub
parent 764fe0ae43
commit ab90104024
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 3 deletions

View file

@ -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);
});
});

View file

@ -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({

View file

@ -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[];