feat: Allow agents/admins to copy the link to a message (#5912)

This commit is contained in:
Pranav Raj S
2023-03-26 22:58:42 -07:00
committed by GitHub
parent 1e8881577a
commit 6000028f64
9 changed files with 107 additions and 33 deletions

View File

@@ -62,7 +62,15 @@
variant="icon"
@click="handleTranslate"
/>
<hr v-if="enabledOptions['cannedResponse']" />
<hr />
<menu-item
:option="{
icon: 'link',
label: this.$t('CONVERSATION.CONTEXT_MENU.COPY_PERMALINK'),
}"
variant="icon"
@click="copyLinkToMessage"
/>
<menu-item
v-if="enabledOptions['cannedResponse']"
:option="{
@@ -95,6 +103,7 @@ import { mixin as clickaway } from 'vue-clickaway';
import messageFormatterMixin from 'shared/mixins/messageFormatterMixin';
import AddCannedModal from 'dashboard/routes/dashboard/settings/canned/AddCanned';
import { copyTextToClipboard } from 'shared/helpers/clipboard';
import { conversationUrl, frontendURL } from '../../../helper/URLHelper';
import { ACCOUNT_EVENTS } from '../../../helper/AnalyticsHelper/events';
import TranslateModal from 'dashboard/components/widgets/conversation/bubble/TranslateModal';
import MenuItem from '../../../components/widgets/conversation/contextMenu/menuItem.vue';
@@ -153,6 +162,21 @@ export default {
},
},
methods: {
async copyLinkToMessage() {
const fullConversationURL =
window.chatwootConfig.hostURL +
frontendURL(
conversationUrl({
id: this.conversationId,
accountId: this.currentAccountId,
})
);
await copyTextToClipboard(
`${fullConversationURL}?messageId=${this.messageId}`
);
this.showAlert(this.$t('CONVERSATION.CONTEXT_MENU.LINK_COPIED'));
this.handleClose();
},
async handleCopy() {
await copyTextToClipboard(this.plainTextContent);
this.showAlert(this.$t('CONTACT_PANEL.COPY_SUCCESSFUL'));