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 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 6x 5x 5x 5x 5x 5x 5x 5x 5x 2x 5x 5x 5x 5x 5x 5x 5x 9x | /* * 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 { useHistory, useParams } from 'react-router-dom' import { Checkbox, Card, Text, Layout, ButtonVariation, Button, ButtonSize, getErrorInfoFromErrorObject } from '@wings-software/uicore' import { Color, FontVariation } from '@harness/design-system' import { Page } from '@common/exports' import { useStrings } from 'framework/strings' import { NGBreadcrumbs } from '@common/components/NGBreadcrumbs/NGBreadcrumbs' import type { OrgPathProps } from '@common/interfaces/RouteInterfaces' import { useGetSmtpConfig, useDeleteSmtpConfig } from 'services/cd-ng' import useCreateSmtpModal from '@common/components/Smtp/useCreateSmtpModal' import routes from '@common/RouteDefinitions' import { ActivityDetailsRowInterface, RenderDetailsTable } from '../RenderDetailsTable/RenderDetailsTable' import css from './useCreateSmtpModal.module.scss' const SmtpDetails: React.FC = () => { const { getString } = useStrings() const history = useHistory() const { accountId } = useParams<OrgPathProps>() const { loading, data, refetch } = useGetSmtpConfig({ queryParams: { accountId } }) const { loading: deleteProcessing, mutate: deleteSmtp } = useDeleteSmtpConfig({ queryParams: { accountIdentifier: accountId } }) const [errorOnPage, setErrorOnPage] = useState<string>('') const refetchData = (): void => { refetch() } const { openCreateSmtpModal } = useCreateSmtpModal({ onCloseModal: refetchData }) const handleEdit = (): void => { openCreateSmtpModal(data?.data) } const handleDelete = (): void => { if (data?.data?.uuid) { deleteSmtp(data?.data?.uuid, { headers: { 'content-type': 'application/json' } }) .then(val => { if (val.status === 'SUCCESS') { history.push(routes.toAccountResources({ accountId })) } else { setErrorOnPage(getErrorInfoFromErrorObject(val)) } }) .catch(err => { setErrorOnPage(getErrorInfoFromErrorObject(err)) }) } } const getSmtpDetailsRow = (): ActivityDetailsRowInterface[] => { const smtpData = data?.data const emtpyString = ' ' Eif (smtpData) { return [ { label: getString('name'), value: smtpData?.name || emtpyString }, { label: getString('pipelineSteps.hostLabel'), value: smtpData?.value?.host || emtpyString }, { label: getString('common.smtp.port'), value: smtpData?.value?.port || emtpyString }, { label: '', value: ( <> <Checkbox label={getString('common.smtp.enableSSL')} checked={smtpData?.value?.useSSL} /> <Checkbox label={getString('common.smtp.startTSL')} checked={smtpData?.value?.startTLS} /> </> ) }, { label: getString('common.smtp.fromAddress'), value: smtpData?.value?.fromAddress || emtpyString }, { label: getString('username'), value: smtpData?.value?.username || emtpyString }, { label: getString('password'), value: smtpData?.value?.password || emtpyString } ] } return [] } return ( <> <Page.Header title={getString('common.smtp.conifg')} breadcrumbs={ <NGBreadcrumbs links={[ { url: routes.toAccountResources({ accountId }), label: getString('common.accountResources') } ]} /> } /> <Page.Body loading={loading || deleteProcessing} error={errorOnPage} loadingMessage={deleteProcessing ? getString('common.smtp.deleteInProgress') : undefined} > <Card className={css.smtpDetailsCardContainer}> <RenderDetailsTable className={css.smtpDetailsCard} title={ <Layout.Horizontal flex> <Text font={{ variation: FontVariation.H5 }} color={Color.GREY_700}> {getString('overview')} </Text> <Layout.Horizontal spacing={'xsmall'}> <Button icon="trash" text={getString('delete')} onClick={handleDelete} size={ButtonSize.SMALL} disabled={deleteProcessing} variation={ButtonVariation.TERTIARY} /> <Button icon="Edit" text={getString('edit')} onClick={handleEdit} disabled={deleteProcessing} size={ButtonSize.SMALL} variation={ButtonVariation.SECONDARY} /> </Layout.Horizontal> </Layout.Horizontal> } data={getSmtpDetailsRow()} /> </Card> </Page.Body> </> ) } export default SmtpDetails |