refactor: remove tables

This commit is contained in:
Mauricio Siu 2025-02-16 14:11:47 -06:00
parent 9856502ece
commit 90156da570
9 changed files with 4869 additions and 25 deletions

View File

@ -5,7 +5,7 @@ vi.mock("node:fs", () => ({
default: fs,
}));
import type { Admin, FileConfig, User } from "@dokploy/server";
import type { FileConfig, User } from "@dokploy/server";
import {
createDefaultServerTraefikConfig,
loadOrCreateConfig,
@ -13,7 +13,7 @@ import {
} from "@dokploy/server";
import { beforeEach, expect, test, vi } from "vitest";
const baseAdmin: Partial<User> = {
const baseAdmin: User = {
enablePaidFeatures: false,
metricsConfig: {
containers: {
@ -51,6 +51,30 @@ const baseAdmin: Partial<User> = {
serversQuantity: 0,
stripeCustomerId: "",
stripeSubscriptionId: "",
accessedProjects: [],
accessedServices: [],
banExpires: new Date(),
banned: true,
banReason: "",
canAccessToAPI: false,
canCreateProjects: false,
canDeleteProjects: false,
canDeleteServices: false,
canAccessToDocker: false,
canAccessToSSHKeys: false,
canCreateServices: false,
canAccessToTraefikFiles: false,
canAccessToGitProviders: false,
email: "",
expirationDate: "",
id: "",
isRegistered: false,
name: "",
createdAt2: new Date().toISOString(),
emailVerified: false,
image: "",
token: "",
updatedAt: new Date(),
};
beforeEach(() => {

View File

@ -26,7 +26,7 @@ const baseApp: ApplicationNested = {
previewWildcard: "",
project: {
env: "",
adminId: "",
organizationId: "",
name: "",
description: "",
createdAt: "",

View File

@ -52,14 +52,6 @@ export const ShowProjects = () => {
const utils = api.useUtils();
const { data, isLoading } = api.project.all.useQuery();
const { data: auth } = api.auth.get.useQuery();
const { data: user } = api.user.byAuthId.useQuery(
{
authId: auth?.id || "",
},
{
enabled: !!auth?.id && auth?.role === "member",
},
);
const { mutateAsync } = api.project.remove.useMutation();
const [searchQuery, setSearchQuery] = useState("");
@ -91,7 +83,7 @@ export const ShowProjects = () => {
</CardDescription>
</CardHeader>
{(auth?.role === "owner" || user?.canCreateProjects) && (
{(auth?.role === "owner" || auth?.user?.canCreateProjects) && (
<div className="">
<HandleProject />
</div>
@ -294,7 +286,7 @@ export const ShowProjects = () => {
onClick={(e) => e.stopPropagation()}
>
{(auth?.role === "owner" ||
user?.canDeleteProjects) && (
auth?.user?.canDeleteProjects) && (
<AlertDialog>
<AlertDialogTrigger className="w-full">
<DropdownMenuItem

View File

@ -35,6 +35,7 @@ export const CreateSSHKey = () => {
description: "Used on Dokploy Cloud",
privateKey: keys.privateKey,
publicKey: keys.publicKey,
organizationId: "",
});
await refetch();
} catch (error) {

View File

@ -0,0 +1,5 @@
DROP TABLE "user" CASCADE;--> statement-breakpoint
DROP TABLE "admin" CASCADE;--> statement-breakpoint
DROP TABLE "auth" CASCADE;--> statement-breakpoint
DROP TABLE "session" CASCADE;--> statement-breakpoint
DROP TYPE "public"."Roles";

File diff suppressed because it is too large Load Diff

View File

@ -512,6 +512,13 @@
"when": 1739672367223,
"tag": "0072_lazy_pixie",
"breakpoints": true
},
{
"idx": 73,
"version": "7",
"when": 1739735739336,
"tag": "0073_brave_wolfpack",
"breakpoints": true
}
]
}

View File

@ -14,21 +14,15 @@ import superjson from "superjson";
const Page = () => {
const { data } = api.auth.get.useQuery();
const { data: user } = api.user.get.useQuery(
{
authId: data?.id || "",
},
{
enabled: !!data?.id && data?.role === "member",
},
);
const { data: isCloud } = api.settings.isCloud.useQuery();
return (
<div className="w-full">
<div className="h-full rounded-xl max-w-5xl mx-auto flex flex-col gap-4">
<ProfileForm />
{(user?.canAccessToAPI || data?.role === "owner") && <GenerateToken />}
{(data?.user?.canAccessToAPI || data?.role === "owner") && (
<GenerateToken />
)}
{isCloud && <RemoveSelfAccount />}
</div>

View File

@ -1,14 +1,14 @@
import { existsSync, readFileSync, writeFileSync } from "node:fs";
import { join } from "node:path";
import { paths } from "@dokploy/server/constants";
import type { Admin } from "@dokploy/server/services/admin";
import { dump, load } from "js-yaml";
import { loadOrCreateConfig, writeTraefikConfig } from "./application";
import type { FileConfig } from "./file-types";
import type { MainTraefikConfig } from "./types";
import type { User } from "@dokploy/server/services/user";
export const updateServerTraefik = (
admin: Admin | null,
user: User | null,
newHost: string | null,
) => {
const appName = "dokploy";
@ -22,7 +22,7 @@ export const updateServerTraefik = (
if (currentRouterConfig && newHost) {
currentRouterConfig.rule = `Host(\`${newHost}\`)`;
if (admin?.certificateType === "letsencrypt") {
if (user?.certificateType === "letsencrypt") {
config.http.routers[`${appName}-router-app-secure`] = {
...currentRouterConfig,
entryPoints: ["websecure"],