Skip to content

Commit 81ee8f6

Browse files
committed
feat: add state management for dialog visibility in MariaDB, MySQL, and Redis update components
1 parent 9507745 commit 81ee8f6

3 files changed

Lines changed: 12 additions & 6 deletions

File tree

apps/dokploy/components/dashboard/mariadb/update-mariadb.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { standardSchemaResolver as zodResolver } from "@hookform/resolvers/standard-schema";
22
import { PenBoxIcon } from "lucide-react";
3-
import { useEffect } from "react";
3+
import { useEffect, useState } from "react";
44
import { useForm } from "react-hook-form";
55
import { toast } from "sonner";
66
import { z } from "zod";
@@ -41,6 +41,7 @@ interface Props {
4141
}
4242

4343
export const UpdateMariadb = ({ mariadbId }: Props) => {
44+
const [isOpen, setIsOpen] = useState(false);
4445
const utils = api.useUtils();
4546
const { mutateAsync, error, isError, isPending } =
4647
api.mariadb.update.useMutation();
@@ -79,6 +80,7 @@ export const UpdateMariadb = ({ mariadbId }: Props) => {
7980
utils.mariadb.one.invalidate({
8081
mariadbId: mariadbId,
8182
});
83+
setIsOpen(false);
8284
})
8385
.catch(() => {
8486
toast.error("Error updating the Mariadb");
@@ -87,7 +89,7 @@ export const UpdateMariadb = ({ mariadbId }: Props) => {
8789
};
8890

8991
return (
90-
<Dialog>
92+
<Dialog open={isOpen} onOpenChange={setIsOpen}>
9193
<DialogTrigger asChild>
9294
<Button
9395
variant="ghost"

apps/dokploy/components/dashboard/mysql/update-mysql.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { standardSchemaResolver as zodResolver } from "@hookform/resolvers/standard-schema";
22
import { PenBoxIcon } from "lucide-react";
3-
import { useEffect } from "react";
3+
import { useEffect, useState } from "react";
44
import { useForm } from "react-hook-form";
55
import { toast } from "sonner";
66
import { z } from "zod";
@@ -41,6 +41,7 @@ interface Props {
4141
}
4242

4343
export const UpdateMysql = ({ mysqlId }: Props) => {
44+
const [isOpen, setIsOpen] = useState(false);
4445
const utils = api.useUtils();
4546
const { mutateAsync, error, isError, isPending } =
4647
api.mysql.update.useMutation();
@@ -79,6 +80,7 @@ export const UpdateMysql = ({ mysqlId }: Props) => {
7980
utils.mysql.one.invalidate({
8081
mysqlId: mysqlId,
8182
});
83+
setIsOpen(false);
8284
})
8385
.catch(() => {
8486
toast.error("Error updating MySQL");
@@ -87,7 +89,7 @@ export const UpdateMysql = ({ mysqlId }: Props) => {
8789
};
8890

8991
return (
90-
<Dialog>
92+
<Dialog open={isOpen} onOpenChange={setIsOpen}>
9193
<DialogTrigger asChild>
9294
<Button
9395
variant="ghost"

apps/dokploy/components/dashboard/redis/update-redis.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { standardSchemaResolver as zodResolver } from "@hookform/resolvers/standard-schema";
22
import { PenBoxIcon } from "lucide-react";
3-
import { useEffect } from "react";
3+
import { useEffect, useState } from "react";
44
import { useForm } from "react-hook-form";
55
import { toast } from "sonner";
66
import { z } from "zod";
@@ -41,6 +41,7 @@ interface Props {
4141
}
4242

4343
export const UpdateRedis = ({ redisId }: Props) => {
44+
const [isOpen, setIsOpen] = useState(false);
4445
const utils = api.useUtils();
4546
const { mutateAsync, error, isError, isPending } =
4647
api.redis.update.useMutation();
@@ -79,6 +80,7 @@ export const UpdateRedis = ({ redisId }: Props) => {
7980
utils.redis.one.invalidate({
8081
redisId: redisId,
8182
});
83+
setIsOpen(false);
8284
})
8385
.catch(() => {
8486
toast.error("Error updating Redis");
@@ -87,7 +89,7 @@ export const UpdateRedis = ({ redisId }: Props) => {
8789
};
8890

8991
return (
90-
<Dialog>
92+
<Dialog open={isOpen} onOpenChange={setIsOpen}>
9193
<DialogTrigger asChild>
9294
<Button
9395
variant="ghost"

0 commit comments

Comments
 (0)