chore: Replace message menu with context menu
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<script setup>
|
||||
import { onMounted, computed, ref, toRefs } from 'vue';
|
||||
import { onMounted, computed, ref, toRefs, useTemplateRef } from 'vue';
|
||||
import { useTimeoutFn } from '@vueuse/core';
|
||||
import { provideMessageContext } from './provider.js';
|
||||
import { useTrack } from 'dashboard/composables';
|
||||
@@ -133,6 +133,7 @@ const props = defineProps({
|
||||
const contextMenuPosition = ref({});
|
||||
const showBackgroundHighlight = ref(false);
|
||||
const showContextMenu = ref(false);
|
||||
const emailBubbleRef = useTemplateRef('emailBubbleRef');
|
||||
const { t } = useI18n();
|
||||
const route = useRoute();
|
||||
|
||||
@@ -342,6 +343,11 @@ const contextMenuEnabledOptions = computed(() => {
|
||||
delete: hasText || hasAttachments,
|
||||
cannedResponse: isOutgoing && hasText,
|
||||
replyTo: !props.private && props.inboxSupportsReplyTo.outgoing,
|
||||
// Forward email is enabled only when the message is not in progress and is not private and is an email inbox
|
||||
forwardEmail:
|
||||
props.isEmailInbox &&
|
||||
!props.private &&
|
||||
props.status !== MESSAGE_STATUS.PROGRESS,
|
||||
};
|
||||
});
|
||||
|
||||
@@ -362,6 +368,9 @@ const shouldRenderMessage = computed(() => {
|
||||
});
|
||||
|
||||
function openContextMenu(e) {
|
||||
// Close forward modal, when opening context menu
|
||||
emailBubbleRef.value?.closeForwardModal();
|
||||
|
||||
const shouldSkipContextMenu =
|
||||
e.target?.classList.contains('skip-context-menu') ||
|
||||
e.target?.tagName.toLowerCase() === 'a';
|
||||
@@ -437,6 +446,11 @@ const setupHighlightTimer = () => {
|
||||
}, HIGHLIGHT_TIMER);
|
||||
};
|
||||
|
||||
const openForwardModal = (event = null) => {
|
||||
// Open forward modal, with the event from context menu
|
||||
emailBubbleRef.value.openForwardModal(event);
|
||||
};
|
||||
|
||||
onMounted(setupHighlightTimer);
|
||||
|
||||
provideMessageContext({
|
||||
@@ -497,7 +511,12 @@ provideMessageContext({
|
||||
}"
|
||||
@contextmenu="openContextMenu($event)"
|
||||
>
|
||||
<Component :is="componentToRender" />
|
||||
<component
|
||||
:is="componentToRender"
|
||||
:ref="
|
||||
componentToRender === EmailBubble ? 'emailBubbleRef' : undefined
|
||||
"
|
||||
/>
|
||||
</div>
|
||||
<MessageError
|
||||
v-if="contentAttributes.externalError"
|
||||
@@ -517,6 +536,7 @@ provideMessageContext({
|
||||
@open="openContextMenu"
|
||||
@close="closeContextMenu"
|
||||
@reply-to="handleReplyTo"
|
||||
@forward-email="openForwardModal"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user