Skip to content

Commit

Permalink
Major refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
jolzee committed Mar 27, 2020
1 parent ce88011 commit fba46d2
Show file tree
Hide file tree
Showing 9 changed files with 1,044 additions and 1,096 deletions.
1,675 changes: 811 additions & 864 deletions package-lock.json

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,27 @@
]
},
"dependencies": {
"@livechat/accounts-sdk": "^1.3.3",
"@livechat/accounts-sdk": "^1.3.4",
"@livechat/agent-app-sdk": "^1.4.1",
"@livechat/agent-app-widget-sdk": "^3.0.0",
"@livechat/customer-auth": "^0.4.0-alpha.6",
"@livechat/customer-sdk": "^2.0.0-beta.1",
"@mdi/font": "^5.0.45",
"@sentry/browser": "^5.15.0",
"@sentry/integrations": "^5.15.0",
"@sentry/browser": "^5.15.4",
"@sentry/integrations": "^5.15.4",
"artyom.js": "git+http://github.com/jolzee/artyom.js.git",
"consola": "^2.11.3",
"copy-to-clipboard": "^3.3.1",
"core-js": "^3.6.4",
"custom-event-polyfill": "^1.0.7",
"dayjs": "^1.8.23",
"element-matches": "^0.1.2",
"firebase": "^7.12.0",
"firebase": "^7.13.0",
"gravatar": "^1.8.0",
"is-html": "^2.0.0",
"is-mobile": "^2.2.1",
"jsonpack": "^1.1.5",
"leopard-tie-client": "^2.0.3",
"leopard-tie-client": "^3.0.4",
"logrocket": "^1.0.7",
"logrocket-vuex": "0.0.3",
"markdown-it": "^10.0.0",
Expand Down Expand Up @@ -111,7 +112,7 @@
"prettier": "^2.0.2",
"prettier-eslint": "^9.0.1",
"prettier-stylelint": "^0.4.2",
"release-it": "^13.3.0",
"release-it": "^13.4.0",
"sass": "^1.26.3",
"sass-loader": "^8.0.2",
"stylelint": "^13.2.1",
Expand Down
4 changes: 2 additions & 2 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -867,9 +867,9 @@ export default {
methods: {
sendEmergencyCode() {
this.$store
.dispatch("sendUserInput", this.emergencyConfig.params)
.dispatch("sendUserInput", this.emergencyConfig.payload)
.then(() => {
logger.debug("Emergency code sent to Teneo: ", this.emergencyConfig.params);
logger.debug("Emergency code sent to Teneo: ", this.emergencyConfig.payload);
})
.catch(err => {
logger.error("Error sending emergency code", err);
Expand Down
32 changes: 14 additions & 18 deletions src/components/Card.vue
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
<template>
<v-card v-if="isValidCard" class="mx-2 mt-2" max-width="400">
<v-img
v-if="config.imageUrl"
class="white--text align-end"
contain
:src="config.imageUrl"
></v-img>
<v-img v-if="config.imageUrl" class="white--text align-end" contain :src="config.imageUrl"></v-img>
<v-card-title
v-if="config.title"
class="subtitle-2 white--text primary cardTitleBackground mb-5"
>{{ config.title }}</v-card-title
>
>{{ config.title }}</v-card-title>
<v-card-subtitle v-if="config.subTitle" class="pb-1">{{ config.subTitle }}</v-card-subtitle>

<v-card-text v-if="config.bodyText" class="text--primary">{{ config.bodyText }}</v-card-text>
Expand All @@ -30,13 +24,13 @@
small
color="secondary"
@click="actionClicked(action)"
>{{ action.name }}</v-btn
>
>{{ action.name }}</v-btn>
</v-card-actions>
</v-card>
</template>
<script>
const logger = require("@/utils/logging").getLogger("Card.vue");
const TIE = require("leopard-tie-client");
export default {
name: "Card",
Expand All @@ -53,18 +47,20 @@ export default {
},
computed: {
isValidCard() {
try {
const theConfig = decodeURIComponent(this.item.teneoResponse.extraData.displayCard);
JSON.parse(theConfig);
return true;
} catch (e) {
return false;
let result = false;
if (this.item.teneoResponse) {
const tResp = TIE.wrap(this.item.teneoResponse);
if (tResp.hasParameter("displayCard")) {
result = true
}
}
return result;
},
config() {
const theConfig = decodeURIComponent(this.item.teneoResponse.extraData.displayCard);
const tResp = TIE.wrap(this.item.teneoResponse);
let theConfig = tResp.getParameter("displayCard");
logger.debug(`Card JSON`, theConfig);
return JSON.parse(theConfig);
return theConfig;
}
},
methods: {
Expand Down
60 changes: 31 additions & 29 deletions src/components/ChatTeneoResponse.vue
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@
import LongPress from "vue-directive-long-press";
import { mapGetters } from "vuex";
import copy from "copy-to-clipboard";
const TIE = require("leopard-tie-client");
const logger = require("@/utils/logging").getLogger("ChatTeneoResponse.vue");
const isHtml = require("is-html");
Expand Down Expand Up @@ -546,13 +547,13 @@ export default {
},
getResponseIcon() {
let icon = this.responseIcon;
if (
"teneoResponse" in this.item &&
this.item.teneoResponse.emotion !== "" &&
decodeURIComponent(this.item.teneoResponse.emotion).indexOf("|") !== -1
) {
const rawEmotion = decodeURIComponent(this.item.teneoResponse.emotion);
icon = `mdi-${rawEmotion.split("|")[1].trim()}`;
if ("teneoResponse" in this.item) {
const tResp = TIE.wrap(this.item.teneoResponse);
if (tResp.hasEmotion() && tResp.getEmotion().indexOf("|") !== -1) {
const rawEmotion = decodeURIComponent(tResp.getEmotion());
icon = `mdi-${rawEmotion.split("|")[1].trim()}`;
}
}
return icon;
},
Expand All @@ -573,6 +574,8 @@ export default {
return filtered;
},
modalButtonText() {
const tResp = TIE.wrap(this.item.teneoResponse);
const response = {
text: this.$t("button.more"),
aria: this.$t("button.more")
Expand All @@ -587,14 +590,14 @@ export default {
let buttonLabel = this.$t("button.more");
let aria = this.$t("button.more");
if (this.item.teneoResponse.link.href !== "") {
if (tResp.hasLink()) {
aria = `Website ${aria}`;
buttonLabel = this.$t("button.page");
}
const externalExtensions = extensions.filter(
extension =>
this.item.teneoResponse.link.href === "" &&
!tResp.hasLink() &&
(!String(extension.name).startsWith("displayCollection") ||
("inline" in extension && !extension.inline))
);
Expand Down Expand Up @@ -647,11 +650,12 @@ export default {
return response;
},
modalButtonIcon() {
const tResp = TIE.wrap(this.item.teneoResponse);
const extensions = this.itemExtensions(this.item);
let countOfNonInlines = 0;
let iconName = "mdi-arrow-top-left-thick";
extensions.forEach(extension => {
if (!extension.inline || this.item.teneoResponse.link.href !== "") {
if (!extension.inline || tResp.hasLink()) {
countOfNonInlines += 1;
}
Expand All @@ -672,7 +676,7 @@ export default {
iconName = "mdi-music-box";
}
if (this.item.teneoResponse.link.href !== "") {
if (tResp.hasLink()) {
iconName = "mdi-link-variant";
}
});
Expand Down Expand Up @@ -756,17 +760,20 @@ export default {
return options;
},
mustShowDate() {
if (decodeURIComponent(this.item.teneoResponse.extraData.datePicker) !== "undefined") {
const tResp = TIE.wrap(this.item.teneoResponse);
if (tResp.hasParameter("datePicker")) {
return true;
}
return false;
},
notLiveChatTranscript() {
const transcript = decodeURIComponent(this.item.teneoResponse.extraData.liveChat);
return transcript === "undefined";
const tResp = TIE.wrap(this.item.teneoResponse);
return !tResp.hasParameter("liveChat");
},
mustShowTime() {
if (decodeURIComponent(this.item.teneoResponse.extraData.timePicker) !== "undefined") {
const tResp = TIE.wrap(this.item.teneoResponse);
if (tResp.hasParameter("timePicker")) {
return true;
}
return false;
Expand Down Expand Up @@ -837,12 +844,12 @@ export default {
this.agentAssist.cannedResponseForm = true;
},
hasLink() {
return this.item.teneoResponse.link.href;
return TIE.wrap(this.item.teneoResponse).hasLink();
},
sendLinkToLiveAgent() {
this.$store.dispatch(
"putLiveChatAgentMessage",
decodeURIComponent(this.item.teneoResponse.link.href)
decodeURIComponent(TIE.wrap(this.item.teneoResponse).getLink())
);
},
resetBotSession() {
Expand Down Expand Up @@ -896,27 +903,22 @@ export default {
this.displayForm = false;
},
hasForm() {
if (
this.item.teneoResponse &&
this.item.teneoResponse.extraData &&
this.item.teneoResponse.extraData.formConfig
) {
const tResp = TIE.wrap(this.item.teneoResponse);
if (tResp.hasParameter("formConfig")) {
return true;
}
return false;
},
getFormConfig() {
if (
this.item.teneoResponse &&
this.item.teneoResponse.extraData &&
this.item.teneoResponse.extraData.formConfig
) {
return JSON.parse(this.item.teneoResponse.extraData.formConfig);
const tResp = TIE.wrap(this.item.teneoResponse);
if (tResp.hasParameter("formConfig")) {
return tResp.getParameter("formConfig");
}
return null;
},
hasCard(item) {
if (item.teneoResponse.extraData && item.teneoResponse.extraData.displayCard) {
const tResp = TIE.wrap(item.teneoResponse);
if (tResp.hasParameter("displayCard")) {
return true;
}
return false;
Expand Down
14 changes: 7 additions & 7 deletions src/components/Modal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ export default {
overlay: false,
overlayMessage: "",
currentModalPosition: "center", // left / right / center / fullscreen
currentModalSize: "medium", // small / medium / large / x-large / fullscreen "" = full screen
currentModalSize: "small", // small / medium / large / x-large / fullscreen "" = full screen
pusherEnabled: false,
pusherMessage: "",
search: "",
Expand Down Expand Up @@ -316,7 +316,7 @@ export default {
return false;
},
toolbarWidth() {
if (this.currentModalSize !== "") {
if (this.currentModalSize) {
logger.debug("Adjusted the custom modal toolbar style");
return `teneo-modal-${this.currentModalSize}-width`;
}
Expand Down Expand Up @@ -353,7 +353,7 @@ export default {
// check if user wants to talk to a live agent
logger.debug(`Live Chat? :${this.isLiveChat}`);
if (transcript !== "undefined" && this.isLiveChat) {
if (transcript && this.isLiveChat) {
this.$store.commit(
"LIVE_CHAT",
`======= VIRTUAL ASSISTANT CONVERSATION HISTORY =======\n${transcript}====================================================\n`
Expand Down Expand Up @@ -385,11 +385,11 @@ export default {
}
// check for modal sizes and positions
if (this.modalSize(item) !== "undefined") {
if (this.modalSize(item)) {
this.currentModalSize = this.modalSize(item);
}
if (this.modalPosition(item) !== "undefined") {
if (this.modalPosition(item)) {
this.currentModalPosition = this.modalPosition(item);
}
Expand Down Expand Up @@ -612,7 +612,7 @@ export default {
logger.debug("Applying custom modal size and position");
logger.debug("Adding sizing and position styles to modal");
const modalElements = document.getElementsByClassName("teneo-modal");
if (modalElements !== "undefined" && this.currentModalSize !== "undefined") {
if (modalElements && this.currentModalSize) {
for (let i = 0; i < modalElements.length; i += 1) {
if (
this.currentModalSize !== "fullscreen" &&
Expand All @@ -635,7 +635,7 @@ export default {
removeCustomStylesFromModal() {
logger.debug("removing custom styles from modal");
const modalElements = document.getElementsByClassName("teneo-modal");
if (modalElements !== "undefined") {
if (modalElements) {
for (let i = 0; i < modalElements.length; i += 1) {
logger.debug("Removing existing modal size and position styles - reset");
modalElements[i].classList.remove("teneo-modal-center");
Expand Down
Loading

0 comments on commit fba46d2

Please sign in to comment.