Skip to content

Commit

Permalink
Merge branch 'main' into sharedux/cleanup-tomountpoint-deprecations-viii
Browse files Browse the repository at this point in the history
  • Loading branch information
tsullivan authored Apr 25, 2024
2 parents 4b5461e + b92890a commit 583887c
Show file tree
Hide file tree
Showing 91 changed files with 2,034 additions and 1,146 deletions.
2 changes: 1 addition & 1 deletion .buildkite/scripts/steps/cloud/purge_projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ async function purgeProjects() {
} else if (
!Boolean(
pullRequest.labels.filter((label: any) =>
/^ci:project-deploy-(elasticearch|security|observability)$/.test(label.name)
/^ci:project-deploy-(elasticsearch|security|observability)$/.test(label.name)
).length
)
) {
Expand Down
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1445,7 +1445,6 @@
"@types/inquirer": "^7.3.1",
"@types/intl-relativeformat": "^2.1.0",
"@types/jest": "^29.5.3",
"@types/jest-axe": "^3.5.3",
"@types/jquery": "^3.3.31",
"@types/js-levenshtein": "^1.1.0",
"@types/js-search": "^1.4.0",
Expand Down Expand Up @@ -1618,7 +1617,6 @@
"http-proxy": "^1.18.1",
"ignore": "^5.3.0",
"jest": "^29.6.1",
"jest-axe": "^5.0.0",
"jest-canvas-mock": "^2.5.2",
"jest-cli": "^29.6.1",
"jest-config": "^29.6.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,26 @@ export interface PanelActionDependencies {
licensing: LicensingPluginStart;
}

type StartServices = [
Pick<
CoreStart,
// required for modules that render React
| 'analytics'
| 'i18n'
| 'theme'
// used extensively in Reporting share panel action
| 'application'
| 'uiSettings'
>,
PanelActionDependencies,
unknown
];

