mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-18 18:05:18 +00:00
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
This commit is contained in:
@@ -80,6 +80,25 @@ export const DuplicateProject = ({
|
|||||||
api.project.duplicate.useMutation({
|
api.project.duplicate.useMutation({
|
||||||
onSuccess: async (newProject) => {
|
onSuccess: async (newProject) => {
|
||||||
await utils.project.all.invalidate();
|
await utils.project.all.invalidate();
|
||||||
|
|
||||||
|
// If duplicating to same project+environment, invalidate the environment query
|
||||||
|
// to refresh the services list
|
||||||
|
if (duplicateType === "existing-environment") {
|
||||||
|
await utils.environment.one.invalidate({ environmentId: selectedTargetEnvironment });
|
||||||
|
await utils.environment.byProjectId.invalidate({ projectId: selectedTargetProject });
|
||||||
|
|
||||||
|
// If duplicating to the same environment we're currently viewing,
|
||||||
|
// also invalidate the current environment to refresh the services list
|
||||||
|
if (selectedTargetEnvironment === environmentId) {
|
||||||
|
await utils.environment.one.invalidate({ environmentId });
|
||||||
|
// Also invalidate the project query to refresh the project data
|
||||||
|
const projectId = router.query.projectId as string;
|
||||||
|
if (projectId) {
|
||||||
|
await utils.project.one.invalidate({ projectId });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
toast.success(
|
toast.success(
|
||||||
duplicateType === "new-project"
|
duplicateType === "new-project"
|
||||||
? "Project duplicated successfully"
|
? "Project duplicated successfully"
|
||||||
@@ -328,4 +347,4 @@ export const DuplicateProject = ({
|
|||||||
</DialogContent>
|
</DialogContent>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user