Skip to content

Commit 01baf77

Browse files
Remove "Back to home" link on import errors when not loading from file (#5279)
Co-authored-by: Nazım Can Altınova <[email protected]>
1 parent 38162fc commit 01baf77

File tree

4 files changed

+60
-14
lines changed

4 files changed

+60
-14
lines changed

src/components/app/AppViewRouter.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ class AppViewRouterImpl extends PureComponent<AppViewRouterProps> {
9898
}
9999
}
100100

101+
const showBackHomeLink = dataSource === 'from-file';
102+
101103
return (
102104
<Localized
103105
id={message}
@@ -116,7 +118,7 @@ class AppViewRouterImpl extends PureComponent<AppViewRouterProps> {
116118
<ProfileRootMessage
117119
additionalMessage={additionalMessage}
118120
showLoader={false}
119-
showBackHomeLink={true}
121+
showBackHomeLink={showBackHomeLink}
120122
>{`missing translation for ${message}`}</ProfileRootMessage>
121123
</Localized>
122124
);

src/components/app/ProfileLoaderAnimation.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ class ProfileLoaderAnimationImpl extends PureComponent<ProfileLoaderAnimationPro
6161
const showBackHomeLink = Boolean(
6262
'additionalData' in view &&
6363
view.additionalData &&
64-
view.additionalData.message
64+
view.additionalData.message &&
65+
dataSource === 'from-file'
6566
);
6667

6768
return (

src/test/components/Root.test.tsx

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,11 @@ describe('app/AppViewRouter', function () {
135135
const {
136136
container,
137137
dispatch,
138-
navigateToStoreLoadingPage,
138+
navigateToFromFileProfileLoadingPage,
139139
navigateBackToHome,
140140
} = setup();
141141

142-
navigateToStoreLoadingPage();
142+
navigateToFromFileProfileLoadingPage();
143143
dispatch(fatalError(new Error('Error while loading profile')));
144144
expect(container.firstChild).toMatchSnapshot();
145145
expect(console.error).toHaveBeenCalled();
@@ -148,6 +148,15 @@ describe('app/AppViewRouter', function () {
148148
expect(container.firstChild).toMatchSnapshot();
149149
});
150150

151+
it('does not render back home link when not opened with from-file', function () {
152+
const { container, dispatch, navigateToStoreLoadingPage } = setup();
153+
154+
navigateToStoreLoadingPage();
155+
dispatch(fatalError(new Error('Error while loading profile')));
156+
expect(container.firstChild).toMatchSnapshot();
157+
expect(console.error).toHaveBeenCalled();
158+
});
159+
151160
it('renders a compare home when navigating to /compare/, then loads when changing profiles', () => {
152161
const { container, dispatch, navigateToCompareHome } = setup();
153162

@@ -211,6 +220,15 @@ function setup() {
211220
actAndDispatch(updateUrlState(newUrlState));
212221
}
213222

223+
function navigateToFromFileProfileLoadingPage() {
224+
const newUrlState = stateFromLocation({
225+
pathname: '/from-file/calltree',
226+
search: '',
227+
hash: '',
228+
});
229+
actAndDispatch(updateUrlState(newUrlState));
230+
}
231+
214232
function navigateBackToHome() {
215233
const newUrlState = stateFromLocation({
216234
pathname: '/',
@@ -243,6 +261,7 @@ function setup() {
243261
dispatch: actAndDispatch,
244262
navigateToStoreLoadingPage,
245263
navigateToFromBrowserProfileLoadingPage,
264+
navigateToFromFileProfileLoadingPage,
246265
navigateBackToHome,
247266
navigateToCompareHome,
248267
navigateToMyProfiles,

src/test/components/__snapshots__/Root.test.tsx.snap

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,38 @@
11
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
22

3+
exports[`app/AppViewRouter does not render back home link when not opened with from-file 1`] = `
4+
<div
5+
class="rootMessageContainer"
6+
>
7+
<div
8+
class="rootMessage"
9+
>
10+
<h1
11+
class="rootMessageTitle"
12+
>
13+
Firefox Profiler
14+
</h1>
15+
<div
16+
class="rootMessageText"
17+
>
18+
<p>
19+
Could not download the profile.
20+
</p>
21+
</div>
22+
<div
23+
class="rootMessageAdditional"
24+
>
25+
<p>
26+
Error: Error while loading profile
27+
</p>
28+
<p>
29+
The full stack has been written to the Web Console.
30+
</p>
31+
</div>
32+
</div>
33+
</div>
34+
`;
35+
336
exports[`app/AppViewRouter does not try to retrieve a profile when moving from from-browser to public 1`] = `<profile-viewer />`;
437

538
exports[`app/AppViewRouter renders an home when the user pressed back after an error 1`] = `
@@ -18,7 +51,7 @@ exports[`app/AppViewRouter renders an home when the user pressed back after an e
1851
class="rootMessageText"
1952
>
2053
<p>
21-
Could not download the profile.
54+
Couldn’t read the file or parse the profile in it.
2255
</p>
2356
</div>
2457
<div
@@ -77,15 +110,6 @@ exports[`app/AppViewRouter renders temporary errors 1`] = `
77110
Tried 3 times out of 10.
78111
</p>
79112
</div>
80-
<div
81-
class="rootBackHomeLink"
82-
>
83-
<a
84-
href="/"
85-
>
86-
Back to home
87-
</a>
88-
</div>
89113
<div
90114
class="loading"
91115
>

0 commit comments

Comments
 (0)