funkwhale/front/src/components/common/ActorLink.vue

43 wiersze
1.2 KiB
Vue
Czysty Zwykły widok Historia

<template>
2021-12-06 10:35:20 +00:00
<router-link
:to="url"
:title="actor.full_username"
>
<template v-if="avatar">
<actor-avatar :actor="actor" /><span>&nbsp;</span>
</template><slot>{{ repr | truncate(truncateLength) }}</slot>
</router-link>
</template>
<script>
export default {
2018-09-13 15:18:23 +00:00
props: {
2021-12-06 10:35:20 +00:00
actor: { type: Object, required: true },
avatar: { type: Boolean, default: true },
admin: { type: Boolean, default: false },
displayName: { type: Boolean, default: false },
truncateLength: { type: Number, default: 30 }
2020-02-05 14:06:07 +00:00
},
computed: {
url () {
2020-03-18 10:57:33 +00:00
if (this.admin) {
2021-12-06 10:35:20 +00:00
return { name: 'manage.moderation.accounts.detail', params: { id: this.actor.full_username } }
2020-03-18 10:57:33 +00:00
}
2020-02-05 14:06:07 +00:00
if (this.actor.is_local) {
2021-12-06 10:35:20 +00:00
return { name: 'profile.overview', params: { username: this.actor.preferred_username } }
2020-02-05 14:06:07 +00:00
} else {
2021-12-06 10:35:20 +00:00
return { name: 'profile.full.overview', params: { username: this.actor.preferred_username, domain: this.actor.domain } }
2020-02-05 14:06:07 +00:00
}
},
repr () {
2020-03-18 10:57:33 +00:00
if (this.displayName || this.actor.is_local) {
2020-02-05 14:06:07 +00:00
return this.actor.preferred_username
} else {
return this.actor.full_username
}
}
}
}
</script>