All files / modules/70-pipeline/components/CommonPipelineStages/ApprovalStage ApprovalTypeCards.tsx

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

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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71              1x   1x 1x 1x 1x 1x 1x           1x 20x 20x 2x                                                                       20x                      
/*
 * Copyright 2021 Harness Inc. All rights reserved.
 * Use of this source code is governed by the PolyForm Shield 1.0.0 license
 * that can be found in the licenses directory at the root of this repository, also available at
 * https://polyformproject.org/wp-content/uploads/2020/06/PolyForm-Shield-1.0.0.txt.
 */
 
import React from 'react'
import type { FormikValues } from 'formik'
import { Layout } from '@wings-software/uicore'
import { StepType } from '@pipeline/components/PipelineSteps/PipelineStepInterface'
import { RbacThumbnailItem, RbacThumbnailSelect } from '@rbac/components/RbacThumbnailSelect/RbacThumbnailSelect'
import { FeatureIdentifier } from 'framework/featureStore/FeatureIdentifier'
import { useFeatureFlags } from '@common/hooks/useFeatureFlag'
import css from './ApprovalStageMinimalMode.module.scss'
 
/*
The component to select approval type card in stage
Used in both minimal view as well as detailed view
*/
export function ApprovalTypeCards({ isReadonly }: { formikProps: FormikValues; isReadonly?: boolean }): JSX.Element {
  const { SERVICENOW_NG_INTEGRATION } = useFeatureFlags()
  const approvalTypeCardsData: RbacThumbnailItem[] = React.useMemo(
    () => [
      {
        label: 'Harness Approval',
        value: StepType.HarnessApproval,
        icon: 'nav-harness'
      },
      {
        label: 'Jira',
        value: StepType.JiraApproval,
        icon: 'service-jira',
        featureProps: {
          featureRequest: {
            featureName: FeatureIdentifier.INTEGRATED_APPROVALS_WITH_JIRA
          }
        }
      },
      {
        label: 'ServiceNow',
        value: 'SERVICENOW_APPROVAL',
        icon: 'service-servicenow',
        disabled: SERVICENOW_NG_INTEGRATION ? false : true,
        featureProps: {
          featureRequest: {
            featureName: FeatureIdentifier.INTEGRATED_APPROVALS_WITH_SERVICE_NOW
          }
        }
      },
      {
        label: 'Custom',
        value: 'CUSTOM_APPROVAL',
        icon: 'other-workload',
        disabled: true
      }
    ],
    [SERVICENOW_NG_INTEGRATION]
  )
  return (
    <Layout.Vertical>
      <RbacThumbnailSelect
        name="approvalType"
        items={approvalTypeCardsData}
        className={css.approvalTypesThumbnail}
        isReadonly={isReadonly}
      />
    </Layout.Vertical>
  )
}