-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update page for missing Short URL Part II (#172422)
## Summary This PR re-opens #171679 which had to be reverted due to CI instability at the time it was originally mergted. --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
- Loading branch information
1 parent
13bdcb5
commit 1e93160
Showing
11 changed files
with
202 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
* 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 type { HttpSetup, IUiSettingsClient } from '@kbn/core/public'; | ||
|
||
export function getHomeHref(http: HttpSetup, uiSettings: IUiSettingsClient) { | ||
return http.basePath.prepend(uiSettings.get('defaultRoute')); | ||
} |
68 changes: 68 additions & 0 deletions
68
src/plugins/share/public/url_service/redirect/components/empty_prompt.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* 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 { EuiButtonEmpty } from '@elastic/eui'; | ||
import { i18n } from '@kbn/i18n'; | ||
|
||
import { ChromeDocTitle } from '@kbn/core-chrome-browser'; | ||
import { NotFoundPrompt } from '@kbn/shared-ux-prompt-not-found'; | ||
|
||
const defaultTitle = i18n.translate('share.urlService.redirect.components.Error.title', { | ||
defaultMessage: 'Unable to open URL', | ||
description: | ||
'Title displayed to user in redirect endpoint when redirection cannot be performed successfully.', | ||
}); | ||
|
||
const defaultBody = i18n.translate('share.urlService.redirect.components.Error.body', { | ||
defaultMessage: | ||
`Sorry, the object you're looking for can't be found at this URL.` + | ||
` It might have been removed or maybe it never existed.`, | ||
}); | ||
|
||
export interface ErrorProps { | ||
title?: string; | ||
body?: string; | ||
homeHref: string; | ||
docTitle: ChromeDocTitle; | ||
error: Error; | ||
} | ||
|
||
export const RedirectEmptyPrompt: React.FC<ErrorProps> = ({ | ||
title = defaultTitle, | ||
body = defaultBody, | ||
homeHref, | ||
docTitle, | ||
error, | ||
}) => { | ||
// eslint-disable-next-line no-console | ||
console.error('Short URL redirect error', error); | ||
|
||
docTitle.change( | ||
i18n.translate('share.urlService.redirect.components.docTitle', { defaultMessage: 'Not Found' }) | ||
); | ||
|
||
return ( | ||
<NotFoundPrompt | ||
title={<h2>{title}</h2>} | ||
body={<p data-test-subj="redirectErrorEmptyPromptBody">{body}</p>} | ||
actions={ | ||
<EuiButtonEmpty | ||
iconType="arrowLeft" | ||
href={homeHref} | ||
data-test-subj="redirectErrorEmptyPromptButton" | ||
> | ||
{i18n.translate('share.urlService.redirect.components.Error.homeButton', { | ||
defaultMessage: 'Back to home', | ||
})} | ||
</EuiButtonEmpty> | ||
} | ||
/> | ||
); | ||
}; |
53 changes: 0 additions & 53 deletions
53
src/plugins/share/public/url_service/redirect/components/error.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* 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 expect from '@kbn/expect'; | ||
import { FtrProviderContext } from '../../ftr_provider_context'; | ||
|
||
export default function ({ getPageObjects, getService }: FtrProviderContext) { | ||
describe('Short URLs', () => { | ||
const PageObjects = getPageObjects(['common']); | ||
const browser = getService('browser'); | ||
const log = getService('log'); | ||
const testSubjects = getService('testSubjects'); | ||
const retry = getService('retry'); | ||
|
||
it('shows Page for missing short URL', async () => { | ||
await PageObjects.common.navigateToApp('home'); | ||
|
||
// go to 404 | ||
const currentUrl = await browser.getCurrentUrl(); | ||
log.info('Changing URL to missing short URL...'); | ||
const newUrl = currentUrl.replace(/\/app\/home/, '/app/r/s/foofoo'); | ||
await browser.get(newUrl); | ||
|
||
// check the page for 404 contents | ||
log.info('Checking page title...'); | ||
await retry.try(async () => { | ||
const title = await browser.getTitle(); | ||
expect(title).to.be('Not Found - Elastic'); | ||
}); | ||
|
||
await retry.try(async () => { | ||
await testSubjects.existOrFail('redirectErrorEmptyPromptBody'); | ||
}); | ||
|
||
// click "back to home" button | ||
log.info('Clicking the prompt button...'); | ||
await testSubjects.click('redirectErrorEmptyPromptButton'); | ||
|
||
// check the page | ||
await retry.try(async () => { | ||
const title = await browser.getTitle(); | ||
expect(title).to.be('Home - Elastic'); | ||
}); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* 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 { FtrConfigProviderContext } from '@kbn/test'; | ||
|
||
export default async function ({ readConfigFile }: FtrConfigProviderContext) { | ||
const functionalConfig = await readConfigFile(require.resolve('../../config.base.js')); | ||
|
||
return { | ||
...functionalConfig.getAll(), | ||
testFiles: [require.resolve('.')], | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
* 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 { FtrProviderContext } from '../../ftr_provider_context'; | ||
|
||
export default function ({ loadTestFile }: FtrProviderContext) { | ||
describe('Sharing features', () => { | ||
loadTestFile(require.resolve('./_short_urls')); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters