From c77998209f779dfccd86afeeafd43a7bbd886ff2 Mon Sep 17 00:00:00 2001 From: Christopher Ng Date: Thu, 9 Feb 2023 17:54:59 -0800 Subject: Port user menu to Vue Signed-off-by: Christopher Ng --- core/src/components/UserMenu.js | 45 ++---- core/src/components/UserMenu/UserMenuEntry.vue | 106 ++++++++++++++ core/src/views/UserMenu.vue | 184 +++++++++++++++++++++++++ 3 files changed, 301 insertions(+), 34 deletions(-) create mode 100644 core/src/components/UserMenu/UserMenuEntry.vue create mode 100644 core/src/views/UserMenu.vue (limited to 'core/src') diff --git a/core/src/components/UserMenu.js b/core/src/components/UserMenu.js index f82a303d1fd..e165e784422 100644 --- a/core/src/components/UserMenu.js +++ b/core/src/components/UserMenu.js @@ -2,6 +2,7 @@ * @copyright 2019 Christoph Wurst * * @author Christoph Wurst + * @author Christopher Ng * * @license AGPL-3.0-or-later * @@ -20,41 +21,17 @@ * */ -import OC from '../OC' +import Vue from 'vue' -import $ from 'jquery' +import UserMenu from '../views/UserMenu.vue' export const setUp = () => { - const $menu = $('#header #settings') - // Using page terminoogy as below - const $excludedPageClasses = [ - 'user-status-menu-item__header', - ] - - // show loading feedback - $menu.delegate('a', 'click', event => { - let $page = $(event.target) - if (!$page.is('a')) { - $page = $page.closest('a') - } - if (event.which === 1 && !event.ctrlKey && !event.metaKey) { - if (!$excludedPageClasses.includes($page.attr('class'))) { - $page.find('img').remove() - $page.find('div').remove() // prevent odd double-clicks - $page.prepend($('
').addClass('icon-loading-small')) - } - } else { - // Close navigation when opening menu entry in - // a new tab - OC.hideMenus(() => false) - } - }) - - $menu.delegate('a', 'mouseup', event => { - if (event.which === 2) { - // Close navigation when opening app in - // a new tab via middle click - OC.hideMenus(() => false) - } - }) + const mountPoint = document.getElementById('user-menu') + if (mountPoint) { + // eslint-disable-next-line no-new + new Vue({ + el: mountPoint, + render: h => h(UserMenu), + }) + } } diff --git a/core/src/components/UserMenu/UserMenuEntry.vue b/core/src/components/UserMenu/UserMenuEntry.vue new file mode 100644 index 00000000000..43f65fa9fdb --- /dev/null +++ b/core/src/components/UserMenu/UserMenuEntry.vue @@ -0,0 +1,106 @@ + + + + + + + diff --git a/core/src/views/UserMenu.vue b/core/src/views/UserMenu.vue new file mode 100644 index 00000000000..5112b8a4eae --- /dev/null +++ b/core/src/views/UserMenu.vue @@ -0,0 +1,184 @@ + + + + + + + -- cgit v1.2.3