Skip to content

Commit abcbd2d

Browse files
feat: auto-refresh services list when duplicating to same environment - Add cache invalidation for environment.one and environment.byProjectId queries - Fix issue where duplicated services weren't visible until hard refresh - Ensure proper invalidation when duplicating to current environment - Resolves #2565
1 parent 24729f3 commit abcbd2d

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

apps/dokploy/components/dashboard/project/duplicate-project.tsx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,25 @@ export const DuplicateProject = ({
8080
api.project.duplicate.useMutation({
8181
onSuccess: async (newProject) => {
8282
await utils.project.all.invalidate();
83+
84+
// If duplicating to same project+environment, invalidate the environment query
85+
// to refresh the services list
86+
if (duplicateType === "existing-environment") {
87+
await utils.environment.one.invalidate({ environmentId: selectedTargetEnvironment });
88+
await utils.environment.byProjectId.invalidate({ projectId: selectedTargetProject });
89+
90+
// If duplicating to the same environment we're currently viewing,
91+
// also invalidate the current environment to refresh the services list
92+
if (selectedTargetEnvironment === environmentId) {
93+
await utils.environment.one.invalidate({ environmentId });
94+
// Also invalidate the project query to refresh the project data
95+
const projectId = router.query.projectId as string;
96+
if (projectId) {
97+
await utils.project.one.invalidate({ projectId });
98+
}
99+
}
100+
}
101+
83102
toast.success(
84103
duplicateType === "new-project"
85104
? "Project duplicated successfully"
@@ -328,4 +347,4 @@ export const DuplicateProject = ({
328347
</DialogContent>
329348
</Dialog>
330349
);
331-
};
350+
};

0 commit comments

Comments
 (0)