Skip to content

Commit

Permalink
Merge pull request #1638 from usdoj/release-7.15.0
Browse files Browse the repository at this point in the history
Release 7.15.0
  • Loading branch information
ameshkin authored Apr 13, 2023
2 parents d1a7d29 + 5da90a1 commit aabf808
Show file tree
Hide file tree
Showing 14 changed files with 2,735 additions and 1,148 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
[![CircleCI](https://circleci.com/gh/usdoj/foia.gov.svg?style=svg)](https://circleci.com/gh/usdoj/foia.gov)

# foia

New FOIA beta site + national portal. The site is based off of
Expand Down
36 changes: 36 additions & 0 deletions bin/xml-dataset-download.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash
start=$SECONDS
set -B
declare -a agencies=(abmc doj achp acus afrh asc ceq cfa cfpb cftc cia cigie cncs co cppbsd cpsc csb csosa dc dfc dhs dnfsb doc dod doe doi dol dos dot eac ed eeoc epa fca fcc fcsic fdic fec ferc ffiec fhfa flra fmc fmcs fmshrc fomc frb frtib ftc gcerc gsa ha hhs hstsf hud iaf imls ipec fpisc jmmff lsc mcc mkuf mmc mspb nara nasa ncd ncpc ncua nea neh nigc nlrb nmb nrc nrpc nsf ntsb nw nwtrb odni oge omb ondcp onhir opm osc oshrc ostp pbgc pc pclob prc pt usrrb sba sec sigar ssa ssab sss stb treasury tva usab usadf usagm usaid usccr usda usibwc usich usip usitc usps ustda ustr va)
agencies+=("exim%20bank")

YEAR=$1
API_KEY=$2

# if there aren't two arguments
if [ $# != 2 ]
then
echo "Please supply the year and api key.\nUSAGE: bash xml-dataset-download.sh <year> <api_key>"
exit;
fi

echo "This script will output a zip file in the public directory: www.foia.gov/$YEAR-FOIASetFull.zip"

for AGENCY in "${agencies[@]}"
do
:
echo -e "Getting XML data for ${AGENCY}... \n"
sleep 1
CLEAN=${AGENCY//%20/-}
FILE=${CLEAN}-${YEAR}'.xml'
curl -H "X-API-Key: $API_KEY" 'https://api.foia.gov/api/annual-report-xml/'$AGENCY'/'$YEAR -o $FILE
done

echo -e "Zipping all XML files for the year ${YEAR}... \n"
sleep 1
zip -r -j ../www.foia.gov/$YEAR-FOIASetFull.zip *.xml
echo -e "Removing all XML files from this directory... \n"
rm -r *.xml
duration=$(( SECONDS - start ))
echo -e "Finished in ${duration} seconds"
echo -e "**********\n"
16 changes: 16 additions & 0 deletions features/ExtLink.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@extlink
Feature: External Link Package

As site visitor
I want to make sure that the external link package is installed and working correctly
So that an icon will appear on external links unless they are on the exclusion list

Background:
Given I am on "/"
And I wait 3 seconds

Scenario: The Hero image credit link has an icon
Then the "the external link script" element should exist
And I should see "_blank" in the "the Hero image credit" element
And I should see an "the justice.gov link" element
And I should not see "svg-icon" in the "the justice.gov link" element
5 changes: 4 additions & 1 deletion features/support/mink.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ const driver = new mink.Mink({
"the View Report button": "button[value='view']",
"the data type dropdown": "select[name='data_type']",
"the Select All Agencies button": ".select-all-agencies > a",
"the Hero image credit": "a[href='https://commons.wikimedia.org/wiki/File:Usdepartmentofjustice.jpg']",
"the justice.gov link": "a[href='http://www.justice.gov']",
"the external link script": "script[src='/assets/js/extlink.min.js']",
}
});

// Avoid timeout issues.
cucumber.setDefaultTimeout(60 * 1000);

driver.hook(cucumber);
driver.hook(cucumber);
17 changes: 11 additions & 6 deletions js/components/foia_request_form.jsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import React from 'react';
import PropTypes from 'prop-types';
import Form from '@rjsf/core';
import validator from '@rjsf/validator-ajv8';
import { Map } from 'immutable';

import CustomFieldTemplate from 'components/request_custom_field_template';
import USWDSRadioWidget from 'components/uswds_radio_widget';
import USWDSCheckboxWidget from 'components/uswds_checkbox_widget';
import { requestActions } from '../actions';
import { SubmissionResult } from '../models';
import ObjectFieldTemplate from './object_field_template';
import CustomObjectFieldTemplate from './object_field_template';
import rf from '../util/request_form';
import FoiaFileWidget from './foia_file_widget';
import { dataUrlToAttachment, findFileFields } from '../util/attachment';
Expand Down Expand Up @@ -70,7 +70,6 @@ function FoiaRequestForm({
.forEach((fileFieldName) => {
payload[fileFieldName] = dataUrlToAttachment(payload[fileFieldName]);
});

// Submit the request
return requestActions
.submitRequestForm(
Expand Down Expand Up @@ -105,20 +104,26 @@ function FoiaRequestForm({
: submissionResult.errors;
const formContext = { steps, errors };
const { jsonSchema, uiSchema } = requestForm;

const templates = {
FieldTemplate: CustomFieldTemplate,
ObjectFieldTemplate: CustomObjectFieldTemplate,
};

return (
<Form
className="foia-request-form sidebar_content-inner"
disabled={upload.get('inProgress')}
FieldTemplate={CustomFieldTemplate}
templates={templates}
formContext={formContext}
formData={formData.toJS()}
ObjectFieldTemplate={ObjectFieldTemplate}
onChange={onChange}
onSubmit={onFormSubmit}
schema={jsonSchema}
uiSchema={uiSchema}
widgets={widgets}
validate={validate}
customValidate={validate}
validator={validator}
onError={onError}
showErrorList={false}
transformErrors={transformErrors}
Expand Down
33 changes: 22 additions & 11 deletions js/components/object_field_template.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
/* eslint-disable */
import React from 'react';
import { getTemplate, getUiOptions } from "@rjsf/utils";

// Would be nice if this template was exported so we could just wrap it without
// having to copy/paste it.
// https://github.com/mozilla-services/react-jsonschema-form/blob/8e9aec57dd2421f37073ec0eac917e0840dde0b3/src/components/fields/ObjectField.js#L10
function ObjectFieldTemplate(props) {
const { TitleField, DescriptionField, formContext = {}} = props;
function CustomObjectFieldTemplate(props) {
const { formContext = {}} = props;
const steps = formContext.steps || [];
const step = steps.indexOf(props.idSchema.$id) + 1;
const uiOptions = getUiOptions(props.uiSchema);
const TitleField = getTemplate(
'TitleFieldTemplate',
props.registry,
uiOptions
);
const DescriptionField = getTemplate(
'DescriptionFieldTemplate',
props.registry,
uiOptions
);

return (
<div>
Expand All @@ -19,17 +31,17 @@ function ObjectFieldTemplate(props) {
<fieldset>
{(props.uiSchema["ui:title"] || props.title) && (
<TitleField
id={`${props.idSchema.$id}__title`}
title={props.title || props.uiSchema["ui:title"]}
required={props.required}
formContext={props.formContext}
id={`${props.idSchema.$id}__title`}
title={props.title || props.uiSchema["ui:title"]}
required={props.required}
formContext={props.formContext}
/>
)}
{props.description && (
<DescriptionField
id={`${props.idSchema.$id}__description`}
description={props.description}
formContext={props.formContext}
id={`${props.idSchema.$id}__description`}
description={props.description}
formContext={props.formContext}
/>
)}
{props.properties.map(prop => prop.content)}
Expand All @@ -41,5 +53,4 @@ function ObjectFieldTemplate(props) {
);
}


export default ObjectFieldTemplate;
export default CustomObjectFieldTemplate;
24 changes: 12 additions & 12 deletions js/components/request_custom_field_template.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,22 @@ function CustomFieldTemplate(props) {
<div className={classes.join(' ')}>
{ displayLabel
&& (
<div>
<label htmlFor={id}>
{label}
<span className="foia-request-form_is-required">{required ? 'Required' : null}</span>
</label>
{description}
</div>
<div>
<label htmlFor={id}>
{label}
<span className="foia-request-form_is-required">{required ? 'Required' : null}</span>
</label>
{description}
</div>
)}
{children}
{ error
&& (
<div
className="usa-input-error-message"
role="alert"
dangerouslySetInnerHTML={{ __html: error }}
/>
<div
className="usa-input-error-message"
role="alert"
dangerouslySetInnerHTML={{ __html: error }}
/>
)}
{help}
</div>
Expand Down
2 changes: 2 additions & 0 deletions js/pages/foia_dataset_download.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ function FoiaDatasetDownload() {
<h1>FOIA Data Set Downloads</h1>
<p>The following compressed files are complete archives of the FOIA Data sets for the years 2008 through 2019.</p>
<ul>
<li><a href="/2022-FOIASetFull.zip">Download the full 2022 FOIA Data set</a> (.zip format)</li>
<li><a href="/2021-FOIASetFull.zip">Download the full 2021 FOIA Data set</a> (.zip format)</li>
<li><a href="/2020-FOIASetFull.zip">Download the full 2020 FOIA Data set</a> (.zip format)</li>
<li><a href="/2019-FOIASetFull.zip">Download the full 2019 FOIA Data set</a> (.zip format)</li>
<li><a href="/2018-FOIASetFull.zip">Download the full 2018 FOIA Data set</a> (.zip format)</li>
Expand Down
Loading

0 comments on commit aabf808

Please sign in to comment.