Skip to content

Commit

Permalink
refresh environment on save
Browse files Browse the repository at this point in the history
  • Loading branch information
ucarion committed May 6, 2024
1 parent f79c803 commit 9bef06d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 1,2 @@
/node_modules
/app/.idea
13 changes: 12 additions & 1 deletion app/src/pages/ViewEnvironmentPage.tsx
Original file line number Diff line number Diff line change
@@ -1,6 1,10 @@
import React, { useCallback, useState } from "react";
import { useParams } from "react-router";
import { useMutation, useQuery } from "@connectrpc/connect-query";
import {
createConnectQueryKey,
useMutation,
useQuery,
} from "@connectrpc/connect-query";
import {
getEnvironment,
listOrganizations,
Expand Down Expand Up @@ -49,6 53,7 @@ import {
FormMessage,
} from "@/components/ui/form";
import { Input } from "@/components/ui/input";
import { useQueryClient } from "@tanstack/react-query";

export function ViewEnvironmentPage() {
const { environmentId } = useParams();
Expand Down Expand Up @@ -162,6 167,7 @@ function EditEnvironmentAlertDialog({

const [open, setOpen] = useState(false);
const updateEnvironmentMutation = useMutation(updateEnvironment);
const queryClient = useQueryClient();
const handleSubmit = useCallback(
async (values: z.infer<typeof FormSchema>, e: any) => {
e.preventDefault();
Expand All @@ -172,6 178,11 @@ function EditEnvironmentAlertDialog({
redirectUrl: values.redirectUrl,
},
});

await queryClient.invalidateQueries({
queryKey: createConnectQueryKey(getEnvironment, { id: environment.id }),
});

setOpen(false);
},
[setOpen, environment, updateEnvironmentMutation],
Expand Down

0 comments on commit 9bef06d

Please sign in to comment.