mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
[Discover] Enable sharing for text based languages (#156652)
## Summary Part of https://github.com/elastic/kibana/issues/154331 Enables the sharing menu for text based languages <img width="2497" alt="image" src="https://user-images.githubusercontent.com/17003240/236152022-62aebfd0-3863-4ba9-8d2b-f6a6fc6a0bf6.png"> There are 2 significant changes from the dataview mode 1. The timefield is not populated on the csv report 2. We dont check if there is a persisted dataview. We don't want this for text based languages mode as this mode won't work with dataviews. ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
This commit is contained in:
parent
5bb8a20143
commit
501bfcdccb
5 changed files with 62 additions and 7 deletions
|
@ -131,6 +131,13 @@ test('getTopNavLinks result for sql mode', () => {
|
|||
"run": [Function],
|
||||
"testId": "discoverOpenButton",
|
||||
},
|
||||
Object {
|
||||
"description": "Share Search",
|
||||
"id": "share",
|
||||
"label": "Share",
|
||||
"run": [Function],
|
||||
"testId": "shareTopNavButton",
|
||||
},
|
||||
Object {
|
||||
"description": "Open Inspector for search",
|
||||
"id": "inspect",
|
||||
|
|
|
@ -159,11 +159,23 @@ export const getTopNavLinks = ({
|
|||
}),
|
||||
testId: 'shareTopNavButton',
|
||||
run: async (anchorElement: HTMLElement) => {
|
||||
const updatedDataView = await persistDataView(dataView);
|
||||
if (!services.share || !updatedDataView) {
|
||||
if (!services.share) {
|
||||
return;
|
||||
}
|
||||
const sharingData = await getSharingData(searchSource, state.appState.getState(), services);
|
||||
// this prompts the user to save the dataview if adhoc dataview is detected
|
||||
// for text based languages we don't want this check
|
||||
if (!isPlainRecord) {
|
||||
const updatedDataView = await persistDataView(dataView);
|
||||
if (!updatedDataView) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
const sharingData = await getSharingData(
|
||||
searchSource,
|
||||
state.appState.getState(),
|
||||
services,
|
||||
isPlainRecord
|
||||
);
|
||||
|
||||
services.share.toggleShareContextMenu({
|
||||
anchorElement,
|
||||
|
@ -208,7 +220,7 @@ export const getTopNavLinks = ({
|
|||
...(services.capabilities.advancedSettings.save ? [options] : []),
|
||||
newSearch,
|
||||
openSearch,
|
||||
...(!isPlainRecord ? [shareSearch] : []),
|
||||
shareSearch,
|
||||
...(services.triggersActionsUi &&
|
||||
services.capabilities.management?.insightsAndAlerting?.triggersActions &&
|
||||
!isPlainRecord
|
||||
|
|
|
@ -197,6 +197,41 @@ describe('getSharingData', () => {
|
|||
`);
|
||||
});
|
||||
|
||||
test('fields do not have prepended timeField for text based languages', async () => {
|
||||
const index = { ...dataViewMock } as DataView;
|
||||
index.timeFieldName = 'cool-timefield';
|
||||
|
||||
const searchSourceMock = createSearchSourceMock({ index });
|
||||
const result = await getSharingData(
|
||||
searchSourceMock,
|
||||
{
|
||||
columns: [
|
||||
'cool-field-1',
|
||||
'cool-field-2',
|
||||
'cool-field-3',
|
||||
'cool-field-4',
|
||||
'cool-field-5',
|
||||
'cool-field-6',
|
||||
],
|
||||
},
|
||||
services,
|
||||
true
|
||||
);
|
||||
expect(result).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"columns": Array [
|
||||
"cool-field-1",
|
||||
"cool-field-2",
|
||||
"cool-field-3",
|
||||
"cool-field-4",
|
||||
"cool-field-5",
|
||||
"cool-field-6",
|
||||
],
|
||||
"getSearchSource": [Function],
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
test('fields conditionally do not have prepended timeField', async () => {
|
||||
services.uiSettings = {
|
||||
get: (key: string) => {
|
||||
|
|
|
@ -32,7 +32,8 @@ import {
|
|||
export async function getSharingData(
|
||||
currentSearchSource: ISearchSource,
|
||||
state: DiscoverAppState | SavedSearch,
|
||||
services: { uiSettings: IUiSettingsClient; data: DataPublicPluginStart }
|
||||
services: { uiSettings: IUiSettingsClient; data: DataPublicPluginStart },
|
||||
isPlainRecord?: boolean
|
||||
) {
|
||||
const { uiSettings: config, data } = services;
|
||||
const searchSource = currentSearchSource.createCopy();
|
||||
|
@ -57,7 +58,7 @@ export async function getSharingData(
|
|||
// conditionally add the time field column:
|
||||
let timeFieldName: string | undefined;
|
||||
const hideTimeColumn = config.get(DOC_HIDE_TIME_COLUMN_SETTING);
|
||||
if (!hideTimeColumn && index && index.timeFieldName) {
|
||||
if (!hideTimeColumn && index && index.timeFieldName && !isPlainRecord) {
|
||||
timeFieldName = index.timeFieldName;
|
||||
}
|
||||
if (timeFieldName && !columns.includes(timeFieldName)) {
|
||||
|
|
|
@ -70,7 +70,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
expect(await testSubjects.exists('unifiedHistogramChart')).to.be(false);
|
||||
expect(await testSubjects.exists('unifiedHistogramQueryHits')).to.be(true);
|
||||
expect(await testSubjects.exists('discoverAlertsButton')).to.be(false);
|
||||
expect(await testSubjects.exists('shareTopNavButton')).to.be(false);
|
||||
expect(await testSubjects.exists('shareTopNavButton')).to.be(true);
|
||||
expect(await testSubjects.exists('docTableExpandToggleColumn')).to.be(false);
|
||||
expect(await testSubjects.exists('dataGridColumnSortingButton')).to.be(false);
|
||||
expect(await testSubjects.exists('fieldListFiltersFieldTypeFilterToggle')).to.be(true);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue