-
Notifications
You must be signed in to change notification settings - Fork 359
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add related reports support and display on single report screen
- Loading branch information
Showing
8 changed files
with
167 additions
and
1 deletion.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
client/src/core/client/admin/routes/Reports/RelatedReports.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
.label { | ||
font-size: var(--font-size-1); | ||
text-transform: uppercase; | ||
} | ||
|
||
.button { | ||
background-color: var(--palette-grey-200); | ||
color: var(--palette-grey-500); | ||
text-align: left; | ||
} | ||
|
||
.reportIDLabel { | ||
text-transform: uppercase; | ||
} | ||
|
||
.referenceID { | ||
margin-left: var(--spacing-2); | ||
text-decoration: underline; | ||
} | ||
|
||
.arrowIcon { | ||
margin-left: auto; | ||
} |
85 changes: 85 additions & 0 deletions
85
client/src/core/client/admin/routes/Reports/RelatedReports.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import { Localized } from "@fluent/react/compat"; | ||
import React, { FunctionComponent } from "react"; | ||
import { graphql } from "react-relay"; | ||
|
||
import { withFragmentContainer } from "coral-framework/lib/relay"; | ||
import { ArrowRightIcon, SvgIcon } from "coral-ui/components/icons"; | ||
import { Flex } from "coral-ui/components/v2"; | ||
import { Button } from "coral-ui/components/v3"; | ||
|
||
import { RelatedReports_dsaReport } from "coral-admin/__generated__/RelatedReports_dsaReport.graphql"; | ||
|
||
import styles from "./RelatedReports.css"; | ||
|
||
interface Props { | ||
dsaReport: RelatedReports_dsaReport; | ||
} | ||
|
||
const RelatedReports: FunctionComponent<Props> = ({ dsaReport }) => { | ||
const relatedReports = dsaReport.relatedReports.edges.map( | ||
(edge) => edge.node | ||
); | ||
|
||
if (relatedReports.length === 0) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<Flex direction="column"> | ||
<Localized id="reports-relatedReports-label"> | ||
<div className={styles.label}>Related Reports</div> | ||
</Localized> | ||
{relatedReports.map((report) => { | ||
return ( | ||
<Flex marginTop={2} key={report.id}> | ||
<Button | ||
className={styles.button} | ||
fullWidth | ||
color="none" | ||
variant="flat" | ||
href={`/admin/reports/report/${report.id}`} | ||
> | ||
<Flex> | ||
<Flex> | ||
<Localized id="reports-relatedReports-reportIDLabel"> | ||
<span className={styles.reportIDLabel}>Report ID</span> | ||
</Localized> | ||
<span className={styles.referenceID}> | ||
{report.referenceID} | ||
</span> | ||
</Flex> | ||
<Flex className={styles.arrowIcon}> | ||
<SvgIcon Icon={ArrowRightIcon} /> | ||
</Flex> | ||
</Flex> | ||
</Button> | ||
</Flex> | ||
); | ||
})} | ||
</Flex> | ||
); | ||
}; | ||
|
||
const enhanced = withFragmentContainer<Props>({ | ||
dsaReport: graphql` | ||
fragment RelatedReports_dsaReport on DSAReport | ||
@argumentDefinitions( | ||
count: { type: "Int", defaultValue: 20 } | ||
cursor: { type: "Cursor" } | ||
orderBy: { type: "REPORT_SORT", defaultValue: CREATED_AT_DESC } | ||
) { | ||
id | ||
relatedReports(first: $count, after: $cursor, orderBy: $orderBy) | ||
@connection(key: "RelatedReports_relatedReports") { | ||
edges { | ||
node { | ||
id | ||
referenceID | ||
} | ||
} | ||
} | ||
} | ||
`, | ||
})(RelatedReports); | ||
|
||
export default enhanced; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters