Skip to content

feat: Sync builder_files with page/script delete and rename operations#507

Open
asaura08 wants to merge 4 commits intofrappe:developfrom
asaura08:feature/sync-standard-page
Open

feat: Sync builder_files with page/script delete and rename operations#507
asaura08 wants to merge 4 commits intofrappe:developfrom
asaura08:feature/sync-standard-page

Conversation

@asaura08
Copy link

@asaura08 asaura08 commented Mar 4, 2026

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 its
client 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
image
image

Changes

builder/export_import_standard_page.py

  • delete_standard_page_files(page_name, app_name) — removes
    builder_files/pages/{export_name}/.
  • delete_standard_client_script_files(script_name, app_name) — removes
    builder_files/client_scripts/{export_name}/.
  • rename_standard_client_script_files(old, new, app_name) — renames the
    client-script directory and its inner JSON file.

builder/doctype/builder_page/builder_page.py

  • on_trash — when is_standard, app and developer_mode are set, deletes
    the 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 subsequent on_update
    call re-exports the page under the new name automatically.

builder/doctype/builder_client_script/builder_client_script.py

  • on_trash — removes the script's builder_files directory for every app
    whose 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 whose
    standard pages link to this script.

frontend/src/components/Settings/PageGeneral.vue

  • Added a Page Name field (visible in developer mode when the page is
    standard) that allows renaming the exported file directly from the Builder UI,
    without having to go to Desk.
  • The rename is committed on Enter or when the field loses focus (focusout).

builder/doctype/builder_page/builder_page.js

  • Fixed a bug where the installed-apps list was being assigned to the wrong
    field (module instead of app), which caused the App select in the
    Desk form to appear empty.

frontend/src/components/PageActionsDropdown.vue

  • The Delete action is now shown for standard pages when developer_mode is
    active, consistent with the rest of the developer-mode affordances.

Tests

TestStandardPageSync (6 cases) covers:

  1. on_trash removes the page directory.
  2. on_trash removes an orphaned client-script directory.
  3. on_trash does not remove a client-script directory shared by another
    standard page.
  4. after_rename deletes the old directory and re-exports under the new name.
  5. Client-script on_trash removes the script's directory.
  6. Client-script after_rename renames the directory and inner JSON file.

@asaura08 asaura08 changed the title Fix: Sync builder_files with page/script delete and rename operations Feat: Sync builder_files with page/script delete and rename operations Mar 4, 2026
@asaura08 asaura08 changed the title Feat: Sync builder_files with page/script delete and rename operations feat: Sync builder_files with page/script delete and rename operations Mar 4, 2026
@stravo1
Copy link
Member

stravo1 commented Mar 19, 2026

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 on_trash checks the is_standard property, which is now false.

*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 PageActionsDropdown.vue hidden for standard pages, even in Developer Mode.

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.

@asaura08 @surajshetty3416

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Sync export to app

2 participants