aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/src/views/FilesHeaderNoteToRecipient.vue
blob: a8a39c41e5dbace5ef5551d6ac42c77097b90542 (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
<!--
  - SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
  - SPDX-License-Identifier: AGPL-3.0-or-later
-->
<template>
	<NcNoteCard v-if="note.length > 0"
		class="note-to-recipient"
		type="info">
		<p v-if="user" class="note-to-recipient__heading">
			{{ t('files_sharing', 'Note from') }}
			<NcUserBubble :user="user.id" :display-name="user.displayName" />
		</p>
		<p v-else class="note-to-recipient__heading">
			{{ t('files_sharing', 'Note:') }}
		</p>
		<p class="note-to-recipient__text" v-text="note" />
	</NcNoteCard>
</template>

<script setup lang="ts">
import type { Folder } from '@nextcloud/files'
import { getCurrentUser } from '@nextcloud/auth'
import { t } from '@nextcloud/l10n'
import { computed, ref } from 'vue'

import NcNoteCard from '@nextcloud/vue/dist/Components/NcNoteCard.js'
import NcUserBubble from '@nextcloud/vue/dist/Components/NcUserBubble.js'

const folder = ref<Folder>()
const note = computed<string>(() => folder.value?.attributes.note ?? '')
const user = computed(() => {
	const id = folder.value?.owner
	const displayName = folder.value?.attributes?.['owner-display-name']
	if (id !== getCurrentUser()?.uid) {
		return {
			id,
			displayName,
		}
	}
	return null
})

/**
 * Update the current folder
 * @param newFolder the new folder to show note for
 */
function updateFolder(newFolder: Folder) {
	folder.value = newFolder
}

defineExpose({ updateFolder })
</script>

<style scoped>
.note-to-recipient {
	margin-inline: var(--row-height)
}

.note-to-recipient__text {
	/* respect new lines */
	white-space: pre-line;
}

.note-to-recipient__heading {
	font-weight: bold;
}

@media screen and (max-width: 512px) {
	.note-to-recipient {
		margin-inline: var(--default-grid-baseline);
	}
}
</style>