Skip to content

Commit c779982

Browse files
committed
Port user menu to Vue
Signed-off-by: Christopher Ng <[email protected]>
1 parent e47d56a commit c779982

File tree

21 files changed

+344
-261
lines changed

21 files changed

+344
-261
lines changed

apps/user_status/appinfo/info.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<bugs>https://github.com/nextcloud/server</bugs>
1414
<navigations>
1515
<navigation>
16-
<id>user_status-menuitem</id>
16+
<id>user_status-menu-entry</id>
1717
<name>User status</name>
1818
<order>1</order>
1919
<type>settings</type>

apps/user_status/src/UserStatus.vue

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<a v-if="!inline"
2727
class="user-status-menu-item__header"
2828
:href="profilePageLink"
29-
@click="loadProfilePage">
29+
@click.exact="loadProfilePage">
3030
<div class="user-status-menu-item__header-content">
3131
<div class="user-status-menu-item__header-content-displayname">{{ displayName }}</div>
3232
<div v-if="!loadingProfilePage" class="user-status-menu-item__header-content-placeholder" />
@@ -234,11 +234,6 @@ export default {
234234
align-items: flex-start !important;
235235
color: var(--color-main-text) !important;
236236
237-
&:focus-visible {
238-
padding: 6px 8px 1px 8px !important;
239-
margin: 2px !important;
240-
}
241-
242237
&:not([href]) {
243238
height: var(--header-menu-item-height) !important;
244239
color: var(--color-text-maxcontrast) !important;

apps/user_status/src/menu.js

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -24,42 +24,35 @@
2424

2525
import Vue from 'vue'
2626
import { getRequestToken } from '@nextcloud/auth'
27-
import UserStatus from './UserStatus'
28-
import store from './store'
29-
import NcAvatar from '@nextcloud/vue/dist/Components/NcAvatar'
30-
import { loadState } from '@nextcloud/initial-state'
27+
import { subscribe } from '@nextcloud/event-bus'
28+
29+
import UserStatus from './UserStatus.vue'
30+
31+
import store from './store/index.js'
3132

3233
// eslint-disable-next-line camelcase
3334
__webpack_nonce__ = btoa(getRequestToken())
3435

3536
Vue.prototype.t = t
3637
Vue.prototype.$t = t
3738

38-
const avatarDiv = document.getElementById('avatardiv-menu')
39-
const userStatusData = loadState('user_status', 'status')
40-
const propsData = {
41-
preloadedUserStatus: {
42-
message: userStatusData.message,
43-
icon: userStatusData.icon,
44-
status: userStatusData.status,
45-
},
46-
user: avatarDiv.dataset.user,
47-
displayName: avatarDiv.dataset.displayname,
48-
disableMenu: true,
49-
disableTooltip: true,
50-
}
39+
const mountPoint = document.getElementById('user_status-menu-entry')
5140

52-
const NcAvatarInMenu = Vue.extend(NcAvatar)
53-
new NcAvatarInMenu({ propsData }).$mount('#avatardiv-menu')
41+
const mountMenuEntry = () => {
42+
const mountPoint = document.getElementById('user_status-menu-entry')
43+
// eslint-disable-next-line no-new
44+
new Vue({
45+
el: mountPoint,
46+
render: h => h(UserStatus),
47+
store,
48+
})
49+
}
5450

55-
// Register settings menu entry
56-
export default new Vue({
57-
el: 'li[data-id="user_status-menuitem"]',
58-
// eslint-disable-next-line vue/match-component-file-name
59-
name: 'UserStatusRoot',
60-
render: h => h(UserStatus),
61-
store,
62-
})
51+
if (mountPoint) {
52+
mountMenuEntry()
53+
} else {
54+
subscribe('core:user-menu:mounted', mountMenuEntry)
55+
}
6356

6457
// Register dashboard status
6558
document.addEventListener('DOMContentLoaded', function() {

core/css/header.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/css/header.css.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)