fix: redirect to apps if multiple apps installed or redirect to apps portal

This commit is contained in:
Shariq Ansari 2024-08-05 16:08:49 +05:30
parent 8e7da4cd7e
commit 67eb28d836
3 changed files with 16 additions and 3 deletions

View file

@ -32,7 +32,7 @@ frappe.setup = {
frappe.pages["setup-wizard"].on_page_load = function (wrapper) {
if (frappe.boot.setup_complete) {
window.location.href = "/app";
window.location.href = frappe.boot.default_path || "/app";
}
let requires = frappe.boot.setup_wizard_requires || [];
frappe.require(requires, function () {
@ -207,7 +207,7 @@ frappe.setup.SetupWizard = class SetupWizard extends frappe.ui.Slides {
}
setTimeout(function () {
// Reload
window.location.href = "/app";
window.location.href = frappe.boot.default_path || "/app";
}, 2000);
}

View file

@ -490,7 +490,7 @@ standard_navbar_items = [
"is_standard": 1,
},
{
"item_label": "App Launcher",
"item_label": "Apps",
"item_type": "Route",
"route": "/apps",
"is_standard": 1,

View file

@ -121,6 +121,18 @@ def clear_expired_sessions():
delete_session(sid, reason="Session Expired")
def get_default_path():
installed_apps = frappe.get_installed_apps()
if len(installed_apps) == 2:
_installed_apps = [app for app in installed_apps if app != "frappe"]
installed_app = _installed_apps[0]
if installed_app:
hooks = frappe.get_hooks(app_name=installed_app)
if hooks.get("app_icon_route"):
return hooks.get("app_icon_route")[0]
return "/apps"
def get():
"""get session boot info"""
from frappe.boot import get_bootinfo, get_unseen_notes
@ -166,6 +178,7 @@ def get():
bootinfo["disable_async"] = frappe.conf.disable_async
bootinfo["setup_complete"] = cint(frappe.get_system_settings("setup_complete"))
bootinfo["default_path"] = get_default_path()
bootinfo["desk_theme"] = frappe.db.get_value("User", frappe.session.user, "desk_theme") or "Light"
bootinfo["user"]["impersonated_by"] = frappe.session.data.get("impersonated_by")