Skip to content

Remove "Back to home" link on import errors when not loading from file #5279

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/components/app/AppViewRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ class AppViewRouterImpl extends PureComponent<AppViewRouterProps> {
}
}

const showBackHomeLink = dataSource === 'from-file';

return (
<Localized
id={message}
Expand All @@ -118,7 +120,7 @@ class AppViewRouterImpl extends PureComponent<AppViewRouterProps> {
<ProfileRootMessage
additionalMessage={additionalMessage}
showLoader={false}
showBackHomeLink={true}
showBackHomeLink={showBackHomeLink}
>{`missing translation for ${message}`}</ProfileRootMessage>
</Localized>
);
Expand Down
4 changes: 3 additions & 1 deletion src/components/app/ProfileLoaderAnimation.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ class ProfileLoaderAnimationImpl extends PureComponent<ProfileLoaderAnimationPro
: 'ProfileLoaderAnimation--loading-view-not-found';
const showLoader = Boolean(loadingMessage);
const showBackHomeLink = Boolean(
view.additionalData && view.additionalData.message
view.additionalData &&
view.additionalData.message &&
dataSource === 'from-file'
);

return (
Expand Down
27 changes: 25 additions & 2 deletions src/test/components/Root.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,11 @@ describe('app/AppViewRouter', function () {
const {
container,
dispatch,
navigateToStoreLoadingPage,
navigateToFromFileProfileLoadingPage,
navigateBackToHome,
} = setup();

navigateToStoreLoadingPage();
navigateToFromFileProfileLoadingPage();
dispatch(fatalError(new Error('Error while loading profile')));
expect(container.firstChild).toMatchSnapshot();
expect(console.error).toHaveBeenCalled();
Expand All @@ -151,6 +151,19 @@ describe('app/AppViewRouter', function () {
expect(container.firstChild).toMatchSnapshot();
});

it('does not render back home link when not opened with from-file', function () {
const {
container,
dispatch,
navigateToStoreLoadingPage,
} = setup();

navigateToStoreLoadingPage();
dispatch(fatalError(new Error('Error while loading profile')));
expect(container.firstChild).toMatchSnapshot();
expect(console.error).toHaveBeenCalled();
});

it('renders a compare home when navigating to /compare/, then loads when changing profiles', () => {
const { container, dispatch, navigateToCompareHome } = setup();

Expand Down Expand Up @@ -214,6 +227,15 @@ function setup() {
actAndDispatch(updateUrlState(newUrlState));
}

function navigateToFromFileProfileLoadingPage() {
const newUrlState = stateFromLocation({
pathname: '/from-file/calltree',
search: '',
hash: '',
});
actAndDispatch(updateUrlState(newUrlState));
}

function navigateBackToHome() {
const newUrlState = stateFromLocation({
pathname: '/',
Expand Down Expand Up @@ -246,6 +268,7 @@ function setup() {
dispatch: actAndDispatch,
navigateToStoreLoadingPage,
navigateToFromBrowserProfileLoadingPage,
navigateToFromFileProfileLoadingPage,
navigateBackToHome,
navigateToCompareHome,
navigateToMyProfiles,
Expand Down
44 changes: 34 additions & 10 deletions src/test/components/__snapshots__/Root.test.js.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,38 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`app/AppViewRouter does not render back home link when not opened with from-file 1`] = `
<div
class="rootMessageContainer"
>
<div
class="rootMessage"
>
<h1
class="rootMessageTitle"
>
Firefox Profiler
</h1>
<div
class="rootMessageText"
>
<p>
Could not download the profile.
</p>
</div>
<div
class="rootMessageAdditional"
>
<p>
Error: Error while loading profile
</p>
<p>
The full stack has been written to the Web Console.
</p>
</div>
</div>
</div>
`;

exports[`app/AppViewRouter does not try to retrieve a profile when moving from from-browser to public 1`] = `<profile-viewer />`;

exports[`app/AppViewRouter renders an home when the user pressed back after an error 1`] = `
Expand All @@ -18,7 +51,7 @@ exports[`app/AppViewRouter renders an home when the user pressed back after an e
class="rootMessageText"
>
<p>
Could not download the profile.
Couldn’t read the file or parse the profile in it.
</p>
</div>
<div
Expand Down Expand Up @@ -77,15 +110,6 @@ exports[`app/AppViewRouter renders temporary errors 1`] = `
Tried 3 times out of 10.
</p>
</div>
<div
class="rootBackHomeLink"
>
<a
href="/"
>
Back to home
</a>
</div>
<div
class="loading"
>
Expand Down