瀏覽代碼

fix: Workspace not found error that happens when a workspace which was deleted when still in use and hence won't let the user to use the desk page

version-14
nikhilponnuru 4 年之前
父節點
當前提交
cd4fff5daf
共有 2 個檔案被更改,包括 17 行新增11 行删除
  1. +13
    -9
      frappe/desk/desktop.py
  2. +4
    -2
      frappe/public/js/frappe/views/workspace/workspace.js

+ 13
- 9
frappe/desk/desktop.py 查看文件

@@ -359,15 +359,18 @@ def get_desktop_page(page):
Returns: Returns:
dict: dictionary of cards, charts and shortcuts to be displayed on website dict: dictionary of cards, charts and shortcuts to be displayed on website
""" """
wspace = Workspace(page)
wspace.build_workspace()
return {
'charts': wspace.charts,
'shortcuts': wspace.shortcuts,
'cards': wspace.cards,
'onboarding': wspace.onboarding,
'allow_customization': not wspace.doc.disable_user_customization
}
try:
wspace = Workspace(page)
wspace.build_workspace()
return {
'charts': wspace.charts,
'shortcuts': wspace.shortcuts,
'cards': wspace.cards,
'onboarding': wspace.onboarding,
'allow_customization': not wspace.doc.disable_user_customization
}
except DoesNotExistError:
return {}


@frappe.whitelist() @frappe.whitelist()
def get_desk_sidebar_items(): def get_desk_sidebar_items():
@@ -608,3 +611,4 @@ def merge_cards_based_on_label(cards):
cards_dict[label] = card cards_dict[label] = card


return list(cards_dict.values()) return list(cards_dict.values())


+ 4
- 2
frappe/public/js/frappe/views/workspace/workspace.js 查看文件

@@ -246,7 +246,7 @@ class DesktopPage {
this.page.appendTo(this.container); this.page.appendTo(this.container);


this.get_data().then(() => { this.get_data().then(() => {
if (!this.data) {
if (Object.keys(this.data).length == 0) {
delete localStorage.current_workspace; delete localStorage.current_workspace;
frappe.set_route("workspace"); frappe.set_route("workspace");
return; return;
@@ -274,7 +274,7 @@ class DesktopPage {
page: this.page_name page: this.page_name
}).then(data => { }).then(data => {
this.data = data; this.data = data;
if (!this.data) return;
if (Object.keys(this.data).length == 0) return;


return frappe.dashboard_utils.get_dashboard_settings().then(settings => { return frappe.dashboard_utils.get_dashboard_settings().then(settings => {
let chart_config = settings.chart_config ? JSON.parse(settings.chart_config) : {}; let chart_config = settings.chart_config ? JSON.parse(settings.chart_config) : {};
@@ -410,3 +410,5 @@ class DesktopPage {
this.sections["cards"] = cards; this.sections["cards"] = cards;
} }
} }



Loading…
取消
儲存