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 <muhsinkeramam@gmail.com>
139 lines
3.8 KiB
Vue
139 lines
3.8 KiB
Vue
<script setup>
|
|
import { computed } from 'vue';
|
|
import { useI18n } from 'vue-i18n';
|
|
import { useToggle } from '@vueuse/core';
|
|
import { buildLocaleMenuItems } from 'dashboard/helper/portalHelper';
|
|
|
|
import CardLayout from 'dashboard/components-next/CardLayout.vue';
|
|
import Button from 'dashboard/components-next/button/Button.vue';
|
|
import DropdownMenu from 'dashboard/components-next/dropdown-menu/DropdownMenu.vue';
|
|
|
|
const props = defineProps({
|
|
locale: {
|
|
type: String,
|
|
required: true,
|
|
},
|
|
isDefault: {
|
|
type: Boolean,
|
|
required: true,
|
|
},
|
|
isDraft: {
|
|
type: Boolean,
|
|
required: true,
|
|
},
|
|
localeCode: {
|
|
type: String,
|
|
required: true,
|
|
},
|
|
articleCount: {
|
|
type: Number,
|
|
required: true,
|
|
},
|
|
categoryCount: {
|
|
type: Number,
|
|
required: true,
|
|
},
|
|
});
|
|
|
|
const emit = defineEmits(['action']);
|
|
|
|
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(() =>
|
|
buildLocaleMenuItems({
|
|
isDefault: props.isDefault,
|
|
isDraft: props.isDraft,
|
|
}).map(item => ({
|
|
...item,
|
|
label: localeMenuLabels.value[item.action],
|
|
}))
|
|
);
|
|
|
|
const handleAction = ({ action, value }) => {
|
|
emit('action', { action, value });
|
|
toggleDropdown(false);
|
|
};
|
|
</script>
|
|
|
|
<template>
|
|
<CardLayout>
|
|
<div class="flex justify-between gap-2">
|
|
<div class="flex items-center justify-start gap-2">
|
|
<span class="text-sm font-medium text-n-slate-12 line-clamp-1">
|
|
{{ localeLabel }}
|
|
</span>
|
|
<span
|
|
v-if="isDefault"
|
|
class="bg-n-alpha-2 h-6 inline-flex items-center justify-center rounded-md text-xs border-px border-transparent text-n-blue-11 px-2 py-0.5"
|
|
>
|
|
{{ $t('HELP_CENTER.LOCALES_PAGE.LOCALE_CARD.DEFAULT') }}
|
|
</span>
|
|
<span
|
|
v-else-if="isDraft"
|
|
class="bg-n-alpha-2 h-6 inline-flex items-center justify-center rounded-md text-xs border-px border-transparent text-n-slate-11 px-2 py-0.5"
|
|
>
|
|
{{ $t('HELP_CENTER.LOCALES_PAGE.LOCALE_CARD.DRAFT') }}
|
|
</span>
|
|
</div>
|
|
<div class="flex items-center justify-end gap-4">
|
|
<div class="flex items-center gap-4">
|
|
<span class="text-sm text-n-slate-11 whitespace-nowrap">
|
|
{{
|
|
$t(
|
|
'HELP_CENTER.LOCALES_PAGE.LOCALE_CARD.ARTICLES_COUNT',
|
|
articleCount
|
|
)
|
|
}}
|
|
</span>
|
|
<div class="w-px h-3 bg-n-weak" />
|
|
<span class="text-sm text-n-slate-11 whitespace-nowrap">
|
|
{{
|
|
$t(
|
|
'HELP_CENTER.LOCALES_PAGE.LOCALE_CARD.CATEGORIES_COUNT',
|
|
categoryCount
|
|
)
|
|
}}
|
|
</span>
|
|
</div>
|
|
<div
|
|
v-if="localeMenuItems.length"
|
|
v-on-clickaway="() => toggleDropdown(false)"
|
|
class="relative group"
|
|
>
|
|
<Button
|
|
icon="i-lucide-ellipsis-vertical"
|
|
color="slate"
|
|
size="xs"
|
|
class="rounded-md group-hover:bg-n-alpha-2"
|
|
@click="toggleDropdown()"
|
|
/>
|
|
|
|
<DropdownMenu
|
|
v-if="showDropdownMenu"
|
|
:menu-items="localeMenuItems"
|
|
class="ltr:right-0 rtl:left-0 mt-1 xl:ltr:left-0 xl:rtl:right-0 top-full z-60 min-w-[150px]"
|
|
@action="handleAction"
|
|
/>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</CardLayout>
|
|
</template>
|