Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use renamed functions in place of raw useApiMutation object #2420

Merged
merged 2 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/pages/system/SiloImagesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export function SiloImagesPage() {
const [demoteImage, setDemoteImage] = useState<Image | null>(null)

const queryClient = useApiQueryClient()
const deleteImage = useApiMutation('imageDelete', {
const { mutateAsync: deleteImage } = useApiMutation('imageDelete', {
onSuccess(_data, variables) {
addToast({ content: `${variables.path.image} has been deleted` })
queryClient.invalidateQueries('imageList')
Expand All @@ -86,7 +86,7 @@ export function SiloImagesPage() {
{
label: 'Delete',
onActivate: confirmDelete({
doDelete: () => deleteImage.mutateAsync({ path: { image: image.name } }),
doDelete: () => deleteImage({ path: { image: image.name } }),
label: image.name,
}),
},
Expand Down
8 changes: 4 additions & 4 deletions app/pages/system/networking/IpPoolPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ function IpRangesTable() {
const { Table } = useQueryTable('ipPoolRangeList', { path: { pool } })
const queryClient = useApiQueryClient()

const removeRange = useApiMutation('ipPoolRangeRemove', {
const { mutateAsync: removeRange } = useApiMutation('ipPoolRangeRemove', {
onSuccess() {
queryClient.invalidateQueries('ipPoolRangeList')
queryClient.invalidateQueries('ipPoolUtilizationView')
Expand All @@ -213,7 +213,7 @@ function IpRangesTable() {
onActivate: () =>
confirmAction({
doAction: () =>
removeRange.mutateAsync({
removeRange({
path: { pool },
body: range,
}),
Expand Down Expand Up @@ -281,7 +281,7 @@ function LinkedSilosTable() {
const queryClient = useApiQueryClient()
const { Table } = useQueryTable('ipPoolSiloList', { path: poolSelector })

const unlinkSilo = useApiMutation('ipPoolSiloUnlink', {
const { mutateAsync: unlinkSilo } = useApiMutation('ipPoolSiloUnlink', {
onSuccess() {
queryClient.invalidateQueries('ipPoolSiloList')
},
Expand All @@ -295,7 +295,7 @@ function LinkedSilosTable() {
onActivate() {
confirmAction({
doAction: () =>
unlinkSilo.mutateAsync({ path: { silo: link.siloId, pool: link.ipPoolId } }),
unlinkSilo({ path: { silo: link.siloId, pool: link.ipPoolId } }),
modalTitle: 'Confirm unlink silo',
// Would be nice to reference the silo by name like we reference the
// pool by name on unlink in the silo pools list, but it's a pain to
Expand Down
4 changes: 2 additions & 2 deletions app/pages/system/networking/IpPoolsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export function IpPoolsPage() {
query: { limit: PAGE_SIZE },
})

const deletePool = useApiMutation('ipPoolDelete', {
const { mutateAsync: deletePool } = useApiMutation('ipPoolDelete', {
onSuccess() {
apiQueryClient.invalidateQueries('ipPoolList')
addToast({ content: 'IP pool deleted' })
Expand All @@ -98,7 +98,7 @@ export function IpPoolsPage() {
{
label: 'Delete',
onActivate: confirmDelete({
doDelete: () => deletePool.mutateAsync({ path: { pool: pool.name } }),
doDelete: () => deletePool({ path: { pool: pool.name } }),
label: pool.name,
}),
},
Expand Down
10 changes: 5 additions & 5 deletions app/pages/system/silos/SiloIpPoolsTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ export function SiloIpPoolsTab() {
[allPools]
)

const updatePoolLink = useApiMutation('ipPoolSiloUpdate', {
const { mutateAsync: updatePoolLink } = useApiMutation('ipPoolSiloUpdate', {
onSuccess() {
queryClient.invalidateQueries('siloIpPoolList')
},
})
const unlinkPool = useApiMutation('ipPoolSiloUnlink', {
const { mutateAsync: unlinkPool } = useApiMutation('ipPoolSiloUnlink', {
onSuccess() {
queryClient.invalidateQueries('siloIpPoolList')
},
Expand All @@ -91,7 +91,7 @@ export function SiloIpPoolsTab() {
if (pool.isDefault) {
confirmAction({
doAction: () =>
updatePoolLink.mutateAsync({
updatePoolLink({
path: { silo, pool: pool.id },
body: { isDefault: false },
}),
Expand Down Expand Up @@ -121,7 +121,7 @@ export function SiloIpPoolsTab() {
const verb = defaultPool ? 'change' : 'make'
confirmAction({
doAction: () =>
updatePoolLink.mutateAsync({
updatePoolLink({
path: { silo, pool: pool.id },
body: { isDefault: true },
}),
Expand All @@ -138,7 +138,7 @@ export function SiloIpPoolsTab() {
className: 'destructive',
onActivate() {
confirmAction({
doAction: () => unlinkPool.mutateAsync({ path: { silo, pool: pool.id } }),
doAction: () => unlinkPool({ path: { silo, pool: pool.id } }),
modalTitle: `Confirm unlink pool`,
modalContent: (
<p>
Expand Down
4 changes: 2 additions & 2 deletions app/pages/system/silos/SilosPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export function SilosPage() {
query: { limit: PAGE_SIZE },
})

const deleteSilo = useApiMutation('siloDelete', {
const { mutateAsync: deleteSilo } = useApiMutation('siloDelete', {
onSuccess() {
queryClient.invalidateQueries('siloList')
},
Expand All @@ -86,7 +86,7 @@ export function SilosPage() {
{
label: 'Delete',
onActivate: confirmDelete({
doDelete: () => deleteSilo.mutateAsync({ path: { silo: silo.name } }),
doDelete: () => deleteSilo({ path: { silo: silo.name } }),
label: silo.name,
}),
},
Expand Down
Loading