interface Params {
apiClient: ReportingAPIClient;
csvConfig: ClientConfigType['csv'];
core: CoreSetup;
startServices$: Observable<[CoreStart, PanelActionDependencies, unknown]>;
startServices$: Observable<StartServices>;
usesUiCapabilities: boolean;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-reporting/public/share/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ export { reportingScreenshotShareProvider } from './share_context_menu/register_
export { reportingCsvShareProvider } from './share_context_menu/register_csv_reporting';
export { reportingCsvShareProvider as reportingCsvShareModalProvider } from './share_context_menu/register_csv_modal_reporting';
export type { ReportingPublicComponents } from './shared/get_shared_components';
export type { JobParamsProviderOptions } from './share_context_menu';
export type { JobParamsProviderOptions, StartServices } from './share_context_menu';
33 changes: 20 additions & 13 deletions packages/kbn-reporting/public/share/share_context_menu/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,42 @@
* Side Public License, v 1.
*/

import type {
ApplicationStart,
I18nStart,
IUiSettingsClient,
ThemeServiceSetup,
ToastsSetup,
} from '@kbn/core/public';
import * as Rx from 'rxjs';

import type { ApplicationStart, CoreStart } from '@kbn/core/public';
import { ILicense } from '@kbn/licensing-plugin/public';
import type { LayoutParams } from '@kbn/screenshotting-plugin/common';

import type { ReportingAPIClient } from '../../reporting_api_client';

export type StartServices = [
Pick<
CoreStart,
// required for modules that render React
| 'analytics'
| 'i18n'
| 'theme'
// used extensively in Reporting share context menus and modal
| 'notifications'
>,
unknown,
unknown
];

export interface ExportModalShareOpts {
apiClient: ReportingAPIClient;
uiSettings: IUiSettingsClient;
usesUiCapabilities: boolean;
license: ILicense;
application: ApplicationStart;
theme: ThemeServiceSetup;
i18n: I18nStart;
startServices$: Rx.Observable<StartServices>;
}

export interface ExportPanelShareOpts {
apiClient: ReportingAPIClient;
toasts: ToastsSetup;
uiSettings: IUiSettingsClient;
usesUiCapabilities: boolean;
license: ILicense;
application: ApplicationStart;
theme: ThemeServiceSetup;
startServices$: Rx.Observable<StartServices>;
}

export interface ReportingSharingData {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
*/

import { i18n } from '@kbn/i18n';
import React from 'react';
import { toMountPoint } from '@kbn/react-kibana-mount';
import React from 'react';
import { firstValueFrom } from 'rxjs';

import { CSV_JOB_TYPE, CSV_JOB_TYPE_V2 } from '@kbn/reporting-export-types-csv-common';

import type { SearchSourceFields } from '@kbn/data-plugin/common';
import { ShareContext, ShareMenuItem } from '@kbn/share-plugin/public';
import { FormattedMessage, InjectedIntl } from '@kbn/i18n-react';
import { ShareContext, ShareMenuItem } from '@kbn/share-plugin/public';
import type { ExportModalShareOpts } from '.';
import { checkLicense } from '../..';

Expand All @@ -23,8 +24,7 @@ export const reportingCsvShareProvider = ({
application,
license,
usesUiCapabilities,
i18n: i18nStart,
theme,
startServices$,
}: ExportModalShareOpts) => {
const getShareMenuItems = ({ objectType, sharingData, toasts }: ShareContext) => {
if ('search' !== objectType) {
Expand Down Expand Up @@ -86,7 +86,8 @@ export const reportingCsvShareProvider = ({
const decoratedJobParams = apiClient.getDecoratedJobParams(getJobParams());
return apiClient
.createReportingJob(reportType, decoratedJobParams)
.then(() => {
.then(() => firstValueFrom(startServices$))
.then(([startServices]) => {
toasts.addSuccess({
title: intl.formatMessage(
{
Expand All @@ -110,7 +111,7 @@ export const reportingCsvShareProvider = ({
),
}}
/>,
{ theme, i18n: i18nStart }
startServices
),
'data-test-subj': 'queueReportSuccess',
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@ import { ReportingPanelContent } from './reporting_panel_content_lazy';

export const reportingCsvShareProvider = ({
apiClient,
toasts,
uiSettings,
application,
license,
usesUiCapabilities,
theme,
startServices$,
}: ExportPanelShareOpts): ShareMenuProvider => {
const getShareMenuItems = ({ objectType, objectId, sharingData, onClose }: ShareContext) => {
if ('search' !== objectType) {
Expand Down Expand Up @@ -104,14 +102,12 @@ export const reportingCsvShareProvider = ({
<ReportingPanelContent
requiresSavedState={false}
apiClient={apiClient}
toasts={toasts}
uiSettings={uiSettings}
reportType={reportType}
layoutId={undefined}
objectId={objectId}
getJobParams={getJobParams}
onClose={onClose}
theme={theme}
startServices$={startServices$}
/>
),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@
*/

import { i18n } from '@kbn/i18n';
import React from 'react';
import { ShareContext, ShareMenuItem, ShareMenuProvider } from '@kbn/share-plugin/public';
import { FormattedMessage, InjectedIntl } from '@kbn/i18n-react';
import { toMountPoint } from '@kbn/react-kibana-mount';
import { checkLicense } from '../../license_check';
import { ShareContext, ShareMenuItem, ShareMenuProvider } from '@kbn/share-plugin/public';
import React from 'react';
import { firstValueFrom } from 'rxjs';
import {
ExportModalShareOpts,
ExportPanelShareOpts,
JobParamsProviderOptions,
ReportingSharingData,
} from '.';
import { checkLicense } from '../../license_check';
import { ScreenCapturePanelContent } from './screen_capture_panel_content_lazy';

const getJobParams = (opts: JobParamsProviderOptions, type: 'pngV2' | 'printablePdfV2') => () => {
Expand Down Expand Up @@ -45,12 +46,10 @@ const getJobParams = (opts: JobParamsProviderOptions, type: 'pngV2' | 'printable
*/
export const reportingScreenshotShareProvider = ({
apiClient,
toasts,
uiSettings,
license,
application,
usesUiCapabilities,
theme,
startServices$,
}: ExportPanelShareOpts): ShareMenuProvider => {
const getShareMenuItems = ({
objectType,
Expand Down Expand Up @@ -136,15 +135,13 @@ export const reportingScreenshotShareProvider = ({
content: (
<ScreenCapturePanelContent
apiClient={apiClient}
toasts={toasts}
uiSettings={uiSettings}
startServices$={startServices$}
reportType={'pngV2'}
objectId={objectId}
requiresSavedState={requiresSavedState}
getJobParams={getJobParams(jobProviderOptions, 'pngV2')}
isDirty={isDirty}
onClose={onClose}
theme={theme}
/>
),
},
Expand All @@ -169,16 +166,14 @@ export const reportingScreenshotShareProvider = ({
content: (
<ScreenCapturePanelContent
apiClient={apiClient}
toasts={toasts}
uiSettings={uiSettings}
startServices$={startServices$}
reportType={'printablePdfV2'}
objectId={objectId}
requiresSavedState={requiresSavedState}
layoutOption={objectType === 'dashboard' ? 'print' : undefined}
getJobParams={getJobParams(jobProviderOptions, 'printablePdfV2')}
isDirty={isDirty}
onClose={onClose}
theme={theme}
/>
),
},
Expand All @@ -200,8 +195,7 @@ export const reportingExportModalProvider = ({
license,
application,
usesUiCapabilities,
theme,
i18n: i18nStart,
startServices$,
}: ExportModalShareOpts): ShareMenuProvider => {
const getShareMenuItems = ({
objectType,
Expand Down Expand Up @@ -294,7 +288,8 @@ export const reportingExportModalProvider = ({

return apiClient
.createReportingJob('printablePdfV2', decoratedJobParams)
.then(() => {
.then(() => firstValueFrom(startServices$))
.then(([startServices]) => {
toasts.addSuccess({
title: intl.formatMessage(
{
Expand All @@ -318,7 +313,7 @@ export const reportingExportModalProvider = ({
),
}}
/>,
{ theme, i18n: i18nStart }
startServices
),
'data-test-subj': 'queueReportSuccess',
});
Expand Down Expand Up @@ -347,7 +342,8 @@ export const reportingExportModalProvider = ({
});
return apiClient
.createReportingJob('pngV2', decoratedJobParams)
.then(() => {
.then(() => firstValueFrom(startServices$))
.then(([startServices]) => {
toasts.addSuccess({
title: intl.formatMessage(
{
Expand All @@ -371,7 +367,7 @@ export const reportingExportModalProvider = ({
),
}}
/>,
{ theme, i18n: i18nStart }
startServices
),
'data-test-subj': 'queueReportSuccess',
});
Expand Down Expand Up @@ -414,7 +410,6 @@ export const reportingExportModalProvider = ({
/>
),
layoutOption: objectType === 'dashboard' ? ('print' as const) : undefined,
theme,
renderLayoutOptionSwitch: objectType === 'dashboard',
renderCopyURLButton: true,
absoluteUrl: new URL(relativePathPDF, window.location.href).toString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,10 @@ const getJobParams =

export const reportingScreenshotShareProvider = ({
apiClient,
toasts,
uiSettings,
license,
application,
usesUiCapabilities,
theme,
startServices$,
}: ExportPanelShareOpts): ShareMenuProvider => {
const getShareMenuItems = ({
objectType,
Expand Down Expand Up @@ -150,15 +148,13 @@ export const reportingScreenshotShareProvider = ({
content: (
<ScreenCapturePanelContent
apiClient={apiClient}
toasts={toasts}
uiSettings={uiSettings}
reportType={pngReportType}
objectId={objectId}
requiresSavedState={requiresSavedState}
getJobParams={getJobParams(apiClient, jobProviderOptions, pngReportType)}
isDirty={isDirty}
onClose={onClose}
theme={theme}
startServices$={startServices$}
/>
),
},
Expand All @@ -185,16 +181,14 @@ export const reportingScreenshotShareProvider = ({
content: (
<ScreenCapturePanelContent
apiClient={apiClient}
toasts={toasts}
uiSettings={uiSettings}
reportType={pdfReportType}
objectId={objectId}
requiresSavedState={requiresSavedState}
layoutOption={objectType === 'dashboard' ? 'print' : undefined}
getJobParams={getJobParams(apiClient, jobProviderOptions, pdfReportType)}
isDirty={isDirty}
onClose={onClose}
theme={theme}
startServices$={startServices$}
/>
),
},
Expand Down
Loading

0 comments on commit 583887c

Please sign in to comment.