summaryrefslogtreecommitdiffstats
path: root/src/components/UserEntry.vue
blob: 1bb3c95ed482a1e9ddf9f589b5d05cf451b91a7a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<!--
  - @copyright Copyright (c) 2018 Julius Härtl <jus@bitgrid.net>
  -
  - @author Julius Härtl <jus@bitgrid.net>
  -
  - @license GNU AGPL version 3 or any later version
  -
  - This program is free software: you can redistribute it and/or modify
  - it under the terms of the GNU Affero General Public License as
  - published by the Free Software Foundation, either version 3 of the
  - License, or (at your option) any later version.
  -
  - This program is distributed in the hope that it will be useful,
  - but WITHOUT ANY WARRANTY; without even the implied warranty of
  - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  - GNU Affero General Public License for more details.
  -
  - You should have received a copy of the GNU Affero General Public License
  - along with this program. If not, see <http://www.gnu.org/licenses/>.
  -
  -->

<template>
	<div v-if="item" class="user-entry">
		<div class="entry-content">
			<div class="user-avatar">
				<avatar v-if="item.local" :size="32" :user="item.preferredUsername"
					:disable-tooltip="true" />
				<avatar v-else :url="avatarUrl" />
			</div>
			<div class="user-details">
				<router-link v-if="!serverData.public" :to="{ name: 'profile', params: { account: item.local ? item.preferredUsername : item.account }}">
					<span class="post-author">
						{{ item.name }}
					</span>
					<span class="user-description">
						{{ item.account }}
					</span>
				</router-link>
				<a v-else :href="item.id" target="_blank"
					rel="noreferrer">
					<span class="post-author">
						{{ item.name }}
					</span>
					<span class="user-description">
						{{ item.account }}
					</span>
				</a>
				<!-- eslint-disable-next-line vue/no-v-html -->
				<p v-html="item.summary" />
			</div>
			<follow-button :account="item.account" />
		</div>
	</div>
</template>

<script>
import Avatar from '@nextcloud/vue/dist/Components/Avatar'
import follow from '../mixins/follow'
import currentUser from '../mixins/currentUserMixin'
import FollowButton from './FollowButton.vue'

export default {
	name: 'UserEntry',
	components: {
		FollowButton,
		Avatar
	},
	mixins: [
		follow,
		currentUser
	],
	props: {
		item: { type: Object, default: () => {} }
	},
	data: function() {
		return {
			followingText: t('social', 'Following')
		}
	},
	computed: {
		id() {
			if (this.item.actor_info) {
				return this.item.actor_info.id
			}
			return this.item.id
		},
		avatarUrl() {
			return OC.generateUrl('/apps/social/api/v1/global/actor/avatar?id=' + this.id)
		}
	}
}
</script>
<style scoped>
	.user-avatar {
		margin: 5px;
		margin-right: 10px;
		border-radius: 50%;
		flex-shrink: 0;
	}

	.post-author {
		font-weight: bold;
	}

	.entry-content {
		display: flex;
		align-items: flex-start;
	}

	.user-details {
		flex-grow: 1;
	}

	.user-description {
		opacity: 0.7;
	}

	button {
		margin-left: 10px;
		min-width: 110px;
	}

	button * {
		cursor: pointer;
	}
</style>