More actionable notification on plugin download failure

Summary: More actionable notification on plugin download failure.

Reviewed By: priteshrnandgaonkar

Differential Revision: D28856728

fbshipit-source-id: bd4a41af8812168949d83e2e0923ca7976485fa7
This commit is contained in:
Anton Nikolaev
2021-06-03 08:35:37 -07:00
committed by Facebook GitHub Bot
parent fa74502a8a
commit cc4bc293c6
2 changed files with 22 additions and 10 deletions

View File

@@ -116,7 +116,7 @@ async function handlePluginDownload(
}); });
if (response.headers['content-type'] !== 'application/octet-stream') { if (response.headers['content-type'] !== 'application/octet-stream') {
throw new Error( throw new Error(
`Unexpected content type ${response.headers['content-type']} received from ${plugin.downloadUrl}`, `It looks like you are not on VPN/Lighthouse. Unexpected content type received: ${response.headers['content-type']}.`,
); );
} }
const responseStream = response.data as fs.ReadStream; const responseStream = response.data as fs.ReadStream;
@@ -149,6 +149,7 @@ async function handlePluginDownload(
if (startedByUser) { if (startedByUser) {
showErrorNotification( showErrorNotification(
`Failed to download plugin "${title}" v${version}.`, `Failed to download plugin "${title}" v${version}.`,
'Please check that you are on VPN/Lighthouse.',
); );
} }
throw error; throw error;

View File

@@ -12,20 +12,31 @@ import React from 'react';
import {ConsoleLogs} from '../chrome/ConsoleLogs'; import {ConsoleLogs} from '../chrome/ConsoleLogs';
import {setStaticView} from '../reducers/connections'; import {setStaticView} from '../reducers/connections';
import {store} from '../store'; import {store} from '../store';
import {Layout} from '../ui';
import {v4 as uuid} from 'uuid';
const {Text, Link} = Typography; const {Link} = Typography;
export function showErrorNotification(message: string) { export function showErrorNotification(message: string, description?: string) {
const key = uuid();
notification.error({ notification.error({
key,
message, message,
description: ( description: (
<Text> <Layout.Container gap>
See{' '} {description ?? <p>{description}</p>}
<Link onClick={() => store.dispatch(setStaticView(ConsoleLogs))}> <p>
logs See{' '}
</Link>{' '} <Link
for details. onClick={() => {
</Text> store.dispatch(setStaticView(ConsoleLogs));
notification.close(key);
}}>
logs
</Link>{' '}
for details.
</p>
</Layout.Container>
), ),
placement: 'bottomLeft', placement: 'bottomLeft',
}); });