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"
|
2021-11-18 09:48:51 +00:00
|
|
|
class="button transparent compact new-window--button "
|
2020-08-28 12:09:46 +00:00
|
|
|
@click="popoutWindow"
|
|
|
|
>
|
2021-11-18 09:48:51 +00:00
|
|
|
<fluent-icon icon="open" size="22" class="text-black-900" />
|
2020-08-28 12:09:46 +00:00
|
|
|
</button>
|
2021-03-15 17:10:26 +00:00
|
|
|
<button
|
|
|
|
class="button transparent compact close-button"
|
|
|
|
:class="{
|
|
|
|
'rn-close-button': isRNWebView,
|
|
|
|
}"
|
2021-11-18 09:48:51 +00:00
|
|
|
@click="closeWindow"
|
2021-03-15 17:10:26 +00:00
|
|
|
>
|
2021-11-18 09:48:51 +00:00
|
|
|
<fluent-icon icon="dismiss" size="24" class="text-black-900" />
|
2020-08-28 12:09:46 +00:00
|
|
|
</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';
|
2021-11-18 09:48:51 +00:00
|
|
|
import FluentIcon from 'shared/components/FluentIcon/Index.vue';
|
2020-08-28 12:09:46 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'HeaderActions',
|
2021-11-18 09:48:51 +00:00
|
|
|
components: { FluentIcon },
|
2020-08-28 12:09:46 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
.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>
|