From b2250877d45bc8871bbeae3afcf48d6f5bd97f47 Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Thu, 24 Apr 2025 14:37:39 +0530 Subject: [PATCH 001/460] chore: upgrade utils to 0.0.43 (#11311) This upgrade includes a fix for the duplicate `CC` and `TO` emails bug - https://github.com/chatwoot/utils/releases/tag/v0.0.43 - https://github.com/chatwoot/utils/pull/50 Fixes https://github.com/chatwoot/chatwoot/issues/11210 Co-authored-by: Muhsin Keloth --- package.json | 2 +- pnpm-lock.yaml | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 18f4b9268..d09360953 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "@breezystack/lamejs": "^1.2.7", "@chatwoot/ninja-keys": "1.2.3", "@chatwoot/prosemirror-schema": "1.1.1-next", - "@chatwoot/utils": "^0.0.42", + "@chatwoot/utils": "^0.0.43", "@formkit/core": "^1.6.7", "@formkit/vue": "^1.6.7", "@hcaptcha/vue3-hcaptcha": "^1.3.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 73799ff19..07d58cbcf 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -23,8 +23,8 @@ importers: specifier: 1.1.1-next version: 1.1.1-next '@chatwoot/utils': - specifier: ^0.0.42 - version: 0.0.42 + specifier: ^0.0.43 + version: 0.0.43 '@formkit/core': specifier: ^1.6.7 version: 1.6.7 @@ -406,8 +406,8 @@ packages: '@chatwoot/prosemirror-schema@1.1.1-next': resolution: {integrity: sha512-/M2qZ+ZF7GlQNt1riwVP499fvp3hxSqd5iy8hxyF9pkj9qQ+OKYn5JK+v3qwwqQY3IxhmNOn1Lp6tm7vstrd9Q==} - '@chatwoot/utils@0.0.42': - resolution: {integrity: sha512-TrEywcG1zjgBScVrQla7GMJwXsbLyc5u/verm/LbLrGxizU2NcNoJecRvJOUgL65kYVEtcO9//+gIDswwqnt6g==} + '@chatwoot/utils@0.0.43': + resolution: {integrity: sha512-kMIXAGebCak9qOi68QnGer+rQLLo/z2N9cR+7tvGdZCW0ThDiVCF7JbHYHVDlYsdDFIx0FLlyIdCfEbooVT2Dw==} engines: {node: '>=10'} '@codemirror/commands@6.7.0': @@ -5255,7 +5255,7 @@ snapshots: prosemirror-utils: 1.2.2(prosemirror-model@1.22.3)(prosemirror-state@1.4.3) prosemirror-view: 1.34.1 - '@chatwoot/utils@0.0.42': + '@chatwoot/utils@0.0.43': dependencies: date-fns: 2.30.0 From 8d92862ba9ac9750f6af67810969817a805c2c38 Mon Sep 17 00:00:00 2001 From: Sojan Jose Date: Thu, 24 Apr 2025 04:24:53 -0700 Subject: [PATCH 002/460] fix: Update pre-commit hook to handle staged deleted files (#11357) The pre-commit hook was failing when there were staged deleted files because: - It was using 'ls' to filter files, which fails when they don't exist in the filesystem - Deleted files are still in Git's staging area but not in the filesystem Changes made: 1. Added a check to filter files with 'test -f' before passing to Rubocop 2. Added the same check for staging Rubocop's changes 3. Added '|| true' to prevent errors when no files match the filters This ensures the pre-commit hook completes successfully even when files are staged for deletion. --- .husky/pre-commit | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.husky/pre-commit b/.husky/pre-commit index adda426ad..b3aceacd6 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -4,8 +4,8 @@ # lint js and vue files npx --no-install lint-staged -# lint only staged ruby files -git diff --name-only --cached | xargs ls -1 2>/dev/null | grep '\.rb$' | xargs bundle exec rubocop --force-exclusion -a +# lint only staged ruby files that still exist (not deleted) +git diff --name-only --cached | xargs -I {} sh -c 'test -f "{}" && echo "{}"' | grep '\.rb$' | xargs -I {} bundle exec rubocop --force-exclusion -a "{}" || true # stage rubocop changes to files -git diff --name-only --cached | xargs git add +git diff --name-only --cached | xargs -I {} sh -c 'test -f "{}" && git add "{}"' || true From 73f768e0bf3998995d380a812c96de396b61305b Mon Sep 17 00:00:00 2001 From: Sivin Varghese <64252451+iamsivin@users.noreply.github.com> Date: Thu, 24 Apr 2025 16:58:05 +0530 Subject: [PATCH 003/460] fix: Handle slug validation errors in Help Center (#11368) # Pull Request Template ## Description This PR fixes an issue with slug validation in the Help Center portal settings. Previously, users were able to create or update slugs with invalid characters such as spaces, slashes, and special symbols, which cause help center to crash. With this update, slug creation and updates are now properly validated. Only slugs that match the allowed pattern will be accepted. No spaces, underscores, slashes, or special characters are allowed. Examples: **user**, **user-guide** --- Fixes https://linear.app/chatwoot/issue/CW-4273/add-validation-for-help-centre-slugs ## Type of change - [x] Bug fix (non-breaking change which fixes an issue) ## How Has This Been Tested? ### Loom video https://www.loom.com/share/a2ca5e2104984f28b29539293ffed33a?sid=e5064cb8-6220-4c43-99da-242c25d32027 ## Checklist: - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my code - [x] I have commented on my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged and published in downstream modules --- .../PortalSettingsPage/PortalBaseSettings.vue | 21 ++++++++++++----- .../PortalSwitcher/CreatePortalDialog.vue | 23 +++++++++++++++---- .../dashboard/i18n/locale/en/helpCenter.json | 3 ++- app/javascript/shared/helpers/Validators.js | 7 ++++++ .../helpers/specs/ValidatorsHelper.spec.js | 22 ++++++++++++++++++ 5 files changed, 64 insertions(+), 12 deletions(-) diff --git a/app/javascript/dashboard/components-next/HelpCenter/Pages/PortalSettingsPage/PortalBaseSettings.vue b/app/javascript/dashboard/components-next/HelpCenter/Pages/PortalSettingsPage/PortalBaseSettings.vue index 5a60fefdc..34f1e003f 100644 --- a/app/javascript/dashboard/components-next/HelpCenter/Pages/PortalSettingsPage/PortalBaseSettings.vue +++ b/app/javascript/dashboard/components-next/HelpCenter/Pages/PortalSettingsPage/PortalBaseSettings.vue @@ -7,8 +7,8 @@ import { useStore, useStoreGetters } from 'dashboard/composables/store'; import { uploadFile } from 'dashboard/helper/uploadHelper'; import { checkFileSizeLimit } from 'shared/helpers/FileHelper'; import { useVuelidate } from '@vuelidate/core'; -import { required, minLength } from '@vuelidate/validators'; -import { shouldBeUrl } from 'shared/helpers/Validators'; +import { required, minLength, helpers } from '@vuelidate/validators'; +import { shouldBeUrl, isValidSlug } from 'shared/helpers/Validators'; import Button from 'dashboard/components-next/button/Button.vue'; import Input from 'dashboard/components-next/input/Input.vue'; @@ -61,7 +61,16 @@ const liveChatWidgets = computed(() => { const rules = { name: { required, minLength: minLength(2) }, - slug: { required }, + slug: { + required: helpers.withMessage( + () => t('HELP_CENTER.CREATE_PORTAL_DIALOG.SLUG.ERROR'), + required + ), + isValidSlug: helpers.withMessage( + () => t('HELP_CENTER.CREATE_PORTAL_DIALOG.SLUG.FORMAT_ERROR'), + isValidSlug + ), + }, homePageLink: { shouldBeUrl }, }; @@ -71,9 +80,9 @@ const nameError = computed(() => v$.value.name.$error ? t('HELP_CENTER.CREATE_PORTAL_DIALOG.NAME.ERROR') : '' ); -const slugError = computed(() => - v$.value.slug.$error ? t('HELP_CENTER.CREATE_PORTAL_DIALOG.SLUG.ERROR') : '' -); +const slugError = computed(() => { + return v$.value.slug.$errors[0]?.$message || ''; +}); const homePageLinkError = computed(() => v$.value.homePageLink.$error diff --git a/app/javascript/dashboard/components-next/HelpCenter/PortalSwitcher/CreatePortalDialog.vue b/app/javascript/dashboard/components-next/HelpCenter/PortalSwitcher/CreatePortalDialog.vue index d245656d0..70c30a241 100644 --- a/app/javascript/dashboard/components-next/HelpCenter/PortalSwitcher/CreatePortalDialog.vue +++ b/app/javascript/dashboard/components-next/HelpCenter/PortalSwitcher/CreatePortalDialog.vue @@ -6,8 +6,9 @@ import { useAlert, useTrack } from 'dashboard/composables'; import { PORTALS_EVENTS } from 'dashboard/helper/AnalyticsHelper/events'; import { convertToCategorySlug } from 'dashboard/helper/commons.js'; import { useVuelidate } from '@vuelidate/core'; -import { required, minLength } from '@vuelidate/validators'; +import { required, minLength, helpers } from '@vuelidate/validators'; import { buildPortalURL } from 'dashboard/helper/portalHelper'; +import { isValidSlug } from 'shared/helpers/Validators'; import Dialog from 'dashboard/components-next/dialog/Dialog.vue'; import Input from 'dashboard/components-next/input/Input.vue'; @@ -31,7 +32,16 @@ const state = reactive({ const rules = { name: { required, minLength: minLength(2) }, - slug: { required }, + slug: { + required: helpers.withMessage( + () => t('HELP_CENTER.CREATE_PORTAL_DIALOG.SLUG.ERROR'), + required + ), + isValidSlug: helpers.withMessage( + () => t('HELP_CENTER.CREATE_PORTAL_DIALOG.SLUG.FORMAT_ERROR'), + isValidSlug + ), + }, }; const v$ = useVuelidate(rules, state); @@ -40,9 +50,9 @@ const nameError = computed(() => v$.value.name.$error ? t('HELP_CENTER.CREATE_PORTAL_DIALOG.NAME.ERROR') : '' ); -const slugError = computed(() => - v$.value.slug.$error ? t('HELP_CENTER.CREATE_PORTAL_DIALOG.SLUG.ERROR') : '' -); +const slugError = computed(() => { + return v$.value.slug.$errors[0]?.$message || ''; +}); const isSubmitDisabled = computed(() => v$.value.$invalid); @@ -131,6 +141,7 @@ defineExpose({ dialogRef }); :message=" nameError || t('HELP_CENTER.CREATE_PORTAL_DIALOG.NAME.MESSAGE') " + @blur="v$.name.$touch()" /> diff --git a/app/javascript/dashboard/i18n/locale/en/helpCenter.json b/app/javascript/dashboard/i18n/locale/en/helpCenter.json index 8fa64108b..f437b83d9 100644 --- a/app/javascript/dashboard/i18n/locale/en/helpCenter.json +++ b/app/javascript/dashboard/i18n/locale/en/helpCenter.json @@ -696,7 +696,8 @@ "SLUG": { "LABEL": "Slug", "PLACEHOLDER": "user-guide", - "ERROR": "Slug is required" + "ERROR": "Slug is required", + "FORMAT_ERROR": "Please enter a valid slug, for eg: user-guide" } }, "PORTAL_SETTINGS": { diff --git a/app/javascript/shared/helpers/Validators.js b/app/javascript/shared/helpers/Validators.js index 6502fef39..1c10121f1 100644 --- a/app/javascript/shared/helpers/Validators.js +++ b/app/javascript/shared/helpers/Validators.js @@ -100,3 +100,10 @@ export const getRegexp = regexPatternValue => { regexPatternValue.slice(lastSlash + 1) ); }; + +/** + * Checks if a string is a valid slug (letters, numbers, hyphens only, no spaces or other symbols). + * @param {string} value - The slug to validate. + * @returns {boolean} True if the slug is valid, false otherwise. + */ +export const isValidSlug = value => /^[a-zA-Z0-9-]+$/.test(value); diff --git a/app/javascript/shared/helpers/specs/ValidatorsHelper.spec.js b/app/javascript/shared/helpers/specs/ValidatorsHelper.spec.js index fc15b772c..4546b43a8 100644 --- a/app/javascript/shared/helpers/specs/ValidatorsHelper.spec.js +++ b/app/javascript/shared/helpers/specs/ValidatorsHelper.spec.js @@ -9,6 +9,7 @@ import { isNumber, isDomain, getRegexp, + isValidSlug, } from '../Validators'; describe('#shouldBeUrl', () => { @@ -153,3 +154,24 @@ describe('#getRegexp', () => { expect(regex.test('12-34-5678')).toBe(false); }); }); + +describe('#isValidSlug', () => { + it('should return true for valid slugs', () => { + expect(isValidSlug('abc')).toEqual(true); + expect(isValidSlug('abc-123')).toEqual(true); + expect(isValidSlug('a-b-c')).toEqual(true); + expect(isValidSlug('123')).toEqual(true); + expect(isValidSlug('abc123-def')).toEqual(true); + }); + it('should return false for invalid slugs', () => { + expect(isValidSlug('abc_def')).toEqual(false); + expect(isValidSlug('abc def')).toEqual(false); + expect(isValidSlug('abc@def')).toEqual(false); + expect(isValidSlug('abc.def')).toEqual(false); + expect(isValidSlug('abc/def')).toEqual(false); + expect(isValidSlug('abc!def')).toEqual(false); + expect(isValidSlug('abc--def!')).toEqual(false); + expect(isValidSlug('abc-def ')).toEqual(false); + expect(isValidSlug(' abc-def')).toEqual(false); + }); +}); From ecc95478b921574969d64a551edab847c2d2ebd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Kube=C5=A1?= <46596180+KubesDavid@users.noreply.github.com> Date: Thu, 24 Apr 2025 13:31:39 +0200 Subject: [PATCH 004/460] feat: widget opened and closed events (#11240) Fixes #9272 --------- Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com> --- app/javascript/sdk/IFrameHelper.js | 8 +++-- app/javascript/sdk/bubbleHelpers.js | 35 ++++++++++++++------ app/javascript/widget/constants/sdkEvents.js | 3 ++ app/views/widget_tests/index.html.erb | 7 ++++ 4 files changed, 40 insertions(+), 13 deletions(-) diff --git a/app/javascript/sdk/IFrameHelper.js b/app/javascript/sdk/IFrameHelper.js index 66e25902b..21b2fb8d4 100644 --- a/app/javascript/sdk/IFrameHelper.js +++ b/app/javascript/sdk/IFrameHelper.js @@ -22,7 +22,11 @@ import { } from './bubbleHelpers'; import { isWidgetColorLighter } from 'shared/helpers/colorHelper'; import { dispatchWindowEvent } from 'shared/helpers/CustomEventHelper'; -import { CHATWOOT_ERROR, CHATWOOT_READY } from '../widget/constants/sdkEvents'; +import { + CHATWOOT_ERROR, + CHATWOOT_POSTBACK, + CHATWOOT_READY, +} from '../widget/constants/sdkEvents'; import { SET_USER_ERROR } from '../widget/constants/errorTypes'; import { getUserCookieName, setCookieWithDomain } from './cookieHelpers'; import { @@ -205,7 +209,7 @@ export const IFrameHelper = { postback(data) { dispatchWindowEvent({ - eventName: 'chatwoot:postback', + eventName: CHATWOOT_POSTBACK, data, }); }, diff --git a/app/javascript/sdk/bubbleHelpers.js b/app/javascript/sdk/bubbleHelpers.js index 609fe04da..05c67f478 100644 --- a/app/javascript/sdk/bubbleHelpers.js +++ b/app/javascript/sdk/bubbleHelpers.js @@ -1,6 +1,11 @@ import { addClasses, removeClasses, toggleClass } from './DOMHelpers'; import { IFrameHelper } from './IFrameHelper'; import { isExpandedView } from './settingsHelper'; +import { + CHATWOOT_CLOSED, + CHATWOOT_OPENED, +} from '../widget/constants/sdkEvents'; +import { dispatchWindowEvent } from 'shared/helpers/CustomEventHelper'; export const bubbleSVG = 'M240.808 240.808H122.123C56.6994 240.808 3.45695 187.562 3.45695 122.122C3.45695 56.7031 56.6994 3.45697 122.124 3.45697C187.566 3.45697 240.808 56.7031 240.808 122.122V240.808Z'; @@ -65,22 +70,30 @@ export const createBubbleHolder = hideMessageBubble => { body.appendChild(bubbleHolder); }; +const handleBubbleToggle = newIsOpen => { + IFrameHelper.events.onBubbleToggle(newIsOpen); + + if (newIsOpen) { + dispatchWindowEvent({ eventName: CHATWOOT_OPENED }); + } else { + dispatchWindowEvent({ eventName: CHATWOOT_CLOSED }); + chatBubble.focus(); + } +}; + export const onBubbleClick = (props = {}) => { const { toggleValue } = props; const { isOpen } = window.$chatwoot; - if (isOpen !== toggleValue) { - const newIsOpen = toggleValue === undefined ? !isOpen : toggleValue; - window.$chatwoot.isOpen = newIsOpen; + if (isOpen === toggleValue) return; - toggleClass(chatBubble, 'woot--hide'); - toggleClass(closeBubble, 'woot--hide'); - toggleClass(widgetHolder, 'woot--hide'); - IFrameHelper.events.onBubbleToggle(newIsOpen); + const newIsOpen = toggleValue === undefined ? !isOpen : toggleValue; + window.$chatwoot.isOpen = newIsOpen; - if (!newIsOpen) { - chatBubble.focus(); - } - } + toggleClass(chatBubble, 'woot--hide'); + toggleClass(closeBubble, 'woot--hide'); + toggleClass(widgetHolder, 'woot--hide'); + + handleBubbleToggle(newIsOpen); }; export const onClickChatBubble = () => { diff --git a/app/javascript/widget/constants/sdkEvents.js b/app/javascript/widget/constants/sdkEvents.js index 766fa1742..305aa16d7 100644 --- a/app/javascript/widget/constants/sdkEvents.js +++ b/app/javascript/widget/constants/sdkEvents.js @@ -1,4 +1,7 @@ export const CHATWOOT_ERROR = 'chatwoot:error'; export const CHATWOOT_ON_MESSAGE = 'chatwoot:on-message'; export const CHATWOOT_ON_START_CONVERSATION = 'chatwoot:on-start-conversation'; +export const CHATWOOT_POSTBACK = 'chatwoot:postback'; export const CHATWOOT_READY = 'chatwoot:ready'; +export const CHATWOOT_OPENED = 'chatwoot:opened'; +export const CHATWOOT_CLOSED = 'chatwoot:closed'; diff --git a/app/views/widget_tests/index.html.erb b/app/views/widget_tests/index.html.erb index 45769bb45..2809b6944 100644 --- a/app/views/widget_tests/index.html.erb +++ b/app/views/widget_tests/index.html.erb @@ -66,6 +66,13 @@ window.addEventListener('chatwoot:postback', function(e) { console.log('chatwoot:postback', e.detail) }) +window.addEventListener('chatwoot:opened', function() { + console.log('chatwoot:opened') +}) + +window.addEventListener('chatwoot:closed', function() { + console.log('chatwoot:closed') +}) window.addEventListener('chatwoot:on-start-conversation', function(e) { console.log('chatwoot:on-start-conversation', e.detail) From 9194984091547bb62376a6bf8e86a897e208d75d Mon Sep 17 00:00:00 2001 From: Sivin Varghese <64252451+iamsivin@users.noreply.github.com> Date: Thu, 24 Apr 2025 21:57:52 +0530 Subject: [PATCH 005/460] fix: Alignment issue with logo in standard type bubble (#11364) --- app/javascript/sdk/sdk.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/javascript/sdk/sdk.js b/app/javascript/sdk/sdk.js index 0a7191812..095fe80ca 100644 --- a/app/javascript/sdk/sdk.js +++ b/app/javascript/sdk/sdk.js @@ -51,6 +51,7 @@ export const SDK_CSS = ` user-select: none; width: 64px; z-index: 2147483000 !important; + overflow: hidden; } .woot-widget-bubble.woot-widget-bubble--flat { @@ -135,6 +136,7 @@ export const SDK_CSS = ` .woot-widget-bubble svg { all: revert; height: 24px; + margin: 20px; width: 24px; } From ef6949e32d474a9d0264f481581a59716d176eb8 Mon Sep 17 00:00:00 2001 From: Sivin Varghese <64252451+iamsivin@users.noreply.github.com> Date: Fri, 25 Apr 2025 10:14:23 +0530 Subject: [PATCH 006/460] fix: Hover issue with Linear issue popup (#11376) --- .../widgets/conversation/linear/Issue.vue | 16 ++++++++-------- .../widgets/conversation/linear/index.vue | 9 ++++++--- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/app/javascript/dashboard/components/widgets/conversation/linear/Issue.vue b/app/javascript/dashboard/components/widgets/conversation/linear/Issue.vue index 2fe46c968..c1d472964 100644 --- a/app/javascript/dashboard/components/widgets/conversation/linear/Issue.vue +++ b/app/javascript/dashboard/components/widgets/conversation/linear/Issue.vue @@ -56,7 +56,7 @@ const unlinkIssue = () => {