Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port user menu to Vue #36232

Merged
merged 1 commit into from
Feb 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/user_status/appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<bugs>https://github.com/nextcloud/server</bugs>
<navigations>
<navigation>
<id>user_status-menuitem</id>
<id>user_status-menu-entry</id>
<name>User status</name>
<order>1</order>
<type>settings</type>
Expand Down
7 changes: 1 addition & 6 deletions apps/user_status/src/UserStatus.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<a v-if="!inline"
class="user-status-menu-item__header"
:href="profilePageLink"
@click="loadProfilePage">
@click.exact="loadProfilePage">
<div class="user-status-menu-item__header-content">
<div class="user-status-menu-item__header-content-displayname">{{ displayName }}</div>
<div v-if="!loadingProfilePage" class="user-status-menu-item__header-content-placeholder" />
Expand Down Expand Up @@ -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;
Expand Down
47 changes: 20 additions & 27 deletions apps/user_status/src/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,42 +24,35 @@

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())

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() {
Expand Down
2 changes: 1 addition & 1 deletion core/css/header.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion core/css/header.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading