From c936972ff7357831bd3c0ba161dd49b65c4f93d4 Mon Sep 17 00:00:00 2001 From: Anna Lonka Date: Thu, 9 Jan 2025 15:13:48 +0200 Subject: [PATCH 1/2] UHF-11225: Removed everything related to chat leijuke --- assets/js/chat_leijuke.js | 337 -------------- assets/js/genesys_auth_redirect.js | 120 ----- assets/js/genesys_suunte.js | 440 ------------------ assets/js/telia_ace.js | 2 +- .../schema/helfi_platform_config.schema.yml | 7 - helfi_platform_config.install | 15 + helfi_platform_config.libraries.yml | 56 --- helfi_platform_config.module | 3 - src/Plugin/Block/ChatLeijuke.php | 163 ------- 9 files changed, 16 insertions(+), 1127 deletions(-) delete mode 100644 assets/js/chat_leijuke.js delete mode 100644 assets/js/genesys_auth_redirect.js delete mode 100644 assets/js/genesys_suunte.js delete mode 100644 src/Plugin/Block/ChatLeijuke.php diff --git a/assets/js/chat_leijuke.js b/assets/js/chat_leijuke.js deleted file mode 100644 index d30cafe98..000000000 --- a/assets/js/chat_leijuke.js +++ /dev/null @@ -1,337 +0,0 @@ -(function (Drupal, drupalSettings) { - 'use strict'; - - Drupal.behaviors.chat_leijuke = { - attach: function (context, settings) { - - const leijukeData = drupalSettings.leijuke_data; - - for (const chat_selection in leijukeData) { - const adapter = getAdapter(chat_selection); - if (!adapter) return; - - setTimeout(() => { - // Only load any leijuke once, in case of ajax triggers. - if (leijukeData[chat_selection].initialized) { - console.warn(`Already initialized ${chat_selection}!`); - return; - } - - new Leijuke(leijukeData[chat_selection], new EuCookieManager, adapter); - drupalSettings.leijuke_data[chat_selection].initialized = true; - }); - } - } - } - - function getAdapter(chatSelection) { - if (chatSelection.indexOf('genesys') != -1) { - return new GenesysAdapter; - } - console.warn(`No adapter found for ${chatSelection}!`); - } - - class EuCookieManager { - cookieCheck(cookieNames) { - let cookiesOk = true; - - // If cookies are not available yet, wait for a while. - if (Drupal.cookieConsent.getConsentStatus(cookieNames) === undefined) { - let i = 0; - - const interval = setInterval(()=> { - let found = false; - cookieNames.map((cookieName) => { - found = Drupal.cookieConsent.getConsentStatus([cookieName]) || false; - }); - - if (i >= 3 || found) { - cookiesOk = found; - clearInterval(interval); - } - i++; - }, 1000) - } else { - cookieNames.map((cookieName) => { - if (!Drupal.cookieConsent.getConsentStatus([cookieName])) cookiesOk = false; - }); - } - - return cookiesOk; - } - cookieSet() { - if (Drupal.cookieConsent.getConsentStatus(['chat'])) return; - - Drupal.cookieConsent.setAcceptedCategories(['chat']); - } - } - - class GenesysAdapter { - - constructor() { - this.requiredCookies = ['chat']; - this.bot = false; - this.persist = true; - this.hasButton = true; - } - - async getChatExtension() { - return await new Promise(resolve => { - let checkChatExtension = setInterval(()=> { - if (typeof chatExtension != 'undefined') { - resolve(chatExtension); - clearInterval(checkChatExtension); - } - }, 100); - }); - } - - open(callback) { - // send open command - this.getChatExtension().then((ext) => chatExtension.command('WebChat.open').done(callback).fail(console.warn('Failed WebChat open command.'))); - } - - onClosed(callback) { - // subscribe to closed event - this.getChatExtension().then((ext) => chatExtension.subscribe('WebChat.closed', callback)); - } - - onLoaded(callback) { - // subscribe to ready event - this.getChatExtension().then((ext) => chatExtension.subscribe('WebChat.ready', callback)); - } - } - - class Leijuke { - constructor(leijukeData, extCookieManager, chatAdapter) { - - this.extCookieManager = extCookieManager; - this.adapter = chatAdapter; - - this.static = { - selector: `chat-leijuke-${leijukeData.name}`, - chatSelection: leijukeData.name, - cookieName: `leijuke.${leijukeData.name}.isOpen`, - modulePath: leijukeData.modulepath, - libraries: leijukeData.libraries, - title: leijukeData.title - } - - this.state = { - cookies: extCookieManager.cookieCheck(this.adapter.requiredCookies), - chatLoaded: false, - isChatOpen: this.isChatOpen(), - busy: false - }; - - if (this.state.cookies) { - this.loadChat(); - } - - this.initWrapper(); - chatAdapter.hasButton && this.render(); - } - - prepButton(button) { - - button.addEventListener('click', (event) => { - - // Debounce button. - if (this.state.busy) { - return; - } - this.state = { - ...this.state, - busy: true, - }; - - // If chat was loaded, cookies are ok. - if (this.state.chatLoaded) { - this.openChat(); - return; - } - - if (!this.state.cookies) { - // Implicitly allow chat cookies if clicking Leijuke. - console.log('Chat cookies allowed implicitly and chat being loaded.'); - - this.extCookieManager.cookieSet(); - } - - this.state = { - ...this.state, - cookies: this.extCookieManager.cookieCheck(this.adapter.requiredCookies) - }; - - if (this.state.cookies) { - this.loadChat(); - this.adapter.onLoaded(this.openChat.bind(this)); - } else { - console.warn('Missing the required cookies to open chat. Missing cookie not allowed to be set implicitly.') - } - - }); - } - - openAdapter = () => { - this.adapter.open(()=>{}); - let acaWidgetInitialized = setInterval(() => { - if (acaWidget) { - setTimeout(this.doOpenAdapter, 800); - clearInterval(acaWidgetInitialized); - } - }, 500) - } - - doOpenAdapter = () => this.adapter.open(()=>{}); - - setLeijukeCookie(cname, cvalue) { - document.cookie = `${cname}=${cvalue}; path=/; SameSite=Strict; `; - } - - getLeijukeCookie(cname) { - var name = cname + "="; - var ca = document.cookie.split(";"); - for (var i = 0; i < ca.length; i++) { - var c = ca[i]; - while (c.charAt(0) == " ") { - c = c.substring(1); - } - if (c.indexOf(name) == 0) { - return c.substring(name.length, c.length); - } - } - return ""; - } - - openChat() { - const leijuke = this; - // Try to open a chat via adapter. - this.adapter.open((e) => { - if(leijuke.adapter.persist) { - leijuke.setLeijukeCookie(leijuke.static.cookieName, true); - } - leijuke.state = { - ...leijuke.state, - isChatOpen: true, - busy: false, - }; - leijuke.render(); - leijuke.adapter.onClosed(leijuke.closeChat.bind(leijuke)); - }); - } - - loadChat() { - const { modulePath, libraries } = this.static; - libraries.js.map((script) => { - - let chatScript = document.createElement('script'); - chatScript.src = script.ext ? script.url : `/${modulePath}/${script.url}`; - chatScript.type = "text/javascript"; - - if (script.onload) { - chatScript.setAttribute('onload', script.onload); - } - - if (script.async) { - chatScript.setAttribute('async', ''); - } - - if (script.dataContainerId) { - chatScript.setAttribute('data-container-id', script.data_container_id); - } - - // Insert chatScript into head - let head = document.querySelector('head'); - head.appendChild(chatScript); - }); - - if (libraries.hasOwnProperty('css')) { - libraries.css.map((script) => { - // Create new link Element for loading css - let css = document.createElement('link'); - css.rel = 'stylesheet'; - css.href = script.ext ? script.url : `/${modulePath}/${script.url}`; - - // Insert chatScript into head - let head = document.querySelector('head'); - head.append(css); - }); - } - - this.adapter.onLoaded(this.loaded.bind(this)); - } - - loaded() { - this.state = { - ...this.state, - chatLoaded: true - }; - this.render(); - } - - closeChat() { - if(this.adapter.persist) { - this.setLeijukeCookie(this.static.cookieName, false); - } - this.state = { - ...this.state, - isChatOpen: false - }; - this.render(); - } - - isChatOpen() { - if (this.getLeijukeCookie(this.static.cookieName) == "true") { - this.adapter.onClosed(this.closeChat.bind(this)); - return true; - } - return false; - } - - initWrapper() { - let leijukeWrapper = document.getElementById('chat-leijuke-wrapper'); - if (!leijukeWrapper) { - leijukeWrapper = document.createElement('aside'); - leijukeWrapper.id = 'chat-leijuke-wrapper'; - document.body.append(leijukeWrapper) - } - - let leijukeTitle = document.createElement('h2'); - leijukeTitle.classList.add('visually-hidden'); - leijukeTitle.innerHTML = Drupal.t('Chat', {}, { context: 'Floating chat title' }); - leijukeWrapper.append(leijukeTitle); - - let leijukeInstance = document.createElement('button'); - leijukeInstance.id = this.static.selector; - leijukeInstance.classList.add('chat-leijuke') - - leijukeWrapper.append(leijukeInstance); - - this.prepButton(leijukeInstance); - } - - render() { - const { isChatOpen } = this.state; - - const icon = this.adapter.bot ? 'customer-bot-neutral' : 'speechbubble-text'; - - const element = document.getElementById(this.static.selector); - - const innerHTML = ` - - ${this.static.title} - - `; - - if (element.innerHTML != innerHTML) { - element.innerHTML = innerHTML; - } - - element.classList.toggle('hidden', isChatOpen); - - } - - } - -})(Drupal, drupalSettings); diff --git a/assets/js/genesys_auth_redirect.js b/assets/js/genesys_auth_redirect.js deleted file mode 100644 index 9cddae7ba..000000000 --- a/assets/js/genesys_auth_redirect.js +++ /dev/null @@ -1,120 +0,0 @@ -function isEmpty(str) { - return (!str || 0 === str.length); -} - -function isBlank(str) { - return (!str || /^\s*$/.test(str)); -} - -String.prototype.isEmpty = function() { - return (this.length === 0 || !this.trim()); -}; - -function getCookieChat(cname) { - var name = cname + "="; - var ca = document.cookie.split(';'); - for (var i = 0; i < ca.length; i++) { - var c = ca[i]; - while (c.charAt(0) == ' ') { - c = c.substring(1); - } - if (c.indexOf(name) == 0) { - return c.substring(name.length, c.length); - } - } - return ""; -} - -function callShibboleth() -{ - var interactionId = ''; - interactionId = getCookieChat("gcReturnSessionId"); - //Current url without querystring: - var currentPage = location.toString().replace(location.search, ""); - var shibbolethString = "https://asiointi.hel.fi/chat/tunnistus/Shibboleth.sso/KAPALogin?"; - shibbolethString += "target="; - shibbolethString += "https://asiointi.hel.fi/chat/tunnistus/MagicPagePlain/ReturnProcessor"; - console.log('currentPage:'+currentPage); - shibbolethString += "%3ForigPage%3D" + currentPage + "?dir%3Din%26gcLoginButtonState%3D1%26errcode%3d0"; - shibbolethString += "%26" + "interactionId" + "%3D" + interactionId; - window.location = shibbolethString; -} - -var _genesys = { - onReady: [], - chat: { - registration: false, - localization : 'https://asiointi.hel.fi/chat/sote/custom/chat-suunte-fi.json', - onReady: [], - ui: { - onBeforeChat: function (chat) { - _genesys.chat.onReady.push(function (chatWidgetApi) { - chatWidgetApi.restoreChat({ - serverUrl: "https://chat-proxy.hel.fi/chat/sote/cobrowse", - registration: function (done) { - done({ - service: 'SUUNTE' - }); - } - }).done(function (session) { - session.setUserData({ - service: 'SUUNTE' - }); - }).fail(function (par) { - alert(par.description); - }); - }); - } - } - } -}; -_genesys.cobrowse = false; - - -var url = window.location.search; -url = decodeURIComponent(url); -var referringURL = ''; -var returnURL = ''; - -/* FILL HERE DRUPAL URL SCOPE UNDER WHICH SUUNTE CHAT IS RUN, COOKIE WOULD BE GOOD TO HAVE URL CONTEXT AS WELL IF MULTIPLE GENESYS CHATS ARE RUN UNDER SAME DOMAIN */ -var helfiChatCookiePath = '/fi/sosiaali-ja-terveyspalvelut/'; - -// show authenticate button 0 no, 1 yes: -var int_gcLoginButtonState=0; - -// dir = out => transfer to authentication -if(url.indexOf('?dir=out') !== -1){ - referringURL = document.referrer; - //setting helper cookie return url: - document.cookie = "gcReturnUrl="+referringURL+";path="+helfiChatCookiePath; - callShibboleth(); -} - -// dir = in => transfer to back to hel.fi -site from authentication -if(url.indexOf('?dir=in') !== -1){ - // set gcLoginButtonState -info cookie, if user has authenticated=1, or not.. - var now = new Date(); - var time = now.getTime(); - int_gcLoginButtonState=1; - time += 180 * 1000; - now.setTime(time); - document.cookie = "gcLoginButtonState="+int_gcLoginButtonState +"; expires=" + now.toUTCString() +";path="+helfiChatCookiePath; - - // get return url back from hel.fi cookie: - returnURL = getCookieChat("gcReturnUrl"); - - // redirect urser back from Vetuma, to hel.fi -site: - // prevent endless loop, do not redirect back to this transfer page itself! - if(returnURL!="" && returnURL.indexOf('transfer') == -1 && !isEmpty(returnURL) && !isBlank(returnURL)){ - window.location.href = returnURL + '?redir=done'; - } - else{ - // search alternative returnURl cookie, set by hel.fi chat page before user clicked authenticate link: - returnURL = getCookieChat("gcAlternativeReturnUrl"); - if(returnURL!="" && returnURL.indexOf('transfer') == -1 && !isEmpty(returnURL) && !isBlank(returnURL)){ - window.location.href = returnURL + '?redir2=done'; - } - // default fallback: some error happened. Redirect back to top level contextual main page: - window.location = helfiChatCookiePath + '?redir3=done'; - } -} diff --git a/assets/js/genesys_suunte.js b/assets/js/genesys_suunte.js deleted file mode 100644 index 9160281be..000000000 --- a/assets/js/genesys_suunte.js +++ /dev/null @@ -1,440 +0,0 @@ -var helfiChatCookiePath = '/fi/sosiaali-ja-terveyspalvelut/'; -var helfiChatTransferPath = helfiChatCookiePath + 'genesys-auth-redirect?dir=out'; -var gcReturnSessionId = ''; - -(function ($, Drupal, drupalSettings) { - 'use strict'; - - Drupal.removeChatIcon = function() { - $(".cx-window-manager").css("display", "none"); - } - - Drupal.setGcReturnSessionId = function() { - // helper cookie to maintain chat session id: - var gcReturnSessionId = Drupal.getCookieChat("_genesys.widgets.webchat.state.session"); - if (!Drupal.isEmpty(gcReturnSessionId) && !Drupal.isBlank(gcReturnSessionId)) { - // Found GS-chat session, setting it to helper cookie: - /* document.cookie = "gcReturnSessionId="+gcReturnSessionId+";path=/helsinki/fi/sosiaali-ja-terveyspalvelut/terveyspalvelut/hammashoito/"; */ - document.cookie = - "gcReturnSessionId=" + gcReturnSessionId + ";path=" + helfiChatCookiePath; - } else { - //console.log("gcReturnSessionId", gcReturnSessionId); - alert( - "Virhe, ei voida tunnistaa käyttäjää, koska chat-keskustelu ei ole auki." - ); - return false; - } - // save alternative return url for cookie: - document.cookie = - "gcAlternativeReturnUrl=" + - window.location.href + - ";path=" + - helfiChatCookiePath; - return true; - } - - Drupal.getCookieChat = function(cname) { - var name = cname + "="; - var ca = document.cookie.split(";"); - for (var i = 0; i < ca.length; i++) { - var c = ca[i]; - while (c.charAt(0) == " ") { - c = c.substring(1); - } - if (c.indexOf(name) == 0) { - return c.substring(name.length, c.length); - } - } - return ""; - } - - Drupal.isEmpty = function(str) { - return !str || 0 === str.length; - } - - Drupal.isBlank = function(str) { - return !str || /^\s*$/.test(str); - } - - Drupal.behaviors.genesys_suunte = { - attach: function (context, settings) { - var helFiChatPageUrl = document.location.href; - helFiChatPageUrl = helFiChatPageUrl.toLowerCase(); - var helfiChat_lang = document.documentElement.lang; - - var accesabilityTexts = { - fi: { - userIconAlt: "käyttäjä", - agentIconAlt: "agentti", - }, - en: { - userIconAlt: "user", - agentIconAlt: "agent", - }, - sv: { - userIconAlt: "användare", - agentIconAlt: "ombud", - }, - }; - - var startChatButtonClasses = { - desktop: { - fi: { - open: "cx-webchat-chat-button-open", - busy: "cx-webchat-chat-button-busy", - close: "cx-webchat-chat-button-closed", - }, - sv: { - open: "cx-webchat-chat-button-open-sv", - busy: "cx-webchat-chat-button-busy-sv", - close: "cx-webchat-chat-button-closed-sv", - }, - en: { - open: "cx-webchat-chat-button-open-en", - busy: "cx-webchat-chat-button-busy-en", - close: "cx-webchat-chat-button-closed-en", - }, - }, - mobile: { - fi: { - open: "cx-webchat-chat-button-mobile-open", - busy: "cx-webchat-chat-button-mobile-busy", - close: "cx-webchat-chat-button-mobile-closed", - }, - sv: { - open: "cx-webchat-chat-button-mobile-open-sv", - busy: "cx-webchat-chat-button-mobile-busy-sv", - close: "cx-webchat-chat-button-mobile-closed-sv", - }, - en: { - open: "cx-webchat-chat-button-mobile-open", - busy: "cx-webchat-chat-button-mobile-busy", - close: "cx-webchat-chat-button-mobile-closed", - }, - }, - }; - - var authEnabled = true; - var helfiChatLogoElement = - 'helsinki-logo'; - - var mobileIksButton = - '
-1) { - helFiChat_button = startChatButtonClasses[screenType][helfiChat_lang].close; - } else if (helFiChat_button.indexOf("chat-busy") > -1) { - helFiChat_button = startChatButtonClasses[screenType][helfiChat_lang].busy; - } else { - helFiChat_button = startChatButtonClasses[screenType][helfiChat_lang].open; - } - })(); - - function generateStartChatButton() { - // var screenType = isMobile(); - // // var mobileIksButton = '
' - - var buttonHtml = - '
'; - return buttonHtml; - } - - if (!window._genesys) { window._genesys = {}; - } - if (!window._gt) { window._gt = []; - } - - window._genesys.widgets = { - main: { - theme: "helsinki-blue", - themes: { - "helsinki-blue": "cx-theme-helsinki-blue", - }, - mobileMode: "auto", - lang: helfiChat_lang, - i18n: helFiChat_localization, - mobileModeBreakpoint: 600, - preload: ["webchat"], - }, - webchat: { - dataURL: "https://chat-proxy.hel.fi/gms/sote/genesys/2/chat/prod", - confirmFormCloseEnabled: false, - userData: { - service: helFiChat_service, - }, - timeFormat: 24, - cometD: { - enabled: false, - }, - autoInvite: { - enabled: false, - timeToInviteSeconds: 10, - inviteTimeoutSeconds: 30, - }, - chatButton: { - enabled: true, - template: generateStartChatButton(), - effect: "fade", - openDelay: 1000, - effectDuration: 300, - hideDuringInvite: true, - }, - uploadEnabled: false, - }, - }; - - if (!window._genesys.widgets.extensions) { - window._genesys.widgets.extensions = {}; - } - var chatExtension = null; - chatExtension = CXBus.registerPlugin("ChatExt"); - - window._genesys.widgets.extensions["ChatExt"] = function ($, CXBus, Common) { - chatExtension.before("WebChat.open", function (oData) { - //Delete X button in mobile view - //console.log("restarted from open"); - $("#gwc-chat-icon-iks-mobile").css("display", "none"); - - if (!oData.restoring) { - oData = { - form: { - autoSubmit: true, - nickname: "Asiakas", - }, - formJSON: { - //wrapper: '
', - inputs: [ - { - id: "cx_webchat_form_nickname", - name: "nickname", - maxlength: "100", - value: "Asiakas", - type: "hidden", - }, - ], - }, - userData: { - service: helFiChat_service, - }, - }; - } - - //console.log(oData); - return oData; - }); - - //Triggers when chat is opened - chatExtension.subscribe("WebChat.opened", function (e) { - //Add auth layout - if (authEnabled) { - $(".cx-body").prepend(helfiChatAuthElement); - $(".cx-body").prepend(helfiChatAuthElementDone); - } - - //Add logo - $(".cx-titlebar .cx-icon").replaceWith(helfiChatLogoElement); - - $(".cx-input-container").removeAttr("tabindex").removeAttr("aria-hidden"); - $(".cx-textarea-cell").removeAttr("tabindex").removeAttr("aria-hidden"); - $(".cx-send").attr("tabindex", 0); - $(".cx-send").removeAttr("aria-hidden"); - - //Delete X button in mobile view - $("#gwc-chat-icon-iks-mobile").css("display", "none"); - setTimeout(function () { - $("#gwc-chat-icon-iks-mobile").css("display", "none"); - }, 500); - - //Add accesability enchanced features on minimize - if ($("[data-icon=minimize]").length) { - $("[data-icon=minimize]").attr("aria-expanded", true); - } - - //Change send icon - if ($(".cx-send").length) { - $(".cx-send").empty().append(helFiChat_SendButton); - } - - //Change user icon - handleChangeAvatarIcons(); - - if ($(".cx-message-input.cx-input").length) { - $(".cx-message-input.cx-input").attr("tabindex", 0); - } - }); - - function minimizeAccesibilityChange(name) { - //Minimizdd button accesibility change - var minimizeElement = $(".cx-button-" + name); - if (minimizeElement) { - var ariaExpanded = JSON.parse(minimizeElement.attr("aria-expanded")); - minimizeElement.attr("aria-expanded", !ariaExpanded); - } - } - - //Triggers when chat is ready to accept commands - chatExtension.subscribe("WebChat.ready", function (e) { - if (isMobile()) { - setTimeout(function () { - //showButton(true); - if ($(".cx-webchat-chat-button").length) { - $(".cx-side-button-group").prepend(mobileIksButton); - } - }, 3000); - } - }); - - // Remove custom visibility logic and show button upon closing chat - chatExtension.subscribe("WebChat.closed", function (e) { - if (isMobile()) { - setTimeout(function () { - if ($(".cx-webchat-chat-button").length) { - $(".cx-side-button-group").prepend(mobileIksButton); - } - }, 3000); - } - }); - - chatExtension.subscribe("WebChat.cancelled", function (e) { - // cancelled event. The Chat session ended before agent is connected to WebChat. - setTimeout(function () { - chatExtension - .command("WebChat.close") - .done(function (e) { - // closing success - }) - .fail(function (e) { - // closing failure - }); - }, 1000); - }); - - chatExtension.subscribe("WebChat.minimized", function (e) { - minimizeAccesibilityChange("maximize"); - }); - - chatExtension.subscribe("WebChat.unminimized", function (e) { - minimizeAccesibilityChange("minimize"); - }); - - chatExtension.subscribe("WebChat.messageAdded", function (event) { - handleChangeAvatarIcons(); - }); - - function handleChangeAvatarIcons() { - //Change user icon - if ($(".cx-avatar.user").length) { - $(".cx-avatar.user").empty().append(helFiChat_UserIcon); - } - - //Change agent icons - if ($(".cx-avatar.agent").length) { - $(".cx-avatar.agent").empty().append(helFiChat_AgentIcon); - } - } - - chatExtension.republish("ready"); - chatExtension.ready(); - window.chatExtension = chatExtension; - - }; - } - }; - -})(jQuery, Drupal, drupalSettings); diff --git a/assets/js/telia_ace.js b/assets/js/telia_ace.js index d17942813..49255e9b9 100644 --- a/assets/js/telia_ace.js +++ b/assets/js/telia_ace.js @@ -176,7 +176,7 @@ } - Drupal.behaviors.chat_leijuke = { + Drupal.behaviors.telia_ace = { attach: function attach() { const teliaAceData = drupalSettings.telia_ace_data; diff --git a/config/schema/helfi_platform_config.schema.yml b/config/schema/helfi_platform_config.schema.yml index 2d5bb7b1d..72dac731e 100644 --- a/config/schema/helfi_platform_config.schema.yml +++ b/config/schema/helfi_platform_config.schema.yml @@ -1,10 +1,3 @@ -block.settings.chat_leijuke: - type: block_settings - label: 'Example configurable text block configuration' - mapping: - chat_title: - type: text - label: 'Chat title' block.settings.telia_ace_widget: type: block_settings diff --git a/helfi_platform_config.install b/helfi_platform_config.install index 45fb3d45a..5f85f78e8 100644 --- a/helfi_platform_config.install +++ b/helfi_platform_config.install @@ -301,3 +301,18 @@ function helfi_platform_config_update_9317() : void { ->save(); } } + +/** + * UHF-11225: Remove the chatleijuke block. + */ +function helfi_platform_config_update_9319() : void { + $config_factory = Drupal::configFactory(); + // Remove the chatleijuke block. + $config_factory->getEditable('block.block.chatleijuke')->delete(); + // Remove the chatleijuke block. + $config_factory->getEditable('block.block.chatleijuke_2')->delete(); + + // Remove the chatleijuke block. + $config_factory->getEditable('block.block.hdbt_subtheme_chatleijuke')->delete(); + +} diff --git a/helfi_platform_config.libraries.yml b/helfi_platform_config.libraries.yml index 552f2cb5f..a09ae83aa 100644 --- a/helfi_platform_config.libraries.yml +++ b/helfi_platform_config.libraries.yml @@ -3,62 +3,6 @@ react_and_share: js: assets/js/reactAndShareSettings.js: {} -# This library is loaded via chat_leijuke.js. -# Setting the preprocess to false will not affect this library. -# See: ChatLeijuke.php::build(). -genesys_suunte: - version: 1.0.2 - header: true - js: - 'https://apps.mypurecloud.ie/widgets/9.0/cxbus.min.js' : { - type: external, - minified: true, - attributes: { - onload: "javascript:CXBus.configure({pluginsPath:'https://apps.mypurecloud.ie/widgets/9.0/plugins/'}); CXBus.loadPlugin('widgets-core');" - } - } - assets/js/genesys_suunte.js: { - attributes: { - onload: "javascript:var checkExist = setInterval(function() {if(typeof CXBus != 'undefined') {clearInterval(checkExist);Drupal.behaviors.genesys_suunte.attach();console.log('suunte attaching');}}, 100);" - } - } - css: - theme: - assets/css/genesys_chat.css: {} - dependencies: - - core/jquery - - core/drupal - - core/drupalSettings - -genesys_auth_redirect: - version: 1.0.1 - header: true - js: - 'https://apps.mypurecloud.ie/widgets/9.0/cxbus.min.js' : { - type: external, - minified: true, - attributes: { - onload: "javascript:CXBus.configure({pluginsPath:'https://apps.mypurecloud.ie/widgets/9.0/plugins/'}); CXBus.loadPlugin('widgets-core');" - } - } - assets/js/genesys_auth_redirect.js: {} - dependencies: - - core/jquery - - core/drupal - - core/drupalSettings - -chat_leijuke: - version: 1.0.2 - header: true - js: - assets/js/chat_leijuke.js: { - minified: true, - preprocess: false - } - dependencies: - - core/drupal - - core/drupalSettings - chat_enhancer: version: 1.0.0 header: true diff --git a/helfi_platform_config.module b/helfi_platform_config.module index 24a6fa564..18f4780e1 100644 --- a/helfi_platform_config.module +++ b/helfi_platform_config.module @@ -492,14 +492,11 @@ function helfi_platform_config_set_language_link_disabled(array &$link): void { * Implements hook_config_ignore_settings_alter(). */ function helfi_platform_config_config_ignore_settings_alter(array &$settings) { - // Chatleijuke is used in hammashoito chat in Sote. // Genesyschat might be used in palvelukeskus later but // the block configs already removed from other instances. $add_ignore = [ 'block.block.ibmchatapp', 'block.block.ibmchatapp_*', - 'block.block.chatleijuke', - 'block.block.chatleijuke_*', 'block.block.genesyschat', 'block.block.genesyschat_*', 'block.block.teliaacewidget*', diff --git a/src/Plugin/Block/ChatLeijuke.php b/src/Plugin/Block/ChatLeijuke.php deleted file mode 100644 index 1c13b9ea2..000000000 --- a/src/Plugin/Block/ChatLeijuke.php +++ /dev/null @@ -1,163 +0,0 @@ -get('extension.list.module'), - $container->get('config.factory'), - ); - } - - /** - * {@inheritdoc} - */ - public function blockForm($form, FormStateInterface $form_state): array { - $form = parent::blockForm($form, $form_state); - $config = $this->getConfiguration(); - - $form['chat_selection'] = [ - '#type' => 'select', - '#title' => $this->t('Chat/bot provider'), - '#description' => $this->t('Choose the approriate chat/bot provider?'), - '#default_value' => $config['chat_selection'] ?? '', - '#options' => [ - 'genesys_suunte' => $this->t('Genesys SUUNTE'), - ], - ]; - - $form['chat_title'] = [ - '#type' => 'textfield', - '#title' => $this->t('Chat title'), - '#default_value' => $config['chat_title'] ?? '', - ]; - - return $form; - } - - /** - * {@inheritdoc} - */ - public function blockSubmit($form, FormStateInterface $form_state): void { - $this->configuration['chat_selection'] = $form_state->getValue('chat_selection'); - $this->configuration['chat_title'] = $form_state->getValue('chat_title'); - } - - /** - * {@inheritdoc} - */ - public function build(): array { - $library = ['helfi_platform_config/chat_leijuke']; - $config = $this->getConfiguration(); - $build = []; - $chat_library = []; - $module_path = $this->moduleList->getPath('helfi_platform_config'); - $asset_path = $this->configFactory->get('helfi_proxy.settings')->get('asset_path'); - $libraries_yaml = Yaml::parseFile($module_path . '/helfi_platform_config.libraries.yml'); - - foreach ($libraries_yaml as $library_name => $library_configuration) { - if ($library_name !== $config['chat_selection']) { - continue; - } - - if (array_key_exists('js', $library_configuration)) { - foreach ($library_configuration['js'] as $key => $value) { - $js = [ - 'url' => $key, - 'ext' => $value['type'] ?? FALSE, - 'onload' => $value['attributes']['onload'] ?? FALSE, - 'async' => $value['attributes']['async'] ?? FALSE, - 'data_container_id' => $value['attributes']['data-container-id'] ?? FALSE, - ]; - $chat_library['js'][] = $js; - } - } - - if (array_key_exists('css', $library_configuration)) { - foreach ($library_configuration['css']['theme'] as $key => $value) { - $css = [ - 'url' => $key, - 'ext' => $value['type'] ?? FALSE, - ]; - - $chat_library['css'][] = $css; - } - } - } - - // We only build it if it makes sense. - if ($config['chat_selection']) { - $build['leijuke'] = [ - '#title' => $this->t('Chat Leijuke'), - '#attached' => [ - 'library' => $library, - 'drupalSettings' => [ - 'leijuke_data' => [ - $config['chat_selection'] => [ - 'name' => $config['chat_selection'], - 'libraries' => $chat_library, - 'modulepath' => $asset_path . '/' . $module_path, - 'title' => $config['chat_title'] ? Xss::filter($config['chat_title']) : 'Chat', - ], - ], - ], - ], - ]; - } - - return $build; - } - -} From 3d73b471f786475f65f81e90d82d7ef6caf834a4 Mon Sep 17 00:00:00 2001 From: Anna Lonka Date: Mon, 13 Jan 2025 11:50:35 +0200 Subject: [PATCH 2/2] UHF-11225: Fixed linter error --- helfi_platform_config.install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helfi_platform_config.install b/helfi_platform_config.install index 5f85f78e8..ece535776 100644 --- a/helfi_platform_config.install +++ b/helfi_platform_config.install @@ -314,5 +314,5 @@ function helfi_platform_config_update_9319() : void { // Remove the chatleijuke block. $config_factory->getEditable('block.block.hdbt_subtheme_chatleijuke')->delete(); - + }