The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/apps/meteor/client/views/admin/settings/hooks/useHasSettingModule.ts

25 lines
813 B

import type { ISetting, LicenseModule } from '@rocket.chat/core-typings';
import { useLicenseBase } from '@rocket.chat/ui-client';
import { useMemo } from 'react';
export const useHasSettingModule = (setting?: ISetting) => {
const { data } = useLicenseBase({
select: (data) => ({ isEnterprise: Boolean(data?.license.license), activeModules: data?.license.activeModules }),
});
const isEnterprise = data?.isEnterprise ?? false;
const hasSettingModule = useMemo(() => {
if (!setting?.modules || setting?.modules.length === 0) {
return false;
}
return setting.modules.every((module) => data?.activeModules.includes(module as LicenseModule));
}, [data?.activeModules, setting?.modules]);
if (!setting) {
throw new Error('No setting provided');
}
return isEnterprise && hasSettingModule;
};