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 | 207x 207x 207x 207x 207x 207x 207x 207x 207x 207x 207x 207x 207x 795x 795x 795x 795x 795x 795x 795x 211x 795x 795x 207x | /* * 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, { useState } from 'react' import { Button, Text, Card, Icon, Layout } from '@wings-software/uicore' import { useModalHook } from '@harness/use-modal' import { Dialog, IDialogProps } from '@blueprintjs/core' import type { ConnectorInfoDTO } from 'services/cd-ng' import { getConnectorIconByType, getConnectorTitleIdByType } from '@connectors/pages/connectors/utils/ConnectorHelper' import { useStrings } from 'framework/strings' import type { IGitContextFormProps } from '@common/components/GitContextForm/GitContextForm' import { useTelemetry } from '@common/hooks/useTelemetry' import { Category, StageActions } from '@common/constants/TrackingConstants' import useCreateConnectorModal, { ConnectorModaldata, UseCreateConnectorModalProps } from './useCreateConnectorModal' import wizardCss from '../../components/CreateConnectorWizard/CreateConnectorWizard.module.scss' import css from './useCreateConnectorMultiTypeModal.module.scss' export interface UseCreateConnectorMultiTypeModalProps { types: ConnectorInfoDTO['type'][] onSuccess?: UseCreateConnectorModalProps['onSuccess'] onClose?: () => void } export interface UseCreateConnectorMultiTypeModalReturn { openConnectorMultiTypeModal: (connector?: ConnectorModaldata) => void hideConnectorMultiTypeModal: () => void } const modalProps: IDialogProps = { isOpen: true, enforceFocus: false, style: { width: 1175, minHeight: 640, borderLeft: 0, paddingBottom: 0, position: 'relative', overflow: 'hidden', backgroundColor: '#0278D5', padding: '300px 140px 0' } } const useCreateConnectorMultiTypeModal = ( props: UseCreateConnectorMultiTypeModalProps ): UseCreateConnectorMultiTypeModalReturn => { const { getString } = useStrings() const [gitDetails, setGitDetails] = useState<IGitContextFormProps | undefined>() const handleClose = (): void => { props.onClose?.() hideModal() } const { openConnectorModal } = useCreateConnectorModal({ onSuccess: props.onSuccess, onClose: handleClose }) const handleSelect = (type: ConnectorInfoDTO['type']): void => { hideModal() openConnectorModal(false, type, { gitDetails: gitDetails }) trackEvent(StageActions.SelectConnectorType, { category: Category.STAGE, type }) } const { trackEvent } = useTelemetry() React.useEffect(() => { trackEvent(StageActions.LoadSelectConnectorTypeView, { category: Category.STAGE }) // eslint-disable-next-line react-hooks/exhaustive-deps }, []) const [showModal, hideModal] = useModalHook( () => ( <Dialog {...modalProps} className={css.modal}> <Text font={{ size: 'large', weight: 'semi-bold' }} color="white" margin={{ bottom: 'small' }}> Select your Connector type </Text> <Text font={{ size: 'normal', weight: 'semi-bold' }} color="white" margin={{ bottom: 'xxlarge' }}> Start by selecting your connector type </Text> <Layout.Horizontal spacing="medium"> {props.types.map(type => ( <div key={type} className={css.card}> <Card interactive={true} elevation={0} selected={false} onClick={() => handleSelect(type)}> <Icon name={getConnectorIconByType(type)} size={20} /> </Card> <Text color="white" margin={{ top: 'small' }} style={{ textAlign: 'center', width: 90, overflowWrap: 'normal', wordBreak: 'keep-all' }} > {getString(getConnectorTitleIdByType(type))} </Text> </div> ))} </Layout.Horizontal> <Button className={wizardCss.crossIcon} minimal icon="cross" iconProps={{ size: 18 }} onClick={handleClose} /> </Dialog> ), [props.types] ) return { openConnectorMultiTypeModal: (connector?: ConnectorModaldata) => { setGitDetails(connector?.gitDetails) showModal() }, hideConnectorMultiTypeModal: hideModal } } export default useCreateConnectorMultiTypeModal |