mirror of
https://github.com/shankar0123/certctl.git
synced 2026-06-07 18:01:37 +00:00
Merge fix/M-029-pass1-batch4: 5 three-mutation pages migrated
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
|
import { useQuery, useQueryClient } from '@tanstack/react-query';
|
||||||
|
import { useTrackedMutation } from '../hooks/useTrackedMutation';
|
||||||
import { getOwners, getTeams, deleteOwner, createOwner, updateOwner } from '../api/client';
|
import { getOwners, getTeams, deleteOwner, createOwner, updateOwner } from '../api/client';
|
||||||
import PageHeader from '../components/PageHeader';
|
import PageHeader from '../components/PageHeader';
|
||||||
import DataTable from '../components/DataTable';
|
import DataTable from '../components/DataTable';
|
||||||
@@ -210,24 +211,24 @@ export default function OwnersPage() {
|
|||||||
queryFn: () => getTeams(),
|
queryFn: () => getTeams(),
|
||||||
});
|
});
|
||||||
|
|
||||||
const deleteMutation = useMutation({
|
const deleteMutation = useTrackedMutation({
|
||||||
mutationFn: deleteOwner,
|
mutationFn: deleteOwner,
|
||||||
onSuccess: () => queryClient.invalidateQueries({ queryKey: ['owners'] }),
|
invalidates: [['owners']],
|
||||||
onError: (err: Error) => alert(`Delete failed: ${err.message}`),
|
onError: (err: Error) => alert(`Delete failed: ${err.message}`),
|
||||||
});
|
});
|
||||||
|
|
||||||
const createMutation = useMutation({
|
const createMutation = useTrackedMutation({
|
||||||
mutationFn: createOwner,
|
mutationFn: createOwner,
|
||||||
|
invalidates: [['owners']],
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
queryClient.invalidateQueries({ queryKey: ['owners'] });
|
|
||||||
setShowCreate(false);
|
setShowCreate(false);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const updateMutation = useMutation({
|
const updateMutation = useTrackedMutation({
|
||||||
mutationFn: ({ id, data }: { id: string; data: Partial<Owner> }) => updateOwner(id, data),
|
mutationFn: ({ id, data }: { id: string; data: Partial<Owner> }) => updateOwner(id, data),
|
||||||
|
invalidates: [['owners']],
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
queryClient.invalidateQueries({ queryKey: ['owners'] });
|
|
||||||
setEditingOwner(null);
|
setEditingOwner(null);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
|
import { useQuery, useQueryClient } from '@tanstack/react-query';
|
||||||
|
import { useTrackedMutation } from '../hooks/useTrackedMutation';
|
||||||
import { getPolicies, updatePolicy, deletePolicy, createPolicy } from '../api/client';
|
import { getPolicies, updatePolicy, deletePolicy, createPolicy } from '../api/client';
|
||||||
import PageHeader from '../components/PageHeader';
|
import PageHeader from '../components/PageHeader';
|
||||||
import DataTable from '../components/DataTable';
|
import DataTable from '../components/DataTable';
|
||||||
@@ -161,20 +162,20 @@ export default function PoliciesPage() {
|
|||||||
queryFn: () => getPolicies(),
|
queryFn: () => getPolicies(),
|
||||||
});
|
});
|
||||||
|
|
||||||
const toggleMutation = useMutation({
|
const toggleMutation = useTrackedMutation({
|
||||||
mutationFn: ({ id, enabled }: { id: string; enabled: boolean }) => updatePolicy(id, { enabled }),
|
mutationFn: ({ id, enabled }: { id: string; enabled: boolean }) => updatePolicy(id, { enabled }),
|
||||||
onSuccess: () => queryClient.invalidateQueries({ queryKey: ['policies'] }),
|
invalidates: [['policies']],
|
||||||
});
|
});
|
||||||
|
|
||||||
const deleteMutation = useMutation({
|
const deleteMutation = useTrackedMutation({
|
||||||
mutationFn: deletePolicy,
|
mutationFn: deletePolicy,
|
||||||
onSuccess: () => queryClient.invalidateQueries({ queryKey: ['policies'] }),
|
invalidates: [['policies']],
|
||||||
});
|
});
|
||||||
|
|
||||||
const createMutation = useMutation({
|
const createMutation = useTrackedMutation({
|
||||||
mutationFn: createPolicy,
|
mutationFn: createPolicy,
|
||||||
|
invalidates: [['policies']],
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
queryClient.invalidateQueries({ queryKey: ['policies'] });
|
|
||||||
setShowCreate(false);
|
setShowCreate(false);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
|
import { useQuery, useQueryClient } from '@tanstack/react-query';
|
||||||
|
import { useTrackedMutation } from '../hooks/useTrackedMutation';
|
||||||
import { getProfiles, deleteProfile, createProfile, updateProfile } from '../api/client';
|
import { getProfiles, deleteProfile, createProfile, updateProfile } from '../api/client';
|
||||||
import PageHeader from '../components/PageHeader';
|
import PageHeader from '../components/PageHeader';
|
||||||
import DataTable from '../components/DataTable';
|
import DataTable from '../components/DataTable';
|
||||||
@@ -300,23 +301,23 @@ export default function ProfilesPage() {
|
|||||||
queryFn: () => getProfiles(),
|
queryFn: () => getProfiles(),
|
||||||
});
|
});
|
||||||
|
|
||||||
const deleteMutation = useMutation({
|
const deleteMutation = useTrackedMutation({
|
||||||
mutationFn: deleteProfile,
|
mutationFn: deleteProfile,
|
||||||
onSuccess: () => queryClient.invalidateQueries({ queryKey: ['profiles'] }),
|
invalidates: [['profiles']],
|
||||||
});
|
});
|
||||||
|
|
||||||
const createMutation = useMutation({
|
const createMutation = useTrackedMutation({
|
||||||
mutationFn: createProfile,
|
mutationFn: createProfile,
|
||||||
|
invalidates: [['profiles']],
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
queryClient.invalidateQueries({ queryKey: ['profiles'] });
|
|
||||||
setShowCreate(false);
|
setShowCreate(false);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const updateMutation = useMutation({
|
const updateMutation = useTrackedMutation({
|
||||||
mutationFn: ({ id, data }: { id: string; data: Partial<CertificateProfile> }) => updateProfile(id, data),
|
mutationFn: ({ id, data }: { id: string; data: Partial<CertificateProfile> }) => updateProfile(id, data),
|
||||||
|
invalidates: [['profiles']],
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
queryClient.invalidateQueries({ queryKey: ['profiles'] });
|
|
||||||
setEditingProfile(null);
|
setEditingProfile(null);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
|
import { useQuery } from '@tanstack/react-query';
|
||||||
|
import { useTrackedMutation } from '../hooks/useTrackedMutation';
|
||||||
import {
|
import {
|
||||||
getRenewalPolicies,
|
getRenewalPolicies,
|
||||||
createRenewalPolicy,
|
createRenewalPolicy,
|
||||||
@@ -174,7 +175,6 @@ function PolicyFormModal({ title, initial, isOpen, onClose, onSubmit, isSaving,
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function RenewalPoliciesPage() {
|
export default function RenewalPoliciesPage() {
|
||||||
const queryClient = useQueryClient();
|
|
||||||
const [showCreate, setShowCreate] = useState(false);
|
const [showCreate, setShowCreate] = useState(false);
|
||||||
const [editing, setEditing] = useState<RenewalPolicy | null>(null);
|
const [editing, setEditing] = useState<RenewalPolicy | null>(null);
|
||||||
|
|
||||||
@@ -183,25 +183,25 @@ export default function RenewalPoliciesPage() {
|
|||||||
queryFn: () => getRenewalPolicies(),
|
queryFn: () => getRenewalPolicies(),
|
||||||
});
|
});
|
||||||
|
|
||||||
const createMutation = useMutation({
|
const createMutation = useTrackedMutation({
|
||||||
mutationFn: createRenewalPolicy,
|
mutationFn: createRenewalPolicy,
|
||||||
|
invalidates: [['renewal-policies']],
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
queryClient.invalidateQueries({ queryKey: ['renewal-policies'] });
|
|
||||||
setShowCreate(false);
|
setShowCreate(false);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const updateMutation = useMutation({
|
const updateMutation = useTrackedMutation({
|
||||||
mutationFn: ({ id, data }: { id: string; data: Partial<RenewalPolicy> }) => updateRenewalPolicy(id, data),
|
mutationFn: ({ id, data }: { id: string; data: Partial<RenewalPolicy> }) => updateRenewalPolicy(id, data),
|
||||||
|
invalidates: [['renewal-policies']],
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
queryClient.invalidateQueries({ queryKey: ['renewal-policies'] });
|
|
||||||
setEditing(null);
|
setEditing(null);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const deleteMutation = useMutation({
|
const deleteMutation = useTrackedMutation({
|
||||||
mutationFn: deleteRenewalPolicy,
|
mutationFn: deleteRenewalPolicy,
|
||||||
onSuccess: () => queryClient.invalidateQueries({ queryKey: ['renewal-policies'] }),
|
invalidates: [['renewal-policies']],
|
||||||
// Backend surfaces ErrRenewalPolicyInUse as a 409. We surface as an
|
// Backend surfaces ErrRenewalPolicyInUse as a 409. We surface as an
|
||||||
// alert so the operator sees "this policy is still attached to N
|
// alert so the operator sees "this policy is still attached to N
|
||||||
// certificates" and can re-target those certs to another policy
|
// certificates" and can re-target those certs to another policy
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
|
import { useQuery, useQueryClient } from '@tanstack/react-query';
|
||||||
|
import { useTrackedMutation } from '../hooks/useTrackedMutation';
|
||||||
import { getTeams, deleteTeam, createTeam, updateTeam } from '../api/client';
|
import { getTeams, deleteTeam, createTeam, updateTeam } from '../api/client';
|
||||||
import PageHeader from '../components/PageHeader';
|
import PageHeader from '../components/PageHeader';
|
||||||
import DataTable from '../components/DataTable';
|
import DataTable from '../components/DataTable';
|
||||||
@@ -152,24 +153,24 @@ export default function TeamsPage() {
|
|||||||
queryFn: () => getTeams(),
|
queryFn: () => getTeams(),
|
||||||
});
|
});
|
||||||
|
|
||||||
const deleteMutation = useMutation({
|
const deleteMutation = useTrackedMutation({
|
||||||
mutationFn: deleteTeam,
|
mutationFn: deleteTeam,
|
||||||
onSuccess: () => queryClient.invalidateQueries({ queryKey: ['teams'] }),
|
invalidates: [['teams']],
|
||||||
onError: (err: Error) => alert(`Delete failed: ${err.message}`),
|
onError: (err: Error) => alert(`Delete failed: ${err.message}`),
|
||||||
});
|
});
|
||||||
|
|
||||||
const createMutation = useMutation({
|
const createMutation = useTrackedMutation({
|
||||||
mutationFn: createTeam,
|
mutationFn: createTeam,
|
||||||
|
invalidates: [['teams']],
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
queryClient.invalidateQueries({ queryKey: ['teams'] });
|
|
||||||
setShowCreate(false);
|
setShowCreate(false);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const updateMutation = useMutation({
|
const updateMutation = useTrackedMutation({
|
||||||
mutationFn: ({ id, data }: { id: string; data: Partial<Team> }) => updateTeam(id, data),
|
mutationFn: ({ id, data }: { id: string; data: Partial<Team> }) => updateTeam(id, data),
|
||||||
|
invalidates: [['teams']],
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
queryClient.invalidateQueries({ queryKey: ['teams'] });
|
|
||||||
setEditingTeam(null);
|
setEditingTeam(null);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user