From 2a90652f05f0a60cf01916ed313f929c6c3b7e0d Mon Sep 17 00:00:00 2001 From: Sojan Jose Date: Tue, 17 Mar 2026 01:45:54 -0700 Subject: [PATCH] feat: Add draft status for help center locales (#13768) This adds a draft status for Help Center locales so teams can prepare localized content in the dashboard without exposing those locales in the public portal switcher until they are ready to publish. Fixes: https://github.com/chatwoot/chatwoot/issues/10412 Closes: https://github.com/chatwoot/chatwoot/issues/10412 ## Why Teams need a way to work on locale-specific Help Center content ahead of launch. The public portal should only show ready locales, while the admin dashboard should continue to expose every allowed locale for ongoing article and category work. ## What this change does - Adds `draft_locales` to portal config as a subset of `allowed_locales` - Hides drafted locales from the public portal language switchers while keeping direct locale URLs working - Keeps drafted locales fully visible in the admin dashboard for article and category management - Adds locale actions to move an existing locale to draft, publish a drafted locale, and keep the default locale protected from drafting - Adds a status dropdown when creating a locale so new locales can be created as `Published` or `Draft` - Returns each admin locale with a `draft` flag so the locale UI can reflect the public visibility state ## Validation - Seed a portal with multiple locales, draft one locale, and confirm the public portal switcher hides it while `/hc/:slug/:locale` still loads directly - In the admin dashboard, confirm drafted locales still appear in the locale list and remain selectable for articles and categories - Create a new locale with `Draft` status and confirm it stays out of the public switcher until published - Move an existing locale back and forth between `Published` and `Draft` and confirm the public switcher updates accordingly ## Demo https://github.com/user-attachments/assets/ba22dc26-c2e7-463a-b1f5-adf1fda1f9be --------- Co-authored-by: Muhsin Keloth --- .../api/v1/accounts/portals_controller.rb | 2 +- .../LocaleCard/LocaleCard.story.vue | 20 ++++++- .../HelpCenter/LocaleCard/LocaleCard.vue | 38 +++++++++++-- .../Pages/LocalePage/AddLocaleDialog.vue | 50 ++++++++++++++++- .../Pages/LocalePage/LocaleList.vue | 48 +++++++++++++++++ .../Pages/LocalePage/LocalesPage.story.vue | 12 +++++ .../dashboard/helper/portalHelper.js | 43 +++++++++++++-- .../helper/specs/portalHelper.spec.js | 41 +++++++++++++- .../dashboard/i18n/locale/en/helpCenter.json | 22 ++++++++ .../pages/PortalsLocalesIndexPage.vue | 1 + app/models/category.rb | 2 +- app/models/portal.rb | 54 ++++++++++++++++++- .../v1/accounts/portals/_portal.json.jbuilder | 2 +- .../v1/models/_portal_config.json.jbuilder | 1 + .../public/api/v1/portals/_header.html.erb | 7 ++- .../api/v1/portals/_mobile_menu.html.erb | 7 ++- .../v1/accounts/portals_controller_spec.rb | 31 +++++++++-- .../public/api/v1/portals_controller_spec.rb | 42 +++++++++++++++ spec/models/portal_spec.rb | 24 +++++++++ 19 files changed, 421 insertions(+), 26 deletions(-) diff --git a/app/controllers/api/v1/accounts/portals_controller.rb b/app/controllers/api/v1/accounts/portals_controller.rb index 8eb24b757..972b244fa 100644 --- a/app/controllers/api/v1/accounts/portals_controller.rb +++ b/app/controllers/api/v1/accounts/portals_controller.rb @@ -79,7 +79,7 @@ class Api::V1::Accounts::PortalsController < Api::V1::Accounts::BaseController def portal_params params.require(:portal).permit( :id, :color, :custom_domain, :header_text, :homepage_link, - :name, :page_title, :slug, :archived, { config: [:default_locale, { allowed_locales: [] }] } + :name, :page_title, :slug, :archived, { config: [:default_locale, { allowed_locales: [] }, { draft_locales: [] }] } ) end diff --git a/app/javascript/dashboard/components-next/HelpCenter/LocaleCard/LocaleCard.story.vue b/app/javascript/dashboard/components-next/HelpCenter/LocaleCard/LocaleCard.story.vue index d51d3dc71..4b00fdb0c 100644 --- a/app/javascript/dashboard/components-next/HelpCenter/LocaleCard/LocaleCard.story.vue +++ b/app/javascript/dashboard/components-next/HelpCenter/LocaleCard/LocaleCard.story.vue @@ -1,8 +1,22 @@ @@ -19,6 +33,8 @@ const locales = [ diff --git a/app/javascript/dashboard/components-next/HelpCenter/LocaleCard/LocaleCard.vue b/app/javascript/dashboard/components-next/HelpCenter/LocaleCard/LocaleCard.vue index 36f90a93f..8619e5b77 100644 --- a/app/javascript/dashboard/components-next/HelpCenter/LocaleCard/LocaleCard.vue +++ b/app/javascript/dashboard/components-next/HelpCenter/LocaleCard/LocaleCard.vue @@ -2,7 +2,7 @@ import { computed } from 'vue'; import { useI18n } from 'vue-i18n'; import { useToggle } from '@vueuse/core'; -import { LOCALE_MENU_ITEMS } from 'dashboard/helper/portalHelper'; +import { buildLocaleMenuItems } from 'dashboard/helper/portalHelper'; import CardLayout from 'dashboard/components-next/CardLayout.vue'; import Button from 'dashboard/components-next/button/Button.vue'; @@ -17,6 +17,10 @@ const props = defineProps({ type: Boolean, required: true, }, + isDraft: { + type: Boolean, + required: true, + }, localeCode: { type: String, required: true, @@ -37,11 +41,28 @@ const { t } = useI18n(); const [showDropdownMenu, toggleDropdown] = useToggle(); +const localeLabel = computed(() => `${props.locale} (${props.localeCode})`); + +const localeMenuLabels = computed(() => ({ + 'change-default': t( + 'HELP_CENTER.LOCALES_PAGE.LOCALE_CARD.DROPDOWN_MENU.MAKE_DEFAULT' + ), + 'move-to-draft': t( + 'HELP_CENTER.LOCALES_PAGE.LOCALE_CARD.DROPDOWN_MENU.MOVE_TO_DRAFT' + ), + 'publish-locale': t( + 'HELP_CENTER.LOCALES_PAGE.LOCALE_CARD.DROPDOWN_MENU.PUBLISH_LOCALE' + ), + delete: t('HELP_CENTER.LOCALES_PAGE.LOCALE_CARD.DROPDOWN_MENU.DELETE'), +})); + const localeMenuItems = computed(() => - LOCALE_MENU_ITEMS.map(item => ({ + buildLocaleMenuItems({ + isDefault: props.isDefault, + isDraft: props.isDraft, + }).map(item => ({ ...item, - label: t(item.label), - disabled: props.isDefault, + label: localeMenuLabels.value[item.action], })) ); @@ -56,7 +77,7 @@ const handleAction = ({ action, value }) => {
- {{ locale }} ({{ localeCode }}) + {{ localeLabel }} { > {{ $t('HELP_CENTER.LOCALES_PAGE.LOCALE_CARD.DEFAULT') }} + + {{ $t('HELP_CENTER.LOCALES_PAGE.LOCALE_CARD.DRAFT') }} +
@@ -86,6 +113,7 @@ const handleAction = ({ action, value }) => {
diff --git a/app/javascript/dashboard/components-next/HelpCenter/Pages/LocalePage/AddLocaleDialog.vue b/app/javascript/dashboard/components-next/HelpCenter/Pages/LocalePage/AddLocaleDialog.vue index 30044a564..5b7573123 100644 --- a/app/javascript/dashboard/components-next/HelpCenter/Pages/LocalePage/AddLocaleDialog.vue +++ b/app/javascript/dashboard/components-next/HelpCenter/Pages/LocalePage/AddLocaleDialog.vue @@ -1,5 +1,5 @@