refactor: remove unused code

This commit is contained in:
Mauricio Siu
2024-08-17 16:57:27 -06:00
parent b7dad5e1d9
commit 0374165a7f
5 changed files with 36 additions and 53 deletions

View File

@@ -30,10 +30,10 @@ export const ShowProviderFormCompose = ({ composeId }: Props) => {
Select the source of your code Select the source of your code
</p> </p>
</div> </div>
{/* <div className="hidden space-y-1 text-sm font-normal md:block"> <div className="hidden space-y-1 text-sm font-normal md:flex flex-row items-center gap-2">
<ShowConvertedCompose composeId={composeId} />
<GitBranch className="size-6 text-muted-foreground" /> <GitBranch className="size-6 text-muted-foreground" />
</div> */} </div>
<ShowConvertedCompose composeId={composeId} />
</CardTitle> </CardTitle>
</CardHeader> </CardHeader>
<CardContent> <CardContent>

View File

@@ -10,7 +10,7 @@ import {
DialogTrigger, DialogTrigger,
} from "@/components/ui/dialog"; } from "@/components/ui/dialog";
import { api } from "@/utils/api"; import { api } from "@/utils/api";
import { Puzzle } from "lucide-react"; import { Puzzle, RefreshCw } from "lucide-react";
import { useState } from "react"; import { useState } from "react";
import { toast } from "sonner"; import { toast } from "sonner";
@@ -39,37 +39,47 @@ export const ShowConvertedCompose = ({ composeId }: Props) => {
<DialogTrigger asChild> <DialogTrigger asChild>
<Button className="max-lg:w-full" variant="outline"> <Button className="max-lg:w-full" variant="outline">
<Puzzle className="h-4 w-4" /> <Puzzle className="h-4 w-4" />
View Converted Compose Preview Compose
</Button> </Button>
</DialogTrigger> </DialogTrigger>
<DialogContent className="sm:max-w-6xl max-h-[50rem] overflow-y-auto"> <DialogContent className="sm:max-w-6xl max-h-[50rem] overflow-y-auto">
<DialogHeader> <DialogHeader>
<DialogTitle>Converted Compose</DialogTitle> <DialogTitle>Converted Compose</DialogTitle>
<DialogDescription> <DialogDescription>
See how the docker compose file will look like after adding the Preview your docker-compose file with added domains. Note: At least
domains one domain must be specified for this conversion to take effect.
</DialogDescription> </DialogDescription>
</DialogHeader> </DialogHeader>
{isError && <AlertBlock type="error">{error?.message}</AlertBlock>} {isError && <AlertBlock type="error">{error?.message}</AlertBlock>}
<Button
isLoading={isLoading} <div className="flex flex-row gap-2 justify-end">
onClick={() => { <Button
mutateAsync({ composeId }) variant="secondary"
.then(() => { isLoading={isLoading}
refetch(); onClick={() => {
toast.success("Fetched source type"); mutateAsync({ composeId })
}) .then(() => {
.catch((err) => { refetch();
toast.error("Error to fetch source type", { toast.success("Fetched source type");
description: err.message, })
.catch((err) => {
toast.error("Error to fetch source type", {
description: err.message,
});
}); });
}); }}
}} >
> Refresh <RefreshCw className="ml-2 h-4 w-4" />
Fetch </Button>
</Button> </div>
<pre> <pre>
<CodeEditor value={compose} language="yaml" readOnly height="50rem" /> <CodeEditor
value={compose || ""}
language="yaml"
readOnly
height="50rem"
/>
</pre> </pre>
</DialogContent> </DialogContent>
</Dialog> </Dialog>

View File

@@ -18,7 +18,6 @@ import {
findDomainsByApplicationId, findDomainsByApplicationId,
findDomainsByComposeId, findDomainsByComposeId,
generateTraefikMeDomain, generateTraefikMeDomain,
generateWildcard,
removeDomainById, removeDomainById,
updateDomainById, updateDomainById,
} from "../services/domain"; } from "../services/domain";
@@ -52,11 +51,7 @@ export const domainRouter = createTRPCRouter({
.mutation(async ({ input }) => { .mutation(async ({ input }) => {
return generateTraefikMeDomain(input.appName); return generateTraefikMeDomain(input.appName);
}), }),
generateWildcard: protectedProcedure
.input(apiFindDomainByApplication)
.mutation(async ({ input }) => {
return generateWildcard(input);
}),
update: protectedProcedure update: protectedProcedure
.input(apiUpdateDomain) .input(apiUpdateDomain)
.mutation(async ({ input }) => { .mutation(async ({ input }) => {

View File

@@ -45,28 +45,6 @@ export const generateTraefikMeDomain = async (appName: string) => {
}); });
}; };
export const generateWildcard = async (
input: typeof apiFindDomainByApplication._type,
) => {
// const application = await findApplicationById(input.applicationId);
// const admin = await findAdmin();
// if (!admin.host) {
// throw new TRPCError({
// code: "BAD_REQUEST",
// message: "We need a host to generate a wildcard domain",
// });
// }
// const domain = await createDomain({
// applicationId: application.applicationId,
// host: generateWildcardDomain(application.appName, admin.host || ""),
// port: 3000,
// certificateType: "none",
// https: false,
// path: "/",
// });
// return domain;
};
export const generateWildcardDomain = ( export const generateWildcardDomain = (
appName: string, appName: string,
serverDomain: string, serverDomain: string,

View File

@@ -84,7 +84,7 @@ export const addDomainToCompose = async (
const { appName } = compose; const { appName } = compose;
const result = await loadDockerCompose(compose); const result = await loadDockerCompose(compose);
if (!result) { if (!result || domains.length === 0) {
return null; return null;
} }