Skip to content

Commit

Permalink
Merge pull request #15 from tsullivan/reporting-ilm
Browse files Browse the repository at this point in the history
Reporting/ILM: Break up ReportListingUi
  • Loading branch information
rshen91 authored Nov 21, 2023
2 parents 5efb739 + 9c4b7cc commit bcd8e49
Show file tree
Hide file tree
Showing 7 changed files with 596 additions and 600 deletions.
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

0 comments on commit bcd8e49

Please sign in to comment.