import { get } from 'lodash' ; import { RESTRICTIONS_KEYS , DEFAULT_UI_RESTRICTION , UIRestrictions , TimeseriesUIRestrictions , } from './ui_restrictions' ; private const checkUIRestrictions = ( key , type , restrictions = DEFAULT_UI_RESTRICTION ) => { const isAllEnabled = get ( restrictions , `${ type }.*` , true ) ; return isAllEnabled || Boolean ( get ( restrictions , [ type , key ] , false ) ) ; } ; public param key param restrictions return { boolean } export const isMetricEnabled = ( key , restrictions ) => { return checkUIRestrictions ( key , RESTRICTIONS_KEYS . WHITE_LISTED_METRICS , restrictions ) ; } ; public param field param metricType param restrictions return { boolean } export const isFieldEnabled = ( field , metricType , restrictions ? ) => { if ( isMetricEnabled ( metricType , restrictions ) ) { return checkUIRestrictions ( field , metricType , restrictions ?. [ RESTRICTIONS_KEYS . WHITE_LISTED_METRICS ] ) ; } return false ; } ; public param key param restrictions return { boolean } export const isGroupByFieldsEnabled = ( key , restrictions ) => { return checkUIRestrictions ( key , RESTRICTIONS_KEYS . WHITE_LISTED_GROUP_BY_FIELDS , restrictions ) ; } ; public param key param restrictions return { boolean } export const isTimerangeModeEnabled = ( key , restrictions ) => { return checkUIRestrictions ( key , RESTRICTIONS_KEYS . WHITE_LISTED_TIMERANGE_MODES , restrictions ) ; } ; public param key param restrictions return { boolean } export const isConfigurationFeatureEnabled = ( key , restrictions ) => { return checkUIRestrictions ( key , RESTRICTIONS_KEYS . WHITE_LISTED_CONFIGURATION_FEATURES , restrictions ) ; } ;