Add check for webSerial & webBluetooth support
This commit is contained in:
@@ -33,6 +33,7 @@ export interface Tab {
|
|||||||
icon: IconType;
|
icon: IconType;
|
||||||
displayName: string;
|
displayName: string;
|
||||||
element: ({ close }: CloseProps) => JSX.Element;
|
element: ({ close }: CloseProps) => JSX.Element;
|
||||||
|
disabled?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const NewDevice = ({ open, onClose }: NewDeviceProps) => {
|
export const NewDevice = ({ open, onClose }: NewDeviceProps) => {
|
||||||
@@ -44,6 +45,7 @@ export const NewDevice = ({ open, onClose }: NewDeviceProps) => {
|
|||||||
icon: FiBluetooth,
|
icon: FiBluetooth,
|
||||||
displayName: "BLE",
|
displayName: "BLE",
|
||||||
element: BLE,
|
element: BLE,
|
||||||
|
disabled: !navigator.bluetooth,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "http",
|
name: "http",
|
||||||
@@ -56,6 +58,7 @@ export const NewDevice = ({ open, onClose }: NewDeviceProps) => {
|
|||||||
icon: FiTerminal,
|
icon: FiTerminal,
|
||||||
displayName: "Serial",
|
displayName: "Serial",
|
||||||
element: Serial,
|
element: Serial,
|
||||||
|
disabled: !navigator.serial,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -84,6 +87,7 @@ export const NewDevice = ({ open, onClose }: NewDeviceProps) => {
|
|||||||
gap={5}
|
gap={5}
|
||||||
isSelected={selectedConnType === TabData.name}
|
isSelected={selectedConnType === TabData.name}
|
||||||
onSelect={() => setSelectedConnType(TabData.name)}
|
onSelect={() => setSelectedConnType(TabData.name)}
|
||||||
|
disabled={TabData.disabled}
|
||||||
>
|
>
|
||||||
<>
|
<>
|
||||||
<TabData.icon />
|
<TabData.icon />
|
||||||
@@ -104,7 +108,7 @@ export const NewDevice = ({ open, onClose }: NewDeviceProps) => {
|
|||||||
flexGrow={1}
|
flexGrow={1}
|
||||||
display={selectedConnType === TabData.name ? "block" : "none"}
|
display={selectedConnType === TabData.name ? "block" : "none"}
|
||||||
>
|
>
|
||||||
<TabData.element close={onClose} />
|
{!TabData.disabled && <TabData.element close={onClose} />}
|
||||||
</Pane>
|
</Pane>
|
||||||
))}
|
))}
|
||||||
</Pane>
|
</Pane>
|
||||||
|
|||||||
Reference in New Issue
Block a user