aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/src/components/ShareExpiryTime.vue
blob: b789bc92db5d0ae32ff649be2fce94875e409b9f (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
<!--
  - SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
  - SPDX-License-Identifier: AGPL-3.0-or-later
-->
<template>
	<div class="share-expiry-time">
		<NcPopover popup-role="dialog">
			<template #trigger>
				<NcButton v-if="expiryTime"
					class="hint-icon"
					type="tertiary"
					:aria-label="t('files_sharing', 'Share expiration: ') + new Date(expiryTime).toLocaleString()">
					<template #icon>
						<ClockIcon :size="20" />
					</template>
				</NcButton>
			</template>
			<h3 class="hint-heading">
				{{ t('files_sharing', 'Share Expiration') }}
			</h3>
			<p v-if="expiryTime" class="hint-body">
				<NcDateTime :timestamp="expiryTime"
					:format="timeFormat"
					:relative-time="false" /> (<NcDateTime :timestamp="expiryTime" />)
			</p>
		</NcPopover>
	</div>
</template>

<script>
import NcButton from '@nextcloud/vue/components/NcButton'
import NcPopover from '@nextcloud/vue/components/NcPopover'
import NcDateTime from '@nextcloud/vue/components/NcDateTime'
import ClockIcon from 'vue-material-design-icons/Clock.vue'

export default {
	name: 'ShareExpiryTime',

	components: {
		NcButton,
		NcPopover,
		NcDateTime,
		ClockIcon,
	},

	props: {
		share: {
			type: Object,
			required: true,
		},
	},

	computed: {
		expiryTime() {
			return this.share?.expireDate ? new Date(this.share.expireDate).getTime() : null
		},
		timeFormat() {
			return { dateStyle: 'full', timeStyle: 'short' }
		},
	},
}
</script>

<style scoped lang="scss">
.share-expiry-time {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    .hint-icon {
        padding: 0;
        margin: 0;
        width: 24px;
        height: 24px;
    }
}

.hint-heading {
    text-align: center;
    font-size: 1rem;
    margin-top: 8px;
    padding-bottom: 8px;
    margin-bottom: 0;
    border-bottom: 1px solid var(--color-border);
}

.hint-body {
    padding: var(--border-radius-element);
    max-width: 300px;
}
</style>