From 3bde463ef0226800e6042bc86fc6c4749f18f46b Mon Sep 17 00:00:00 2001 From: Morten Mikalsen Date: Thu, 28 Sep 2023 08:21:05 +0200 Subject: [PATCH 1/6] Adds filter change to the chatbot --- .../footer/chatbot/ChatbotWrapper.tsx | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/komponenter/footer/chatbot/ChatbotWrapper.tsx b/src/komponenter/footer/chatbot/ChatbotWrapper.tsx index 760a51d23..f38c288b1 100644 --- a/src/komponenter/footer/chatbot/ChatbotWrapper.tsx +++ b/src/komponenter/footer/chatbot/ChatbotWrapper.tsx @@ -8,6 +8,8 @@ import { FridaIcon } from './FridaIcon'; import { BoostConfig, BoostObject } from './boost-config'; import style from './ChatbotWrapper.module.scss'; +import { MenuValue } from 'utils/meny-storage-utils'; +import { Locale } from 'store/reducers/language-duck'; const stateSelector = (state: AppState) => ({ chatbotParamEnabled: state.environment.PARAMS.CHATBOT, @@ -15,6 +17,8 @@ const stateSelector = (state: AppState) => ({ featureToggles: state.featureToggles, context: state.arbeidsflate.status, env: state.environment.ENV, + language: state.language.language, + arbeidsflate: state.arbeidsflate.status, }); const conversationCookieName = 'nav-chatbot%3Aconversation'; @@ -23,7 +27,7 @@ const boostApiUrlBaseTest = 'navtest'; const boostApiUrlBaseProduction = 'nav'; export const ChatbotWrapper = () => { - const { chatbotParamEnabled, chatbotParamVisible, env } = useSelector(stateSelector); + const { chatbotParamEnabled, chatbotParamVisible, env, language, arbeidsflate } = useSelector(stateSelector); const [cookies, setCookie, removeCookie] = useCookies([conversationCookieName]); // Do not mount chatbot on initial render. Prevents hydration errors @@ -52,6 +56,13 @@ export const ChatbotWrapper = () => { return; } + const preferredFilter = + arbeidsflate === MenuValue.ARBEIDSGIVER + ? 'arbeidsgiver' + : language === Locale.NYNORSK + ? 'nynorsk' + : 'bokmal'; + const options: BoostConfig = { chatPanel: { settings: { @@ -64,6 +75,11 @@ export const ChatbotWrapper = () => { multiline: true, }, }, + header: { + filters: { + filterValues: preferredFilter, + }, + }, }, }; @@ -116,6 +132,9 @@ export const ChatbotWrapper = () => { domain: isProduction ? '.nav.no' : '.dev.nav.no', }); }); + boost.chatPanel.addEventListener('setFilterValue', function (ev: any) { + boost.chatPanel.setFilterValues(ev.detail.filterValue); + }); if (bufferLoad) { setBufferLoad(false); From 983b2b4a81d86fb2538b30898a0d358249a0561d Mon Sep 17 00:00:00 2001 From: Morten Mikalsen Date: Fri, 29 Sep 2023 09:11:33 +0200 Subject: [PATCH 2/6] Adds google storage csp --- src/csp.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/csp.ts b/src/csp.ts index 285c62d9f..8509df860 100644 --- a/src/csp.ts +++ b/src/csp.ts @@ -14,6 +14,7 @@ const vimeoCdn = '*.vimeocdn.com'; // used for video preview images const hotjarCom = '*.hotjar.com'; const hotjarIo = '*.hotjar.io'; const taskAnalytics = '*.taskanalytics.com'; +const googleStorage = 'https://storage.googleapis.com'; const styleSrc = [ navNo, @@ -51,7 +52,7 @@ const directives: Partial = { cdnNavNo, DATA, // ds-css ], - 'img-src': [navNo, vergicScreenSharing, vimeoCdn, hotjarCom, vergicDotCom], + 'img-src': [navNo, vergicScreenSharing, vimeoCdn, hotjarCom, vergicDotCom, googleStorage], 'frame-src': [hotjarCom, vimeoPlayer, qbrick], 'connect-src': [navNo, boostChatbot, vergicScreenSharing, hotjarCom, hotjarIo, taskAnalytics], }; From d7dd63539403696d03f9bb78f658ee0428a49781 Mon Sep 17 00:00:00 2001 From: Morten Mikalsen Date: Fri, 29 Sep 2023 09:16:30 +0200 Subject: [PATCH 3/6] Fix code smell --- src/komponenter/footer/chatbot/ChatbotWrapper.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/komponenter/footer/chatbot/ChatbotWrapper.tsx b/src/komponenter/footer/chatbot/ChatbotWrapper.tsx index f38c288b1..c8d2b2d71 100644 --- a/src/komponenter/footer/chatbot/ChatbotWrapper.tsx +++ b/src/komponenter/footer/chatbot/ChatbotWrapper.tsx @@ -56,12 +56,12 @@ export const ChatbotWrapper = () => { return; } - const preferredFilter = - arbeidsflate === MenuValue.ARBEIDSGIVER - ? 'arbeidsgiver' - : language === Locale.NYNORSK - ? 'nynorsk' - : 'bokmal'; + let preferredFilter; + if (arbeidsflate === MenuValue.ARBEIDSGIVER) { + preferredFilter = 'arbeidsgiver'; + } else { + preferredFilter = language === Locale.NYNORSK ? 'nynorsk' : 'bokmal'; + } const options: BoostConfig = { chatPanel: { From 41983ad6067e26c1a3c6013b21eebee80d7e9360 Mon Sep 17 00:00:00 2001 From: Morten Mikalsen Date: Fri, 29 Sep 2023 09:35:54 +0200 Subject: [PATCH 4/6] Remove protocol from google storage csp --- src/csp.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/csp.ts b/src/csp.ts index 8509df860..375a0170b 100644 --- a/src/csp.ts +++ b/src/csp.ts @@ -14,7 +14,7 @@ const vimeoCdn = '*.vimeocdn.com'; // used for video preview images const hotjarCom = '*.hotjar.com'; const hotjarIo = '*.hotjar.io'; const taskAnalytics = '*.taskanalytics.com'; -const googleStorage = 'https://storage.googleapis.com'; +const googleStorage = 'storage.googleapis.com'; const styleSrc = [ navNo, From 6803d40be277fd2f01dbfabb871925587db06117 Mon Sep 17 00:00:00 2001 From: Morten Mikalsen Date: Fri, 29 Sep 2023 09:56:50 +0200 Subject: [PATCH 5/6] Remove default filterValues from chatbot --- .../footer/chatbot/ChatbotWrapper.tsx | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/komponenter/footer/chatbot/ChatbotWrapper.tsx b/src/komponenter/footer/chatbot/ChatbotWrapper.tsx index c8d2b2d71..eb1cf7388 100644 --- a/src/komponenter/footer/chatbot/ChatbotWrapper.tsx +++ b/src/komponenter/footer/chatbot/ChatbotWrapper.tsx @@ -56,12 +56,12 @@ export const ChatbotWrapper = () => { return; } - let preferredFilter; - if (arbeidsflate === MenuValue.ARBEIDSGIVER) { - preferredFilter = 'arbeidsgiver'; - } else { - preferredFilter = language === Locale.NYNORSK ? 'nynorsk' : 'bokmal'; - } + // let preferredFilter; + // if (arbeidsflate === MenuValue.ARBEIDSGIVER) { + // preferredFilter = 'arbeidsgiver'; + // } else { + // preferredFilter = language === Locale.NYNORSK ? 'nynorsk' : 'bokmal'; + // } const options: BoostConfig = { chatPanel: { @@ -75,11 +75,6 @@ export const ChatbotWrapper = () => { multiline: true, }, }, - header: { - filters: { - filterValues: preferredFilter, - }, - }, }, }; From 277413b671a4a4efd3cbe4f57f421760a6b4cf78 Mon Sep 17 00:00:00 2001 From: Morten Mikalsen Date: Fri, 29 Sep 2023 09:59:10 +0200 Subject: [PATCH 6/6] Removed everything because of code smells... --- src/komponenter/footer/chatbot/ChatbotWrapper.tsx | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/komponenter/footer/chatbot/ChatbotWrapper.tsx b/src/komponenter/footer/chatbot/ChatbotWrapper.tsx index eb1cf7388..92ca66e1b 100644 --- a/src/komponenter/footer/chatbot/ChatbotWrapper.tsx +++ b/src/komponenter/footer/chatbot/ChatbotWrapper.tsx @@ -8,8 +8,6 @@ import { FridaIcon } from './FridaIcon'; import { BoostConfig, BoostObject } from './boost-config'; import style from './ChatbotWrapper.module.scss'; -import { MenuValue } from 'utils/meny-storage-utils'; -import { Locale } from 'store/reducers/language-duck'; const stateSelector = (state: AppState) => ({ chatbotParamEnabled: state.environment.PARAMS.CHATBOT, @@ -17,8 +15,6 @@ const stateSelector = (state: AppState) => ({ featureToggles: state.featureToggles, context: state.arbeidsflate.status, env: state.environment.ENV, - language: state.language.language, - arbeidsflate: state.arbeidsflate.status, }); const conversationCookieName = 'nav-chatbot%3Aconversation'; @@ -27,7 +23,7 @@ const boostApiUrlBaseTest = 'navtest'; const boostApiUrlBaseProduction = 'nav'; export const ChatbotWrapper = () => { - const { chatbotParamEnabled, chatbotParamVisible, env, language, arbeidsflate } = useSelector(stateSelector); + const { chatbotParamEnabled, chatbotParamVisible, env } = useSelector(stateSelector); const [cookies, setCookie, removeCookie] = useCookies([conversationCookieName]); // Do not mount chatbot on initial render. Prevents hydration errors @@ -56,13 +52,6 @@ export const ChatbotWrapper = () => { return; } - // let preferredFilter; - // if (arbeidsflate === MenuValue.ARBEIDSGIVER) { - // preferredFilter = 'arbeidsgiver'; - // } else { - // preferredFilter = language === Locale.NYNORSK ? 'nynorsk' : 'bokmal'; - // } - const options: BoostConfig = { chatPanel: { settings: {