mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-01 01:32:16 +00:00
refactor(patch-editor): streamline patch saving and loading logic
- Removed the local state for saving status and integrated loading state directly from the mutation hook. - Updated the saveAsPatch function to handle success and error notifications more cleanly. - Adjusted the file content loading to ensure it retrieves the latest data, improving user experience and consistency in the PatchEditor component. - Refactored API calls in the patch router to unify patch retrieval logic for applications and composes, enhancing maintainability.
This commit is contained in:
@@ -76,23 +76,15 @@ export const findPatchesByComposeId = async (composeId: string) => {
|
||||
|
||||
export const findPatchByFilePath = async (
|
||||
filePath: string,
|
||||
applicationId?: string,
|
||||
composeId?: string,
|
||||
id: string,
|
||||
type: "application" | "compose",
|
||||
) => {
|
||||
if (applicationId) {
|
||||
return await db.query.patch.findFirst({
|
||||
where: and(
|
||||
eq(patch.filePath, filePath),
|
||||
eq(patch.applicationId, applicationId),
|
||||
),
|
||||
});
|
||||
}
|
||||
if (composeId) {
|
||||
return await db.query.patch.findFirst({
|
||||
where: and(eq(patch.filePath, filePath), eq(patch.composeId, composeId)),
|
||||
});
|
||||
}
|
||||
return null;
|
||||
return await db.query.patch.findFirst({
|
||||
where:
|
||||
type === "application"
|
||||
? and(eq(patch.filePath, filePath), eq(patch.applicationId, id))
|
||||
: and(eq(patch.filePath, filePath), eq(patch.composeId, id)),
|
||||
});
|
||||
};
|
||||
|
||||
export const updatePatch = async (patchId: string, data: Partial<Patch>) => {
|
||||
|
||||
Reference in New Issue
Block a user