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 --- apps/user_status/appinfo/info.xml | 2 +- apps/user_status/src/UserStatus.vue | 7 +----- apps/user_status/src/menu.js | 47 ++++++++++++++++--------------------- 3 files changed, 22 insertions(+), 34 deletions(-) (limited to 'apps/user_status') diff --git a/apps/user_status/appinfo/info.xml b/apps/user_status/appinfo/info.xml index 90744d40747..3c2486fde76 100644 --- a/apps/user_status/appinfo/info.xml +++ b/apps/user_status/appinfo/info.xml @@ -13,7 +13,7 @@ https://github.com/nextcloud/server - user_status-menuitem + user_status-menu-entry User status 1 settings diff --git a/apps/user_status/src/UserStatus.vue b/apps/user_status/src/UserStatus.vue index a4b7b9552f3..28c0896fee5 100644 --- a/apps/user_status/src/UserStatus.vue +++ b/apps/user_status/src/UserStatus.vue @@ -26,7 +26,7 @@ + @click.exact="loadProfilePage">
{{ displayName }}
@@ -234,11 +234,6 @@ export default { align-items: flex-start !important; color: var(--color-main-text) !important; - &:focus-visible { - padding: 6px 8px 1px 8px !important; - margin: 2px !important; - } - &:not([href]) { height: var(--header-menu-item-height) !important; color: var(--color-text-maxcontrast) !important; diff --git a/apps/user_status/src/menu.js b/apps/user_status/src/menu.js index 66010102f10..abcfe7b7527 100644 --- a/apps/user_status/src/menu.js +++ b/apps/user_status/src/menu.js @@ -24,10 +24,11 @@ import Vue from 'vue' import { getRequestToken } from '@nextcloud/auth' -import UserStatus from './UserStatus' -import store from './store' -import NcAvatar from '@nextcloud/vue/dist/Components/NcAvatar' -import { loadState } from '@nextcloud/initial-state' +import { subscribe } from '@nextcloud/event-bus' + +import UserStatus from './UserStatus.vue' + +import store from './store/index.js' // eslint-disable-next-line camelcase __webpack_nonce__ = btoa(getRequestToken()) @@ -35,31 +36,23 @@ __webpack_nonce__ = btoa(getRequestToken()) Vue.prototype.t = t Vue.prototype.$t = t -const avatarDiv = document.getElementById('avatardiv-menu') -const userStatusData = loadState('user_status', 'status') -const propsData = { - preloadedUserStatus: { - message: userStatusData.message, - icon: userStatusData.icon, - status: userStatusData.status, - }, - user: avatarDiv.dataset.user, - displayName: avatarDiv.dataset.displayname, - disableMenu: true, - disableTooltip: true, -} +const mountPoint = document.getElementById('user_status-menu-entry') -const NcAvatarInMenu = Vue.extend(NcAvatar) -new NcAvatarInMenu({ propsData }).$mount('#avatardiv-menu') +const mountMenuEntry = () => { + const mountPoint = document.getElementById('user_status-menu-entry') + // eslint-disable-next-line no-new + new Vue({ + el: mountPoint, + render: h => h(UserStatus), + store, + }) +} -// Register settings menu entry -export default new Vue({ - el: 'li[data-id="user_status-menuitem"]', - // eslint-disable-next-line vue/match-component-file-name - name: 'UserStatusRoot', - render: h => h(UserStatus), - store, -}) +if (mountPoint) { + mountMenuEntry() +} else { + subscribe('core:user-menu:mounted', mountMenuEntry) +} // Register dashboard status document.addEventListener('DOMContentLoaded', function() { -- cgit v1.2.3