use approp dialog menus

This commit is contained in:
mbecker20
2024-06-08 04:12:55 -07:00
parent 914f4c6197
commit ad168c87f7
2 changed files with 13 additions and 20 deletions

View File

@@ -1,8 +1,8 @@
import { ConfirmButton } from "@components/util";
import { ActionWithDialog } from "@components/util";
import { useExecute, useRead } from "@lib/hooks";
import { RequiredResourceComponents } from "@types";
import { Card, CardHeader } from "@ui/card";
import { Loader2, Route } from "lucide-react";
import { Route } from "lucide-react";
import { ProcedureConfig } from "./config";
import { ProcedureTable } from "./table";
import { DeleteResource, NewResource } from "../common";
@@ -57,18 +57,16 @@ export const ProcedureComponents: RequiredResourceComponents = {
{ refetchInterval: 5000 }
).data?.running;
const { mutate, isPending } = useExecute("RunProcedure");
const procedure = useProcedure(id);
if (!procedure) return null;
return (
<ConfirmButton
<ActionWithDialog
name={procedure.name}
title={running ? "Running" : "Run"}
icon={
running ? (
<Loader2 className="w-4 h-4 animate-spin" />
) : (
<Route className="h-4 w-4" />
)
}
icon={<Route className="h-4 w-4" />}
onClick={() => mutate({ procedure: id })}
disabled={running || isPending}
loading={running}
/>
);
},

View File

@@ -1,4 +1,4 @@
import { ConfirmButton } from "@components/util";
import { ActionButton, ActionWithDialog } from "@components/util";
import { useExecute, useInvalidate, useRead, useWrite } from "@lib/hooks";
import { sync_no_changes } from "@lib/utils";
import { Loader2, RefreshCcw, SquarePlay } from "lucide-react";
@@ -10,7 +10,7 @@ export const RefreshSync = ({ id }: { id: string }) => {
});
const pending = isPending;
return (
<ConfirmButton
<ActionButton
title="Refresh"
icon={
pending ? (
@@ -40,15 +40,10 @@ export const ExecuteSync = ({ id }: { id: string }) => {
const pending = isPending || syncing;
return (
<ConfirmButton
<ActionWithDialog
name={sync.name}
title="Execute Sync"
icon={
pending ? (
<Loader2 className="w-4 h-4 animate-spin" />
) : (
<SquarePlay className="w-4 h-4" />
)
}
icon={<SquarePlay className="w-4 h-4" />}
onClick={() => mutate({ sync: id })}
disabled={pending}
loading={pending}