Skip to content

Commit c2c704a

Browse files
committed
Port user menu to Vue
Signed-off-by: Christopher Ng <chrng8@gmail.com>
1 parent 75d7203 commit c2c704a

File tree

19 files changed

+321
-255
lines changed

19 files changed

+321
-255
lines changed

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: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -24,42 +24,31 @@
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,
39+
const mountMenu = () => {
40+
const mountPoint = document.querySelector('li[data-id="user_status-menuitem"]')
41+
if (mountPoint) {
42+
// eslint-disable-next-line no-new
43+
new Vue({
44+
el: mountPoint,
45+
render: h => h(UserStatus),
46+
store,
47+
})
48+
}
5049
}
5150

52-
const NcAvatarInMenu = Vue.extend(NcAvatar)
53-
new NcAvatarInMenu({ propsData }).$mount('#avatardiv-menu')
54-
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+
subscribe('core:user-menu:mounted', mountMenu)
6352

6453
// Register dashboard status
6554
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.

core/css/header.scss

Lines changed: 0 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -130,61 +130,6 @@
130130
-webkit-overflow-scrolling: touch;
131131
@include header-menu-height();
132132
}
133-
134-
/* Use by the settings right menu */
135-
&.settings-menu > ul {
136-
padding: 4px;
137-
display: flex;
138-
flex-direction: column;
139-
gap: 2px;
140-
li {
141-
a {
142-
border-radius: 6px;
143-
display: inline-flex;
144-
align-items: center;
145-
height: $header-menu-entry-height;
146-
color: var(--color-main-text);
147-
padding: 10px 12px;
148-
box-sizing: border-box;
149-
white-space: nowrap;
150-
position: relative;
151-
width: 100%;
152-
&:hover,
153-
&:focus {
154-
background-color: var(--color-background-hover);
155-
}
156-
&:active,
157-
&.active {
158-
background-color: var(--color-primary-light);
159-
}
160-
&:focus-visible {
161-
box-shadow: inset 0 0 0 2px var(--color-primary);
162-
outline: none;
163-
}
164-
span {
165-
display: inline-block;
166-
padding-bottom: 0;
167-
color: var(--color-main-text);
168-
white-space: nowrap;
169-
overflow: hidden;
170-
text-overflow: ellipsis;
171-
max-width: 110px;
172-
}
173-
.icon-loading-small {
174-
margin-right: 10px;
175-
background-size: 16px 16px;
176-
}
177-
img,
178-
svg {
179-
opacity: .7;
180-
margin-right: 10px;
181-
height: 16px;
182-
width: 16px;
183-
filter: var(--background-invert-if-dark);
184-
}
185-
}
186-
}
187-
}
188133
}
189134
.logo {
190135
display: inline-flex;
@@ -284,86 +229,6 @@
284229
text-overflow: ellipsis;
285230
}
286231

287-
/* USER MENU -----------------------------------------------------------------*/
288-
#settings {
289-
display: inline-block;
290-
height: 100%;
291-
cursor: pointer;
292-
flex: 0 0 auto;
293-
294-
/* User menu on the right */
295-
#expand {
296-
opacity: 1; /* override icon opacity */
297-
margin-right: 12px;
298-
299-
&:hover,
300-
&:focus,
301-
&:active {
302-
color: var(--color-primary-text);
303-
304-
#expandDisplayName,
305-
.avatardiv{
306-
border-radius: 50%;
307-
border: 2px solid var(--color-primary-text);
308-
margin: -2px;
309-
}
310-
.avatardiv{
311-
background-color: var(--color-primary-text);
312-
}
313-
#expandDisplayName {
314-
opacity: 1;
315-
}
316-
}
317-
318-
/* Profile picture in header */
319-
.avatardiv {
320-
cursor: pointer;
321-
height: 32px;
322-
width: 32px;
323-
324-
img {
325-
opacity: 1;
326-
cursor: pointer;
327-
}
328-
/* do not show display name when profile picture is present */
329-
&.avatardiv-shown + #expandDisplayName {
330-
display: none;
331-
}
332-
}
333-
334-
#expandDisplayName {
335-
padding: 8px;
336-
opacity: .6;
337-
cursor: pointer;
338-
339-
/* full opacity for gear icon if active */
340-
#body-settings & {
341-
opacity: 1;
342-
}
343-
}
344-
345-
/* show triangle below user menu if active */
346-
#body-settings &:before {
347-
content: ' ';
348-
height: 0;
349-
width: 0;
350-
position: absolute;
351-
pointer-events: none;
352-
bottom: 2px;
353-
z-index: 100;
354-
display: block;
355-
width: 10px;
356-
height: 5px;
357-
border-radius: 3px;
358-
background-color: var(--color-primary-text);
359-
}
360-
}
361-
362-
#expanddiv:after {
363-
right: 22px;
364-
}
365-
}
366-
367232
/* Skip navigation links – show only on keyboard focus */
368233
#skip-actions {
369234
position: absolute;
@@ -379,7 +244,6 @@
379244
}
380245
}
381246

382-
383247
/* Empty content messages in the header e.g. notifications, contacts menu, … */
384248
header #emptycontent,
385249
header .emptycontent {

core/css/server.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.

0 commit comments

Comments
 (0)