mirror of
https://github.com/fosrl/pangolin.git
synced 2026-01-29 06:10:47 +00:00
invalidate queries on save
This commit is contained in:
@@ -262,7 +262,7 @@ export default function Page() {
|
||||
|
||||
if (res && res.status === 201) {
|
||||
const data = res.data.data;
|
||||
router.push(`/${orgId}/settings/clients/${data.clientId}`);
|
||||
router.push(`/${orgId}/settings/clients/machine/${data.clientId}`);
|
||||
}
|
||||
|
||||
setCreateLoading(false);
|
||||
|
||||
@@ -528,7 +528,7 @@ export default function CreateInternalResourceDialog({
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
{/*
|
||||
{/*
|
||||
{mode === "port" && (
|
||||
<>
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
@@ -811,7 +811,7 @@ export default function CreateInternalResourceDialog({
|
||||
render={({ field }) => (
|
||||
<FormItem className="flex flex-col items-start">
|
||||
<FormLabel>
|
||||
{t("clients")}
|
||||
{t("machineClients")}
|
||||
</FormLabel>
|
||||
<FormControl>
|
||||
<TagInput
|
||||
@@ -861,12 +861,6 @@ export default function CreateInternalResourceDialog({
|
||||
/>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
<FormDescription>
|
||||
{t(
|
||||
"resourceClientDescription"
|
||||
) ||
|
||||
"Machine clients that can access this resource"}
|
||||
</FormDescription>
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
@@ -45,7 +45,7 @@ import { ListClientsResponse } from "@server/routers/client/listClients";
|
||||
import { Tag, TagInput } from "@app/components/tags/tag-input";
|
||||
import { AxiosResponse } from "axios";
|
||||
import { UserType } from "@server/types/UserTypes";
|
||||
import { useQueries, useQuery } from "@tanstack/react-query";
|
||||
import { useQueries, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { orgQueries, resourceQueries } from "@app/lib/queries";
|
||||
|
||||
type InternalResourceData = {
|
||||
@@ -80,6 +80,7 @@ export default function EditInternalResourceDialog({
|
||||
}: EditInternalResourceDialogProps) {
|
||||
const t = useTranslations();
|
||||
const api = createApiClient(useEnvContext());
|
||||
const queryClient = useQueryClient();
|
||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||
|
||||
const formSchema = z.object({
|
||||
@@ -310,6 +311,16 @@ export default function EditInternalResourceDialog({
|
||||
// })
|
||||
// ]);
|
||||
|
||||
await queryClient.invalidateQueries(
|
||||
resourceQueries.resourceRoles({ resourceId: resource.id })
|
||||
);
|
||||
await queryClient.invalidateQueries(
|
||||
resourceQueries.resourceUsers({ resourceId: resource.id })
|
||||
);
|
||||
await queryClient.invalidateQueries(
|
||||
resourceQueries.resourceClients({ resourceId: resource.id })
|
||||
);
|
||||
|
||||
toast({
|
||||
title: t("editInternalResourceDialogSuccess"),
|
||||
description: t(
|
||||
@@ -367,6 +378,8 @@ export default function EditInternalResourceDialog({
|
||||
users: [],
|
||||
clients: []
|
||||
});
|
||||
// Reset initialization flag so form can re-initialize with fresh data when reopened
|
||||
hasInitialized.current = false;
|
||||
}
|
||||
setOpen(open);
|
||||
}}
|
||||
@@ -730,7 +743,7 @@ export default function EditInternalResourceDialog({
|
||||
render={({ field }) => (
|
||||
<FormItem className="flex flex-col items-start">
|
||||
<FormLabel>
|
||||
{t("clients")}
|
||||
{t("machineClients")}
|
||||
</FormLabel>
|
||||
<FormControl>
|
||||
<TagInput
|
||||
@@ -780,12 +793,6 @@ export default function EditInternalResourceDialog({
|
||||
/>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
<FormDescription>
|
||||
{t(
|
||||
"resourceClientDescription"
|
||||
) ||
|
||||
"Machine clients that can access this resource"}
|
||||
</FormDescription>
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user