Move remove button to quick options
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import { toast } from "@app/core/hooks/useToast";
|
import { toast } from "@app/core/hooks/useToast";
|
||||||
|
import { useAppStore } from "@app/core/stores/appStore";
|
||||||
import { useDevice } from "@app/core/stores/deviceStore";
|
import { useDevice } from "@app/core/stores/deviceStore";
|
||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
@@ -8,6 +9,7 @@ import {
|
|||||||
} from "@components/UI/Dialog";
|
} from "@components/UI/Dialog";
|
||||||
import type { Protobuf } from "@meshtastic/js";
|
import type { Protobuf } from "@meshtastic/js";
|
||||||
import { numberToHexUnpadded } from "@noble/curves/abstract/utils";
|
import { numberToHexUnpadded } from "@noble/curves/abstract/utils";
|
||||||
|
import { TrashIcon } from "lucide-react";
|
||||||
import type { JSX } from "react";
|
import type { JSX } from "react";
|
||||||
import { Button } from "../UI/Button";
|
import { Button } from "../UI/Button";
|
||||||
|
|
||||||
@@ -22,7 +24,8 @@ export const NodeOptionsDialog = ({
|
|||||||
open,
|
open,
|
||||||
onOpenChange,
|
onOpenChange,
|
||||||
}: NodeOptionsDialogProps): JSX.Element => {
|
}: NodeOptionsDialogProps): JSX.Element => {
|
||||||
const { connection } = useDevice();
|
const { setDialogOpen, connection } = useDevice();
|
||||||
|
const { setNodeNumToBeRemoved } = useAppStore();
|
||||||
const longName =
|
const longName =
|
||||||
node?.user?.longName ??
|
node?.user?.longName ??
|
||||||
(node ? `!${numberToHexUnpadded(node?.num)}` : "Unknown");
|
(node ? `!${numberToHexUnpadded(node?.num)}` : "Unknown");
|
||||||
@@ -30,19 +33,6 @@ export const NodeOptionsDialog = ({
|
|||||||
node?.user?.shortName ??
|
node?.user?.shortName ??
|
||||||
(node ? `${numberToHexUnpadded(node?.num).substring(0, 4)}` : "UNK");
|
(node ? `${numberToHexUnpadded(node?.num).substring(0, 4)}` : "UNK");
|
||||||
|
|
||||||
function handleTraceroute() {
|
|
||||||
if (!node) return;
|
|
||||||
toast({
|
|
||||||
title: "Sending Traceroute, please wait...",
|
|
||||||
});
|
|
||||||
connection?.traceRoute(node.num).then(() =>
|
|
||||||
toast({
|
|
||||||
title: "Traceroute sent.",
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
onOpenChange();
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleRequestPosition() {
|
function handleRequestPosition() {
|
||||||
if (!node) return;
|
if (!node) return;
|
||||||
toast({
|
toast({
|
||||||
@@ -56,6 +46,19 @@ export const NodeOptionsDialog = ({
|
|||||||
onOpenChange();
|
onOpenChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleTraceroute() {
|
||||||
|
if (!node) return;
|
||||||
|
toast({
|
||||||
|
title: "Sending Traceroute, please wait...",
|
||||||
|
});
|
||||||
|
connection?.traceRoute(node.num).then(() =>
|
||||||
|
toast({
|
||||||
|
title: "Traceroute sent.",
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
onOpenChange();
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||||
<DialogContent>
|
<DialogContent>
|
||||||
@@ -63,11 +66,24 @@ export const NodeOptionsDialog = ({
|
|||||||
<DialogTitle>{`${longName} (${shortName})`}</DialogTitle>
|
<DialogTitle>{`${longName} (${shortName})`}</DialogTitle>
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
<div className="flex flex-col space-y-1">
|
<div className="flex flex-col space-y-1">
|
||||||
|
<div>
|
||||||
|
<Button onClick={handleRequestPosition}>Request Position</Button>
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<Button onClick={handleTraceroute}>Trace Route</Button>
|
<Button onClick={handleTraceroute}>Trace Route</Button>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<Button onClick={handleRequestPosition}>Request Position</Button>
|
<Button
|
||||||
|
key="remove"
|
||||||
|
variant="destructive"
|
||||||
|
onClick={() => {
|
||||||
|
setNodeNumToBeRemoved(node.num);
|
||||||
|
setDialogOpen("nodeRemoval", true);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<TrashIcon />
|
||||||
|
Remove
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
|
|||||||
+5
-13
@@ -62,7 +62,6 @@ const NodesPage = (): JSX.Element => {
|
|||||||
{ title: "SNR", type: "normal", sortable: true },
|
{ title: "SNR", type: "normal", sortable: true },
|
||||||
{ title: "Encryption", type: "normal", sortable: false },
|
{ title: "Encryption", type: "normal", sortable: false },
|
||||||
{ title: "Connection", type: "normal", sortable: true },
|
{ title: "Connection", type: "normal", sortable: true },
|
||||||
{ title: "Remove", type: "normal", sortable: false },
|
|
||||||
]}
|
]}
|
||||||
rows={filteredNodes.map((node) => [
|
rows={filteredNodes.map((node) => [
|
||||||
<span
|
<span
|
||||||
@@ -70,7 +69,11 @@ const NodesPage = (): JSX.Element => {
|
|||||||
className="h-3 w-3 rounded-full bg-accent"
|
className="h-3 w-3 rounded-full bg-accent"
|
||||||
/>,
|
/>,
|
||||||
|
|
||||||
<h1 key="header" onMouseDown={() => setSelectedNode(node)}>
|
<h1
|
||||||
|
key="header"
|
||||||
|
onMouseDown={() => setSelectedNode(node)}
|
||||||
|
className="cursor-pointer"
|
||||||
|
>
|
||||||
{node.user?.longName ??
|
{node.user?.longName ??
|
||||||
(node.user?.macaddr
|
(node.user?.macaddr
|
||||||
? `Meshtastic ${base16
|
? `Meshtastic ${base16
|
||||||
@@ -117,17 +120,6 @@ const NodesPage = (): JSX.Element => {
|
|||||||
: "-"}
|
: "-"}
|
||||||
{node.viaMqtt === true ? ", via MQTT" : ""}
|
{node.viaMqtt === true ? ", via MQTT" : ""}
|
||||||
</Mono>,
|
</Mono>,
|
||||||
<Button
|
|
||||||
key="remove"
|
|
||||||
variant="destructive"
|
|
||||||
onClick={() => {
|
|
||||||
setNodeNumToBeRemoved(node.num);
|
|
||||||
setDialogOpen("nodeRemoval", true);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<TrashIcon />
|
|
||||||
Remove
|
|
||||||
</Button>,
|
|
||||||
])}
|
])}
|
||||||
/>
|
/>
|
||||||
<NodeOptionsDialog
|
<NodeOptionsDialog
|
||||||
|
|||||||
Reference in New Issue
Block a user