From 99047cba038987fc9d6ade7df1326d8a674e9438 Mon Sep 17 00:00:00 2001 From: Pavel Feldman Date: Thu, 7 Sep 2023 18:34:59 -0700 Subject: [PATCH] chore: add install browsers dialog (#26940) --- packages/trace-viewer/src/ui/uiModeView.tsx | 41 +++++++++++--- packages/web/src/common.css | 55 ++++++++++++++++++- packages/web/src/components/toolbarButton.tsx | 2 +- 3 files changed, 88 insertions(+), 10 deletions(-) diff --git a/packages/trace-viewer/src/ui/uiModeView.tsx b/packages/trace-viewer/src/ui/uiModeView.tsx index 3fd5ce588b..a5c7cabb54 100644 --- a/packages/trace-viewer/src/ui/uiModeView.tsx +++ b/packages/trace-viewer/src/ui/uiModeView.tsx @@ -168,6 +168,26 @@ export const UIModeView: React.FC<{}> = ({ }, [projectFilters, runningState, testModel]); const isRunningTest = !!runningState; + const dialogRef = React.useRef(null); + const openInstallDialog = React.useCallback((e: React.MouseEvent) => { + e.preventDefault(); + e.stopPropagation(); + dialogRef.current?.showModal(); + }, []); + const closeInstallDialog = React.useCallback((e: React.MouseEvent) => { + e.preventDefault(); + e.stopPropagation(); + dialogRef.current?.close(); + }, []); + const installBrowsers = React.useCallback((e: React.MouseEvent) => { + closeInstallDialog(e); + setIsShowingOutput(true); + sendMessage('installBrowsers').then(async () => { + setIsShowingOutput(false); + const { hasBrowsers } = await sendMessage('checkBrowsers'); + setHasBrowsers(hasBrowsers); + }); + }, [closeInstallDialog]); return
{isDisconnected &&
@@ -196,14 +216,19 @@ export const UIModeView: React.FC<{}> = ({ toggleTheme()} /> reloadTests()} disabled={isRunningTest || isLoading}> { setIsShowingOutput(!isShowingOutput); }} /> - {!hasBrowsers && { - setIsShowingOutput(true); - sendMessage('installBrowsers').then(async () => { - setIsShowingOutput(false); - const { hasBrowsers } = await sendMessage('checkBrowsers'); - setHasBrowsers(hasBrowsers); - }); - }} />} + {!hasBrowsers && + +
Install browsers
+
+ Playwright did not find installed browsers. +

+ Would you like to run `playwright install`? +

+ + +
+
+
} void, + onClick: (e: React.MouseEvent) => void, style?: React.CSSProperties }