From ba9fc598055b939d912e4b0fef7f6872aeb1ad99 Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Sun, 21 Jul 2024 01:35:52 -0600 Subject: [PATCH 1/3] refactor(databases): show hide and show icon in enviroment tab --- .../environment/show-mariadb-environment.tsx | 31 +++++++++++++++---- .../environment/show-mongo-environment.tsx | 30 ++++++++++++++---- .../environment/show-mysql-environment.tsx | 30 ++++++++++++++---- .../environment/show-postgres-environment.tsx | 30 ++++++++++++++---- .../environment/show-redis-environment.tsx | 30 ++++++++++++++---- 5 files changed, 121 insertions(+), 30 deletions(-) diff --git a/components/dashboard/mariadb/environment/show-mariadb-environment.tsx b/components/dashboard/mariadb/environment/show-mariadb-environment.tsx index 807dcae0..61f64cd8 100644 --- a/components/dashboard/mariadb/environment/show-mariadb-environment.tsx +++ b/components/dashboard/mariadb/environment/show-mariadb-environment.tsx @@ -14,9 +14,11 @@ import { FormItem, FormMessage, } from "@/components/ui/form"; +import { Toggle } from "@/components/ui/toggle"; import { api } from "@/utils/api"; import { zodResolver } from "@hookform/resolvers/zod"; -import React, { useEffect } from "react"; +import { EyeIcon, EyeOffIcon } from "lucide-react"; +import React, { useEffect, useState } from "react"; import { useForm } from "react-hook-form"; import { toast } from "sonner"; import { z } from "zod"; @@ -32,6 +34,7 @@ interface Props { } export const ShowMariadbEnvironment = ({ mariadbId }: Props) => { + const [isEnvVisible, setIsEnvVisible] = useState(true); const { mutateAsync, isLoading } = api.mariadb.saveEnvironment.useMutation(); const { data, refetch } = api.mariadb.one.useQuery( @@ -74,11 +77,26 @@ export const ShowMariadbEnvironment = ({ mariadbId }: Props) => { return (
- - Environment Settings - - You can add environment variables to your database. - + {" "} + +
+ Environment Settings + + You can add environment variables to your resource. + +
+ + + {isEnvVisible ? ( + + ) : ( + + )} +
@@ -95,6 +113,7 @@ export const ShowMariadbEnvironment = ({ mariadbId }: Props) => { { + const [isEnvVisible, setIsEnvVisible] = useState(true); const { mutateAsync, isLoading } = api.mongo.saveEnvironment.useMutation(); const { data, refetch } = api.mongo.one.useQuery( @@ -74,11 +77,25 @@ export const ShowMongoEnvironment = ({ mongoId }: Props) => { return (
- - Environment Settings - - You can add environment variables to your database. - + +
+ Environment Settings + + You can add environment variables to your resource. + +
+ + + {isEnvVisible ? ( + + ) : ( + + )} +
@@ -95,6 +112,7 @@ export const ShowMongoEnvironment = ({ mongoId }: Props) => { { + const [isEnvVisible, setIsEnvVisible] = useState(true); const { mutateAsync, isLoading } = api.mysql.saveEnvironment.useMutation(); const { data, refetch } = api.mysql.one.useQuery( @@ -74,11 +77,25 @@ export const ShowMysqlEnvironment = ({ mysqlId }: Props) => { return (
- - Environment Settings - - You can add environment variables to your database. - + +
+ Environment Settings + + You can add environment variables to your resource. + +
+ + + {isEnvVisible ? ( + + ) : ( + + )} +
@@ -95,6 +112,7 @@ export const ShowMysqlEnvironment = ({ mysqlId }: Props) => { { + const [isEnvVisible, setIsEnvVisible] = useState(true); const { mutateAsync, isLoading } = api.postgres.saveEnvironment.useMutation(); const { data, refetch } = api.postgres.one.useQuery( @@ -74,11 +77,25 @@ export const ShowPostgresEnvironment = ({ postgresId }: Props) => { return (
- - Environment Settings - - You can add environment variables to your database. - + +
+ Environment Settings + + You can add environment variables to your resource. + +
+ + + {isEnvVisible ? ( + + ) : ( + + )} +
@@ -95,6 +112,7 @@ export const ShowPostgresEnvironment = ({ postgresId }: Props) => { { + const [isEnvVisible, setIsEnvVisible] = useState(true); const { mutateAsync, isLoading } = api.redis.saveEnvironment.useMutation(); const { data, refetch } = api.redis.one.useQuery( @@ -74,11 +77,25 @@ export const ShowRedisEnvironment = ({ redisId }: Props) => { return (
- - Environment Settings - - You can add environment variables to your database. - + +
+ Environment Settings + + You can add environment variables to your resource. + +
+ + + {isEnvVisible ? ( + + ) : ( + + )} +
@@ -95,6 +112,7 @@ export const ShowRedisEnvironment = ({ redisId }: Props) => { Date: Sun, 21 Jul 2024 01:36:18 -0600 Subject: [PATCH 2/3] refactor(applications): enable autodeploy by default --- .../dashboard/application/deployments/refresh-token.tsx | 4 ++-- components/dashboard/compose/general/actions.tsx | 6 +++--- server/db/schema/application.ts | 2 +- server/db/schema/compose.ts | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/components/dashboard/application/deployments/refresh-token.tsx b/components/dashboard/application/deployments/refresh-token.tsx index e633a9f4..88d5beee 100644 --- a/components/dashboard/application/deployments/refresh-token.tsx +++ b/components/dashboard/application/deployments/refresh-token.tsx @@ -29,8 +29,8 @@ export const RefreshToken = ({ applicationId }: Props) => { Are you absolutely sure? - This action cannot be undone. This will permanently delete the - domain + This action cannot be undone. This will change the refresh token and + other tokens will be invalidated. diff --git a/components/dashboard/compose/general/actions.tsx b/components/dashboard/compose/general/actions.tsx index 85ad4506..754fb345 100644 --- a/components/dashboard/compose/general/actions.tsx +++ b/components/dashboard/compose/general/actions.tsx @@ -10,7 +10,7 @@ import { } from "@/components/ui/dropdown-menu"; import { Toggle } from "@/components/ui/toggle"; import { api } from "@/utils/api"; -import { ExternalLink, Globe, Terminal } from "lucide-react"; +import { CheckCircle2, ExternalLink, Globe, Terminal } from "lucide-react"; import Link from "next/link"; import { toast } from "sonner"; import { DockerTerminalModal } from "../../settings/web-server/docker-terminal-modal"; @@ -50,7 +50,6 @@ export const ComposeActions = ({ composeId }: Props) => { return (
- { toast.error("Error to update Auto Deploy"); }); }} + className="flex flex-row gap-2 items-center" > - Autodeploy + Autodeploy {data?.autoDeploy && } {data?.composeType === "docker-compose" && ( diff --git a/server/db/schema/application.ts b/server/db/schema/application.ts index d9b9f247..8b3c4b11 100644 --- a/server/db/schema/application.ts +++ b/server/db/schema/application.ts @@ -122,7 +122,7 @@ export const applications = pgTable("application", { owner: text("owner"), branch: text("branch"), buildPath: text("buildPath").default("/"), - autoDeploy: boolean("autoDeploy"), + autoDeploy: boolean("autoDeploy").$defaultFn(() => true), // Docker username: text("username"), password: text("password"), diff --git a/server/db/schema/compose.ts b/server/db/schema/compose.ts index 78033793..1ac9a33d 100644 --- a/server/db/schema/compose.ts +++ b/server/db/schema/compose.ts @@ -37,7 +37,7 @@ export const compose = pgTable("compose", { repository: text("repository"), owner: text("owner"), branch: text("branch"), - autoDeploy: boolean("autoDeploy"), + autoDeploy: boolean("autoDeploy").$defaultFn(() => true), // Git customGitUrl: text("customGitUrl"), customGitBranch: text("customGitBranch"), From f6128bdf0c9c30ae31ff8fb9c83b5dac599d545c Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Sun, 21 Jul 2024 01:36:41 -0600 Subject: [PATCH 3/3] refactor(webhook): change autodeploy message --- pages/api/deploy/[refreshToken].ts | 4 +++- pages/api/deploy/compose/[refreshToken].ts | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pages/api/deploy/[refreshToken].ts b/pages/api/deploy/[refreshToken].ts index d05f7e1e..d65f6834 100644 --- a/pages/api/deploy/[refreshToken].ts +++ b/pages/api/deploy/[refreshToken].ts @@ -27,7 +27,9 @@ export default async function handler( return; } if (!application?.autoDeploy) { - res.status(400).json({ message: "Application Not Deployable" }); + res.status(400).json({ + message: "Automatic deployments are disabled for this application", + }); return; } diff --git a/pages/api/deploy/compose/[refreshToken].ts b/pages/api/deploy/compose/[refreshToken].ts index b750ffac..65ab80df 100644 --- a/pages/api/deploy/compose/[refreshToken].ts +++ b/pages/api/deploy/compose/[refreshToken].ts @@ -32,7 +32,9 @@ export default async function handler( return; } if (!composeResult?.autoDeploy) { - res.status(400).json({ message: "Compose Not Deployable" }); + res.status(400).json({ + message: "Automatic deployments are disabled for this compose", + }); return; }