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 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 2x 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, Card, Container, ButtonVariation, PageError } from '@wings-software/uicore' import { Color } from '@harness/design-system' import { useParams } from 'react-router-dom' import ReactTimeago from 'react-timeago' import cx from 'classnames' import { useStrings } from 'framework/strings' import { useGetUserGroupAggregate, UserGroupAggregateDTO } 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 RoleBindingsList from '@rbac/components/RoleBindingsList/RoleBindingsList' import type { PipelineType, ProjectPathProps } from '@common/interfaces/RouteInterfaces' import { useRoleAssignmentModal } from '@rbac/modals/RoleAssignmentModal/useRoleAssignmentModal' import { getUserGroupActionTooltipText, PrincipalType } from '@rbac/utils/utils' import { useDocumentTitle } from '@common/hooks/useDocumentTitle' import { useUserGroupModal } from '@rbac/modals/UserGroupModal/useUserGroupModal' import { useLinkToSSOProviderModal } from '@rbac/modals/LinkToSSOProviderModal/useLinkToSSOProviderModal' import MemberList from '@rbac/pages/UserGroupDetails/views/MemberList' import { ResourceType } from '@rbac/interfaces/ResourceType' import ManagePrincipalButton from '@rbac/components/ManagePrincipalButton/ManagePrincipalButton' import NotificationList from '@rbac/components/NotificationList/NotificationList' import { useLicenseStore, isCDCommunity } from 'framework/LicenseStore/LicenseStoreContext' import css from './UserGroupDetails.module.scss' const UserGroupDetails: React.FC = () => { const { getString } = useStrings() const { accountId, orgIdentifier, projectIdentifier, module, userGroupIdentifier } = useParams<PipelineType<ProjectPathProps & { userGroupIdentifier: string }>>() const { licenseInformation } = useLicenseStore() const isCommunity = isCDCommunity(licenseInformation) const { data, loading, error, refetch } = useGetUserGroupAggregate({ identifier: userGroupIdentifier, queryParams: { accountIdentifier: accountId, orgIdentifier, projectIdentifier } }) const { openRoleAssignmentModal } = useRoleAssignmentModal({ onSuccess: refetch }) const { openUserGroupModal } = useUserGroupModal({ onSuccess: refetch }) const { openLinkToSSOProviderModal } = useLinkToSSOProviderModal({ onSuccess: refetch }) const userGroupAggregateResponse: UserGroupAggregateDTO | undefined = data?.data const userGroup = userGroupAggregateResponse?.userGroupDTO useDocumentTitle([userGroup?.name || '', getString('common.userGroups')]) const membersBtnTooltipTextId = userGroup ? getUserGroupActionTooltipText(userGroup) : undefined const membersBtnTooltipText = membersBtnTooltipTextId ? getString(membersBtnTooltipTextId) : undefined Iif (loading) return <PageSpinner /> Iif (error) return <PageError message={(error.data as Error)?.message || error.message} onClick={() => refetch()} /> Iif (!userGroup) return <></> return ( <> <Page.Header size="xlarge" breadcrumbs={ <NGBreadcrumbs links={[ { url: routes.toUserGroups({ accountId, orgIdentifier, projectIdentifier, module }), label: `${getString('accessControl')}: ${getString('common.userGroups')}` } ]} /> } title={ <Layout.Vertical spacing="xsmall"> <Text color={Color.BLACK} font="medium"> {userGroup.name} </Text> {userGroup.description && <Text>{userGroup.description}</Text>} {userGroup.tags && ( <Layout.Horizontal padding={{ top: 'small' }}> <TagsRenderer tags={userGroup.tags || /* istanbul ignore next */ {}} length={6} /> </Layout.Horizontal> )} </Layout.Vertical> } toolbar={ <Layout.Horizontal flex> {userGroupAggregateResponse?.lastModifiedAt && ( <Layout.Vertical spacing="xsmall" padding={{ left: 'small' }}> <Text>{getString('lastUpdated')}</Text> <ReactTimeago date={userGroupAggregateResponse?.lastModifiedAt} /> </Layout.Vertical> )} </Layout.Horizontal> } /> <Page.Body className={css.body}> <Container width="50%" padding={{ bottom: 'large' }} className={css.membersContainer}> <Layout.Horizontal flex> <Layout.Horizontal flex={{ alignItems: 'baseline' }} spacing="medium"> <Text color={Color.BLACK} font={{ size: 'medium', weight: 'semi-bold' }}> {getString('members')} </Text> {userGroup.ssoLinked ? ( <Layout.Horizontal className={css.truncatedText} flex={{ alignItems: 'center' }} spacing="xsmall"> <Text icon={'link'} iconProps={{ color: Color.BLUE_500, size: 10 }} color={Color.BLACK}> {getString('rbac.userDetails.linkToSSOProviderModal.saml')} </Text> <Text lineClamp={1} width={70}> {userGroup.linkedSsoDisplayName} </Text> <Text color={Color.BLACK}>{getString('rbac.userDetails.linkToSSOProviderModal.group')}</Text> <Text lineClamp={1} width={70}> {userGroup.ssoGroupName} </Text> </Layout.Horizontal> ) : null} </Layout.Horizontal> <Layout.Horizontal className={cx({ [css.buttonPadding]: userGroup.ssoLinked })}> <ManagePrincipalButton disabled={userGroup.externallyManaged} text={ userGroup.ssoLinked ? getString('rbac.userDetails.linkToSSOProviderModal.delinkLabel') : getString('rbac.userDetails.linkToSSOProviderModal.linkLabel') } icon={userGroup.ssoLinked ? 'cross' : 'link'} variation={ButtonVariation.LINK} onClick={() => { openLinkToSSOProviderModal(userGroup) }} tooltip={userGroup.externallyManaged ? getString('rbac.unableToEditSCIMMembership') : undefined} resourceType={ResourceType.USERGROUP} resourceIdentifier={userGroupIdentifier} /> <ManagePrincipalButton disabled={userGroup.ssoLinked || userGroup.externallyManaged} tooltip={membersBtnTooltipText} text={getString('common.plusNumber', { number: getString('members') })} variation={ButtonVariation.LINK} onClick={() => { openUserGroupModal(userGroup, true) }} resourceType={ResourceType.USERGROUP} resourceIdentifier={userGroupIdentifier} /> </Layout.Horizontal> </Layout.Horizontal> <MemberList ssoLinked={userGroup.ssoLinked} /> </Container> <Container width="50%" className={css.detailsContainer}> {!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={userGroupAggregateResponse?.roleAssignmentsMetadataDTO} showNoData={true} /> </Card> <Layout.Horizontal flex={{ alignItems: 'center', justifyContent: 'flex-start' }} padding={{ top: 'medium' }} > <ManagePrincipalButton data-testid={'addRole-UserGroup'} text={getString('common.plusNumber', { number: getString('common.role') })} variation={ButtonVariation.LINK} onClick={event => { event.stopPropagation() openRoleAssignmentModal(PrincipalType.USER_GROUP, userGroup, data?.data?.roleAssignmentsMetadataDTO) }} resourceType={ResourceType.USERGROUP} resourceIdentifier={userGroupIdentifier} /> </Layout.Horizontal> </Layout.Vertical> )} <Layout.Vertical spacing="medium"> <Text color={Color.BLACK} font={{ size: 'medium', weight: 'bold' }}> {getString('common.notificationPreferences')} </Text> <NotificationList userGroup={userGroup} onSubmit={refetch} /> </Layout.Vertical> </Container> </Page.Body> </> ) } export default UserGroupDetails |