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 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 11x 10x 10x 10x 10x 10x 10x 2x 10x 10x 20x 1x 10x 20x 42x 1x 1x 1x 42x 1x | /*
* 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 { useParams, useHistory } from 'react-router-dom'
import { ExpandingSearchInput, Layout, Container, ButtonVariation } from '@wings-software/uicore'
import { Page } from '@common/exports'
import routes from '@common/RouteDefinitions'
import { OrganizationAggregateDTO, useGetOrganizationAggregateDTOList, Error } from 'services/cd-ng'
import { NGBreadcrumbs } from '@common/components/NGBreadcrumbs/NGBreadcrumbs'
import { useOrganizationModal } from '@projects-orgs/modals/OrganizationModal/useOrganizationModal'
import { OrganizationCard } from '@projects-orgs/components/OrganizationCard/OrganizationCard'
import { useCollaboratorModal } from '@projects-orgs/modals/ProjectModal/useCollaboratorModal'
import { useStrings } from 'framework/strings'
import { useDocumentTitle } from '@common/hooks/useDocumentTitle'
import type { AccountPathProps } from '@common/interfaces/RouteInterfaces'
import { PermissionIdentifier } from '@rbac/interfaces/PermissionIdentifier'
import RbacButton from '@rbac/components/Button/Button'
import { ResourceType } from '@rbac/interfaces/ResourceType'
import { FeatureIdentifier } from 'framework/featureStore/FeatureIdentifier'
import css from './OrganizationsPage.module.scss'
const OrganizationsPage: React.FC = () => {
const { accountId } = useParams<AccountPathProps>()
const [searchParam, setSearchParam] = useState<string>()
const history = useHistory()
const { getString } = useStrings()
useDocumentTitle(getString('orgsText'))
const { loading, data, refetch, error } = useGetOrganizationAggregateDTOList({
queryParams: { accountIdentifier: accountId, searchTerm: searchParam },
debounce: 300
})
const { openOrganizationModal } = useOrganizationModal({
onSuccess: () => refetch()
})
const { openCollaboratorModal } = useCollaboratorModal()
const newOrgButton = (): JSX.Element => (
<RbacButton
variation={ButtonVariation.PRIMARY}
icon="plus"
text={getString('projectsOrgs.newOrganization')}
onClick={() => openOrganizationModal()}
permission={{
permission: PermissionIdentifier.CREATE_ORG,
resource: {
resourceType: ResourceType.ORGANIZATION
}
}}
featuresProps={{
featuresRequest: {
featureNames: [FeatureIdentifier.MULTIPLE_ORGANIZATIONS]
}
}}
/>
)
return (
<>
<Page.Header breadcrumbs={<NGBreadcrumbs />} title={getString('orgsText')} />
<Page.Header
title={<Layout.Horizontal padding="small">{newOrgButton()}</Layout.Horizontal>}
toolbar={
<ExpandingSearchInput
alwaysExpanded
placeholder={getString('projectsOrgs.searchPlaceHolder')}
onChange={text => {
setSearchParam(text.trim())
}}
className={css.search}
width={320}
/>
}
/>
<Page.Body
loading={loading}
error={(error?.data as Error)?.message || error?.message}
retryOnError={() => refetch()}
noData={
!searchParam
? {
when: () => !data?.data?.content?.length,
icon: 'nav-dashboard',
message: getString('projectsOrgs.noDataMessage'),
button: newOrgButton()
}
: {
when: () => !data?.data?.content?.length,
icon: 'nav-dashboard',
message: getString('projectsOrgs.noOrganizations')
}
}
className={css.orgPage}
>
<Container className={css.masonry}>
<Layout.Masonry
center
gutter={20}
items={data?.data?.content || []}
renderItem={(org: OrganizationAggregateDTO) => (
<OrganizationCard
data={org}
editOrg={() => openOrganizationModal(org.organizationResponse.organization)}
inviteCollab={() =>
openCollaboratorModal({ orgIdentifier: org.organizationResponse.organization.identifier })
}
reloadOrgs={() => refetch()}
onClick={() =>
history.push(
routes.toOrganizationDetails({
orgIdentifier: org.organizationResponse.organization.identifier as string,
accountId
})
)
}
/>
)}
keyOf={(org: OrganizationAggregateDTO) => org.organizationResponse.organization.identifier as string}
/>
</Container>
</Page.Body>
</>
)
}
export default OrganizationsPage
|