Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 49 additions & 1 deletion src/components/MenuEnvelope.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
- SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
- SPDX-FileCopyrightText: 2021-2026 Nextcloud GmbH and Nextcloud contributors
- SPDX-License-Identifier: AGPL-3.0-or-later
-->
<!-- Standard Actions menu for Envelopes -->
Expand Down Expand Up @@ -29,6 +29,21 @@
</template>
{{ t('mail', 'Forward') }}
</ActionButton>
<ActionButton
:close-after-click="false"
:description="t('mail', 'Only for message recipients')"
@click.prevent="onCopyMessageLink">
<template #icon>
<CheckIcon
v-if="copied"
:size="20" />
<ContentCopyIcon
v-else
:title="t('mail', 'Copy direct link')"
:size="20" />
</template>
{{ copied ? t('mail', 'Link copied') : t('mail', 'Copy direct link') }}
</ActionButton>
<ActionButton
v-if="hasWriteAcl"
:close-after-click="true"
Expand Down Expand Up @@ -277,6 +292,7 @@ import CalendarClock from 'vue-material-design-icons/CalendarClockOutline.vue'
import CheckIcon from 'vue-material-design-icons/Check.vue'
import TaskIcon from 'vue-material-design-icons/CheckboxMarkedCirclePlusOutline.vue'
import ChevronLeft from 'vue-material-design-icons/ChevronLeft.vue'
import ContentCopyIcon from 'vue-material-design-icons/ContentCopy.vue'
import DotsHorizontalIcon from 'vue-material-design-icons/DotsHorizontal.vue'
import FilterIcon from 'vue-material-design-icons/FilterOutline.vue'
import InformationIcon from 'vue-material-design-icons/InformationOutline.vue'
Expand Down Expand Up @@ -321,6 +337,7 @@ export default {
AlarmIcon,
PrinterIcon,
FilterIcon,
ContentCopyIcon,
},

props: {
Expand Down Expand Up @@ -367,6 +384,8 @@ export default {
snoozeActionsOpen: false,
forwardMessages: this.envelope.databaseId,
customSnoozeDateTime: new Date(moment().add(2, 'hours').minute(0).second(0).valueOf()),
copied: false,
copyResetTimer: null,
}
},

Expand Down Expand Up @@ -634,6 +653,35 @@ export default {
this.$emit('print')
},

async onCopyMessageLink() {
if (this.copyResetTimer) {
clearTimeout(this.copyResetTimer)
}

if (!this.envelope || typeof this.envelope.messageId !== 'string' || !this.envelope.messageId.trim()) {
showError(t('mail', 'Could not generate direct link: Message ID is missing'))
return
}

const trimmedMessageId = this.envelope.messageId.trim().replace(/^<|>$/g, '')
const url = window.location.origin + generateUrl('/apps/mail/open/' + encodeURIComponent(trimmedMessageId))
Comment thread
SoleroTG marked this conversation as resolved.

try {
await navigator.clipboard.writeText(url)
this.copied = true
showSuccess(t('mail', 'Direct link copied to clipboard'))
} catch (error) {
// Fallback for cases where clipboard API is not available (e.g. non-HTTPS localhost)
// or permission is denied. This exactly matches Nextcloud's useCopy composable behavior.
window.prompt(t('mail', 'Copy direct link'), url)
} finally {
this.copyResetTimer = setTimeout(() => {
this.copied = false
this.localMoreActionsOpen = false
}, 2000)
}
},

isSieveEnabled() {
return this.account.sieveEnabled
},
Expand Down
Loading