All files / modules/75-cf/pages/segment-details/flags-use-segment/flag-item-options-menu-button FlagItemOptionsMenuButton.tsx

100% Statements 16/16
50% Branches 1/2
100% Functions 1/1
100% Lines 16/16

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 503x 3x 3x 3x 3x 3x 3x 3x           3x 4x   4x 4x   4x 4x                   4x                                   3x  
import React, { ReactElement } from 'react'
import usePlanEnforcement from '@cf/hooks/usePlanEnforcement'
import RbacOptionsMenuButton from '@rbac/components/RbacOptionsMenuButton/RbacOptionsMenuButton'
import { PermissionIdentifier } from '@rbac/interfaces/PermissionIdentifier'
import { ResourceType } from '@rbac/interfaces/ResourceType'
import { FeatureIdentifier } from 'framework/featureStore/FeatureIdentifier'
import { useStrings } from 'framework/strings'
import useActiveEnvironment from '@cf/hooks/useActiveEnvironment'
 
export interface FlagItemOptionsMenuButtonProps {
  onClick: () => void
}
 
const FlagItemOptionsMenuButton = (props: FlagItemOptionsMenuButtonProps): ReactElement => {
  const { onClick } = props
 
  const { getString } = useStrings()
  const { activeEnvironment } = useActiveEnvironment()
 
  const { isPlanEnforcementEnabled } = usePlanEnforcement()
  const planEnforcementProps = isPlanEnforcementEnabled
    ? {
        featuresProps: {
          featuresRequest: {
            featureNames: [FeatureIdentifier.MAUS]
          }
        }
      }
    : undefined
 
  return (
    <RbacOptionsMenuButton
      items={[
        {
          text: getString('cf.segmentDetail.removeFomFlag'),
          icon: 'cross',
          permission: {
            resource: { resourceType: ResourceType.ENVIRONMENT, resourceIdentifier: activeEnvironment },
            permission: PermissionIdentifier.EDIT_FF_TARGETGROUP
          },
          onClick: onClick,
          ...planEnforcementProps
        }
      ]}
    />
  )
}
 
export default FlagItemOptionsMenuButton