mirror of
				https://github.com/lingble/chatwoot.git
				synced 2025-10-31 02:57:57 +00:00 
			
		
		
		
	 6d3ecfe3c1
			
		
	
	6d3ecfe3c1
	
	
	
		
			
			This PR has the initial version of the new sidebar targeted for the next major redesign of the app. This PR includes the following changes - Components in the `layouts-next` and `base-next` directories in `dashboard/components` - Two generic components `Avatar` and `Icon` - `SidebarGroup` component to manage expandable sidebar groups with nested navigation items. This includes handling active states, transitions, and permissions. - `SidebarGroupHeader` component to display the header of each navigation group with optional icons and active state indication. - `SidebarGroupLeaf` component for individual navigation items within a group, supporting icons and active state. - `SidebarGroupSeparator` component to visually separate nested navigation items. (They look a lot like header) - `SidebarGroupEmptyLeaf` component to render empty state of any navigation groups. ---- Co-authored-by: Pranav <pranav@chatwoot.com> Co-authored-by: Pranav <pranavrajs@gmail.com>
		
			
				
	
	
		
			30 lines
		
	
	
		
			990 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			30 lines
		
	
	
		
			990 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| import { useMapGetter } from 'dashboard/composables/store';
 | |
| import { useAccount } from 'dashboard/composables/useAccount';
 | |
| import {
 | |
|   getUserPermissions,
 | |
|   hasPermissions,
 | |
| } from 'dashboard/helper/permissionsHelper';
 | |
| 
 | |
| export function usePolicy() {
 | |
|   const user = useMapGetter('getCurrentUser');
 | |
|   const isFeatureEnabled = useMapGetter('accounts/isFeatureEnabledonAccount');
 | |
|   const { accountId } = useAccount();
 | |
| 
 | |
|   const getUserPermissionsForAccount = () => {
 | |
|     return getUserPermissions(user.value, accountId.value);
 | |
|   };
 | |
| 
 | |
|   const checkFeatureAllowed = featureFlag => {
 | |
|     if (!featureFlag) return true;
 | |
|     return isFeatureEnabled.value(accountId.value, featureFlag);
 | |
|   };
 | |
| 
 | |
|   const checkPermissions = requiredPermissions => {
 | |
|     if (!requiredPermissions || !requiredPermissions.length) return true;
 | |
|     const userPermissions = getUserPermissionsForAccount();
 | |
|     return hasPermissions(requiredPermissions, userPermissions);
 | |
|   };
 | |
| 
 | |
|   return { checkFeatureAllowed, checkPermissions };
 | |
| }
 |