-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Update page for missing Short URL #171679
Changes from 10 commits
6adeb1b
3195a3b
a1572bb
b0f932a
e5813ec
c285b77
15b06af
24bdc5d
9a1ed44
b2e94a4
6482582
5b1f254
beac26f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* 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: | ||
'The stored URL for this link could not be opened. This could be due to lost Kibana Saved Object data.', | ||
}); | ||
|
||
export interface ErrorProps { | ||
title?: string; | ||
body?: string; | ||
docTitle: ChromeDocTitle; | ||
error: Error; | ||
} | ||
|
||
export const RedirectEmptyPrompt: React.FC<ErrorProps> = ({ | ||
title = defaultTitle, | ||
body = defaultBody, | ||
docTitle, | ||
error, | ||
}) => { | ||
// eslint-disable-next-line no-console | ||
console.error('Short URL Redirect Error', error); | ||
|
||
// Using the current URL containing "/app/r/", make a URL to the root basePath | ||
// by trimming that part to end up at the Home app or project home. | ||
const currentUrl = window.location.href; | ||
const newUrl = currentUrl.replace(/\/app\/r\/.*/, ''); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why wouldn't we use home href from settings instead? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ++ to use the |
||
|
||
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={newUrl} | ||
data-test-subj="redirectErrorEmptyPromptButton" | ||
> | ||
{i18n.translate('share.urlService.redirect.components.Error.homeButton', { | ||
defaultMessage: 'Back to home', | ||
})} | ||
</EuiButtonEmpty> | ||
} | ||
/> | ||
); | ||
}; |
This file was deleted.
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'); | ||
}); | ||
}); | ||
}); | ||
} |
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('.')], | ||
}; | ||
} |
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')); | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the text could be improved.
I like the text from the screenshot better #171679 (comment)
Also the URL might be broken because it just was incorrect (e.g. mistaken when manually typed or not fully copied)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe something like
Sorry, the object you're looking for can't be found at this URL. It might have been removed or maybe it never existed.