Skip to content

Commit

Permalink
Merge pull request #6821 from pratu16x7/explore-2.0
Browse files Browse the repository at this point in the history
feat(explore_page): Modules and Module Detail views
  • Loading branch information
rmehta committed Feb 7, 2019
2 parents 9200415 + 043e290 commit 056daa8
Show file tree
Hide file tree
Showing 60 changed files with 850 additions and 1,252 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Expand Up @@ -120,6 +120,7 @@
"md5": true,
"$": true,
"jQuery": true,
"Vue": true,
"moment": true,
"hljs": true,
"Awesomplete": true,
Expand Down
7 changes: 0 additions & 7 deletions cypress/integration/awesome_bar.js
Expand Up @@ -8,13 +8,6 @@ context('Awesome Bar', () => {
cy.get('.navbar-home').click();
});

it('navigates to modules', () => {
cy.get('#navbar-search')
.type('modules{downarrow}{enter}', { delay: 100 });

cy.location('hash').should('eq', '#modules');
});

it('navigates to doctype list', () => {
cy.get('#navbar-search')
.type('todo{downarrow}{enter}', { delay: 100 });
Expand Down
4 changes: 2 additions & 2 deletions frappe/boot.py
Expand Up @@ -96,8 +96,8 @@ def load_conf_settings(bootinfo):
if key in conf: bootinfo[key] = conf.get(key)

def load_desktop_icons(bootinfo):
from frappe.desk.doctype.desktop_icon.desktop_icon import get_desktop_icons
bootinfo.desktop_icons = get_desktop_icons()
from frappe.config import get_modules_from_all_apps_for_user
bootinfo.allowed_modules = get_modules_from_all_apps_for_user()

def get_allowed_pages():
return get_user_pages_or_reports('Page')
Expand Down
85 changes: 85 additions & 0 deletions frappe/config/__init__.py
@@ -0,0 +1,85 @@
from __future__ import unicode_literals
from frappe import _
import frappe
from frappe.desk.moduleview import get_data
from six import iteritems

def get_modules_from_all_apps_for_user(user=None):
if not user:
user = frappe.session.user

all_modules = get_modules_from_all_apps()
user_blocked_modules = frappe.get_doc('User', user).get_blocked_modules()

allowed_modules_list = [m for m in all_modules if m.get("module_name") not in user_blocked_modules]

return allowed_modules_list

def get_modules_from_all_apps():
modules_list = []
for app in frappe.get_installed_apps():
modules_list += get_modules_from_app(app)
return modules_list

def get_modules_from_app(app):
try:
modules = frappe.get_attr(app + '.config.desktop.get_data')() or {}
except ImportError:
return []

# Only newly formatted modules that have a category to be shown on desk
modules = [m for m in modules if m.get("category")]

active_domains = frappe.get_active_domains()

if isinstance(modules, dict):
active_modules_list = []
for m, module in iteritems(modules):
module['module_name'] = m
active_modules_list.append(module)
else:
active_modules_list = []
for m in modules:
to_add = True
module_name = m.get("module_name")

# Check Domain
if is_domain(m):
if module_name not in active_domains:
to_add = False

if "condition" in m and not m["condition"]:
to_add = False

if to_add:
onboard_present = is_onboard_present(m) if show_onboard(m) else False
m["onboard_present"] = onboard_present
active_modules_list.append(m)

return active_modules_list

def show_onboard(module):
return module.get("type") == "module" and module.get("category") in ["Modules", "Domains"]

def is_onboard_present(module):
print(module["module_name"])
exists_cache = {}
def exists(name, link_type):
exists = exists_cache.get(name)
if not exists:
if link_type == "doctype" and not frappe.db.get_value('DocType', name, 'issingle'):
exists = frappe.db.count(name)
else:
exists = True
exists_cache[name] = exists
return exists

sections = get_data(module["module_name"], False)
for section in sections:
for item in section["items"]:
if exists(item.get("name"), item.get("type")):
return True
return False

def is_domain(module):
return module.get("category") == "Domains"
24 changes: 14 additions & 10 deletions frappe/config/desk.py
Expand Up @@ -12,18 +12,26 @@ def get_data():
"name": "ToDo",
"label": _("To Do"),
"description": _("Documents assigned to you and by you."),
},
{
"type": "doctype",
"name": "File",
"label": _("Files"),
"onboard": 1,
},
{
"type": "doctype",
"name": "Event",
"label": _("Calendar"),
"link": "List/Event/Calendar",
"description": _("Event and other calendars."),
"onboard": 1,
},
{
"type": "doctype",
"name": "Note",
"description": _("Private and public Notes."),
"onboard": 1,
},
{
"type": "doctype",
"name": "File",
"label": _("Files"),
},
{
"type": "page",
Expand All @@ -32,11 +40,6 @@ def get_data():
"description": _("Chat messages and other notifications."),
"data_doctype": "Communication"
},
{
"type": "doctype",
"name": "Note",
"description": _("Private and public Notes."),
},
{
"type": "page",
"label": _("Activity"),
Expand All @@ -52,6 +55,7 @@ def get_data():
"type": "doctype",
"name": "Newsletter",
"description": _("Newsletters to contacts, leads."),
"onboard": 1,
},
{
"type": "doctype",
Expand Down
92 changes: 44 additions & 48 deletions frappe/config/desktop.py
@@ -1,91 +1,87 @@
from __future__ import unicode_literals
import frappe
from frappe import _

def get_data():
return [
# Administration
{
"module_name": "Desk",
"category": "Administration",
"label": _("Tools"),
"color": "#FFF5A7",
"reverse": 1,
"icon": "octicon octicon-calendar",
"type": "module"
},
{
"module_name": "File Manager",
"color": "#AA784D",
"doctype": "File",
"icon": "octicon octicon-file-directory",
"label": _("File Manager"),
"link": "List/File",
"type": "list",
"hidden": 1
"type": "module",
"description": "Todos, Notes and other basic tools to help you track your work."
},
{
"module_name": "Website",
"color": "#16a085",
"icon": "octicon octicon-globe",
"module_name": "Settings",
"category": "Administration",
"label": _("Settings"),
"color": "#bdc3c7",
"reverse": 1,
"icon": "octicon octicon-settings",
"type": "module",
"hidden": 1
"hidden": 1,
"description": "Configure your ERPNext account."
},
{
"module_name": "Integrations",
"category": "Administration",
"label": _("Integrations"),
"color": "#16a085",
"icon": "octicon octicon-globe",
"type": "module",
"hidden": 1
},
{
"module_name": "Setup",
"color": "#bdc3c7",
"reverse": 1,
"icon": "octicon octicon-settings",
"type": "module",
"hidden": 1
"hidden": 1,
"description": "DropBox, Woocomerce, AWS, Shopify and GoCardless."
},
{
"module_name": 'Email Inbox',
"type": 'list',
"label": 'Email Inbox',
"_label": _('Email Inbox'),
"_id": 'Email Inbox',
"_doctype": 'Communication',
"icon": 'fa fa-envelope-o',
"color": '#589494',
"link": 'List/Communication/Inbox'
"module_name": 'Contacts',
"category": "Administration",
"label": _("Contacts"),
"type": 'module',
"icon": "octicon octicon-book",
"color": '#ffaedb',
"hidden": 1,
"description": "People Contacts and Address Book."
},
{
"module_name": "Core",
"label": "Developer",
"category": "Administration",
"_label": _("Developer"),
"label": "Developer",
"color": "#589494",
"icon": "octicon octicon-circuit-board",
"type": "module",
"system_manager": 1,
"hidden": 1
"condition": getattr(frappe.local.conf, 'developer_mode', 0),
"hidden": 1,
"description": "The Frappe innards of ERPNext. (Only active when developer mode is enabled)"
},

# Places
{
"module_name": 'Contacts',
"type": 'module',
"icon": "octicon octicon-book",
"color": '#FFAEDB',
"module_name": "Website",
"category": "Places",
"label": _("Website"),
"_label": _("Website"),
"color": "#16a085",
"icon": "octicon octicon-globe",
"type": "module",
"hidden": 1,
"description": "Webpages and the Portal Side of Things."
},
{
"module_name": 'Social',
"category": "Places",
"label": _('Social'),
"icon": "octicon octicon-heart",
"type": 'link',
"link": 'social/home',
"link": '#social/home',
"color": '#FF4136',
'standard': 1,
'idx': 15
'idx': 15,
"description": "Build your profile and share posts on the feed with other users."
},
{
"module_name": 'Settings',
"color": "#bdc3c7",
"reverse": 1,
"icon": "octicon octicon-settings",
"type": "module"
}
]
51 changes: 0 additions & 51 deletions frappe/config/settings.py

This file was deleted.

0 comments on commit 056daa8

Please sign in to comment.