pleroma-fe/src/components/nav_panel/nav_panel.js

154 lines
4.8 KiB
JavaScript
Raw Normal View History

import BookmarkFoldersMenuContent from 'src/components/bookmark_folders_menu/bookmark_folders_menu_content.vue'
2022-08-15 20:34:45 +03:00
import ListsMenuContent from 'src/components/lists_menu/lists_menu_content.vue'
2020-05-07 16:10:53 +03:00
import { mapState, mapGetters } from 'vuex'
2023-04-06 16:32:21 -06:00
import { mapState as mapPiniaState } from 'pinia'
2022-08-11 21:00:27 +03:00
import { TIMELINES, ROOT_ITEMS } from 'src/components/navigation/navigation.js'
2022-08-15 23:31:05 +03:00
import { filterNavigation } from 'src/components/navigation/filter.js'
2022-08-11 21:00:27 +03:00
import NavigationEntry from 'src/components/navigation/navigation_entry.vue'
import NavigationPins from 'src/components/navigation/navigation_pins.vue'
2022-08-15 21:56:07 +03:00
import Checkbox from 'src/components/checkbox/checkbox.vue'
2025-03-23 20:03:25 +02:00
2025-01-30 21:56:07 +02:00
import { useAnnouncementsStore } from 'src/stores/announcements'
2025-03-23 20:03:25 +02:00
import { useServerSideStorageStore } from 'src/stores/serverSideStorage'
import { library } from '@fortawesome/fontawesome-svg-core'
import {
faUsers,
2020-10-21 00:25:59 +03:00
faGlobe,
2025-06-18 17:48:11 +03:00
faCity,
faBookmark,
faEnvelope,
2021-02-22 16:24:04 +02:00
faChevronDown,
faChevronUp,
faComments,
faBell,
2021-02-22 16:24:04 +02:00
faInfoCircle,
2022-08-06 17:26:43 +03:00
faStream,
faList,
2023-03-10 12:10:39 -05:00
faBullhorn,
faFilePen
} from '@fortawesome/free-solid-svg-icons'
library.add(
faUsers,
2020-10-21 00:25:59 +03:00
faGlobe,
2025-06-18 17:48:11 +03:00
faCity,
faBookmark,
faEnvelope,
2021-02-22 16:24:04 +02:00
faChevronDown,
faChevronUp,
faComments,
faBell,
2021-02-22 16:24:04 +02:00
faInfoCircle,
2022-08-06 17:26:43 +03:00
faStream,
faList,
2023-03-10 12:10:39 -05:00
faBullhorn,
faFilePen
)
2016-11-06 20:10:20 +01:00
const NavPanel = {
2022-08-15 21:56:07 +03:00
props: ['forceExpand', 'forceEditMode'],
created () {
},
2021-02-22 16:24:04 +02:00
components: {
BookmarkFoldersMenuContent,
2022-08-11 21:00:27 +03:00
ListsMenuContent,
NavigationEntry,
2022-08-15 21:56:07 +03:00
NavigationPins,
Checkbox
2021-02-22 16:24:04 +02:00
},
data () {
return {
2022-08-15 21:56:07 +03:00
editMode: false,
2022-08-06 17:26:43 +03:00
showTimelines: false,
showLists: false,
showBookmarkFolders: false,
timelinesList: Object.entries(TIMELINES).map(([k, v]) => ({ ...v, name: k })),
rootList: Object.entries(ROOT_ITEMS).map(([k, v]) => ({ ...v, name: k }))
2021-02-22 16:24:04 +02:00
}
},
methods: {
toggleTimelines () {
this.showTimelines = !this.showTimelines
2022-08-06 17:26:43 +03:00
},
toggleLists () {
this.showLists = !this.showLists
},
toggleBookmarkFolders () {
this.showBookmarkFolders = !this.showBookmarkFolders
},
2022-08-15 21:56:07 +03:00
toggleEditMode () {
this.editMode = !this.editMode
},
toggleCollapse () {
2025-03-23 20:03:25 +02:00
useServerSideStorageStore().setPreference({ path: 'simple.collapseNav', value: !this.collapsed })
useServerSideStorageStore().pushServerSideStorage()
},
isPinned (item) {
return this.pinnedItems.has(item)
},
togglePin (item) {
if (this.isPinned(item)) {
2025-03-23 20:03:25 +02:00
useServerSideStorageStore().removeCollectionPreference({ path: 'collections.pinnedNavItems', value: item })
} else {
2025-03-23 20:03:25 +02:00
useServerSideStorageStore().addCollectionPreference({ path: 'collections.pinnedNavItems', value: item })
}
2025-03-23 20:03:25 +02:00
useServerSideStorageStore().pushServerSideStorage()
2021-02-22 16:24:04 +02:00
}
},
computed: {
2023-04-06 16:32:21 -06:00
...mapPiniaState(useAnnouncementsStore, {
unreadAnnouncementCount: 'unreadAnnouncementCount',
supportsAnnouncements: store => store.supportsAnnouncements
}),
2025-03-23 20:03:25 +02:00
...mapPiniaState(useServerSideStorageStore, {
collapsed: store => store.prefsStorage.simple.collapseNav,
pinnedItems: store => new Set(store.prefsStorage.collections.pinnedNavItems)
}),
...mapState({
currentUser: state => state.users.currentUser,
followRequestCount: state => state.api.followRequests.length,
privateMode: state => state.instance.private,
2020-05-07 16:10:53 +03:00
federating: state => state.instance.federating,
pleromaChatMessagesAvailable: state => state.instance.pleromaChatMessagesAvailable,
2025-06-18 17:48:11 +03:00
bookmarkFolders: state => state.instance.pleromaBookmarkFoldersAvailable,
bubbleTimeline: state => state.instance.localBubbleInstances.length > 0
2020-05-07 16:10:53 +03:00
}),
2022-08-12 00:50:08 +03:00
timelinesItems () {
return filterNavigation(
Object
.entries({ ...TIMELINES })
2025-06-24 17:01:17 +03:00
// do not show in timeliens list since it's in a better place now
.filter(([key]) => key !== 'bookmarks')
2022-08-12 00:50:08 +03:00
.map(([k, v]) => ({ ...v, name: k })),
{
hasChats: this.pleromaChatMessagesAvailable,
hasAnnouncements: this.supportsAnnouncements,
2022-08-12 00:50:08 +03:00
isFederating: this.federating,
2022-08-12 01:19:19 +03:00
isPrivate: this.privateMode,
currentUser: this.currentUser,
2025-06-24 17:15:00 +03:00
supportsBubbleTimeline: this.bubbleTimeline,
supportsBookmarkFolders: this.bookmarkFolders
2022-08-12 00:50:08 +03:00
}
)
},
rootItems () {
2022-08-11 21:00:27 +03:00
return filterNavigation(
Object
.entries({ ...ROOT_ITEMS })
.map(([k, v]) => ({ ...v, name: k })),
{
hasChats: this.pleromaChatMessagesAvailable,
hasAnnouncements: this.supportsAnnouncements,
2022-08-11 21:00:27 +03:00
isFederating: this.federating,
2022-08-12 01:19:19 +03:00
isPrivate: this.privateMode,
currentUser: this.currentUser,
2025-06-24 17:01:17 +03:00
supportsBubbleTimeline: this.bubbleTimeline,
supportsBookmarkFolders: this.bookmarkFolders
2022-08-11 21:00:27 +03:00
}
)
},
2023-04-06 16:32:21 -06:00
...mapGetters(['unreadChatCount'])
}
2016-11-06 20:10:20 +01:00
}
export default NavPanel