feat(web): show patch policy coverage on servers and open the run after Apply updates
This commit is contained in:
@@ -130,7 +130,13 @@ export default function ServerDetailPage() {
|
||||
|
||||
const { mutate: applyUpdates, isPending: isApplying } = useMutation({
|
||||
mutationFn: () => api.applyUpdates(serverId),
|
||||
onSuccess: () => toast.success("Update command sent. Patching runs in the background and may take several minutes."),
|
||||
onSuccess: (res) => {
|
||||
if (res.run_id) {
|
||||
router.push(`/patching/runs/${res.run_id}`);
|
||||
} else {
|
||||
toast.success("Update command sent.");
|
||||
}
|
||||
},
|
||||
onError: toast.error,
|
||||
});
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
import { useMemo, useState } from "react";
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { api, vulnerabilities, type FindingState, type Severity, type VulnFinding } from "@/lib/api";
|
||||
import { useAuth } from "@/components/AuthProvider";
|
||||
import { Button, Card, Pagination, usePagination, useToast } from "@/components/ui";
|
||||
@@ -42,6 +43,7 @@ const FIX_FILTERS: { key: string; label: string; hasFix: boolean | undefined }[]
|
||||
export default function VulnerabilitiesPage() {
|
||||
const { isAdmin } = useAuth();
|
||||
const qc = useQueryClient();
|
||||
const router = useRouter();
|
||||
|
||||
const [state, setState] = useState<FindingState>("open");
|
||||
const [severity, setSeverity] = useState<Severity | "">("");
|
||||
@@ -112,10 +114,10 @@ export default function VulnerabilitiesPage() {
|
||||
});
|
||||
|
||||
const applyUpdates = useMutation({
|
||||
mutationFn: (serverId: string) => api.applyUpdates(serverId),
|
||||
// This one had no feedback of any kind: the button dispatched a patch
|
||||
// run to a whole server and the page did not change in any way.
|
||||
onSuccess: (_data, serverId) => toast.success(`Update command sent to ${serverName(serverId)}.`),
|
||||
mutationFn: (serverId: string) => api.applyUpdates(serverId, "vulnerabilities"),
|
||||
onSuccess: (res) => {
|
||||
if (res.run_id) router.push(`/patching/runs/${res.run_id}`);
|
||||
},
|
||||
onError: toast.error,
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user