feat(patch): implement CreateFileDialog and integrate file creation in PatchEditor

- Added CreateFileDialog component for creating new files within the dashboard.
- Integrated file creation functionality into the PatchEditor, allowing users to create files directly from the directory structure.
- Enhanced user experience with form validation and success/error notifications during file creation.
- Updated ShowPatches to display file types with badges for better clarity on patch operations.
This commit is contained in:
Mauricio Siu
2026-02-17 02:28:20 -06:00
parent 9eeac50642
commit 8aba7b08cf
6 changed files with 395 additions and 40 deletions

View File

@@ -106,6 +106,26 @@ export const deletePatch = async (patchId: string) => {
return result[0];
};
export const markPatchForDeletion = async (
filePath: string,
entityId: string,
entityType: "application" | "compose",
) => {
const existing = await findPatchByFilePath(filePath, entityId, entityType);
if (existing) {
return await updatePatch(existing.patchId, { type: "delete", content: "" });
}
return await createPatch({
filePath,
content: "",
type: "delete",
applicationId: entityType === "application" ? entityId : undefined,
composeId: entityType === "compose" ? entityId : undefined,
});
};
interface ApplyPatchesOptions {
id: string;
type: "application" | "compose";
@@ -133,12 +153,20 @@ export const generateApplyPatchesCommand = async ({
for (const p of patches) {
const filePath = join(codePath, p.filePath);
command += `
if (p.type === "delete") {
command += `
rm -f "${filePath}";
`;
} else {
// create and update: write file
command += `
file="${filePath}"
dir="$(dirname "$file")"
mkdir -p "$dir"
echo "${encodeBase64(p.content)}" | base64 -d > "$file"
`;
}
}
return command;