fix: remove enterprise-only restriction from Captain in self-hosted
This commit is contained in:
parent
4e066bbf61
commit
75e3dde312
@ -5,7 +5,6 @@ import { useStore } from 'dashboard/composables/store';
|
|||||||
import Copilot from 'dashboard/components-next/copilot/Copilot.vue';
|
import Copilot from 'dashboard/components-next/copilot/Copilot.vue';
|
||||||
import { useMapGetter } from 'dashboard/composables/store';
|
import { useMapGetter } from 'dashboard/composables/store';
|
||||||
import { useUISettings } from 'dashboard/composables/useUISettings';
|
import { useUISettings } from 'dashboard/composables/useUISettings';
|
||||||
import { useConfig } from 'dashboard/composables/useConfig';
|
|
||||||
import { useWindowSize } from '@vueuse/core';
|
import { useWindowSize } from '@vueuse/core';
|
||||||
import { vOnClickOutside } from '@vueuse/components';
|
import { vOnClickOutside } from '@vueuse/components';
|
||||||
import { FEATURE_FLAGS } from 'dashboard/featureFlags';
|
import { FEATURE_FLAGS } from 'dashboard/featureFlags';
|
||||||
@ -20,7 +19,6 @@ defineProps({
|
|||||||
|
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
const { uiSettings, updateUISettings } = useUISettings();
|
const { uiSettings, updateUISettings } = useUISettings();
|
||||||
const { isEnterprise } = useConfig();
|
|
||||||
const { width: windowWidth } = useWindowSize();
|
const { width: windowWidth } = useWindowSize();
|
||||||
|
|
||||||
const currentUser = useMapGetter('getCurrentUser');
|
const currentUser = useMapGetter('getCurrentUser');
|
||||||
@ -85,9 +83,6 @@ const setAssistant = async assistant => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const shouldShowCopilotPanel = computed(() => {
|
const shouldShowCopilotPanel = computed(() => {
|
||||||
if (!isEnterprise) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
const isCaptainEnabled = isFeatureEnabledonAccount.value(
|
const isCaptainEnabled = isFeatureEnabledonAccount.value(
|
||||||
currentAccountId.value,
|
currentAccountId.value,
|
||||||
FEATURE_FLAGS.CAPTAIN
|
FEATURE_FLAGS.CAPTAIN
|
||||||
@ -123,9 +118,7 @@ const sendMessage = async message => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
if (isEnterprise) {
|
store.dispatch('captainAssistants/get');
|
||||||
store.dispatch('captainAssistants/get');
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@ -3,9 +3,7 @@ import { computed, onMounted } from 'vue';
|
|||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { storeToRefs } from 'pinia';
|
import { storeToRefs } from 'pinia';
|
||||||
import { useAlert } from 'dashboard/composables';
|
import { useAlert } from 'dashboard/composables';
|
||||||
import { useAccount } from 'dashboard/composables/useAccount';
|
|
||||||
import { useCaptain } from 'dashboard/composables/useCaptain';
|
import { useCaptain } from 'dashboard/composables/useCaptain';
|
||||||
import { useConfig } from 'dashboard/composables/useConfig';
|
|
||||||
import { useCaptainConfigStore } from 'dashboard/store/captain/preferences';
|
import { useCaptainConfigStore } from 'dashboard/store/captain/preferences';
|
||||||
|
|
||||||
import SettingsLayout from '../SettingsLayout.vue';
|
import SettingsLayout from '../SettingsLayout.vue';
|
||||||
@ -17,8 +15,6 @@ import CaptainPaywall from 'next/captain/pageComponents/Paywall.vue';
|
|||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const { captainEnabled } = useCaptain();
|
const { captainEnabled } = useCaptain();
|
||||||
const { isEnterprise, enterprisePlanName } = useConfig();
|
|
||||||
const { isOnChatwootCloud } = useAccount();
|
|
||||||
|
|
||||||
const captainConfigStore = useCaptainConfigStore();
|
const captainConfigStore = useCaptainConfigStore();
|
||||||
const { uiFlags } = storeToRefs(captainConfigStore);
|
const { uiFlags } = storeToRefs(captainConfigStore);
|
||||||
@ -59,34 +55,11 @@ const featureToggles = computed(() => [
|
|||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const shouldShowFeature = feature => {
|
const shouldShowFeature = () => {
|
||||||
// Cloud will always see these features as long as captain is enabled
|
|
||||||
if (isOnChatwootCloud.value && captainEnabled) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (feature.enterprise) {
|
|
||||||
// if the app is in enterprise mode, then we can show the feature
|
|
||||||
// this is not the installation plan, but when the enterprise folder is missing
|
|
||||||
return isEnterprise;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
const isFeatureAccessible = feature => {
|
const isFeatureAccessible = () => {
|
||||||
// Cloud will always see these features as long as captain is enabled
|
|
||||||
if (isOnChatwootCloud.value && captainEnabled) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (feature.enterprise) {
|
|
||||||
// plan is shown, but is it accessible?
|
|
||||||
// This ensures that the instance has purchased the enterprise license, and only then we allow
|
|
||||||
// access
|
|
||||||
return isEnterprise && enterprisePlanName === 'enterprise';
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user