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 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 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 { Text, Layout, Avatar, Card, ButtonVariation, PageError } from '@wings-software/uicore' import { Color } from '@harness/design-system' import { useParams } from 'react-router-dom' import ReactTimeago from 'react-timeago' import { useStrings } from 'framework/strings' import { useListAggregatedServiceAccounts } from 'services/cd-ng' import { Page } from '@common/exports' import routes from '@common/RouteDefinitions' import TagsRenderer from '@common/components/TagsRenderer/TagsRenderer' import { NGBreadcrumbs } from '@common/components/NGBreadcrumbs/NGBreadcrumbs' import { PageSpinner } from '@common/components' import type { ModulePathParams, ProjectPathProps, ServiceAccountPathProps } from '@common/interfaces/RouteInterfaces' import { useDocumentTitle } from '@common/hooks/useDocumentTitle' import RoleBindingsList from '@rbac/components/RoleBindingsList/RoleBindingsList' import { useRoleAssignmentModal } from '@rbac/modals/RoleAssignmentModal/useRoleAssignmentModal' import ApiKeyList from '@rbac/components/ApiKeyList/ApiKeyList' import RbacButton from '@rbac/components/Button/Button' import { PermissionIdentifier } from '@rbac/interfaces/PermissionIdentifier' import { ResourceType } from '@rbac/interfaces/ResourceType' import { PrincipalType } from '@rbac/utils/utils' import { useLicenseStore, isCDCommunity } from 'framework/LicenseStore/LicenseStoreContext' import css from './ServiceAccountDetails.module.scss' const ServiceAccountDetails: React.FC = () => { const { getString } = useStrings() const { accountId, orgIdentifier, projectIdentifier, module, serviceAccountIdentifier } = useParams< ProjectPathProps & ServiceAccountPathProps & ModulePathParams >() const { licenseInformation } = useLicenseStore() const isCommunity = isCDCommunity(licenseInformation) const { data, loading, error, refetch } = useListAggregatedServiceAccounts({ queryParams: { accountIdentifier: accountId, orgIdentifier, projectIdentifier, identifiers: [serviceAccountIdentifier] }, queryParamStringifyOptions: { arrayFormat: 'repeat' } }) const { openRoleAssignmentModal } = useRoleAssignmentModal({ onSuccess: refetch }) const serviceAccountData = data?.data?.content?.[0] useDocumentTitle([serviceAccountData?.serviceAccount?.name || '', getString('serviceAccount')]) Iif (loading) return <PageSpinner /> Iif (error) return <PageError message={(error.data as Error)?.message || error.message} onClick={() => refetch()} /> Iif (!serviceAccountData) return <PageError onClick={() => refetch()} /> return ( <> <Page.Header size="xlarge" breadcrumbs={ <NGBreadcrumbs links={[ { url: routes.toServiceAccounts({ accountId, orgIdentifier, projectIdentifier, module }), label: `${getString('accessControl')}: ${getString('rbac.serviceAccounts.label')}` } ]} /> } title={ <Layout.Horizontal spacing="medium"> <Avatar name={serviceAccountData.serviceAccount.name} email={serviceAccountData.serviceAccount.email} hoverCard={false} size="medium" /> <Layout.Vertical padding={{ left: 'small' }} spacing="xsmall" className={css.width}> <Layout.Horizontal spacing="medium" flex={{ alignItems: 'center', justifyContent: 'start' }}> <Text color={Color.BLACK} lineClamp={1} font="medium" className={css.wrap}> {serviceAccountData.serviceAccount.name} </Text> <Text icon="main-email" lineClamp={1} className={css.wrap}> {serviceAccountData.serviceAccount.email} </Text> </Layout.Horizontal> <Text lineClamp={1} className={css.wrap}> {serviceAccountData.serviceAccount.description} </Text> <Layout.Horizontal padding={{ top: 'small' }}> <TagsRenderer tags={serviceAccountData.serviceAccount.tags || /* istanbul ignore next */ {}} length={6} /> </Layout.Horizontal> </Layout.Vertical> </Layout.Horizontal> } toolbar={ <Layout.Horizontal flex> <Layout.Vertical spacing="xsmall" padding={{ left: 'small' }}> <Text font={{ size: 'small', weight: 'bold' }} color={Color.BLACK}> {getString('created')} </Text> <Text font="small" color={Color.BLACK}> <ReactTimeago date={serviceAccountData.createdAt || ''} /> </Text> </Layout.Vertical> <Layout.Vertical spacing="xsmall" padding={{ left: 'xlarge' }}> <Text font={{ size: 'small', weight: 'bold' }} color={Color.BLACK}> {getString('common.lastModifiedTime')} </Text> <Text font="small" color={Color.BLACK}> <ReactTimeago date={serviceAccountData.lastModifiedAt || ''} /> </Text> </Layout.Vertical> </Layout.Horizontal> } /> <Page.Body className={css.body}> {!isCommunity && ( <Layout.Vertical spacing="medium" padding={{ bottom: 'large' }}> <Text color={Color.BLACK} font={{ size: 'medium', weight: 'semi-bold' }}> {getString('rbac.roleBinding')} </Text> <Card className={css.card}> <RoleBindingsList data={serviceAccountData.roleAssignmentsMetadataDTO} showNoData={true} /> </Card> <Layout.Horizontal flex={{ alignItems: 'center', justifyContent: 'flex-start' }} padding={{ top: 'medium' }} > <RbacButton data-testid={'addRole-ServiceAccount'} text={getString('common.plusNumber', { number: getString('common.role') })} variation={ButtonVariation.LINK} onClick={event => { event.stopPropagation() openRoleAssignmentModal( PrincipalType.SERVICE, serviceAccountData.serviceAccount, serviceAccountData.roleAssignmentsMetadataDTO ) }} permission={{ permission: PermissionIdentifier.EDIT_SERVICEACCOUNT, resource: { resourceType: ResourceType.SERVICEACCOUNT, resourceIdentifier: serviceAccountData.serviceAccount.identifier } }} /> </Layout.Horizontal> </Layout.Vertical> )} <ApiKeyList /> </Page.Body> </> ) } export default ServiceAccountDetails |