Merge pull request #27876 from rmehta/fix-workspace-app

fix(minor): Set default app in Workspace and Module Def
This commit is contained in:
Rushabh Mehta 2024-09-23 21:25:51 +05:30 committed by GitHub
commit 1a0d82f63c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 39 additions and 3 deletions

View file

@ -26,6 +26,12 @@ class ModuleDef(Document):
restrict_to_domain: DF.Link | None
# end: auto-generated types
def validate(self):
from frappe.modules.utils import get_module_app
if not self.app_name and not self.custom:
self.app_name = get_module_app(self.name)
def on_update(self):
"""If in `developer_mode`, create folder for module and
add in `modules.txt` of app if missing."""

View file

@ -0,0 +1,19 @@
# update app in `Module Def` and `Workspace`
import frappe
from frappe.modules.utils import get_module_app
def execute():
for module in frappe.get_all("Module Def", ["name", "app_name"], filters=dict(custom=0)):
if not module.app_name:
frappe.db.set_value("Module Def", module.name, "app_name", get_module_app(module.name))
for workspace in frappe.get_all("Workspace", ["name", "module", "app"]):
if not workspace.app and workspace.module:
frappe.db.set_value(
"Workspace",
workspace.name,
"app",
frappe.db.get_value("Module Def", workspace.module, "app_name"),
)

View file

@ -85,6 +85,11 @@ class Workspace(Document):
if d.link_type == "Report" and d.is_query_report != 1:
d.report_ref_doctype = frappe.get_value("Report", d.link_to, "ref_doctype")
if not self.app and self.module:
from frappe.modules.utils import get_module_app
self.app = get_module_app(self.module)
def clear_cache(self):
super().clear_cache()
if self.for_user:
@ -262,7 +267,7 @@ def new_page(new_page):
doc = frappe.new_doc("Workspace")
doc.title = page.get("title")
doc.icon = page.get("icon") or "dashboard"
doc.icon = page.get("icon") or "grid"
doc.indicator_color = page.get("indicator_color")
doc.content = page.get("content")
doc.parent_page = page.get("parent_page")

View file

@ -240,3 +240,4 @@ frappe.patches.v16_0.switch_default_sort_order
frappe.integrations.doctype.oauth_client.patches.set_default_allowed_role_in_oauth_client
execute:frappe.db.set_single_value("Workspace Settings", "workspace_setup_completed", 1)
frappe.patches.v16_0.add_app_launcher_in_navbar_settings
frappe.desk.doctype.workspace.patches.update_app

View file

@ -200,8 +200,13 @@ frappe.views.Workspace = class Workspace {
let current_page = this.sidebar.all_pages.filter((p) => p.name == page.name)[0];
this._page = current_page;
let app =
this._page.app || frappe.boot.module_app[frappe.router.slug(this._page.module)];
// set app
let app = this._page.app;
if (!app && this._page.module) {
app = frappe.boot.module_app[frappe.router.slug(this._page.module)];
}
if (!app) app = "frappe";
if (typeof current_page.content == "string") {
current_page.content = JSON.parse(current_page.content);