UNPKG

box-ui-elements

Version:
22 lines (17 loc) 769 B
import { PERMISSION_CAN_DOWNLOAD, PERMISSION_CAN_PREVIEW } from '../../../constants'; export const getAllowedPermissionLevels = ( canChangeAccessLevel, isDownloadSettingAvailable, permission, ): Array<string> => { let allowedPermissionLevels = [PERMISSION_CAN_DOWNLOAD, PERMISSION_CAN_PREVIEW]; if (!canChangeAccessLevel) { // remove all but current level allowedPermissionLevels = allowedPermissionLevels.filter(level => level === permission); } // if we cannot set the download value, we remove this option from the dropdown if (!isDownloadSettingAvailable) { allowedPermissionLevels = allowedPermissionLevels.filter(level => level !== PERMISSION_CAN_DOWNLOAD); } return allowedPermissionLevels; };