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 | 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 154x 154x 16x 140x 140x 140x 140x 154x 16x | /* * Copyright 2021 Harness Inc. All rights reserved. * Use of this source code is governed by the PolyForm Free Trial 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/05/PolyForm-Free-Trial-1.0.0.txt. */ import React from 'react' import { isEmpty } from 'lodash-es' import { Tag, Popover, PopoverInteractionKind } from '@blueprintjs/core' import { Layout, Text } from '@wings-software/uicore' import { Color } from '@harness/design-system' import { Link, useParams } from 'react-router-dom' import { useStrings } from 'framework/strings' import type { RoleAssignmentMetadataDTO, RoleBinding } from 'services/cd-ng' import type { PipelineType, ProjectPathProps } from '@common/interfaces/RouteInterfaces' import routes from '@common/RouteDefinitions' import css from './RoleBindingsList.module.scss' interface RoleBindingsListProps { data?: RoleAssignmentMetadataDTO[] | RoleBinding[] length?: number showNoData?: boolean } const RoleBindingTag = ({ roleAssignment }: { roleAssignment: RoleBinding }): React.ReactElement => { const { accountId, orgIdentifier, projectIdentifier, module } = useParams<PipelineType<ProjectPathProps>>() return ( <Tag className={roleAssignment.managedRole ? css.harnesstag : css.customtag} onClick={e => { e.stopPropagation() }} > <Link to={routes.toRoleDetails({ accountId, orgIdentifier, projectIdentifier, module, roleIdentifier: roleAssignment.roleIdentifier })} className={css.link} > {roleAssignment.roleName} </Link> {` - `} <Link to={routes.toResourceGroupDetails({ accountId, orgIdentifier, projectIdentifier, module, resourceGroupIdentifier: roleAssignment.resourceGroupIdentifier })} className={css.link} > {roleAssignment.resourceGroupName} </Link> </Tag> ) } const RoleBindingsList: React.FC<RoleBindingsListProps> = ({ data, length = data?.length, showNoData = false }) => { const baseData = data?.slice(0, length) const popoverData = data?.slice(length, data.length) const { getString } = useStrings() return ( <> {showNoData && isEmpty(baseData) ? ( <Text color={Color.GREY_500}>{getString('rbac.noRoleBinding')}</Text> ) : ( baseData?.map(roleAssignment => ( <RoleBindingTag key={`${roleAssignment.roleIdentifier} ${roleAssignment.resourceGroupIdentifier}`} roleAssignment={roleAssignment} /> )) )} {popoverData?.length ? ( <Popover interactionKind={PopoverInteractionKind.HOVER}> <Layout.Horizontal flex={{ align: 'center-center' }} spacing="xsmall"> <Tag className={css.tag}>{getString('common.plusNumber', { number: popoverData?.length })}</Tag> </Layout.Horizontal> <Layout.Vertical padding="small" spacing="small"> {popoverData?.map(roleAssignment => ( <RoleBindingTag key={`${roleAssignment.roleIdentifier} ${roleAssignment.resourceGroupIdentifier}`} roleAssignment={roleAssignment} /> ))} </Layout.Vertical> </Popover> ) : null} </> ) } export default RoleBindingsList |