mirror of
https://github.com/elastic/kibana.git
synced 2025-04-25 02:09:32 -04:00
[Discover Session] Fix "Untitled" export title when exporting CSV on a dashboard (#210143)
- Fixes "Untitled" CSV exports when an export of a Discover session CSV is triggered on a Dashboard - Switches to make use of the embeddable title when exporting CSV of Discover session embeddables on a Dashboard.
This commit is contained in:
parent
22144405f7
commit
7a72b14fd5
2 changed files with 15 additions and 8 deletions
|
@ -93,7 +93,6 @@ describe('GetCsvReportPanelAction', () => {
|
||||||
embeddable: {
|
embeddable: {
|
||||||
type: 'search',
|
type: 'search',
|
||||||
savedSearch$: new BehaviorSubject({ searchSource: mockSearchSource }),
|
savedSearch$: new BehaviorSubject({ searchSource: mockSearchSource }),
|
||||||
getTitle: () => `The Dude`,
|
|
||||||
getInspectorAdapters: () => null,
|
getInspectorAdapters: () => null,
|
||||||
getInput: () => ({
|
getInput: () => ({
|
||||||
viewMode: 'list',
|
viewMode: 'list',
|
||||||
|
@ -103,6 +102,8 @@ describe('GetCsvReportPanelAction', () => {
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
hasTimeRange: () => true,
|
hasTimeRange: () => true,
|
||||||
|
title$: new BehaviorSubject('embeddable title'),
|
||||||
|
hideTitle$: new BehaviorSubject(false),
|
||||||
parentApi: {
|
parentApi: {
|
||||||
viewMode$: new BehaviorSubject('view'),
|
viewMode$: new BehaviorSubject('view'),
|
||||||
},
|
},
|
||||||
|
@ -131,7 +132,7 @@ describe('GetCsvReportPanelAction', () => {
|
||||||
columns: [],
|
columns: [],
|
||||||
objectType: 'search',
|
objectType: 'search',
|
||||||
searchSource: {},
|
searchSource: {},
|
||||||
title: '',
|
title: 'embeddable title',
|
||||||
version: '7.15.0',
|
version: '7.15.0',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -165,7 +166,7 @@ describe('GetCsvReportPanelAction', () => {
|
||||||
columns: ['column_a', 'column_b'],
|
columns: ['column_a', 'column_b'],
|
||||||
objectType: 'search',
|
objectType: 'search',
|
||||||
searchSource: { testData: 'testDataValue' },
|
searchSource: { testData: 'testDataValue' },
|
||||||
title: '',
|
title: 'embeddable title',
|
||||||
version: '7.15.0',
|
version: '7.15.0',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -183,7 +184,7 @@ describe('GetCsvReportPanelAction', () => {
|
||||||
await panel.execute(context);
|
await panel.execute(context);
|
||||||
|
|
||||||
expect(core.http.post).toHaveBeenCalledWith('/internal/reporting/generate/csv_searchsource', {
|
expect(core.http.post).toHaveBeenCalledWith('/internal/reporting/generate/csv_searchsource', {
|
||||||
body: '{"jobParams":"(columns:!(),objectType:search,searchSource:(),title:\'\',version:\'7.15.0\')"}',
|
body: '{"jobParams":"(columns:!(),objectType:search,searchSource:(),title:\'embeddable title\',version:\'7.15.0\')"}',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -30,10 +30,12 @@ import {
|
||||||
apiCanAccessViewMode,
|
apiCanAccessViewMode,
|
||||||
apiHasType,
|
apiHasType,
|
||||||
apiIsOfType,
|
apiIsOfType,
|
||||||
|
apiPublishesTitle,
|
||||||
CanAccessViewMode,
|
CanAccessViewMode,
|
||||||
EmbeddableApiContext,
|
EmbeddableApiContext,
|
||||||
getInheritedViewMode,
|
getInheritedViewMode,
|
||||||
HasType,
|
HasType,
|
||||||
|
PublishesTitle,
|
||||||
} from '@kbn/presentation-publishing';
|
} from '@kbn/presentation-publishing';
|
||||||
import { toMountPoint } from '@kbn/react-kibana-mount';
|
import { toMountPoint } from '@kbn/react-kibana-mount';
|
||||||
import { CSV_REPORTING_ACTION, JobAppParamsCSV } from '@kbn/reporting-export-types-csv-common';
|
import { CSV_REPORTING_ACTION, JobAppParamsCSV } from '@kbn/reporting-export-types-csv-common';
|
||||||
|
@ -43,7 +45,6 @@ import { IncompatibleActionError } from '@kbn/ui-actions-plugin/public';
|
||||||
import type { ClientConfigType } from '@kbn/reporting-public/types';
|
import type { ClientConfigType } from '@kbn/reporting-public/types';
|
||||||
import { checkLicense } from '@kbn/reporting-public/license_check';
|
import { checkLicense } from '@kbn/reporting-public/license_check';
|
||||||
import type { ReportingAPIClient } from '@kbn/reporting-public/reporting_api_client';
|
import type { ReportingAPIClient } from '@kbn/reporting-public/reporting_api_client';
|
||||||
|
|
||||||
import { getI18nStrings } from './strings';
|
import { getI18nStrings } from './strings';
|
||||||
|
|
||||||
export interface PanelActionDependencies {
|
export interface PanelActionDependencies {
|
||||||
|
@ -82,7 +83,11 @@ interface ExecutionParams {
|
||||||
i18nStart: I18nStart;
|
i18nStart: I18nStart;
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetCsvActionApi = HasType & PublishesSavedSearch & CanAccessViewMode & HasTimeRange;
|
type GetCsvActionApi = HasType &
|
||||||
|
PublishesSavedSearch &
|
||||||
|
CanAccessViewMode &
|
||||||
|
HasTimeRange &
|
||||||
|
PublishesTitle;
|
||||||
|
|
||||||
const compatibilityCheck = (api: EmbeddableApiContext['embeddable']): api is GetCsvActionApi => {
|
const compatibilityCheck = (api: EmbeddableApiContext['embeddable']): api is GetCsvActionApi => {
|
||||||
return (
|
return (
|
||||||
|
@ -90,7 +95,8 @@ const compatibilityCheck = (api: EmbeddableApiContext['embeddable']): api is Get
|
||||||
apiIsOfType(api, SEARCH_EMBEDDABLE_TYPE) &&
|
apiIsOfType(api, SEARCH_EMBEDDABLE_TYPE) &&
|
||||||
apiPublishesSavedSearch(api) &&
|
apiPublishesSavedSearch(api) &&
|
||||||
apiCanAccessViewMode(api) &&
|
apiCanAccessViewMode(api) &&
|
||||||
Boolean((api as unknown as HasTimeRange).hasTimeRange)
|
Boolean((api as unknown as HasTimeRange).hasTimeRange) &&
|
||||||
|
apiPublishesTitle(api)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -196,7 +202,7 @@ export class ReportingCsvPanelAction implements ActionDefinition<EmbeddableApiCo
|
||||||
addGlobalTimeFilter: !embeddable.hasTimeRange(),
|
addGlobalTimeFilter: !embeddable.hasTimeRange(),
|
||||||
absoluteTime: true,
|
absoluteTime: true,
|
||||||
});
|
});
|
||||||
const title = savedSearch.title || '';
|
const title = embeddable.title$.getValue() ?? '';
|
||||||
const executionParams = { searchSource, columns, title, savedSearch, i18nStart, analytics };
|
const executionParams = { searchSource, columns, title, savedSearch, i18nStart, analytics };
|
||||||
|
|
||||||
return this.executeGenerate(executionParams);
|
return this.executeGenerate(executionParams);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue