feat: complete current GoChat updates

This commit is contained in:
2026-09-13 00:13:55 +08:00
parent 6e62f5094f
commit 0dd188c46f
58 changed files with 2662 additions and 1503 deletions
@@ -7,8 +7,6 @@ import {
} from 'dashboard/helper/permissionsHelper';
import { PREMIUM_FEATURES } from 'dashboard/featureFlags';
import { INSTALLATION_TYPES } from 'dashboard/constants/installationTypes';
export function usePolicy() {
const user = useMapGetter('getCurrentUser');
const isFeatureEnabled = useMapGetter('accounts/isFeatureEnabledonAccount');
@@ -34,35 +32,17 @@ export function usePolicy() {
return hasPermissions(requiredPermissions, userPermissions);
};
const checkInstallationType = config => {
if (Array.isArray(config) && config.length > 0) {
const installationCheck = {
[INSTALLATION_TYPES.ENTERPRISE]: true,
[INSTALLATION_TYPES.CLOUD]: isOnChatwootCloud.value,
[INSTALLATION_TYPES.COMMUNITY]: true,
};
return config.some(type => installationCheck[type]);
}
return true;
};
const isPremiumFeature = featureFlag => {
if (!featureFlag) return true;
return PREMIUM_FEATURES.includes(featureFlag);
};
const shouldShow = (featureFlag, permissions, installationTypes) => {
const shouldShow = (featureFlag, permissions) => {
const flag = unref(featureFlag);
const perms = unref(permissions);
const installation = unref(installationTypes);
// if the user does not have permissions or installation type is not supported
// return false;
// This supersedes everything
// Permissions supersede feature visibility.
if (!checkPermissions(perms)) return false;
if (!checkInstallationType(installation)) return false;
if (isACustomBrandedInstance.value) {
// if this is a custom branded instance, we just use the feature flag as a reference
@@ -76,8 +56,9 @@ export function usePolicy() {
return isFeatureFlagEnabled(flag) || isPremiumFeature(flag);
}
// default to true
return true;
// Premium routes remain visible so their page can render its paywall;
// other routes still honor the account feature flag on self-hosted installs.
return isFeatureFlagEnabled(flag) || isPremiumFeature(flag);
};
const shouldShowPaywall = featureFlag => {
@@ -89,7 +70,7 @@ export function usePolicy() {
return false;
}
if (isPremiumFeature(flag) && isOnChatwootCloud.value) {
if (isPremiumFeature(flag)) {
return !isFeatureFlagEnabled(flag);
}