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

125 lines
2.6 KiB
JavaScript
Raw Normal View History

// routes that take :username property
2022-08-23 22:10:21 +03:00
export const USERNAME_ROUTES = new Set([
'dms',
'interactions',
'notifications',
'chat',
'chats'
])
// routes that take :name property
export const NAME_ROUTES = new Set([
'user-profile',
'legacy-user-profile'
2022-08-23 22:10:21 +03:00
])
export const TIMELINES = {
home: {
route: 'friends',
icon: 'home',
label: 'nav.home_timeline',
criteria: ['!private']
},
public: {
route: 'public-timeline',
anon: true,
icon: 'users',
label: 'nav.public_tl',
criteria: ['!private']
},
2025-06-18 17:48:11 +03:00
bubble: {
route: 'bubble',
icon: 'city',
label: 'nav.bubble',
criteria: ['supportsBubbleTimeline']
},
twkn: {
route: 'public-external-timeline',
anon: true,
icon: 'globe',
label: 'nav.twkn',
criteria: ['!private', 'federating']
},
bookmarks: {
route: 'bookmarks',
icon: 'bookmark',
label: 'nav.bookmarks',
criteria: ['!supportsBookmarkFolders']
},
2022-08-30 00:53:20 +03:00
favorites: {
routeObject: { name: 'user-profile', query: { tab: 'favorites' } },
icon: 'star',
label: 'user_card.favorites'
},
dms: {
route: 'dms',
icon: 'envelope',
label: 'nav.dms'
}
}
export const ROOT_ITEMS = {
interactions: {
route: 'interactions',
icon: 'bell',
label: 'nav.interactions'
},
chats: {
route: 'chats',
icon: 'comments',
label: 'nav.chats',
2023-04-06 12:35:51 -04:00
badgeStyle: 'notification',
badgeGetter: 'unreadChatCount',
criteria: ['chats']
},
friendRequests: {
route: 'friend-requests',
icon: 'user-plus',
label: 'nav.friend_requests',
2023-04-06 12:35:51 -04:00
badgeStyle: 'notification',
criteria: ['lockedUser'],
badgeGetter: 'followRequestCount'
},
about: {
route: 'about',
anon: true,
icon: 'info-circle',
label: 'nav.about'
},
announcements: {
route: 'announcements',
icon: 'bullhorn',
2022-03-17 17:51:39 -04:00
label: 'nav.announcements',
2023-04-06 16:32:21 -06:00
store: 'announcements',
2023-04-06 12:35:51 -04:00
badgeStyle: 'notification',
badgeGetter: 'unreadAnnouncementCount',
criteria: ['announcements']
2023-03-10 12:10:39 -05:00
},
drafts: {
route: 'drafts',
icon: 'file-pen',
2023-03-10 20:22:41 -05:00
label: 'nav.drafts',
2023-04-06 12:35:51 -04:00
badgeStyle: 'neutral',
2023-03-10 20:22:41 -05:00
badgeGetter: 'draftCount'
}
}
export function routeTo (item, currentUser) {
if (!item.route && !item.routeObject) return null
let route
if (item.routeObject) {
route = item.routeObject
} else {
route = { name: (item.anon || currentUser) ? item.route : item.anonRoute }
}
if (USERNAME_ROUTES.has(route.name)) {
route.params = { username: currentUser.screen_name }
} else if (NAME_ROUTES.has(route.name)) {
route.params = { name: currentUser.screen_name }
}
return route
}