mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-08 04:55:17 +00:00
chore: resolved greptile review comments
This commit is contained in:
@@ -64,6 +64,105 @@ interface ServiceItem {
|
|||||||
appName?: string;
|
appName?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface EnvironmentData {
|
||||||
|
applications?: Array<{
|
||||||
|
applicationId: string;
|
||||||
|
name: string;
|
||||||
|
appName: string;
|
||||||
|
}>;
|
||||||
|
compose?: Array<{ composeId: string; name: string; appName: string }>;
|
||||||
|
postgres?: Array<{ postgresId: string; name: string; appName: string }>;
|
||||||
|
mysql?: Array<{ mysqlId: string; name: string; appName: string }>;
|
||||||
|
mariadb?: Array<{ mariadbId: string; name: string; appName: string }>;
|
||||||
|
redis?: Array<{ redisId: string; name: string; appName: string }>;
|
||||||
|
mongo?: Array<{ mongoId: string; name: string; appName: string }>;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper function to count total services in an environment
|
||||||
|
const countEnvironmentServices = (env: EnvironmentData): number => {
|
||||||
|
return (
|
||||||
|
(env.applications?.length || 0) +
|
||||||
|
(env.compose?.length || 0) +
|
||||||
|
(env.postgres?.length || 0) +
|
||||||
|
(env.mysql?.length || 0) +
|
||||||
|
(env.mariadb?.length || 0) +
|
||||||
|
(env.redis?.length || 0) +
|
||||||
|
(env.mongo?.length || 0)
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Helper function to extract services from an environment into a flat array
|
||||||
|
const extractServicesFromEnvironment = (
|
||||||
|
env: EnvironmentData,
|
||||||
|
): ServiceItem[] => {
|
||||||
|
const services: ServiceItem[] = [];
|
||||||
|
|
||||||
|
env.applications?.forEach((app) => {
|
||||||
|
services.push({
|
||||||
|
id: app.applicationId,
|
||||||
|
name: app.name,
|
||||||
|
type: "application",
|
||||||
|
appName: app.appName,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
env.compose?.forEach((comp) => {
|
||||||
|
services.push({
|
||||||
|
id: comp.composeId,
|
||||||
|
name: comp.name,
|
||||||
|
type: "compose",
|
||||||
|
appName: comp.appName,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
env.postgres?.forEach((pg) => {
|
||||||
|
services.push({
|
||||||
|
id: pg.postgresId,
|
||||||
|
name: pg.name,
|
||||||
|
type: "postgres",
|
||||||
|
appName: pg.appName,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
env.mysql?.forEach((my) => {
|
||||||
|
services.push({
|
||||||
|
id: my.mysqlId,
|
||||||
|
name: my.name,
|
||||||
|
type: "mysql",
|
||||||
|
appName: my.appName,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
env.mariadb?.forEach((maria) => {
|
||||||
|
services.push({
|
||||||
|
id: maria.mariadbId,
|
||||||
|
name: maria.name,
|
||||||
|
type: "mariadb",
|
||||||
|
appName: maria.appName,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
env.redis?.forEach((red) => {
|
||||||
|
services.push({
|
||||||
|
id: red.redisId,
|
||||||
|
name: red.name,
|
||||||
|
type: "redis",
|
||||||
|
appName: red.appName,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
env.mongo?.forEach((mon) => {
|
||||||
|
services.push({
|
||||||
|
id: mon.mongoId,
|
||||||
|
name: mon.name,
|
||||||
|
type: "mongo",
|
||||||
|
appName: mon.appName,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
return services;
|
||||||
|
};
|
||||||
|
|
||||||
export const AdvanceBreadcrumb = ({
|
export const AdvanceBreadcrumb = ({
|
||||||
projectId,
|
projectId,
|
||||||
environmentId,
|
environmentId,
|
||||||
@@ -114,79 +213,9 @@ export const AdvanceBreadcrumb = ({
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
// Extract services from current environment
|
// Extract services from current environment
|
||||||
const services: ServiceItem[] = [];
|
const services: ServiceItem[] = currentEnvironment
|
||||||
if (currentEnvironment) {
|
? extractServicesFromEnvironment(currentEnvironment)
|
||||||
currentEnvironment.applications?.forEach(
|
: [];
|
||||||
(app: { applicationId: string; name: string; appName: string }) => {
|
|
||||||
services.push({
|
|
||||||
id: app.applicationId,
|
|
||||||
name: app.name,
|
|
||||||
type: "application",
|
|
||||||
appName: app.appName,
|
|
||||||
});
|
|
||||||
},
|
|
||||||
);
|
|
||||||
currentEnvironment.compose?.forEach(
|
|
||||||
(comp: { composeId: string; name: string; appName: string }) => {
|
|
||||||
services.push({
|
|
||||||
id: comp.composeId,
|
|
||||||
name: comp.name,
|
|
||||||
type: "compose",
|
|
||||||
appName: comp.appName,
|
|
||||||
});
|
|
||||||
},
|
|
||||||
);
|
|
||||||
currentEnvironment.postgres?.forEach(
|
|
||||||
(pg: { postgresId: string; name: string; appName: string }) => {
|
|
||||||
services.push({
|
|
||||||
id: pg.postgresId,
|
|
||||||
name: pg.name,
|
|
||||||
type: "postgres",
|
|
||||||
appName: pg.appName,
|
|
||||||
});
|
|
||||||
},
|
|
||||||
);
|
|
||||||
currentEnvironment.mysql?.forEach(
|
|
||||||
(my: { mysqlId: string; name: string; appName: string }) => {
|
|
||||||
services.push({
|
|
||||||
id: my.mysqlId,
|
|
||||||
name: my.name,
|
|
||||||
type: "mysql",
|
|
||||||
appName: my.appName,
|
|
||||||
});
|
|
||||||
},
|
|
||||||
);
|
|
||||||
currentEnvironment.mariadb?.forEach(
|
|
||||||
(maria: { mariadbId: string; name: string; appName: string }) => {
|
|
||||||
services.push({
|
|
||||||
id: maria.mariadbId,
|
|
||||||
name: maria.name,
|
|
||||||
type: "mariadb",
|
|
||||||
appName: maria.appName,
|
|
||||||
});
|
|
||||||
},
|
|
||||||
);
|
|
||||||
currentEnvironment.redis?.forEach(
|
|
||||||
(red: { redisId: string; name: string; appName: string }) => {
|
|
||||||
services.push({
|
|
||||||
id: red.redisId,
|
|
||||||
name: red.name,
|
|
||||||
type: "redis",
|
|
||||||
appName: red.appName,
|
|
||||||
});
|
|
||||||
},
|
|
||||||
);
|
|
||||||
currentEnvironment.mongo?.forEach(
|
|
||||||
(mon: { mongoId: string; name: string; appName: string }) => {
|
|
||||||
services.push({
|
|
||||||
id: mon.mongoId,
|
|
||||||
name: mon.name,
|
|
||||||
type: "mongo",
|
|
||||||
appName: mon.appName,
|
|
||||||
});
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get current service
|
// Get current service
|
||||||
const currentService = services.find((s) => s.id === serviceId);
|
const currentService = services.find((s) => s.id === serviceId);
|
||||||
@@ -199,15 +228,18 @@ export const AdvanceBreadcrumb = ({
|
|||||||
const project = allProjects?.find((p) => p.projectId === selectedProjectId);
|
const project = allProjects?.find((p) => p.projectId === selectedProjectId);
|
||||||
if (project && project.environments.length > 0) {
|
if (project && project.environments.length > 0) {
|
||||||
// Use provided environment or find production environment or use the first one
|
// Use provided environment or find production environment or use the first one
|
||||||
|
const firstEnvironment = project.environments[0];
|
||||||
const targetEnvId =
|
const targetEnvId =
|
||||||
selectedEnvironmentId ||
|
selectedEnvironmentId ||
|
||||||
project.environments.find((e) => e.name === "production")
|
project.environments.find((e) => e.name === "production")
|
||||||
?.environmentId ||
|
?.environmentId ||
|
||||||
project.environments[0]?.environmentId;
|
firstEnvironment?.environmentId;
|
||||||
|
|
||||||
router.push(
|
if (targetEnvId) {
|
||||||
`/dashboard/project/${selectedProjectId}/environment/${targetEnvId}`,
|
router.push(
|
||||||
);
|
`/dashboard/project/${selectedProjectId}/environment/${targetEnvId}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
setProjectOpen(false);
|
setProjectOpen(false);
|
||||||
setExpandedProjectId(null);
|
setExpandedProjectId(null);
|
||||||
@@ -305,15 +337,7 @@ export const AdvanceBreadcrumb = ({
|
|||||||
<ScrollArea className="h-[300px]">
|
<ScrollArea className="h-[300px]">
|
||||||
{filteredProjects.map((project) => {
|
{filteredProjects.map((project) => {
|
||||||
const totalServices = project.environments.reduce(
|
const totalServices = project.environments.reduce(
|
||||||
(total, env) =>
|
(total, env) => total + countEnvironmentServices(env),
|
||||||
total +
|
|
||||||
(env.applications?.length || 0) +
|
|
||||||
(env.compose?.length || 0) +
|
|
||||||
(env.postgres?.length || 0) +
|
|
||||||
(env.mysql?.length || 0) +
|
|
||||||
(env.mariadb?.length || 0) +
|
|
||||||
(env.redis?.length || 0) +
|
|
||||||
(env.mongo?.length || 0),
|
|
||||||
0,
|
0,
|
||||||
);
|
);
|
||||||
const isSelected = project.projectId === projectId;
|
const isSelected = project.projectId === projectId;
|
||||||
@@ -370,13 +394,7 @@ export const AdvanceBreadcrumb = ({
|
|||||||
<div className="ml-11 border-l pl-3 py-1 space-y-1">
|
<div className="ml-11 border-l pl-3 py-1 space-y-1">
|
||||||
{project.environments.map((env) => {
|
{project.environments.map((env) => {
|
||||||
const envServices =
|
const envServices =
|
||||||
(env.applications?.length || 0) +
|
countEnvironmentServices(env);
|
||||||
(env.compose?.length || 0) +
|
|
||||||
(env.postgres?.length || 0) +
|
|
||||||
(env.mysql?.length || 0) +
|
|
||||||
(env.mariadb?.length || 0) +
|
|
||||||
(env.redis?.length || 0) +
|
|
||||||
(env.mongo?.length || 0);
|
|
||||||
const isEnvSelected =
|
const isEnvSelected =
|
||||||
env.environmentId === environmentId;
|
env.environmentId === environmentId;
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@
|
|||||||
"@oslojs/crypto": "1.0.1",
|
"@oslojs/crypto": "1.0.1",
|
||||||
"@oslojs/encoding": "1.1.0",
|
"@oslojs/encoding": "1.1.0",
|
||||||
"@react-email/components": "^0.0.21",
|
"@react-email/components": "^0.0.21",
|
||||||
"@better-auth/sso":"1.4.18",
|
"@better-auth/sso": "1.4.18",
|
||||||
"@trpc/server": "^10.45.2",
|
"@trpc/server": "^10.45.2",
|
||||||
"adm-zip": "^0.5.16",
|
"adm-zip": "^0.5.16",
|
||||||
"ai": "^5.0.17",
|
"ai": "^5.0.17",
|
||||||
@@ -85,7 +85,7 @@
|
|||||||
"semver": "7.7.3"
|
"semver": "7.7.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@better-auth/cli": "1.4.18",
|
"@better-auth/cli": "1.4.18",
|
||||||
"@types/semver": "7.7.1",
|
"@types/semver": "7.7.1",
|
||||||
"@types/adm-zip": "^0.5.7",
|
"@types/adm-zip": "^0.5.7",
|
||||||
"@types/bcrypt": "5.0.2",
|
"@types/bcrypt": "5.0.2",
|
||||||
@@ -115,4 +115,4 @@
|
|||||||
"node": "^20.16.0",
|
"node": "^20.16.0",
|
||||||
"pnpm": ">=9.12.0"
|
"pnpm": ">=9.12.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user