From 1fa81b95f9d36a8a1a66efbf1f8f2dc2a6286eed Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pawe=C5=82=20Ma=C5=82ecki?=
<92953623+p-malecki@users.noreply.github.com>
Date: Fri, 20 Dec 2024 17:17:54 +0100
Subject: [PATCH] Update disabling of UrlBars buttons (#871)
This PR updates the disabling of buttons in the UrlBar:
- reload button's option list when project is in devicesNotFound state
- goBack, goHome and UrlSelect when project is in either devicesNotFound
or starting state
|Before|After|
|-|-|
|||
|||
---
.../src/webview/components/IconButtonWithOptions.tsx | 9 +++++----
.../vscode-extension/src/webview/components/UrlBar.tsx | 10 ++++++----
2 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/packages/vscode-extension/src/webview/components/IconButtonWithOptions.tsx b/packages/vscode-extension/src/webview/components/IconButtonWithOptions.tsx
index 65cbd6979..31b404f3f 100644
--- a/packages/vscode-extension/src/webview/components/IconButtonWithOptions.tsx
+++ b/packages/vscode-extension/src/webview/components/IconButtonWithOptions.tsx
@@ -6,11 +6,12 @@ import "./IconButtonWithOptions.css";
interface IconButtonWithOptions extends IconButtonProps {
options: Record void>;
+ disabled?: boolean;
}
export const IconButtonWithOptions = forwardRef(
(props, ref) => {
- const { options, children, ...iconButtonProps } = props;
+ const { options, disabled, children, ...iconButtonProps } = props;
const [dropdownTriggerVisible, setDropdownTriggerVisible] = useState(false);
@@ -23,16 +24,16 @@ export const IconButtonWithOptions = forwardRef {
setDropdownTriggerVisible(false);
}}>
-
+
{children}
-
+
{
}
diff --git a/packages/vscode-extension/src/webview/components/UrlBar.tsx b/packages/vscode-extension/src/webview/components/UrlBar.tsx
index 213865d3a..4915b1aa6 100644
--- a/packages/vscode-extension/src/webview/components/UrlBar.tsx
+++ b/packages/vscode-extension/src/webview/components/UrlBar.tsx
@@ -28,7 +28,7 @@ function ReloadButton({ disabled }: { disabled: boolean }) {
}
function UrlBar({ disabled }: { disabled?: boolean }) {
- const { project } = useProject();
+ const { project, projectState } = useProject();
const MAX_URL_HISTORY_SIZE = 20;
const MAX_RECENT_URL_SIZE = 5;
@@ -79,6 +79,8 @@ function UrlBar({ disabled }: { disabled?: boolean }) {
return [...urlList].sort((a, b) => a.name.localeCompare(b.name));
}, [urlList]);
+ const disabledAlsoWhenStarting = disabled || projectState.status === "starting";
+
return (
<>
{
setUrlHistory((prevUrlHistory) => {
const newUrlHistory = prevUrlHistory.slice(1);
@@ -106,7 +108,7 @@ function UrlBar({ disabled }: { disabled?: boolean }) {
label: "Go to main screen",
side: "bottom",
}}
- disabled={disabled}>
+ disabled={disabledAlsoWhenStarting}>
>
);