Skip to content

Commit

Permalink
Merge branch 'main' into discover_less_field_list_loading_v2
Browse files Browse the repository at this point in the history
  • Loading branch information
mattkime authored Dec 1, 2023
2 parents 5e503e6 + 6fceda6 commit 27e3c0b
Show file tree
Hide file tree
Showing 10 changed files with 66 additions and 201 deletions.
1 change: 0 additions & 1 deletion .buildkite/ftr_configs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ enabled:
- test/functional/apps/kibana_overview/config.ts
- test/functional/apps/management/config.ts
- test/functional/apps/saved_objects_management/config.ts
- test/functional/apps/sharing/config.ts
- test/functional/apps/status_page/config.ts
- test/functional/apps/visualize/group1/config.ts
- test/functional/apps/visualize/group2/config.ts
Expand Down
13 changes: 0 additions & 13 deletions src/plugins/share/public/lib/get_home_href.ts

This file was deleted.

This file was deleted.

53 changes: 53 additions & 0 deletions src/plugins/share/public/url_service/redirect/components/error.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import * as React from 'react';
import {
EuiEmptyPrompt,
EuiCallOut,
EuiCodeBlock,
EuiSpacer,
EuiFlexGroup,
EuiFlexItem,
EuiText,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';

const defaultTitle = i18n.translate('share.urlService.redirect.components.Error.title', {
defaultMessage: 'Redirection error',
description:
'Title displayed to user in redirect endpoint when redirection cannot be performed successfully.',
});

export interface ErrorProps {
title?: string;
error: Error;
}

export const Error: React.FC<ErrorProps> = ({ title = defaultTitle, error }) => {
return (
<EuiEmptyPrompt
iconType={'error'}
iconColor={'danger'}
title={<h2>{title}</h2>}
body={
<EuiCallOut color="danger">
<EuiFlexGroup justifyContent="spaceAround">
<EuiFlexItem>
<EuiText color="danger">{error.message}</EuiText>
</EuiFlexItem>
</EuiFlexGroup>
<EuiSpacer size={'l'} />
<EuiCodeBlock language="bash" className="eui-textBreakAll" isCopyable>
{error.stack ? error.stack : ''}
</EuiCodeBlock>
</EuiCallOut>
}
/>
);
};
24 changes: 7 additions & 17 deletions src/plugins/share/public/url_service/redirect/components/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,29 @@

import * as React from 'react';
import useObservable from 'react-use/lib/useObservable';

import { EuiPageTemplate } from '@elastic/eui';
import type { CustomBrandingSetup } from '@kbn/core-custom-branding-browser';
import type { ChromeDocTitle, ThemeServiceSetup } from '@kbn/core/public';
import { ThemeServiceSetup } from '@kbn/core/public';
import { KibanaThemeProvider } from '@kbn/react-kibana-context-theme';

import type { RedirectManager } from '../redirect_manager';
import { RedirectEmptyPrompt } from './empty_prompt';
import { CustomBrandingStart } from '@kbn/core-custom-branding-browser';
import { Error } from './error';
import { RedirectManager } from '../redirect_manager';
import { Spinner } from './spinner';

export interface PageProps {
homeHref: string;
docTitle: ChromeDocTitle;
customBranding: CustomBrandingSetup;
manager: Pick<RedirectManager, 'error$'>;
theme: ThemeServiceSetup;
customBranding: CustomBrandingStart;
}

export const Page: React.FC<PageProps> = ({
manager,
homeHref,
customBranding,
docTitle,
theme,
}) => {
export const Page: React.FC<PageProps> = ({ manager, theme, customBranding }) => {
const error = useObservable(manager.error$);
const hasCustomBranding = useObservable(customBranding.hasCustomBranding$);

if (error) {
return (
<KibanaThemeProvider theme={{ theme$: theme.theme$ }}>
<EuiPageTemplate>
<RedirectEmptyPrompt docTitle={docTitle} error={error} homeHref={homeHref} />
<Error error={error} />
</EuiPageTemplate>
</KibanaThemeProvider>
);
Expand Down
22 changes: 6 additions & 16 deletions src/plugins/share/public/url_service/redirect/redirect_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,15 @@

import type { CoreSetup } from '@kbn/core/public';
import { i18n } from '@kbn/i18n';
import { migrateToLatest } from '@kbn/kibana-utils-plugin/common';
import type { Location } from 'history';
import { BehaviorSubject } from 'rxjs';
import type { Location } from 'history';
import { migrateToLatest } from '@kbn/kibana-utils-plugin/common';
import type { UrlService } from '../../../common/url_service';
import { parseSearchParams, RedirectOptions } from '../../../common/url_service/locators/redirect';
import {
LEGACY_SHORT_URL_LOCATOR_ID,
LegacyShortUrlLocatorParams,
} from '../../../common/url_service/locators/legacy_short_url_locator';
import { parseSearchParams, RedirectOptions } from '../../../common/url_service/locators/redirect';
import { getHomeHref } from '../../lib/get_home_href';

export interface RedirectManagerDependencies {
url: UrlService;
Expand All @@ -29,27 +28,18 @@ export class RedirectManager {
constructor(public readonly deps: RedirectManagerDependencies) {}

public registerLocatorRedirectApp(core: CoreSetup) {
const { application, customBranding, http, theme } = core;

application.register({
core.application.register({
id: 'r',
title: 'Redirect endpoint',
chromeless: true,
mount: async (params) => {
const { render } = await import('./render');
const [start] = await core.getStartServices();
const { chrome, uiSettings } = start;

const unmount = render(params.element, {
manager: this,
customBranding,
docTitle: chrome.docTitle,
theme,
homeHref: getHomeHref(http, uiSettings),
theme: core.theme,
customBranding: core.customBranding,
});

this.onMount(params.history.location);

return () => {
unmount();
};
Expand Down
2 changes: 0 additions & 2 deletions src/plugins/share/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
"@kbn/react-kibana-context-theme",
"@kbn/core-analytics-browser",
"@kbn/shared-ux-error-boundary",
"@kbn/core-chrome-browser",
"@kbn/shared-ux-prompt-not-found",
],
"exclude": [
"target/**/*",
Expand Down
51 changes: 0 additions & 51 deletions test/functional/apps/sharing/_short_urls.ts

This file was deleted.

18 changes: 0 additions & 18 deletions test/functional/apps/sharing/config.ts

This file was deleted.

15 changes: 0 additions & 15 deletions test/functional/apps/sharing/index.ts

This file was deleted.

0 comments on commit 27e3c0b

Please sign in to comment.