feat: Sync builder_files with page/script delete and rename operations#507
feat: Sync builder_files with page/script delete and rename operations#507asaura08 wants to merge 4 commits intofrappe:developfrom
builder_files with page/script delete and rename operations#507Conversation
builder_files with page/script delete and rename operationsbuilder_files with page/script delete and rename operations
builder_files with page/script delete and rename operationsbuilder_files with page/script delete and rename operations
|
Hi, thanks for the PR! I noticed a couple of things that could be improved. It works correctly when directly deleting a standard page (more on this below*), but if I first uncheck “Standard Page”, the files remain. Then, when deleting that now non-standard page, the files are still not removed, since *In the PR, deleting a standard page is allowed in Developer Mode. However, I feel it might be better to keep the “Delete” action in Perhaps a cleaner approach would be to delete the page files when the “Standard Page” toggle is unchecked. This seems like a better UX and would also remove the need to enable the “Delete” action in Developer Mode. |
Problem
When a page is marked as a standard page, Builder writes its source files to
{app}/builder_files/pages/{page_name}/. However, when that page (or any of itsclient scripts) was deleted or renamed through the Builder UI or Desk, the
corresponding files on disk were not removed or updated. This left orphaned
directories in the app's source code that had no corresponding record in the
database — inconsistent with how Frappe handles standard DocTypes in developer
mode.
fix #496
Solution
Mirrors the behaviour of Frappe's own DocType sync in developer mode: any
filesystem artifact created when a record is exported must be cleaned up when
that record is deleted or renamed.
now


Changes
builder/export_import_standard_page.pydelete_standard_page_files(page_name, app_name)— removesbuilder_files/pages/{export_name}/.delete_standard_client_script_files(script_name, app_name)— removesbuilder_files/client_scripts/{export_name}/.rename_standard_client_script_files(old, new, app_name)— renames theclient-script directory and its inner JSON file.
builder/doctype/builder_page/builder_page.pyon_trash— whenis_standard,appanddeveloper_modeare set, deletesthe page directory and any client-script directories that are no longer
referenced by another standard page in the same app.
after_rename— deletes the old page directory; the subsequenton_updatecall re-exports the page under the new name automatically.
builder/doctype/builder_client_script/builder_client_script.pyon_trash— removes the script'sbuilder_filesdirectory for every appwhose standard pages reference it.
after_rename— renames the script directory in every referencing app._get_referencing_apps()— helper that returns the unique set of apps whosestandard pages link to this script.
frontend/src/components/Settings/PageGeneral.vuestandard) that allows renaming the exported file directly from the Builder UI,
without having to go to Desk.
Enteror when the field loses focus (focusout).builder/doctype/builder_page/builder_page.jsfield (
moduleinstead ofapp), which caused the App select in theDesk form to appear empty.
frontend/src/components/PageActionsDropdown.vuedeveloper_modeisactive, consistent with the rest of the developer-mode affordances.
Tests
TestStandardPageSync(6 cases) covers:on_trashremoves the page directory.on_trashremoves an orphaned client-script directory.on_trashdoes not remove a client-script directory shared by anotherstandard page.
after_renamedeletes the old directory and re-exports under the new name.on_trashremoves the script's directory.after_renamerenames the directory and inner JSON file.