You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

menu.js 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /**
  2. * @copyright Copyright (c) 2020 Georg Ehrke
  3. *
  4. * @author Georg Ehrke <oc.list@georgehrke.com>
  5. * @author John Molakvoæ <skjnldsv@protonmail.com>
  6. * @author Julius Härtl <jus@bitgrid.net>
  7. *
  8. * @license AGPL-3.0-or-later
  9. *
  10. * This program is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License as
  12. * published by the Free Software Foundation, either version 3 of the
  13. * License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU Affero General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Affero General Public License
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. *
  23. */
  24. import Vue from 'vue'
  25. import { getRequestToken } from '@nextcloud/auth'
  26. import UserStatus from './UserStatus'
  27. import store from './store'
  28. import Avatar from '@nextcloud/vue/dist/Components/Avatar'
  29. import { loadState } from '@nextcloud/initial-state'
  30. // eslint-disable-next-line camelcase
  31. __webpack_nonce__ = btoa(getRequestToken())
  32. Vue.prototype.t = t
  33. Vue.prototype.$t = t
  34. const avatarDiv = document.getElementById('avatardiv-menu')
  35. const userStatusData = loadState('user_status', 'status')
  36. const propsData = {
  37. preloadedUserStatus: {
  38. message: userStatusData.message,
  39. icon: userStatusData.icon,
  40. status: userStatusData.status,
  41. },
  42. user: avatarDiv.dataset.user,
  43. displayName: avatarDiv.dataset.displayname,
  44. url: avatarDiv.dataset.avatar,
  45. disableMenu: true,
  46. disableTooltip: true,
  47. }
  48. const AvatarInMenu = Vue.extend(Avatar)
  49. new AvatarInMenu({ propsData }).$mount('#avatardiv-menu')
  50. // Register settings menu entry
  51. export default new Vue({
  52. el: 'li[data-id="user_status-menuitem"]',
  53. // eslint-disable-next-line vue/match-component-file-name
  54. name: 'UserStatusRoot',
  55. render: h => h(UserStatus),
  56. store,
  57. })
  58. // Register dashboard status
  59. document.addEventListener('DOMContentLoaded', function() {
  60. if (!OCA.Dashboard) {
  61. return
  62. }
  63. OCA.Dashboard.registerStatus('status', (el) => {
  64. const Dashboard = Vue.extend(UserStatus)
  65. return new Dashboard({
  66. propsData: {
  67. inline: true,
  68. },
  69. store,
  70. }).$mount(el)
  71. })
  72. })