2020-08-28 12:09:46 +00:00
|
|
|
<template>
|
2021-03-15 17:10:26 +00:00
|
|
|
<div v-if="showHeaderActions" class="actions flex items-center">
|
2020-08-28 12:09:46 +00:00
|
|
|
<button
|
|
|
|
v-if="showPopoutButton"
|
|
|
|
class="button transparent compact new-window--button"
|
|
|
|
@click="popoutWindow"
|
|
|
|
>
|
|
|
|
<span class="ion-android-open"></span>
|
|
|
|
</button>
|
2021-03-15 17:10:26 +00:00
|
|
|
<button
|
|
|
|
class="button transparent compact close-button"
|
|
|
|
:class="{
|
|
|
|
'rn-close-button': isRNWebView,
|
|
|
|
}"
|
|
|
|
>
|
2020-08-28 12:09:46 +00:00
|
|
|
<span class="ion-android-close" @click="closeWindow"></span>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script>
|
2021-03-15 17:10:26 +00:00
|
|
|
import { IFrameHelper, RNHelper } from 'widget/helpers/utils';
|
2020-08-28 12:09:46 +00:00
|
|
|
import { buildPopoutURL } from '../helpers/urlParamsHelper';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'HeaderActions',
|
|
|
|
props: {
|
|
|
|
showPopoutButton: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
isIframe() {
|
|
|
|
return IFrameHelper.isIFrame();
|
|
|
|
},
|
2021-03-15 17:10:26 +00:00
|
|
|
isRNWebView() {
|
|
|
|
return RNHelper.isRNWebView();
|
|
|
|
},
|
|
|
|
showHeaderActions() {
|
|
|
|
return this.isIframe || this.isRNWebView;
|
|
|
|
},
|
2020-08-28 12:09:46 +00:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
popoutWindow() {
|
|
|
|
this.closeWindow();
|
|
|
|
const {
|
|
|
|
location: { origin },
|
|
|
|
chatwootWebChannel: { websiteToken },
|
|
|
|
authToken,
|
|
|
|
} = window;
|
|
|
|
|
|
|
|
const popoutWindowURL = buildPopoutURL({
|
|
|
|
origin,
|
|
|
|
websiteToken,
|
2020-12-12 06:38:36 +00:00
|
|
|
locale: this.$root.$i18n.locale,
|
2020-08-28 12:09:46 +00:00
|
|
|
conversationCookie: authToken,
|
|
|
|
});
|
|
|
|
const popoutWindow = window.open(
|
|
|
|
popoutWindowURL,
|
|
|
|
`webwidget_session_${websiteToken}`,
|
|
|
|
'resizable=off,width=400,height=600'
|
|
|
|
);
|
|
|
|
popoutWindow.focus();
|
|
|
|
},
|
|
|
|
closeWindow() {
|
|
|
|
if (IFrameHelper.isIFrame()) {
|
|
|
|
IFrameHelper.sendMessage({
|
|
|
|
event: 'toggleBubble',
|
|
|
|
});
|
2021-03-15 17:10:26 +00:00
|
|
|
} else if (RNHelper.isRNWebView) {
|
|
|
|
RNHelper.sendMessage({ type: 'close-widget' });
|
2020-08-28 12:09:46 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
<style scoped lang="scss">
|
|
|
|
@import '~widget/assets/scss/variables.scss';
|
|
|
|
|
|
|
|
.actions {
|
|
|
|
button {
|
|
|
|
margin-left: $space-normal;
|
|
|
|
}
|
|
|
|
|
|
|
|
span {
|
|
|
|
color: $color-heading;
|
|
|
|
font-size: $font-size-large;
|
|
|
|
|
|
|
|
&.ion-android-close {
|
|
|
|
font-size: $font-size-big;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.close-button {
|
|
|
|
display: none;
|
|
|
|
}
|
2021-03-15 17:10:26 +00:00
|
|
|
.rn-close-button {
|
|
|
|
display: block !important;
|
|
|
|
}
|
2020-08-28 12:09:46 +00:00
|
|
|
}
|
|
|
|
</style>
|