mirror of
				https://github.com/lingble/chatwoot.git
				synced 2025-11-03 20:48:07 +00:00 
			
		
		
		
	# Pull Request Template ## Description ### Issue The Community Edition (CE) dashboard was making API requests to enterprise-only endpoints, causing 404 errors: * `/enterprise/api/v1/accounts/1/limits` * `/api/v1/accounts/1/captain/assistants?page=1` ### Solution 1. Added conditional checks to prevent these calls. 2. Remove unused component `app/javascript/dashboard/components/app/UpgradeBanner.vue` Fixes [CW-4695](https://linear.app/chatwoot/issue/CW-4695/440-ce-dashboard-calls-enterprise-urls), https://github.com/chatwoot/chatwoot/issues/12023 ## Type of change - [x] Bug fix (non-breaking change which fixes an issue) ## Checklist: - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my code - [ ] 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 - [ ] 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 --------- Co-authored-by: Pranav <pranavrajs@gmail.com>
		
			
				
	
	
		
			51 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			51 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
import { computed } from 'vue';
 | 
						|
import { useStore } from 'dashboard/composables/store.js';
 | 
						|
import { useAccount } from 'dashboard/composables/useAccount';
 | 
						|
import { useConfig } from 'dashboard/composables/useConfig';
 | 
						|
import { useCamelCase } from 'dashboard/composables/useTransformKeys';
 | 
						|
import { FEATURE_FLAGS } from 'dashboard/featureFlags';
 | 
						|
 | 
						|
export function useCaptain() {
 | 
						|
  const store = useStore();
 | 
						|
  const { isCloudFeatureEnabled, currentAccount } = useAccount();
 | 
						|
  const { isEnterprise } = useConfig();
 | 
						|
 | 
						|
  const captainEnabled = computed(() => {
 | 
						|
    return isCloudFeatureEnabled(FEATURE_FLAGS.CAPTAIN);
 | 
						|
  });
 | 
						|
 | 
						|
  const captainLimits = computed(() => {
 | 
						|
    return currentAccount.value?.limits?.captain;
 | 
						|
  });
 | 
						|
 | 
						|
  const documentLimits = computed(() => {
 | 
						|
    if (captainLimits.value?.documents) {
 | 
						|
      return useCamelCase(captainLimits.value.documents);
 | 
						|
    }
 | 
						|
 | 
						|
    return null;
 | 
						|
  });
 | 
						|
 | 
						|
  const responseLimits = computed(() => {
 | 
						|
    if (captainLimits.value?.responses) {
 | 
						|
      return useCamelCase(captainLimits.value.responses);
 | 
						|
    }
 | 
						|
 | 
						|
    return null;
 | 
						|
  });
 | 
						|
 | 
						|
  const fetchLimits = () => {
 | 
						|
    if (isEnterprise) {
 | 
						|
      store.dispatch('accounts/limits');
 | 
						|
    }
 | 
						|
  };
 | 
						|
 | 
						|
  return {
 | 
						|
    captainEnabled,
 | 
						|
    captainLimits,
 | 
						|
    documentLimits,
 | 
						|
    responseLimits,
 | 
						|
    fetchLimits,
 | 
						|
  };
 | 
						|
}
 |