All files / modules/70-pipeline/components/PipelineStudio/RightDrawer RightDrawerTitle.tsx

100% Statements 11/11
44.44% Branches 8/18
100% Functions 1/1
100% Lines 11/11

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              23x 23x 23x 23x 23x   23x   23x             11x 10x 10x 10x                                                                  
/*
 * Copyright 2022 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 { Button, Icon, Text, ButtonVariation, ButtonSize } from '@wings-software/uicore'
import { FontVariation, Color } from '@harness/design-system'
import { useStrings } from 'framework/strings'
import { usePipelineContext } from '../PipelineContext/PipelineContext'
import type { StepData } from '../../AbstractSteps/AbstractStepFactory'
import css from './RightDrawer.module.scss'
 
export function RightDrawerTitle(props: {
  stepType: string
  toolTipType: string
  stepData: StepData | null | undefined
  discardChanges: () => void
  applyChanges: () => void
}): JSX.Element {
  const { stepsFactory } = usePipelineContext()
  const { stepType, toolTipType, stepData } = props
  const { getString } = useStrings()
  return (
    <div className={css.stepConfig}>
      <div className={css.title}>
        <Icon
          name={stepsFactory.getStepIcon(stepType || '')}
          {...(stepsFactory.getStepIconColor(stepType || '')
            ? { color: stepsFactory.getStepIconColor(stepType || '') }
            : {})}
          style={{ color: stepsFactory.getStepIconColor(stepType || '') }}
          size={24}
        />
        <Text
          lineClamp={1}
          color={Color.BLACK}
          tooltipProps={{ dataTooltipId: `${stepType}_stepName${toolTipType}` }}
          font={{ variation: FontVariation.H4 }}
        >
          {stepData ? stepData?.name : stepsFactory.getStepName(stepType || '')}
        </Text>
      </div>
      <div>
        <Button
          variation={ButtonVariation.SECONDARY}
          size={ButtonSize.SMALL}
          className={css.applyChanges}
          text={getString('applyChanges')}
          onClick={props.applyChanges}
        />
        <Button minimal className={css.discard} text={getString('pipeline.discard')} onClick={props.discardChanges} />
      </div>
    </div>
  )
}