11<script setup lang="ts">
2- import { ref , onMounted , onBeforeUnmount } from ' vue' ;
2+ import { onBeforeUnmount , onMounted , ref , useTemplateRef , computed } from ' vue' ;
33import { useI18n } from ' vue-i18n' ;
4- import { useRoute , useRouter } from ' vue-router' ;
4+ import { useRoute } from ' vue-router' ;
55import { UserAvatar } from ' @thunderbirdops/services-ui' ;
66
77defineProps <{
88 username: string ;
99}>();
1010
1111const { t } = useI18n ();
12- const router = useRouter ();
1312const currentRoute = useRoute ();
1413
15- const internalMenuItems = [
16- {
17- label: t (' components.userMenu.contact' ),
14+ const isSubscribePage = computed (() => currentRoute .path .startsWith (' /subscribe' ));
15+
16+ const internalMenuItems = computed (() => {
17+ const items = []
18+
19+ // Only show the account / dashboard link on non subscribe pages
20+ if (! isSubscribePage .value ) {
21+ items .push ({
22+ label: t (' components.userMenu.account' ),
23+ to: ' /dashboard' ,
24+ });
25+ }
26+
27+ items .push ({
28+ label: t (' components.userMenu.support' ),
1829 to: ' /contact' ,
19- },
20- ]
30+ });
31+
32+ return items ;
33+ });
2134
2235const externalMenuItems = [
2336 {
@@ -27,14 +40,9 @@ const externalMenuItems = [
2740];
2841
2942const showMenu = ref (false );
30- const menuRef = ref <HTMLElement | null >( null );
43+ const menuRef = useTemplateRef <HTMLElement >( ' menuRef ' );
3144
3245const toggleMenu = () => {
33- if (currentRoute .path .startsWith (' /mail' )) {
34- router .push (' /' );
35- return ;
36- }
37-
3846 showMenu .value = ! showMenu .value ;
3947};
4048
@@ -59,24 +67,17 @@ onBeforeUnmount(() => {
5967
6068 <div v-if =" showMenu" class =" dropdown" >
6169 <!-- Holds internal links (VueJS routes) -->
62- <router-link
63- v-for =" internalItem in internalMenuItems"
64- :key =" internalItem.label"
65- :to =" internalItem.to"
66- >
70+ <router-link v-for =" internalItem in internalMenuItems" :key =" internalItem.label" :to =" internalItem.to"
71+ @click =" toggleMenu" >
6772 {{ internalItem.label }}
6873 </router-link >
6974
7075 <!-- Holds external links (primarily Django routes) -->
71- <a
72- v-for =" externalItem in externalMenuItems"
73- :key =" externalItem.label"
74- :href =" externalItem.href"
75- >
76+ <a v-for =" externalItem in externalMenuItems" :key =" externalItem.label" :href =" externalItem.href" >
7677 {{ externalItem.label }}
7778 </a >
7879 </div >
79- </button >
80+ </button >
8081</template >
8182
8283<style scoped>
@@ -85,12 +86,14 @@ onBeforeUnmount(() => {
8586 display : inline-block ;
8687 background : none ;
8788 border : none ;
88- cursor : pointer ;
8989
9090 /* TODO: Temporary fix for UserAvatar color bug */
9191 .avatar {
92+ cursor : pointer ;
93+
9294 & :first-child {
93- color : #eeeef0 ; /* var(--colour-ti-base) dark mode */
95+ color : #eeeef0 ;
96+ /* var(--colour-ti-base) dark mode */
9497 }
9598 }
9699
@@ -104,6 +107,7 @@ onBeforeUnmount(() => {
104107 box-shadow : 0 0.5rem 1.5rem rgba (0 , 0 , 0 , 0.2 );
105108 padding : 0.5rem 0 ;
106109 min-width : 150px ;
110+ z-index : var (--z-index-header-dropdown );
107111
108112 a {
109113 display : flex ;
0 commit comments