2019-08-14 09:48:44 +00:00
|
|
|
<template>
|
|
|
|
<div class="conv-header">
|
2021-03-02 17:14:04 +00:00
|
|
|
<div class="user">
|
2022-08-01 05:23:50 +00:00
|
|
|
<back-button v-if="showBackButton" :back-url="backButtonUrl" />
|
2019-08-14 09:48:44 +00:00
|
|
|
<Thumbnail
|
2020-06-02 17:29:02 +00:00
|
|
|
:src="currentContact.thumbnail"
|
2019-08-14 09:48:44 +00:00
|
|
|
size="40px"
|
2021-10-06 14:04:34 +00:00
|
|
|
:badge="inboxBadge"
|
2020-06-02 17:29:02 +00:00
|
|
|
:username="currentContact.name"
|
2020-07-04 06:12:47 +00:00
|
|
|
:status="currentContact.availability_status"
|
2019-08-14 09:48:44 +00:00
|
|
|
/>
|
2019-11-14 08:16:43 +00:00
|
|
|
<div class="user--profile__meta">
|
2021-03-02 17:14:04 +00:00
|
|
|
<h3 class="user--name text-truncate">
|
2021-11-22 18:02:17 +00:00
|
|
|
<span class="margin-right-smaller">{{ currentContact.name }}</span>
|
2021-12-01 05:03:18 +00:00
|
|
|
<fluent-icon
|
2021-11-22 18:02:17 +00:00
|
|
|
v-if="!isHMACVerified"
|
|
|
|
v-tooltip="$t('CONVERSATION.UNVERIFIED_SESSION')"
|
2021-12-01 05:03:18 +00:00
|
|
|
size="14"
|
2022-04-11 11:57:28 +00:00
|
|
|
class="hmac-warning__icon"
|
2021-12-01 05:03:18 +00:00
|
|
|
icon="warning"
|
2021-11-22 18:02:17 +00:00
|
|
|
/>
|
2019-11-14 08:16:43 +00:00
|
|
|
</h3>
|
2021-09-29 14:03:51 +00:00
|
|
|
<div class="conversation--header--actions">
|
|
|
|
<inbox-name :inbox="inbox" class="margin-right-small" />
|
|
|
|
<span
|
|
|
|
v-if="isSnoozed"
|
|
|
|
class="snoozed--display-text margin-right-small"
|
|
|
|
>
|
|
|
|
{{ snoozedDisplayText }}
|
|
|
|
</span>
|
|
|
|
<woot-button
|
|
|
|
class="user--profile__button margin-right-small"
|
|
|
|
size="small"
|
|
|
|
variant="link"
|
|
|
|
@click="$emit('contact-panel-toggle')"
|
|
|
|
>
|
|
|
|
{{ contactPanelToggleText }}
|
|
|
|
</woot-button>
|
|
|
|
</div>
|
2019-11-14 08:16:43 +00:00
|
|
|
</div>
|
2019-08-14 09:48:44 +00:00
|
|
|
</div>
|
2020-08-17 05:55:13 +00:00
|
|
|
<div
|
2020-09-03 08:41:07 +00:00
|
|
|
class="header-actions-wrap"
|
|
|
|
:class="{ 'has-open-sidebar': isContactPanelOpen }"
|
2020-08-17 05:55:13 +00:00
|
|
|
>
|
|
|
|
<more-actions :conversation-id="currentChat.id" />
|
2019-08-14 09:48:44 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script>
|
2022-08-01 05:23:50 +00:00
|
|
|
import { hasPressedAltAndOKey } from 'shared/helpers/KeyboardHelpers';
|
2019-08-14 09:48:44 +00:00
|
|
|
import { mapGetters } from 'vuex';
|
2021-07-09 07:50:54 +00:00
|
|
|
import agentMixin from '../../../mixins/agentMixin.js';
|
2022-08-01 05:23:50 +00:00
|
|
|
import BackButton from '../BackButton';
|
|
|
|
import differenceInHours from 'date-fns/differenceInHours';
|
2021-08-09 07:38:52 +00:00
|
|
|
import eventListenerMixins from 'shared/mixins/eventListenerMixins';
|
2021-09-29 07:26:45 +00:00
|
|
|
import inboxMixin from 'shared/mixins/inboxMixin';
|
2021-09-29 14:03:51 +00:00
|
|
|
import InboxName from '../InboxName';
|
2022-08-01 05:23:50 +00:00
|
|
|
import MoreActions from './MoreActions';
|
|
|
|
import Thumbnail from '../Thumbnail';
|
|
|
|
import wootConstants from '../../../constants';
|
|
|
|
import { conversationListPageURL } from 'dashboard/helper/URLHelper';
|
2019-08-14 09:48:44 +00:00
|
|
|
export default {
|
2019-10-27 13:31:59 +00:00
|
|
|
components: {
|
2022-08-01 05:23:50 +00:00
|
|
|
BackButton,
|
2021-09-29 14:03:51 +00:00
|
|
|
InboxName,
|
2020-08-17 05:55:13 +00:00
|
|
|
MoreActions,
|
2019-10-27 13:31:59 +00:00
|
|
|
Thumbnail,
|
|
|
|
},
|
2021-09-29 07:26:45 +00:00
|
|
|
mixins: [inboxMixin, agentMixin, eventListenerMixins],
|
2019-11-14 08:16:43 +00:00
|
|
|
props: {
|
|
|
|
chat: {
|
|
|
|
type: Object,
|
|
|
|
default: () => {},
|
|
|
|
},
|
|
|
|
isContactPanelOpen: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
2022-08-01 05:23:50 +00:00
|
|
|
showBackButton: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
2019-11-14 08:16:43 +00:00
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
computed: {
|
|
|
|
...mapGetters({
|
2021-04-22 17:47:29 +00:00
|
|
|
uiFlags: 'inboxAssignableAgents/getUIFlags',
|
2019-08-14 09:48:44 +00:00
|
|
|
currentChat: 'getSelectedChat',
|
|
|
|
}),
|
2020-07-04 14:16:17 +00:00
|
|
|
chatMetadata() {
|
|
|
|
return this.chat.meta;
|
|
|
|
},
|
2022-08-01 05:23:50 +00:00
|
|
|
backButtonUrl() {
|
|
|
|
const {
|
|
|
|
params: { accountId, inbox_id: inboxId, label, teamId },
|
|
|
|
name,
|
|
|
|
} = this.$route;
|
|
|
|
return conversationListPageURL({
|
|
|
|
accountId,
|
|
|
|
inboxId,
|
|
|
|
label,
|
|
|
|
teamId,
|
|
|
|
conversationType: name === 'conversation_mentions' ? 'mention' : '',
|
|
|
|
});
|
|
|
|
},
|
2021-11-22 18:02:17 +00:00
|
|
|
isHMACVerified() {
|
|
|
|
if (!this.isAWebWidgetInbox) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return this.chatMetadata.hmac_verified;
|
|
|
|
},
|
2020-06-02 17:29:02 +00:00
|
|
|
currentContact() {
|
|
|
|
return this.$store.getters['contacts/getContact'](
|
|
|
|
this.chat.meta.sender.id
|
|
|
|
);
|
|
|
|
},
|
2021-09-29 14:03:51 +00:00
|
|
|
isSnoozed() {
|
|
|
|
return this.currentChat.status === wootConstants.STATUS_TYPE.SNOOZED;
|
|
|
|
},
|
|
|
|
snoozedDisplayText() {
|
|
|
|
const { snoozed_until: snoozedUntil } = this.currentChat;
|
|
|
|
if (snoozedUntil) {
|
|
|
|
// When the snooze is applied, it schedules the unsnooze event to next day/week 9AM.
|
|
|
|
// By that logic if the time difference is less than or equal to 24 + 9 hours we can consider it tomorrow.
|
|
|
|
const MAX_TIME_DIFFERENCE = 33;
|
|
|
|
const isSnoozedUntilTomorrow =
|
|
|
|
differenceInHours(new Date(snoozedUntil), new Date()) <=
|
|
|
|
MAX_TIME_DIFFERENCE;
|
|
|
|
return this.$t(
|
|
|
|
isSnoozedUntilTomorrow
|
|
|
|
? 'CONVERSATION.HEADER.SNOOZED_UNTIL_TOMORROW'
|
|
|
|
: 'CONVERSATION.HEADER.SNOOZED_UNTIL_NEXT_WEEK'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return this.$t('CONVERSATION.HEADER.SNOOZED_UNTIL_NEXT_REPLY');
|
|
|
|
},
|
|
|
|
contactPanelToggleText() {
|
|
|
|
return `${
|
|
|
|
this.isContactPanelOpen
|
|
|
|
? this.$t('CONVERSATION.HEADER.CLOSE')
|
|
|
|
: this.$t('CONVERSATION.HEADER.OPEN')
|
|
|
|
} ${this.$t('CONVERSATION.HEADER.DETAILS')}`;
|
|
|
|
},
|
|
|
|
inbox() {
|
|
|
|
const { inbox_id: inboxId } = this.chat;
|
|
|
|
return this.$store.getters['inboxes/getInbox'](inboxId);
|
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
2021-08-09 07:38:52 +00:00
|
|
|
handleKeyEvents(e) {
|
|
|
|
if (hasPressedAltAndOKey(e)) {
|
|
|
|
this.$emit('contact-panel-toggle');
|
|
|
|
}
|
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
2020-01-01 17:00:43 +00:00
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.text-truncate {
|
|
|
|
white-space: nowrap;
|
|
|
|
overflow: hidden;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
}
|
2021-03-09 09:56:03 +00:00
|
|
|
|
|
|
|
.conv-header {
|
|
|
|
flex: 0 0 var(--space-jumbo);
|
|
|
|
}
|
2021-04-21 06:48:48 +00:00
|
|
|
|
|
|
|
.option__desc {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
}
|
|
|
|
|
|
|
|
.option__desc {
|
|
|
|
&::v-deep .status-badge {
|
|
|
|
margin-right: var(--space-small);
|
|
|
|
min-width: 0;
|
|
|
|
flex-shrink: 0;
|
|
|
|
}
|
|
|
|
}
|
2021-09-29 14:03:51 +00:00
|
|
|
|
|
|
|
.user--name {
|
|
|
|
display: inline-block;
|
|
|
|
font-size: var(--font-size-medium);
|
|
|
|
line-height: 1.3;
|
|
|
|
margin: 0;
|
|
|
|
text-transform: capitalize;
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
|
|
|
|
.conversation--header--actions {
|
|
|
|
align-items: center;
|
|
|
|
display: flex;
|
|
|
|
font-size: var(--font-size-mini);
|
|
|
|
|
|
|
|
.user--profile__button {
|
|
|
|
padding: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.snoozed--display-text {
|
|
|
|
font-weight: var(--font-weight-medium);
|
2022-04-11 11:57:28 +00:00
|
|
|
color: var(--y-600);
|
2021-09-29 14:03:51 +00:00
|
|
|
}
|
|
|
|
}
|
2022-04-11 11:57:28 +00:00
|
|
|
|
|
|
|
.hmac-warning__icon {
|
|
|
|
color: var(--y-600);
|
|
|
|
}
|
2020-01-01 17:00:43 +00:00
|
|
|
</style>
|