mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
refactor: remove tables
This commit is contained in:
@@ -5,7 +5,7 @@ vi.mock("node:fs", () => ({
|
|||||||
default: fs,
|
default: fs,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
import type { Admin, FileConfig, User } from "@dokploy/server";
|
import type { FileConfig, User } from "@dokploy/server";
|
||||||
import {
|
import {
|
||||||
createDefaultServerTraefikConfig,
|
createDefaultServerTraefikConfig,
|
||||||
loadOrCreateConfig,
|
loadOrCreateConfig,
|
||||||
@@ -13,7 +13,7 @@ import {
|
|||||||
} from "@dokploy/server";
|
} from "@dokploy/server";
|
||||||
import { beforeEach, expect, test, vi } from "vitest";
|
import { beforeEach, expect, test, vi } from "vitest";
|
||||||
|
|
||||||
const baseAdmin: Partial<User> = {
|
const baseAdmin: User = {
|
||||||
enablePaidFeatures: false,
|
enablePaidFeatures: false,
|
||||||
metricsConfig: {
|
metricsConfig: {
|
||||||
containers: {
|
containers: {
|
||||||
@@ -51,6 +51,30 @@ const baseAdmin: Partial<User> = {
|
|||||||
serversQuantity: 0,
|
serversQuantity: 0,
|
||||||
stripeCustomerId: "",
|
stripeCustomerId: "",
|
||||||
stripeSubscriptionId: "",
|
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(() => {
|
beforeEach(() => {
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ const baseApp: ApplicationNested = {
|
|||||||
previewWildcard: "",
|
previewWildcard: "",
|
||||||
project: {
|
project: {
|
||||||
env: "",
|
env: "",
|
||||||
adminId: "",
|
organizationId: "",
|
||||||
name: "",
|
name: "",
|
||||||
description: "",
|
description: "",
|
||||||
createdAt: "",
|
createdAt: "",
|
||||||
|
|||||||
@@ -52,14 +52,6 @@ export const ShowProjects = () => {
|
|||||||
const utils = api.useUtils();
|
const utils = api.useUtils();
|
||||||
const { data, isLoading } = api.project.all.useQuery();
|
const { data, isLoading } = api.project.all.useQuery();
|
||||||
const { data: auth } = api.auth.get.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 { mutateAsync } = api.project.remove.useMutation();
|
||||||
const [searchQuery, setSearchQuery] = useState("");
|
const [searchQuery, setSearchQuery] = useState("");
|
||||||
|
|
||||||
@@ -91,7 +83,7 @@ export const ShowProjects = () => {
|
|||||||
</CardDescription>
|
</CardDescription>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
|
|
||||||
{(auth?.role === "owner" || user?.canCreateProjects) && (
|
{(auth?.role === "owner" || auth?.user?.canCreateProjects) && (
|
||||||
<div className="">
|
<div className="">
|
||||||
<HandleProject />
|
<HandleProject />
|
||||||
</div>
|
</div>
|
||||||
@@ -294,7 +286,7 @@ export const ShowProjects = () => {
|
|||||||
onClick={(e) => e.stopPropagation()}
|
onClick={(e) => e.stopPropagation()}
|
||||||
>
|
>
|
||||||
{(auth?.role === "owner" ||
|
{(auth?.role === "owner" ||
|
||||||
user?.canDeleteProjects) && (
|
auth?.user?.canDeleteProjects) && (
|
||||||
<AlertDialog>
|
<AlertDialog>
|
||||||
<AlertDialogTrigger className="w-full">
|
<AlertDialogTrigger className="w-full">
|
||||||
<DropdownMenuItem
|
<DropdownMenuItem
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ export const CreateSSHKey = () => {
|
|||||||
description: "Used on Dokploy Cloud",
|
description: "Used on Dokploy Cloud",
|
||||||
privateKey: keys.privateKey,
|
privateKey: keys.privateKey,
|
||||||
publicKey: keys.publicKey,
|
publicKey: keys.publicKey,
|
||||||
|
organizationId: "",
|
||||||
});
|
});
|
||||||
await refetch();
|
await refetch();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
5
apps/dokploy/drizzle/0073_brave_wolfpack.sql
Normal file
5
apps/dokploy/drizzle/0073_brave_wolfpack.sql
Normal 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";
|
||||||
4821
apps/dokploy/drizzle/meta/0073_snapshot.json
Normal file
4821
apps/dokploy/drizzle/meta/0073_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -512,6 +512,13 @@
|
|||||||
"when": 1739672367223,
|
"when": 1739672367223,
|
||||||
"tag": "0072_lazy_pixie",
|
"tag": "0072_lazy_pixie",
|
||||||
"breakpoints": true
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 73,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1739735739336,
|
||||||
|
"tag": "0073_brave_wolfpack",
|
||||||
|
"breakpoints": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -14,21 +14,15 @@ import superjson from "superjson";
|
|||||||
|
|
||||||
const Page = () => {
|
const Page = () => {
|
||||||
const { data } = api.auth.get.useQuery();
|
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();
|
const { data: isCloud } = api.settings.isCloud.useQuery();
|
||||||
return (
|
return (
|
||||||
<div className="w-full">
|
<div className="w-full">
|
||||||
<div className="h-full rounded-xl max-w-5xl mx-auto flex flex-col gap-4">
|
<div className="h-full rounded-xl max-w-5xl mx-auto flex flex-col gap-4">
|
||||||
<ProfileForm />
|
<ProfileForm />
|
||||||
{(user?.canAccessToAPI || data?.role === "owner") && <GenerateToken />}
|
{(data?.user?.canAccessToAPI || data?.role === "owner") && (
|
||||||
|
<GenerateToken />
|
||||||
|
)}
|
||||||
|
|
||||||
{isCloud && <RemoveSelfAccount />}
|
{isCloud && <RemoveSelfAccount />}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
||||||
import { join } from "node:path";
|
import { join } from "node:path";
|
||||||
import { paths } from "@dokploy/server/constants";
|
import { paths } from "@dokploy/server/constants";
|
||||||
import type { Admin } from "@dokploy/server/services/admin";
|
|
||||||
import { dump, load } from "js-yaml";
|
import { dump, load } from "js-yaml";
|
||||||
import { loadOrCreateConfig, writeTraefikConfig } from "./application";
|
import { loadOrCreateConfig, writeTraefikConfig } from "./application";
|
||||||
import type { FileConfig } from "./file-types";
|
import type { FileConfig } from "./file-types";
|
||||||
import type { MainTraefikConfig } from "./types";
|
import type { MainTraefikConfig } from "./types";
|
||||||
|
import type { User } from "@dokploy/server/services/user";
|
||||||
|
|
||||||
export const updateServerTraefik = (
|
export const updateServerTraefik = (
|
||||||
admin: Admin | null,
|
user: User | null,
|
||||||
newHost: string | null,
|
newHost: string | null,
|
||||||
) => {
|
) => {
|
||||||
const appName = "dokploy";
|
const appName = "dokploy";
|
||||||
@@ -22,7 +22,7 @@ export const updateServerTraefik = (
|
|||||||
if (currentRouterConfig && newHost) {
|
if (currentRouterConfig && newHost) {
|
||||||
currentRouterConfig.rule = `Host(\`${newHost}\`)`;
|
currentRouterConfig.rule = `Host(\`${newHost}\`)`;
|
||||||
|
|
||||||
if (admin?.certificateType === "letsencrypt") {
|
if (user?.certificateType === "letsencrypt") {
|
||||||
config.http.routers[`${appName}-router-app-secure`] = {
|
config.http.routers[`${appName}-router-app-secure`] = {
|
||||||
...currentRouterConfig,
|
...currentRouterConfig,
|
||||||
entryPoints: ["websecure"],
|
entryPoints: ["websecure"],
|
||||||
|
|||||||
Reference in New Issue
Block a user