logo

pleroma-fe

My custom branche(s) on git.pleroma.social/pleroma/pleroma-fe git clone https://anongit.hacktivis.me/git/pleroma-fe.git/

nav_panel.js (4275B)


  1. import BookmarkFoldersMenuContent from 'src/components/bookmark_folders_menu/bookmark_folders_menu_content.vue'
  2. import ListsMenuContent from 'src/components/lists_menu/lists_menu_content.vue'
  3. import { mapState, mapGetters } from 'vuex'
  4. import { TIMELINES, ROOT_ITEMS } from 'src/components/navigation/navigation.js'
  5. import { filterNavigation } from 'src/components/navigation/filter.js'
  6. import NavigationEntry from 'src/components/navigation/navigation_entry.vue'
  7. import NavigationPins from 'src/components/navigation/navigation_pins.vue'
  8. import Checkbox from 'src/components/checkbox/checkbox.vue'
  9. import { library } from '@fortawesome/fontawesome-svg-core'
  10. import {
  11. faUsers,
  12. faGlobe,
  13. faBookmark,
  14. faEnvelope,
  15. faChevronDown,
  16. faChevronUp,
  17. faComments,
  18. faBell,
  19. faInfoCircle,
  20. faStream,
  21. faList,
  22. faBullhorn,
  23. faFilePen
  24. } from '@fortawesome/free-solid-svg-icons'
  25. library.add(
  26. faUsers,
  27. faGlobe,
  28. faBookmark,
  29. faEnvelope,
  30. faChevronDown,
  31. faChevronUp,
  32. faComments,
  33. faBell,
  34. faInfoCircle,
  35. faStream,
  36. faList,
  37. faBullhorn,
  38. faFilePen
  39. )
  40. const NavPanel = {
  41. props: ['forceExpand', 'forceEditMode'],
  42. created () {
  43. },
  44. components: {
  45. BookmarkFoldersMenuContent,
  46. ListsMenuContent,
  47. NavigationEntry,
  48. NavigationPins,
  49. Checkbox
  50. },
  51. data () {
  52. return {
  53. editMode: false,
  54. showTimelines: false,
  55. showLists: false,
  56. showBookmarkFolders: false,
  57. timelinesList: Object.entries(TIMELINES).map(([k, v]) => ({ ...v, name: k })),
  58. rootList: Object.entries(ROOT_ITEMS).map(([k, v]) => ({ ...v, name: k }))
  59. }
  60. },
  61. methods: {
  62. toggleTimelines () {
  63. this.showTimelines = !this.showTimelines
  64. },
  65. toggleLists () {
  66. this.showLists = !this.showLists
  67. },
  68. toggleBookmarkFolders () {
  69. this.showBookmarkFolders = !this.showBookmarkFolders
  70. },
  71. toggleEditMode () {
  72. this.editMode = !this.editMode
  73. },
  74. toggleCollapse () {
  75. this.$store.commit('setPreference', { path: 'simple.collapseNav', value: !this.collapsed })
  76. this.$store.dispatch('pushServerSideStorage')
  77. },
  78. isPinned (item) {
  79. return this.pinnedItems.has(item)
  80. },
  81. togglePin (item) {
  82. if (this.isPinned(item)) {
  83. this.$store.commit('removeCollectionPreference', { path: 'collections.pinnedNavItems', value: item })
  84. } else {
  85. this.$store.commit('addCollectionPreference', { path: 'collections.pinnedNavItems', value: item })
  86. }
  87. this.$store.dispatch('pushServerSideStorage')
  88. }
  89. },
  90. computed: {
  91. ...mapState({
  92. currentUser: state => state.users.currentUser,
  93. followRequestCount: state => state.api.followRequests.length,
  94. privateMode: state => state.instance.private,
  95. federating: state => state.instance.federating,
  96. pleromaChatMessagesAvailable: state => state.instance.pleromaChatMessagesAvailable,
  97. supportsAnnouncements: state => state.announcements.supportsAnnouncements,
  98. pinnedItems: state => new Set(state.serverSideStorage.prefsStorage.collections.pinnedNavItems),
  99. collapsed: state => state.serverSideStorage.prefsStorage.simple.collapseNav,
  100. bookmarkFolders: state => state.instance.pleromaBookmarkFoldersAvailable
  101. }),
  102. timelinesItems () {
  103. return filterNavigation(
  104. Object
  105. .entries({ ...TIMELINES })
  106. .map(([k, v]) => ({ ...v, name: k })),
  107. {
  108. hasChats: this.pleromaChatMessagesAvailable,
  109. hasAnnouncements: this.supportsAnnouncements,
  110. isFederating: this.federating,
  111. isPrivate: this.privateMode,
  112. currentUser: this.currentUser,
  113. supportsBookmarkFolders: this.bookmarkFolders
  114. }
  115. )
  116. },
  117. rootItems () {
  118. return filterNavigation(
  119. Object
  120. .entries({ ...ROOT_ITEMS })
  121. .map(([k, v]) => ({ ...v, name: k })),
  122. {
  123. hasChats: this.pleromaChatMessagesAvailable,
  124. hasAnnouncements: this.supportsAnnouncements,
  125. isFederating: this.federating,
  126. isPrivate: this.privateMode,
  127. currentUser: this.currentUser,
  128. supportsBookmarkFolders: this.bookmarkFolders
  129. }
  130. )
  131. },
  132. ...mapGetters(['unreadChatCount', 'unreadAnnouncementCount'])
  133. }
  134. }
  135. export default NavPanel