Skip to content

Commit

Permalink
[TTAHUB-404] Add target populations to Grantee record page (#480)
Browse files Browse the repository at this point in the history
* add label to input in search form

* create new widget front and back

* ui test

* put it in a grid

* fix ui test

* clean up tests

* radd scopes to goals for grant

* I put the where in the wrong place (oopsie)

* fix test

* Add SES to the diagram

* Add to ignored yarn vulnerabilities

Co-authored-by: unknown <[email protected]>
  • Loading branch information
thewatermethod and kryswisnaskas authored Nov 9, 2021
1 parent d9b8e4d commit 19b8aee
Show file tree
Hide file tree
Showing 15 changed files with 352 additions and 141 deletions.
7 changes: 5 additions & 2 deletions docs/boundary_diagram.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
System Boundary Diagram
=======================

![rendered boundary diagram](http://www.plantuml.com/plantuml/png/dLPHRnit37xFh-3oKAH04sDfNpOCGvtOJJCagvjpsvS2WQoZRIqwIHKfkyRG_pvHELzySJCKVKYiayIF7qNoaruJgyYfiGU_6ATjgX6Mp85-7moYMfyi32_JB156xHsZunFjcu6ger5kPLD8W_DNnnEh77-ulXfOnKYSfsxFlMDb7CQJ8DXis29CfqEe6XKPtgOPp7nojOeRM1bS7qmmadT7eVmuj2_Wy67h1y9uc6U63j3Lnq87_1nu-GZpyFaMfyOLMf_HUZYZxUnXRtgLGNs4peP0kHekfjSPxwnbUQJM90m-LN3XL-VMf_hmEVnx0D3jq3AvyAkyhGnFyhZT0r1jYB6v7NzbGRfLThQx3QnNzV5CMULqOLSS3Q_ECeE-TUVbLWNJWnXEBlzdT_I9osdyySog3KRw4nvCxnT9_9R8u8t453V0KStdHWDXN1cDBVx3cR2V2LUj8zQ65HllkjKkT82k6exMwtKc7dey-cNn2MSm3C4QNU24qz--nh-g5p3-6Y9IJiCDAisoCZ8KCinzmhIt5ZLJ0QmLgnEuJfPDi0Z64SlP4iJad76B7CeUDn_lCBRq7f4gIq_nEalMolS4uzp71cPAtosY70C8PY4dV214hv7e--wrLOsIudbZB09fLNYMj9Qyg6RuKKQNZZ4wPK4zi87izy6az4SAKbEq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PSFgXIFy-pORZoTraDe71cpUlpnAwOBSDtaCEsFZ018mMQ-Im4JZMJSzmxtfv5iWwS-eQ-jTeECy8mLHB1k_06lTqCh8MjA1hgLY24XkZ6KjG0G6T3fj6ljQ6a-3V5V3NYqk8pY8HU5vYM1j24DpouWHTcOV2kglg_Sknz6idlTSMCBFIoneTKuz-B_WkucEzReB_RaIty5j4OlhrL1nXTRdvVT2UI7QA9Sf3ETmz9461mTzUi6rRAY07WoliUk8epOVLrJDNaPVefCKPAUkUs7uOfUdBmxhgZ5OOp683fXHBtXp7thcyCZsddMm6L2KDry68Ls5Co11G-r2Im3NqpNRcNTI_Yz0d8DLsRBwJPx5TDHhGbOqtZWzP_3xC8P5EUj5z4rqbaL9eL50rxXuJUSi1XME04dyA0AyWDebKUo747cAdcQsMIN_jjFFwTdWzXgbfq1g7nwAP7ywIX1l3Sbk9ihylpYNquAr5kTzA154jCkpb9TC7q2PeYzg8hpoylZqGNRcZg_PwBBgtqv7wTaocSMuDBRDZWKeBGEbxS7dPbdx7Uj-vhsl3iFJ-IHJ9BAIbTuo0FOJeO7iQJNSQ6UmPvE0vESR6-atlQU4TKDGQYHRHRk44-B0a3fxO1Rgo1vC9jX_K6lTjkaxz5VCxjNaS7rmQszc7V5st4syJJgpj_m40)

UML Source
----------
Expand All @@ -26,6 +26,7 @@ Boundary(aws, "AWS GovCloud") {
ContainerDb(www_redis, "Redis Database", "AWS Elasticache", "Queue of background jobs to work on")
}
}
Container(email_server, "Amazon Simple Email Server (SES)", "Through Truss", "TTA Hub mail server")
}
System(HSES, "HSES", "Single Sign On\nMFA via Time-Based App or PIV card\n\nSource of Grantee Data")
Boundary(gsa_saas, "FedRAMP-approved SaaS") {
Expand Down Expand Up @@ -57,6 +58,8 @@ Boundary(development_saas, "CI/CD Pipeline") {
Rel(developer, github, "Publish code", "git ssh (22)")
Rel(github, circleci, "Commit hook notifies CircleCI to run CI/CD pipeline")
Rel(circleci, cloudgov_api, "Deploy application on successful CI/CD run")
Rel(www_app, email_server, "Send application notifications")
Rel(email_server, personnel, "Send application notifications")
Lay_D(personnel, aws)
Lay_R(HSES, aws)
@enduml
Expand All @@ -65,7 +68,7 @@ Lay_R(HSES, aws)
Instructions
------------

1. [Edit this diagram with plantuml.com](http://www.plantuml.com/plantuml/uml/dLPHRnit37xFh-3oKAH04sDfNpOCGvtOJJCagvjpsvS2WQoZRIqwIHKfkyRG_pvHELzySJCKVKYiayIF7qNoaruJgyYfiGU_6ATjgX6Mp85-7moYMfyi32_JB156xHsZunFjcu6ger5kPLD8W_DNnnEh77-ulXfOnKYSfsxFlMDb7CQJ8DXis29CfqEe6XKPtgOPp7nojOeRM1bS7qmmadT7eVmuj2_Wy67h1y9uc6U63j3Lnq87_1nu-GZpyFaMfyOLMf_HUZYZxUnXRtgLGNs4peP0kHekfjSPxwnbUQJM90m-LN3XL-VMf_hmEVnx0D3jq3AvyAkyhGnFyhZT0r1jYB6v7NzbGRfLThQx3QnNzV5CMULqOLSS3Q_ECeE-TUVbLWNJWnXEBlzdT_I9osdyySog3KRw4nvCxnT9_9R8u8t453V0KStdHWDXN1cDBVx3cR2V2LUj8zQ65HllkjKkT82k6exMwtKc7dey-cNn2MSm3C4QNU24qz--nh-g5p3-6Y9IJiCDAisoCZ8KCinzmhIt5ZLJ0QmLgnEuJfPDi0Z64SlP4iJad76B7CeUDn_lCBRq7f4gIq_nEalMolS4uzp71cPAtosY70C8PY4dV214hv7e--wrLOsIudbZB09fLNYMj9Qyg6RuKKQNZZ4wPK4zi87izy6az4SAKbEqxsWqArcePyBO4oyYLk-lOAHOpHJXjlXkHfKCMpE2jl_RatPpiqYnyztFuPC-wMKBNhs4MT9to8VTH6b9zX49I2f9mrpEGH4XFns5r9tqvOtyxiKmjeeoajBBClK-OKBmyzq4_UDd1Epl4-LTw-ZRWVnzExZlfAEtrRZAzl9JQ1gti0YLMJXuvpwxwpT3M1a5KzFWyPaYhALIm4UON7u4hMBzEU-gV8gwkB-8oZ5YeRihCGjIjwGKI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pj1Tssf09oCBZ2hYQEmdoONJrr5Nc9Jle88q5ito8VHcdxyZYlMgKL1hFOW2b5apV7ldSchqpFQDUR0wgIXkjWnAem9cG8g7qeIU0Q-cOxzSxhtqNe4v1iErRVpG3HNJKQq9MDDuwFMVmkp26Hhh-ZIpaKaQHVGwE2gd7tOiaYXnIE04hyAG2yWjWaKktKYJt4hcUslKpgQzSxhs-7rsEOcWQjSNZSDBSFvoHuOrX6edJszyMvk1wyjIX3j4IGhaM6lJoN-W3Q16rH6x6LbzUt1qrN7W9LEuEBxe5sr7qx9jCujuQMsR10fGEWz3sul6nJlsEzRzpNjM5OUlya7SaifAHtZ80zXEXWUnjDTniPx1dauCqwniRwJU_zalvHr1g95j6sS0duC2KEnd21hkp1P8Bj1xNAVPskKdz5_Kvj7iS7GsEx-z2EwxpnDk74sluV)
1. Copy and paste the final UML into the UML Source section
1. Update the img src and edit link target to the current values

Expand Down
9 changes: 9 additions & 0 deletions frontend/src/pages/GranteeRecord/pages/TTAHistory.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Helmet } from 'react-helmet';
import { Grid } from '@trussworks/react-uswds';
import Overview from '../../../widgets/DashboardOverview';
import FilterMenu from '../../../components/filter/FilterMenu';
import TargetPopulationsTable from '../../../widgets/TargetPopulationsTable';

function expandFilters(filters) {
const arr = [];
Expand Down Expand Up @@ -60,6 +62,13 @@ export default function TTAHistory({
showTooltips
filters={filtersToApply}
/>
<Grid row>
<Grid desktop={{ col: 5 }} tabletLg={{ col: 12 }}>
<TargetPopulationsTable
filters={filtersToApply}
/>
</Grid>
</Grid>
</div>
</>
);
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/pages/GranteeSearch/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ function GranteeSearch({ user }) {
</div>
)}
<form role="search" className="ttahub-grantee-search--search-form display-flex" onSubmit={onSubmit}>
<input type="search" name="search" className="ttahub-grantee-search--search-input" ref={inputRef} disabled={loading} />
{ /* eslint-disable-next-line jsx-a11y/label-has-associated-control */ }
<label htmlFor="granteeRecordSearch" className="sr-only">Search grantee records by name or grant id</label>
<input id="granteeRecordSearch" type="search" name="search" className="ttahub-grantee-search--search-input" ref={inputRef} disabled={loading} />
<button type="submit" className="ttahub-grantee-search--submit-button usa-button" disabled={loading}>
<FontAwesomeIcon color="white" icon={faSearch} />
{' '}
Expand Down
61 changes: 0 additions & 61 deletions frontend/src/widgets/ReasonList.css
Original file line number Diff line number Diff line change
@@ -1,61 +0,0 @@
.reason-list {
font-family: Source Sans Pro Web, Helvetica Neue, Helvetica, Roboto, Arial,
sans-serif;
height: calc(100% - 1.5rem);
}

.reason-list .usa-table-container--scrollable {
min-height: 393px;
max-height: 393px;
overflow-y: auto;
overflow-x: auto;
}

.reason-list .usa-table {
width: 100%;
height: 100%;
}

.reason-list .usa-table caption {
margin-bottom: 26px;
}

.reason-list .usa-table tr {
background-color: #fff;
border-bottom: 0px;
font-weight: bold;
}

.reason-list .usa-table th {
border-bottom: 0px;
text-align: left;
padding: 0px;
font-weight: bold;
position: sticky;
top: 0;
background-color: white;
}

.reason-list .usa-table th:nth-child(2), .reason-list .usa-table td:nth-child(2) {
padding-left: 60px;
}

.reason-list .usa-table td {
border: none;
padding-top: 10px;
padding-bottom: 0px;
padding-left: 0px;
padding-right: 0px;
text-align: left;
}

.reason-list .usa-table td:first-child {
width: 320px;
white-space: normal;
}

.reason-list .usa-table p:first-child {
margin: 0px;
padding: 0px;
}

71 changes: 27 additions & 44 deletions frontend/src/widgets/ReasonList.js
Original file line number Diff line number Diff line change
@@ -1,53 +1,36 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Table } from '@trussworks/react-uswds';
import withWidgetData from './withWidgetData';
import Container from '../components/Container';
import DateTime from '../components/DateTime';
import './ReasonList.css';
import FormatNumber from './WidgetHelper';
import formatNumber from './WidgetHelper';
import TableWidget from './TableWidget';

function ReasonList({ data, dateTime, loading }) {
const renderReasonList = () => {
if (data && Array.isArray(data) && data.length > 0) {
return data.map((reason) => (
<tr key={`reason_list_row_${reason.name}`}>
<td>
{reason.name}
</td>
<td>
{FormatNumber(reason.count)}
</td>
</tr>
));
}
return null;
};
const renderReasonList = (data) => {
if (data && Array.isArray(data) && data.length > 0) {
return data.map((reason) => (
<tr key={`reason_list_row_${reason.name}`}>
<td>
{reason.name}
</td>
<td>
{formatNumber(reason.count)}
</td>
</tr>
));
}
return null;
};

function ReasonList({ data, dateTime, loading }) {
return (
<Container className="reason-list shadow-2" padding={3} loading={loading} loadingLabel="Reason list loading">
<div className="usa-table-container--scrollable margin-top-0">
<Table className="smart-hub--reason-list-table" fullWidth>
<caption className="smart-hub--reason-list-caption">
<div className="display-flex flex-wrap flex-align-center">
<h2 className="smart-hub--reason-list-heading ttahub--dashboard-widget-heading margin-0">Reasons in Activity Reports</h2>
<DateTime classNames="margin-left-1 padding-x-1" timestamp={dateTime.timestamp} label={dateTime.label} />
</div>
</caption>
<thead>
<tr>
<th scope="col" className="text-left">Reason</th>
<th scope="col" className="text-left"># of Activities</th>
</tr>
</thead>
<tbody>
{
renderReasonList()
}
</tbody>
</Table>
</div>
</Container>
<TableWidget
data={data}
headings={['Reason', '# of Activities']}
dateTime={dateTime}
loading={loading}
loadingLabel="Reason list loading"
title="Reasons in Activity Reports"
renderData={renderReasonList}
/>
);
}

Expand Down
59 changes: 59 additions & 0 deletions frontend/src/widgets/TableWidget.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
.smarthub-table-widget {
height: calc(100% - 1.5rem);
}

.smarthub-table-widget .usa-table-container--scrollable {
min-height: 393px;
max-height: 393px;
overflow-y: auto;
overflow-x: auto;
}

.smarthub-table-widget .usa-table {
width: 100%;
height: 100%;
}

.smarthub-table-widget .usa-table caption {
margin-bottom: 26px;
}

.smarthub-table-widget .usa-table tr {
background-color: #fff;
border-bottom: 0px;
font-weight: bold;
}

.smarthub-table-widget .usa-table th {
border-bottom: 0px;
text-align: left;
padding: 0px;
font-weight: bold;
position: sticky;
top: 0;
background-color: white;
}

.smarthub-table-widget .usa-table th:nth-child(2), .smarthub-table-widget .usa-table td:nth-child(2) {
padding-left: 60px;
}

.smarthub-table-widget .usa-table td {
border: none;
padding-top: 10px;
padding-bottom: 0px;
padding-left: 0px;
padding-right: 0px;
text-align: left;
}

.smarthub-table-widget .usa-table td:first-child {
width: 320px;
white-space: normal;
}

.smarthub-table-widget .usa-table p:first-child {
margin: 0px;
padding: 0px;
}

72 changes: 72 additions & 0 deletions frontend/src/widgets/TableWidget.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Table } from '@trussworks/react-uswds';
import Container from '../components/Container';
import DateTime from '../components/DateTime';
import './TableWidget.css';

export default function TableWidget(
{
data,
headings,
dateTime,
showDateTime,
loading,
loadingLabel,
title,
renderData,
},
) {
return (
<Container className="smarthub-table-widget shadow-2" padding={3} loading={loading} loadingLabel={loadingLabel}>
<div className="usa-table-container--scrollable margin-top-0">
<Table className="smart-hub--table-widget-table" fullWidth>
<caption className="smart-hub--table-widget-caption">
<div className="display-flex flex-wrap flex-align-center">
<h2 className="smart-hub--table-widget-heading ttahub--dashboard-widget-heading margin-0">{title}</h2>
{showDateTime && <DateTime classNames="margin-left-1 padding-x-1" timestamp={dateTime.timestamp} label={dateTime.label} /> }
</div>
</caption>
<thead>
<tr>
{headings.map((heading) => <th key={heading.replace(' ', '_')} scope="col" className="text-left">{heading}</th>)}
</tr>
</thead>
<tbody>
{ renderData(data) }
</tbody>
</Table>
</div>
</Container>
);
}

TableWidget.propTypes = {
data: PropTypes.oneOfType([
PropTypes.arrayOf(
PropTypes.shape({
name: PropTypes.string,
count: PropTypes.number,
}),
), PropTypes.shape({}),
]),
dateTime: PropTypes.shape({
timestamp: PropTypes.string,
label: PropTypes.string,
}),
loading: PropTypes.bool.isRequired,
loadingLabel: PropTypes.string.isRequired,
title: PropTypes.string.isRequired,
headings: PropTypes.arrayOf(PropTypes.string).isRequired,
renderData: PropTypes.func.isRequired,
showDateTime: PropTypes.bool,
};

TableWidget.defaultProps = {
showDateTime: true,
dateTime: {
timestamp: '',
label: '',
},
data: [],
};
Loading

0 comments on commit 19b8aee

Please sign in to comment.