From 5310a559b0487a946e3bd603751e688691a971cf Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Sun, 19 Jan 2025 01:29:29 -0600 Subject: [PATCH] refactor: improve sidebar --- .../server/update-server-config.test.ts | 112 +++++++++--------- .../database/backups/show-backups.tsx | 2 +- .../dashboard/monitoring/docker/show.tsx | 2 +- .../components/dashboard/projects/show.tsx | 6 +- .../certificates/show-certificates.tsx | 2 +- .../notifications/show-notifications.tsx | 2 +- .../dashboard/swarm/details/details-card.tsx | 2 +- .../dashboard/swarm/monitoring-card.tsx | 2 +- .../components/layouts/dashboard-layout.tsx | 6 +- .../components/layouts/onboarding-layout.tsx | 23 +--- .../components/layouts/project-layout.tsx | 6 +- apps/dokploy/components/layouts/side.tsx | 4 +- .../components/shared/breadcrumb-sidebar.tsx | 4 +- apps/dokploy/components/ui/sidebar.tsx | 2 +- .../pages/dashboard/project/[projectId].tsx | 6 +- apps/dokploy/pages/dashboard/swarm.tsx | 6 +- 16 files changed, 78 insertions(+), 109 deletions(-) diff --git a/apps/dokploy/__test__/traefik/server/update-server-config.test.ts b/apps/dokploy/__test__/traefik/server/update-server-config.test.ts index 9c5beb40..fac90cc7 100644 --- a/apps/dokploy/__test__/traefik/server/update-server-config.test.ts +++ b/apps/dokploy/__test__/traefik/server/update-server-config.test.ts @@ -1,98 +1,98 @@ import { fs, vol } from "memfs"; vi.mock("node:fs", () => ({ - ...fs, - default: fs, + ...fs, + default: fs, })); import type { Admin, FileConfig } from "@dokploy/server"; import { - createDefaultServerTraefikConfig, - loadOrCreateConfig, - updateServerTraefik, + createDefaultServerTraefikConfig, + loadOrCreateConfig, + updateServerTraefik, } from "@dokploy/server"; import { beforeEach, expect, test, vi } from "vitest"; const baseAdmin: Admin = { - cleanupCacheApplications: false, - cleanupCacheOnCompose: false, - cleanupCacheOnPreviews: false, - createdAt: "", - authId: "", - adminId: "string", - serverIp: null, - certificateType: "none", - host: null, - letsEncryptEmail: null, - sshPrivateKey: null, - enableDockerCleanup: false, - enableLogRotation: false, - serversQuantity: 0, - stripeCustomerId: "", - stripeSubscriptionId: "", + cleanupCacheApplications: false, + cleanupCacheOnCompose: false, + cleanupCacheOnPreviews: false, + createdAt: "", + authId: "", + adminId: "string", + serverIp: null, + certificateType: "none", + host: null, + letsEncryptEmail: null, + sshPrivateKey: null, + enableDockerCleanup: false, + enableLogRotation: false, + serversQuantity: 0, + stripeCustomerId: "", + stripeSubscriptionId: "", }; beforeEach(() => { - vol.reset(); - createDefaultServerTraefikConfig(); + vol.reset(); + createDefaultServerTraefikConfig(); }); test("Should read the configuration file", () => { - const config: FileConfig = loadOrCreateConfig("dokploy"); + const config: FileConfig = loadOrCreateConfig("dokploy"); - expect(config.http?.routers?.["dokploy-router-app"]?.service).toBe( - "dokploy-service-app" - ); + expect(config.http?.routers?.["dokploy-router-app"]?.service).toBe( + "dokploy-service-app", + ); }); test("Should apply redirect-to-https", () => { - updateServerTraefik( - { - ...baseAdmin, - certificateType: "letsencrypt", - }, - "example.com" - ); + updateServerTraefik( + { + ...baseAdmin, + certificateType: "letsencrypt", + }, + "example.com", + ); - const config: FileConfig = loadOrCreateConfig("dokploy"); + const config: FileConfig = loadOrCreateConfig("dokploy"); - expect(config.http?.routers?.["dokploy-router-app"]?.middlewares).toContain( - "redirect-to-https" - ); + expect(config.http?.routers?.["dokploy-router-app"]?.middlewares).toContain( + "redirect-to-https", + ); }); test("Should change only host when no certificate", () => { - updateServerTraefik(baseAdmin, "example.com"); + updateServerTraefik(baseAdmin, "example.com"); - const config: FileConfig = loadOrCreateConfig("dokploy"); + const config: FileConfig = loadOrCreateConfig("dokploy"); - expect(config.http?.routers?.["dokploy-router-app-secure"]).toBeUndefined(); + expect(config.http?.routers?.["dokploy-router-app-secure"]).toBeUndefined(); }); test("Should not touch config without host", () => { - const originalConfig: FileConfig = loadOrCreateConfig("dokploy"); + const originalConfig: FileConfig = loadOrCreateConfig("dokploy"); - updateServerTraefik(baseAdmin, null); + updateServerTraefik(baseAdmin, null); - const config: FileConfig = loadOrCreateConfig("dokploy"); + const config: FileConfig = loadOrCreateConfig("dokploy"); - expect(originalConfig).toEqual(config); + expect(originalConfig).toEqual(config); }); test("Should remove websecure if https rollback to http", () => { - const originalConfig: FileConfig = loadOrCreateConfig("dokploy"); + const originalConfig: FileConfig = loadOrCreateConfig("dokploy"); - updateServerTraefik( - { ...baseAdmin, certificateType: "letsencrypt" }, - "example.com" - ); + updateServerTraefik( + { ...baseAdmin, certificateType: "letsencrypt" }, + "example.com", + ); - updateServerTraefik({ ...baseAdmin, certificateType: "none" }, "example.com"); + updateServerTraefik({ ...baseAdmin, certificateType: "none" }, "example.com"); - const config: FileConfig = loadOrCreateConfig("dokploy"); + const config: FileConfig = loadOrCreateConfig("dokploy"); - expect(config.http?.routers?.["dokploy-router-app-secure"]).toBeUndefined(); - expect( - config.http?.routers?.["dokploy-router-app"]?.middlewares - ).not.toContain("redirect-to-https"); + expect(config.http?.routers?.["dokploy-router-app-secure"]).toBeUndefined(); + expect( + config.http?.routers?.["dokploy-router-app"]?.middlewares, + ).not.toContain("redirect-to-https"); }); diff --git a/apps/dokploy/components/dashboard/database/backups/show-backups.tsx b/apps/dokploy/components/dashboard/database/backups/show-backups.tsx index 9e493529..21fe28d4 100644 --- a/apps/dokploy/components/dashboard/database/backups/show-backups.tsx +++ b/apps/dokploy/components/dashboard/database/backups/show-backups.tsx @@ -75,7 +75,7 @@ export const ShowBackups = ({ id, type }: Props) => { {data?.length === 0 ? (
- + To create a backup it is required to set at least 1 provider. Please, go to{" "} -
+
CPU Usage diff --git a/apps/dokploy/components/dashboard/projects/show.tsx b/apps/dokploy/components/dashboard/projects/show.tsx index 16f842ed..c4b2f672 100644 --- a/apps/dokploy/components/dashboard/projects/show.tsx +++ b/apps/dokploy/components/dashboard/projects/show.tsx @@ -77,8 +77,8 @@ export const ShowProjects = () => {
-
- +
+ Projects @@ -87,7 +87,7 @@ export const ShowProjects = () => { Create and manage your projects -
+
diff --git a/apps/dokploy/components/dashboard/settings/certificates/show-certificates.tsx b/apps/dokploy/components/dashboard/settings/certificates/show-certificates.tsx index f28a814d..6aaa2563 100644 --- a/apps/dokploy/components/dashboard/settings/certificates/show-certificates.tsx +++ b/apps/dokploy/components/dashboard/settings/certificates/show-certificates.tsx @@ -50,7 +50,7 @@ export const ShowCertificates = () => { {data?.length === 0 ? (
- + You don't have any certificates created diff --git a/apps/dokploy/components/dashboard/settings/notifications/show-notifications.tsx b/apps/dokploy/components/dashboard/settings/notifications/show-notifications.tsx index 77fb8858..d65069d4 100644 --- a/apps/dokploy/components/dashboard/settings/notifications/show-notifications.tsx +++ b/apps/dokploy/components/dashboard/settings/notifications/show-notifications.tsx @@ -47,7 +47,7 @@ export const ShowNotifications = () => { {data?.length === 0 ? (
- + To send notifications it is required to set at least 1 provider. diff --git a/apps/dokploy/components/dashboard/swarm/details/details-card.tsx b/apps/dokploy/components/dashboard/swarm/details/details-card.tsx index 8901ba58..52c90c0f 100644 --- a/apps/dokploy/components/dashboard/swarm/details/details-card.tsx +++ b/apps/dokploy/components/dashboard/swarm/details/details-card.tsx @@ -60,7 +60,7 @@ export function NodeCard({ node, serverId }: Props) {
{node.Hostname}
{node.ManagerStatus || "Worker"}
-
+
TLS Status: {node.TLSStatus} Availability: {node.Availability}
diff --git a/apps/dokploy/components/dashboard/swarm/monitoring-card.tsx b/apps/dokploy/components/dashboard/swarm/monitoring-card.tsx index 98dc0d96..0c38b509 100644 --- a/apps/dokploy/components/dashboard/swarm/monitoring-card.tsx +++ b/apps/dokploy/components/dashboard/swarm/monitoring-card.tsx @@ -72,7 +72,7 @@ export default function SwarmMonitorCard({ serverId }: Props) { return (
-
+
diff --git a/apps/dokploy/components/layouts/dashboard-layout.tsx b/apps/dokploy/components/layouts/dashboard-layout.tsx index 13e9061d..00697e7c 100644 --- a/apps/dokploy/components/layouts/dashboard-layout.tsx +++ b/apps/dokploy/components/layouts/dashboard-layout.tsx @@ -5,9 +5,5 @@ interface Props { } export const DashboardLayout = ({ children }: Props) => { - return ( - -
{children}
-
- ); + return {children}; }; diff --git a/apps/dokploy/components/layouts/onboarding-layout.tsx b/apps/dokploy/components/layouts/onboarding-layout.tsx index 093c1492..9d4068cf 100644 --- a/apps/dokploy/components/layouts/onboarding-layout.tsx +++ b/apps/dokploy/components/layouts/onboarding-layout.tsx @@ -11,7 +11,7 @@ interface Props { export const OnboardingLayout = ({ children }: Props) => { return (
-
+
{
-

+

“The Open Source alternative to Netlify, Vercel, Heroku.”

- {/*
Sofia Davis
*/}
{children} - - {/*

- By clicking continue, you agree to our{" "} - - Terms of Service - {" "} - and{" "} - - Privacy Policy - - . -

*/}
diff --git a/apps/dokploy/pages/dashboard/swarm.tsx b/apps/dokploy/pages/dashboard/swarm.tsx index f40a0a83..3a8a60b2 100644 --- a/apps/dokploy/pages/dashboard/swarm.tsx +++ b/apps/dokploy/pages/dashboard/swarm.tsx @@ -8,11 +8,7 @@ import type { ReactElement } from "react"; import superjson from "superjson"; const Dashboard = () => { - return ( - <> - - - ); + return ; }; export default Dashboard;