Skip to content

Commit 0a0adc3

Browse files
authored
Merge pull request #5477 from nextcloud-libraries/feat/NcAvatar--router-link-support-for-contacts-menu
fix(NcAvatar): support in-app router links for contact menu
2 parents a8c6b73 + f5ce1a1 commit 0a0adc3

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

src/components/NcAvatar/NcAvatar.vue

+20-8
Original file line numberDiff line numberDiff line change
@@ -149,15 +149,15 @@ export default {
149149
:aria-label="avatarAriaLabel"
150150
:title="tooltip"
151151
@click="toggleMenu">
152-
<NcActionLink v-for="(item, key) in menu"
152+
<component :is="item.ncActionComponent"
153+
v-for="(item, key) in menu"
153154
:key="key"
154-
:href="item.href"
155-
:icon="item.icon">
155+
v-bind="item.ncActionComponentProps">
156156
<template v-if="item.iconSvg" #icon>
157157
<NcIconSvgWrapper :svg="item.iconSvg" />
158158
</template>
159159
{{ item.text }}
160-
</NcActionLink>
160+
</component>
161161
<template v-if="contactsMenuLoading" #icon>
162162
<NcLoadingIcon />
163163
</template>
@@ -186,6 +186,8 @@ export default {
186186
<script>
187187
import NcActions from '../NcActions/index.js'
188188
import NcActionLink from '../NcActionLink/index.js'
189+
import NcActionRouter from '../NcActionRouter/index.js'
190+
import NcActionText from '../NcActionText/index.js'
189191
import NcButton from '../NcButton/index.js'
190192
import NcIconSvgWrapper from '../NcIconSvgWrapper/index.js'
191193
import NcLoadingIcon from '../NcLoadingIcon/index.js'
@@ -195,6 +197,7 @@ import { getAvatarUrl } from '../../utils/getAvatarUrl.ts'
195197
import { getUserStatusText } from '../../utils/UserStatus.ts'
196198
import { userStatus } from '../../mixins/index.js'
197199
import { t } from '../../l10n.js'
200+
import { getRoute } from '../../components/NcRichText/autolink.js'
198201

199202
import axios from '@nextcloud/axios'
200203
import DotsHorizontal from 'vue-material-design-icons/DotsHorizontal.vue'
@@ -237,7 +240,6 @@ export default {
237240
components: {
238241
DotsHorizontal,
239242
NcActions,
240-
NcActionLink,
241243
NcButton,
242244
NcIconSvgWrapper,
243245
NcLoadingIcon,
@@ -504,9 +506,18 @@ export default {
504506
},
505507
menu() {
506508
const actions = this.contactsMenuActions.map((item) => {
509+
const route = getRoute(this.$router, item.hyperlink)
507510
return {
508-
href: item.hyperlink,
509-
icon: item.icon,
511+
ncActionComponent: route ? NcActionRouter : NcActionLink,
512+
ncActionComponentProps: route
513+
? {
514+
to: route,
515+
icon: item.icon,
516+
}
517+
: {
518+
href: item.hyperlink,
519+
icon: item.icon,
520+
},
510521
text: item.title,
511522
}
512523
})
@@ -527,7 +538,8 @@ export default {
527538
<text x="50%" y="50%" text-anchor="middle" style="dominant-baseline: central; font-size: 85%">${escape(this.userStatus.icon)}</text>
528539
</svg>`
529540
return [{
530-
href: '#',
541+
ncActionComponent: NcActionText,
542+
ncActionComponentProps: {},
531543
iconSvg: this.userStatus.icon ? emojiIcon : undefined,
532544
text: `${this.userStatus.message}`,
533545
}].concat(actions)

0 commit comments

Comments
 (0)