Skip to content

Commit

Permalink
Merge pull request #5477 from nextcloud-libraries/feat/NcAvatar--rout…
Browse files Browse the repository at this point in the history
…er-link-support-for-contacts-menu

fix(NcAvatar): support in-app router links for contact menu
  • Loading branch information
Antreesy committed Apr 10, 2024
2 parents a8c6b73 + f5ce1a1 commit 0a0adc3
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions src/components/NcAvatar/NcAvatar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,15 @@ export default {
:aria-label="avatarAriaLabel"
:title="tooltip"
@click="toggleMenu">
<NcActionLink v-for="(item, key) in menu"
<component :is="item.ncActionComponent"
v-for="(item, key) in menu"
:key="key"
:href="item.href"
:icon="item.icon">
v-bind="item.ncActionComponentProps">
<template v-if="item.iconSvg" #icon>
<NcIconSvgWrapper :svg="item.iconSvg" />
</template>
{{ item.text }}
</NcActionLink>
</component>
<template v-if="contactsMenuLoading" #icon>
<NcLoadingIcon />
</template>
Expand Down Expand Up @@ -186,6 +186,8 @@ export default {
<script>
import NcActions from '../NcActions/index.js'
import NcActionLink from '../NcActionLink/index.js'
import NcActionRouter from '../NcActionRouter/index.js'
import NcActionText from '../NcActionText/index.js'
import NcButton from '../NcButton/index.js'
import NcIconSvgWrapper from '../NcIconSvgWrapper/index.js'
import NcLoadingIcon from '../NcLoadingIcon/index.js'
Expand All @@ -195,6 +197,7 @@ import { getAvatarUrl } from '../../utils/getAvatarUrl.ts'
import { getUserStatusText } from '../../utils/UserStatus.ts'
import { userStatus } from '../../mixins/index.js'
import { t } from '../../l10n.js'
import { getRoute } from '../../components/NcRichText/autolink.js'
import axios from '@nextcloud/axios'
import DotsHorizontal from 'vue-material-design-icons/DotsHorizontal.vue'
Expand Down Expand Up @@ -237,7 +240,6 @@ export default {
components: {
DotsHorizontal,
NcActions,
NcActionLink,
NcButton,
NcIconSvgWrapper,
NcLoadingIcon,
Expand Down Expand Up @@ -504,9 +506,18 @@ export default {
},
menu() {
const actions = this.contactsMenuActions.map((item) => {
const route = getRoute(this.$router, item.hyperlink)
return {
href: item.hyperlink,
icon: item.icon,
ncActionComponent: route ? NcActionRouter : NcActionLink,
ncActionComponentProps: route
? {
to: route,
icon: item.icon,
}
: {
href: item.hyperlink,
icon: item.icon,
},
text: item.title,
}
})
Expand All @@ -527,7 +538,8 @@ export default {
<text x="50%" y="50%" text-anchor="middle" style="dominant-baseline: central; font-size: 85%">${escape(this.userStatus.icon)}</text>
</svg>`
return [{
href: '#',
ncActionComponent: NcActionText,
ncActionComponentProps: {},
iconSvg: this.userStatus.icon ? emojiIcon : undefined,
text: `${this.userStatus.message}`,
}].concat(actions)
Expand Down

0 comments on commit 0a0adc3

Please sign in to comment.