Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reporting/ILM: Break up ReportListingUi #15

Merged
merged 3 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions packages/kbn-reporting/common/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ export interface IlmPolicyStatusResponse {
status: IlmPolicyMigrationStatus;
}

export interface DefaultPolicyStatusResponse {
status: undefined;
}

type Url = string;
type UrlLocatorTuple = [url: Url, locatorParams: LocatorParams];

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import React, { FC } from 'react';

import { EuiPageHeader, EuiSpacer } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';

import { ListingPropsInternal } from '..';
import { ReportListingTable } from '../report_listing_table';

/**
* Used in non-stateful (Serverless)
* Does not render controls for features only applicable in Stateful
*/
export const ReportListingDefault: FC<ListingPropsInternal> = (props) => {
const { apiClient, capabilities, config, navigateToUrl, toasts, urlService, ...listingProps } =
props;
return (
<>
<EuiPageHeader
data-test-subj="reportingPageHeader"
bottomBorder
pageTitle={
<FormattedMessage id="xpack.reporting.listing.reportstitle" defaultMessage="Reports" />
}
description={
<FormattedMessage
id="xpack.reporting.listing.reports.subtitle"
defaultMessage="Get reports generated in Kibana applications."
/>
}
/>
<EuiSpacer size={'l'} />
<ReportListingTable
{...listingProps}
apiClient={apiClient}
capabilities={capabilities}
config={config}
toasts={toasts}
navigateToUrl={navigateToUrl}
urlService={urlService}
/>
</>
);
};
7 changes: 4 additions & 3 deletions x-pack/plugins/reporting/public/management/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,21 @@
import type { ApplicationStart, ToastsSetup } from '@kbn/core/public';
import type { LicensingPluginStart } from '@kbn/licensing-plugin/public';
import type { ClientConfigType } from '@kbn/reporting-public';
import type { UseIlmPolicyStatusReturn } from '../lib/ilm_policy_status_context';
import type { ReportingAPIClient } from '../lib/reporting_api_client';
import type { SharePluginSetup } from '../shared_imports';

export interface ListingProps {
apiClient: ReportingAPIClient;
capabilities: ApplicationStart['capabilities'];
license$: LicensingPluginStart['license$'];
config: ClientConfigType;
redirect: ApplicationStart['navigateToApp'];
navigateToUrl: ApplicationStart['navigateToUrl'];
toasts: ToastsSetup;
urlService: SharePluginSetup['url'];
ilmPolicyContextValue?: UseIlmPolicyStatusReturn;
}

export type ListingPropsInternal = ListingProps & {
capabilities: ApplicationStart['capabilities'];
};

export { ReportListing } from './report_listing';
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { ILicense } from '@kbn/licensing-plugin/public';
import { KibanaThemeProvider } from '@kbn/react-kibana-context-theme';
import type { ClientConfigType } from '@kbn/reporting-public';
import { ReportListing } from '.';
import { IlmPolicyStatusContextProvider } from '../lib/ilm_policy_status_context';
import { InternalApiClientProvider, ReportingAPIClient } from '../lib/reporting_api_client';
import type { ManagementAppMountParams, SharePluginSetup } from '../shared_imports';
import { KibanaContextProvider } from '../shared_imports';
Expand All @@ -30,29 +29,6 @@ export async function mountManagementSection(
urlService: SharePluginSetup['url'],
params: ManagementAppMountParams
) {
const CtxProvider = config.statefulSettings.enabled ? (
<IlmPolicyStatusContextProvider>
<ReportListing
toasts={coreSetup.notifications.toasts}
license$={license$}
config={config}
redirect={coreStart.application.navigateToApp}
navigateToUrl={coreStart.application.navigateToUrl}
urlService={urlService}
/>
</IlmPolicyStatusContextProvider>
) : (
<PolicyStatusContextProvider config={config}>
<ReportListing
toasts={coreSetup.notifications.toasts}
license$={license$}
config={config}
redirect={coreStart.application.navigateToApp}
navigateToUrl={coreStart.application.navigateToUrl}
urlService={urlService}
/>
</PolicyStatusContextProvider>
);
render(
<KibanaThemeProvider theme={{ theme$: params.theme$ }}>
<I18nProvider>
Expand All @@ -64,7 +40,19 @@ export async function mountManagementSection(
docLinks: coreStart.docLinks,
}}
>
<InternalApiClientProvider apiClient={apiClient}>{CtxProvider}</InternalApiClientProvider>
<InternalApiClientProvider apiClient={apiClient}>
<PolicyStatusContextProvider config={config}>
<ReportListing
apiClient={apiClient}
toasts={coreSetup.notifications.toasts}
license$={license$}
config={config}
redirect={coreStart.application.navigateToApp}
navigateToUrl={coreStart.application.navigateToUrl}
urlService={urlService}
/>
</PolicyStatusContextProvider>
</InternalApiClientProvider>
</KibanaContextProvider>
</I18nProvider>
</KibanaThemeProvider>,
Expand Down
Loading
Loading