Skip to content

Commit 0f4ef7a

Browse files
authored
Add domainCount to orgs page (canada-ca#591)
This commit makes use of the new domainCount field that is now available to display the number of domains associated with an organization.
1 parent 113e83e commit 0f4ef7a

5 files changed

Lines changed: 61 additions & 25 deletions

File tree

frontend/schema.faker.graphql

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ type DmarcReportEdge {
402402
}
403403

404404
type Domain implements Node {
405-
organization: Organization
405+
organization: Organizations
406406
dmarcReports(
407407
before: String
408408
after: String
@@ -951,6 +951,15 @@ type OrganizationDetail {
951951
]
952952
)
953953

954+
"""
955+
The number of domains under this organization
956+
"""
957+
domainCount: Int
958+
@fake(
959+
type: number
960+
options: { minNumber: 0, maxNumber: 20, precisionNumber: 1 }
961+
)
962+
954963
"""
955964
The zone which the organization belongs to.
956965
"""
@@ -984,6 +993,14 @@ type OrganizationDetail {
984993

985994
type Organizations implements Node {
986995
"""
996+
The number of domains under this organization
997+
"""
998+
domainCount: Int
999+
@fake(
1000+
type: number
1001+
options: { minNumber: 0, maxNumber: 20, precisionNumber: 1 }
1002+
)
1003+
"""
9871004
The ID of the object.
9881005
"""
9891006
id: ID!
@@ -1012,7 +1029,6 @@ type Organizations implements Node {
10121029
]
10131030
)
10141031

1015-
10161032
"""
10171033
The zone which the organization belongs to.
10181034
"""
@@ -1381,9 +1397,9 @@ type Query {
13811397
Select all information on all organizations that a user has access to.
13821398
"""
13831399
findMyOrganizations(
1384-
before: String,
1385-
after: String,
1386-
first: Int,
1400+
before: String
1401+
after: String
1402+
first: Int
13871403
last: Int
13881404
): OrganizationsConnection
13891405

@@ -1396,19 +1412,20 @@ type Query {
13961412
Select information on an organizations domains, or all domains a user has access to.
13971413
"""
13981414
findDomainsByOrg(
1399-
orgSlug: Slug,
1400-
before: String,
1401-
after: String,
1402-
first: Int, last: Int
1403-
): DomainConnection
1415+
orgSlug: Slug
1416+
before: String
1417+
after: String
1418+
first: Int
1419+
last: Int
1420+
): DomainConnection
14041421

14051422
"""
14061423
Select information on all domains a user has access to.
14071424
"""
14081425
findMyDomains(
1409-
before: String,
1410-
after: String,
1411-
first: Int,
1426+
before: String
1427+
after: String
1428+
first: Int
14121429
last: Int
14131430
): DomainConnection
14141431

@@ -1529,10 +1546,14 @@ enum RoleEnums {
15291546
}
15301547

15311548
enum ScanTypeEnums {
1532-
"""Used for defining if DMARC and DKIM scans should be performed"""
1549+
"""
1550+
Used for defining if DMARC and DKIM scans should be performed
1551+
"""
15331552
MAIL
15341553

1535-
"""Used for defining if HTTPS and SSL scans should be performed"""
1554+
"""
1555+
Used for defining if HTTPS and SSL scans should be performed
1556+
"""
15361557
WEB
15371558
}
15381559

@@ -1796,7 +1817,7 @@ type UserAffClass implements Node {
17961817
"""
17971818
The organization this affiliation belongs to
17981819
"""
1799-
organization: Organization
1820+
organization: Organizations
18001821

18011822
"""
18021823
The ID of the object.
@@ -1949,7 +1970,6 @@ type UserPageAffiliations implements Node {
19491970
organization: Acronym @examples(values: ["GC", "ABC", "ASDF", "NSTIR", "BC"])
19501971
}
19511972

1952-
19531973
type ValidateTwoFactor {
19541974
user: User
19551975
}

frontend/src/Organization.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,27 @@
11
import React from 'react'
2-
import { Link, ListItem, Stack } from '@chakra-ui/core'
2+
import { Trans } from '@lingui/macro'
3+
import { Text, Link, ListItem, Stack } from '@chakra-ui/core'
34
import { Link as RouteLink, useRouteMatch } from 'react-router-dom'
4-
import { string } from 'prop-types'
5-
export function Organization({ name, slug, ...rest }) {
5+
import { string, number } from 'prop-types'
6+
export function Organization({ name, slug, domainCount, ...rest }) {
67
const { path, _url } = useRouteMatch()
78
console.log(`path: ${path}, url: ${_url}`)
89
return (
910
<ListItem {...rest}>
10-
<Stack spacing={4} padding={[1, 2, 3]} direction="row" flexWrap="wrap">
11+
<Stack spacing={4} padding={[1, 2, 3]} flexWrap="wrap">
1112
<Link as={RouteLink} to={`${path}/${slug}`}>
12-
{name}
13+
<Text fontWeight="bold">{name}</Text>
1314
</Link>
15+
<Text>
16+
<Trans>Internet facing services: {domainCount}</Trans>
17+
</Text>
1418
</Stack>
1519
</ListItem>
1620
)
1721
}
1822

19-
Organization.propTypes = { name: string, slug: string }
23+
Organization.propTypes = {
24+
name: string.isRequired,
25+
slug: string.isRequired,
26+
domainCount: number.isRequired,
27+
}

frontend/src/Organizations.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,13 @@ export default function Organisations() {
5757
elements={organizations}
5858
ifEmpty={() => <Trans>No Organizations</Trans>}
5959
>
60-
{({ name, slug }, index) => (
61-
<Organization key={'org' + index} slug={slug} name={name} />
60+
{({ name, slug, domainCount }, index) => (
61+
<Organization
62+
key={'org' + index}
63+
slug={slug}
64+
name={name}
65+
domainCount={domainCount}
66+
/>
6267
)}
6368
</ListOf>
6469
</Stack>

frontend/src/__tests__/Organizations.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@ const mocks = [
2323
node: {
2424
name: 'Fisheries and Oceans Canada',
2525
slug: 'fisheries-and-oceans-canada',
26+
domainCount: 2,
2627
},
2728
},
2829
{
2930
node: {
3031
name: 'Treasury Board of Canada Secretariat',
3132
slug: 'treasury-board-secretariat',
33+
domainCount: 5,
3234
},
3335
},
3436
],

frontend/src/graphql/queries.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export const ORGANIZATIONS = gql`
2626
edges {
2727
node {
2828
name
29+
domainCount
2930
slug
3031
}
3132
}

0 commit comments

Comments
 (0)