Skip to content

Commit

Permalink
feat(workspace): Allow user to choose a default workspace
Browse files Browse the repository at this point in the history
(cherry picked from commit 3ec47b0)

# Conflicts:
#	frappe/core/doctype/user/user.json
  • Loading branch information
cogk authored and mergify[bot] committed Mar 20, 2024
1 parent 01f469f commit bfa1a83
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 2 deletions.
10 changes: 10 additions & 0 deletions frappe/core/doctype/user/user.js
@@ -1,4 +1,14 @@
frappe.ui.form.on("User", {
setup: function (frm) {
frm.set_query("default_workspace", () => {
return {
filters: {
parent_page: ["is", "not set"],
for_user: ["in", [null, frappe.session.user]],
},
};
});
},
before_load: function (frm) {
let update_tz_options = function () {
frm.fields_dict.time_zone.set_data(frappe.all_timezones);
Expand Down
27 changes: 26 additions & 1 deletion frappe/core/doctype/user/user.json
Expand Up @@ -23,6 +23,8 @@
"send_welcome_email",
"unsubscribed",
"user_image",
"workspaces_section",
"default_workspace",
"roles_permissions_tab",
"sb1",
"role_profile_name",
Expand Down Expand Up @@ -702,6 +704,29 @@
"fieldtype": "Small Text",
"hidden": 1,
"label": "Onboarding Status"
<<<<<<< HEAD
=======
},
{
"allow_in_quick_entry": 1,
"fieldname": "role_profiles",
"fieldtype": "Table MultiSelect",
"label": "Role Profiles",
"options": "User Role Profile",
"permlevel": 1
},
{
"fieldname": "workspaces_section",
"fieldtype": "Section Break",
"label": "Workspaces"
},
{
"description": "If left empty, the default workspace will be the last visited workspace",
"fieldname": "default_workspace",
"fieldtype": "Link",
"label": "Default Workspace",
"options": "Workspace"
>>>>>>> 3ec47b0975 (feat(workspace): Allow user to choose a default workspace)
}
],
"icon": "fa fa-user",
Expand Down Expand Up @@ -764,7 +789,7 @@
"link_fieldname": "user"
}
],
"modified": "2024-02-11 13:16:29.574666",
"modified": "2024-03-06 11:14:38.424148",
"modified_by": "Administrator",
"module": "Core",
"name": "User",
Expand Down
7 changes: 6 additions & 1 deletion frappe/public/js/frappe/views/workspace/workspace.js
Expand Up @@ -351,7 +351,12 @@ frappe.views.Workspace = class Workspace {
get_page_to_show() {
let default_page;

if (
if (frappe.boot.user.default_workspace) {
default_page = {
name: frappe.boot.user.default_workspace.name,
public: frappe.boot.user.default_workspace.public,
};
} else if (
localStorage.current_page &&
this.all_pages.filter((page) => page.title == localStorage.current_page).length != 0
) {
Expand Down
5 changes: 5 additions & 0 deletions frappe/utils/user.py
Expand Up @@ -226,13 +226,18 @@ def load_user(self):
"send_me_a_copy",
"user_type",
"onboarding_status",
"default_workspace",
],
as_dict=True,
)

if not self.can_read:
self.build_permissions()

if d.get("default_workspace"):
public = frappe.get_cached_value("Workspace", d.default_workspace, "public")
d.default_workspace = {"name": d.default_workspace, "public": public}

d.name = self.name
d.onboarding_status = frappe.parse_json(d.onboarding_status)
d.roles = self.get_roles()
Expand Down

0 comments on commit bfa1a83

Please sign in to comment.