mirror of
https://github.com/fosrl/pangolin.git
synced 2026-02-25 06:16:40 +00:00
invalidate queries on save
This commit is contained in:
@@ -2233,5 +2233,6 @@
|
|||||||
"identifier": "Identifier",
|
"identifier": "Identifier",
|
||||||
"deviceLoginUseDifferentAccount": "Not you? Use a different account.",
|
"deviceLoginUseDifferentAccount": "Not you? Use a different account.",
|
||||||
"deviceLoginDeviceRequestingAccessToAccount": "A device is requesting access to this account.",
|
"deviceLoginDeviceRequestingAccessToAccount": "A device is requesting access to this account.",
|
||||||
"noData": "No Data"
|
"noData": "No Data",
|
||||||
|
"machineClients": "Machine Clients"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -262,7 +262,7 @@ export default function Page() {
|
|||||||
|
|
||||||
if (res && res.status === 201) {
|
if (res && res.status === 201) {
|
||||||
const data = res.data.data;
|
const data = res.data.data;
|
||||||
router.push(`/${orgId}/settings/clients/${data.clientId}`);
|
router.push(`/${orgId}/settings/clients/machine/${data.clientId}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
setCreateLoading(false);
|
setCreateLoading(false);
|
||||||
|
|||||||
@@ -811,7 +811,7 @@ export default function CreateInternalResourceDialog({
|
|||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem className="flex flex-col items-start">
|
<FormItem className="flex flex-col items-start">
|
||||||
<FormLabel>
|
<FormLabel>
|
||||||
{t("clients")}
|
{t("machineClients")}
|
||||||
</FormLabel>
|
</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<TagInput
|
<TagInput
|
||||||
@@ -861,12 +861,6 @@ export default function CreateInternalResourceDialog({
|
|||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
<FormDescription>
|
|
||||||
{t(
|
|
||||||
"resourceClientDescription"
|
|
||||||
) ||
|
|
||||||
"Machine clients that can access this resource"}
|
|
||||||
</FormDescription>
|
|
||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ import { ListClientsResponse } from "@server/routers/client/listClients";
|
|||||||
import { Tag, TagInput } from "@app/components/tags/tag-input";
|
import { Tag, TagInput } from "@app/components/tags/tag-input";
|
||||||
import { AxiosResponse } from "axios";
|
import { AxiosResponse } from "axios";
|
||||||
import { UserType } from "@server/types/UserTypes";
|
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";
|
import { orgQueries, resourceQueries } from "@app/lib/queries";
|
||||||
|
|
||||||
type InternalResourceData = {
|
type InternalResourceData = {
|
||||||
@@ -80,6 +80,7 @@ export default function EditInternalResourceDialog({
|
|||||||
}: EditInternalResourceDialogProps) {
|
}: EditInternalResourceDialogProps) {
|
||||||
const t = useTranslations();
|
const t = useTranslations();
|
||||||
const api = createApiClient(useEnvContext());
|
const api = createApiClient(useEnvContext());
|
||||||
|
const queryClient = useQueryClient();
|
||||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||||
|
|
||||||
const formSchema = z.object({
|
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({
|
toast({
|
||||||
title: t("editInternalResourceDialogSuccess"),
|
title: t("editInternalResourceDialogSuccess"),
|
||||||
description: t(
|
description: t(
|
||||||
@@ -367,6 +378,8 @@ export default function EditInternalResourceDialog({
|
|||||||
users: [],
|
users: [],
|
||||||
clients: []
|
clients: []
|
||||||
});
|
});
|
||||||
|
// Reset initialization flag so form can re-initialize with fresh data when reopened
|
||||||
|
hasInitialized.current = false;
|
||||||
}
|
}
|
||||||
setOpen(open);
|
setOpen(open);
|
||||||
}}
|
}}
|
||||||
@@ -730,7 +743,7 @@ export default function EditInternalResourceDialog({
|
|||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem className="flex flex-col items-start">
|
<FormItem className="flex flex-col items-start">
|
||||||
<FormLabel>
|
<FormLabel>
|
||||||
{t("clients")}
|
{t("machineClients")}
|
||||||
</FormLabel>
|
</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<TagInput
|
<TagInput
|
||||||
@@ -780,12 +793,6 @@ export default function EditInternalResourceDialog({
|
|||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
<FormDescription>
|
|
||||||
{t(
|
|
||||||
"resourceClientDescription"
|
|
||||||
) ||
|
|
||||||
"Machine clients that can access this resource"}
|
|
||||||
</FormDescription>
|
|
||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user