diff --git a/frontend/src/components/Apps.vue b/frontend/src/components/Apps.vue new file mode 100644 index 00000000..6ee170a8 --- /dev/null +++ b/frontend/src/components/Apps.vue @@ -0,0 +1,67 @@ + + \ No newline at end of file diff --git a/frontend/src/components/UserDropdown.vue b/frontend/src/components/UserDropdown.vue index 67c4bc96..348e7918 100644 --- a/frontend/src/components/UserDropdown.vue +++ b/frontend/src/components/UserDropdown.vue @@ -66,6 +66,7 @@ import LMSLogo from '@/components/Icons/LMSLogo.vue' import { sessionStore } from '@/stores/session' import { Dropdown } from 'frappe-ui' +import Apps from '@/components/Apps.vue' import { ChevronDown, LogIn, @@ -77,7 +78,7 @@ import { import { useRouter } from 'vue-router' import { convertToTitleCase } from '../utils' import { usersStore } from '@/stores/user' -import { ref } from 'vue' +import { ref, markRaw } from 'vue' import SettingsModal from '@/components/Modals/Settings.vue' const router = useRouter() @@ -105,11 +106,7 @@ const userDropdownOptions = [ }, }, { - icon: ArrowRightLeft, - label: 'Switch to Desk', - onClick: () => { - window.location.href = '/app' - }, + component: markRaw(Apps), condition: () => { let cookies = new URLSearchParams(document.cookie.split('; ').join('&')) let system_user = cookies.get('system_user') diff --git a/lms/hooks.py b/lms/hooks.py index f513c8d6..db020daa 100644 --- a/lms/hooks.py +++ b/lms/hooks.py @@ -4,9 +4,11 @@ app_name = "frappe_lms" app_title = "Frappe LMS" app_publisher = "Frappe" app_description = "Frappe LMS App" -app_icon = "octicon octicon-file-directory" +app_icon_url = "/assets/lms/images/lms-logo.png" +app_icon_title = "Learning" +app_icon_route = "/lms" app_color = "grey" -app_email = "school@frappe.io" +app_email = "jannat@frappe.io" app_license = "AGPL" # Includes in @@ -61,8 +63,6 @@ web_include_js = ["website.bundle.js"] after_install = "lms.install.after_install" after_sync = "lms.install.after_sync" before_uninstall = "lms.install.before_uninstall" - - setup_wizard_requires = "assets/lms/js/setup_wizard.js" # Desk Notifications @@ -231,3 +231,11 @@ profile_url_prefix = "/users/" signup_form_template = "lms.plugins.show_custom_signup" on_session_creation = "lms.overrides.user.on_session_creation" + +add_to_apps_screen = [{ + "name": "lms", + "logo": "/assets/lms/images/lms-logo.png", + "title": "Learning", + "route": "/lms", + "has_permission": "lms.lms.api.check_app_permission" +}] \ No newline at end of file diff --git a/lms/lms/api.py b/lms/lms/api.py index df2272cd..9440b998 100644 --- a/lms/lms/api.py +++ b/lms/lms/api.py @@ -597,3 +597,15 @@ def get_members(start=0, search=""): member.role = "LMS Student" return members + +def check_app_permission(): + """Check if the user has permission to access the app.""" + if frappe.session.user == "Administrator": + return True + + roles = frappe.get_roles() + lms_roles = ["Moderator", "Course Creator", "Batch Evaluator", "LMS Student"] + if any(role in roles for role in lms_roles): + return True + + return False diff --git a/lms/public/images/desk.png b/lms/public/images/desk.png new file mode 100644 index 00000000..f4a09599 Binary files /dev/null and b/lms/public/images/desk.png differ