forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
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 (elastic#171679)
## Summary Closes elastic#169935 ### Screenshots <details> <summary>Before</summary> <img width="1259" alt="image" src="https://github.com/elastic/kibana/assets/908371/dbc91683-4088-48df-a402-1432615a2ff4"> </details> <details> <summary>After</summary> <img width="1260" alt="image" src="https://github.com/elastic/kibana/assets/908371/a1efabba-9402-4e97-935e-93656069c650"> </details> ### Testing 1. Create a simple dashboard 2. Use the Share > Short URL feature to create a short link to the dashboard. 3. Copy the shortened URL link to the clipboard, create a browser bookmark using the link. 4. Navigate to Saved Objects Management and delete the backing saved object of the short link 5. Click the new bookmark to try to open the shortened URL 6. Land on this new page ### Checklist Delete any items that are not applicable to this PR. - [x] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md) - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [x] Any UI touched in this PR is usable by keyboard only (learn more about [keyboard accessibility](https://webaim.org/techniques/keyboard/)) - [x] Any UI touched in this PR does not create any new axe failures (run axe in browser: [FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/), [Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US)) - [x] This renders correctly on smaller devices using a responsive layout. (You can test this [in your browser](https://www.browserstack.com/guide/responsive-testing-on-local-server)) - [x] This was checked for [cross-browser compatibility](https://www.elastic.co/support/matrix#matrix_browsers) --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
- Loading branch information
1 parent
2e52943
commit e6f3f06
Showing
10 changed files
with
201 additions
and
66 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')); | ||
}); | ||
} |