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 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 17x 17x 17x 17x 17x 10x 17x 90x 90x 5x 1x | /* * 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, { useEffect } from 'react' import { ButtonSize, ButtonVariation, Card, Icon, IconName, Layout, Heading } from '@wings-software/uicore' import cx from 'classnames' import { Color } from '@harness/design-system' import { useStrings } from 'framework/strings' import { ComingSoonIcon } from '@common/components/ComingSoonIcon/ComingSoonIcon' import { useTelemetry } from '@common/hooks/useTelemetry' import { StageType } from '@pipeline/utils/stageHelpers' import { FeatureFlag } from '@common/featureFlags' import { useFeatureFlag } from '@common/hooks/useFeatureFlag' import RbacButton from '@rbac/components/Button/Button' import { FeatureIdentifier } from 'framework/featureStore/FeatureIdentifier' import { Category, StageActions } from '@common/constants/TrackingConstants' import { isContextTypeNotStageTemplate } from '@pipeline/components/PipelineStudio/PipelineUtils' import type { PipelineStageProps } from '../PipelineStage' import EmptyStageView from './EmptyStageView' import StageHoverView from './StageHoverView' import css from './AddStageView.module.scss' export interface AddStageViewProps { callback: (type: string) => void stages: Array<PipelineStageProps> isParallel?: boolean contextType?: string onUseTemplate?: () => void } export interface SelectedAddStageTypeData { title?: string description?: string type?: string icon?: IconName hoverIcon?: IconName isComingSoon?: boolean } export function AddStageView({ callback, isParallel = false, stages, contextType, onUseTemplate }: AddStageViewProps): JSX.Element { const isTemplatesEnabled = useFeatureFlag(FeatureFlag.NG_TEMPLATES) const { getString } = useStrings() const { trackEvent } = useTelemetry() const [selectedType, setSelectedType] = React.useState<SelectedAddStageTypeData | undefined>(undefined) useEffect(() => { trackEvent(StageActions.LoadSelectStageTypeView, { category: Category.STAGE }) // eslint-disable-next-line react-hooks/exhaustive-deps }, []) return ( <div className={cx(css.createNewContent, { [css.parallel]: isParallel })}> <div className={css.stageTypeSection}> <Layout.Horizontal className={css.stageTitle} margin={{ bottom: 'large' }}> <Heading level={6} color={Color.GREY_800}> {getString('pipeline.addStage.title')} </Heading> {isContextTypeNotStageTemplate(contextType) && isTemplatesEnabled && ( <RbacButton text={getString('common.useTemplate')} variation={ButtonVariation.SECONDARY} size={ButtonSize.SMALL} icon="template-library" iconProps={{ size: 12 }} onClick={onUseTemplate} featuresProps={{ featuresRequest: { featureNames: [FeatureIdentifier.TEMPLATE_SERVICE] } }} /> )} </Layout.Horizontal> <div className={css.createNewCards}> {stages .filter(stage => stage.type !== StageType.Template) .map(stage => ( <React.Fragment key={stage.type}> {stage.isHidden !== true && (!stage.isApproval || !isParallel) ? ( <div> <Card data-testid={`stage-${stage.type}`} onMouseOver={() => selectedType?.type !== stage.type && setSelectedType(stage)} onMouseLeave={() => setSelectedType(undefined)} interactive={true} disabled={stage.isDisabled} className={cx(css.cardNew)} onClick={e => { if (stage.isDisabled) { e.stopPropagation() } else { // call telemetry trackEvent(StageActions.SelectStage, { stageType: stage.type }) callback(stage.type) } }} > {stage.isComingSoon && ( <ComingSoonIcon className={css.comingSoon} active={selectedType?.type === stage.type} /> )} <Icon name={stage.icon} size={24} {...stage.iconsProps} style={stage.iconsStyle} /> </Card> <div className={cx(css.cardTitle, { [css.selected]: selectedType?.type === stage.type })}> {stage.name} </div> </div> ) : null} </React.Fragment> ))} </div> </div> {selectedType ? <StageHoverView selectedStageType={selectedType} /> : <EmptyStageView />} </div> ) } |