Skip to content

Commit

Permalink
Resolve new merge conflicts (#485)
Browse files Browse the repository at this point in the history
* Bump validator from 13.6.0 to 13.7.0

Bumps [validator](https://github.com/validatorjs/validator.js) from 13.6.0 to 13.7.0.
- [Release notes](https://github.com/validatorjs/validator.js/releases)
- [Changelog](https://github.com/validatorjs/validator.js/blob/master/CHANGELOG.md)
- [Commits](validatorjs/validator.js@13.6.0...13.7.0)

---
updated-dependencies:
- dependency-name: validator
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>

* welcoming robots in certain situations

* Update known vulnerabilities

* trying a different approach in the config

* is this how we set vars?

* fix var name

* test on dev since sandbox does not do what I thought

* update trusworks with modal changes

* need to learn how to do bash

* more bash better

* for christmas sake

* testing complete

* fix bash script var names

* updated file uploader modal

* updated external resource modal

* move logic to circlci config

* awaken robot on prod

* Update .circleci/config.yml

Co-authored-by: Josh Salisbury <[email protected]>

* add approvedat migration

* update approvedAt on approval

* clean up constants, add new one

* add approved and created dates to fe landing page

* add approved and created date to csv download

* remove console statement

* fixing tests

* fixed modal unit tests

* updated my alert test

* fixed modal tests for external resource

* partial fixes for ui tests

* clean up prop type

* cleanup UI tests

* more unit test fixes for trussworks2

* idle modal test fixes

* add backend tests

* fixed accessibility issue and added test coverage

* add target populations to ar

* add approved and created date to ar, table css fixes

* fix failing ui test

* fix failing tooltip test

* unique id value

* update known issues

* fix axe

* Update known vulnerabilities

* fix axe again

* fix axe issues again

* try heading axe fix

* update test for axe

* update

* see if remvoing display none fixes issue

* hide headings

* limit number of headings

* added cusom accordion with heading size prop

* added test for accordion

* fix capitalizations while we're here

* fixes based on Kryss comments

* linter fixes

* audit vuln

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: unknown <[email protected]>
Co-authored-by: Adam Levin <[email protected]>
Co-authored-by: Josh Salisbury <[email protected]>
Co-authored-by: Adam Levin <[email protected]>
  • Loading branch information
6 people authored Nov 15, 2021
1 parent 97a8eae commit 3fbe926
Show file tree
Hide file tree
Showing 20 changed files with 839 additions and 526 deletions.
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"@fortawesome/free-solid-svg-icons": "^5.15.1",
"@fortawesome/react-fontawesome": "^0.1.11",
"@hookform/error-message": "^0.0.5",
"@trussworks/react-uswds": "1.11.0",
"@trussworks/react-uswds": "2.4.1",
"@use-it/interval": "^1.0.0",
"draft-js": "^0.11.7",
"draftjs-to-html": "^0.9.1",
Expand Down
122 changes: 122 additions & 0 deletions frontend/src/components/Accordion.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
import React, { useState } from 'react';
import PropTypes from 'prop-types';

export const AccordionItem = ({
title,
id,
content,
expanded,
className,
handleToggle,
headingSize,
}) => {
const headingClasses = `usa-accordion__heading ${className}`;
const contentClasses = `usa-accordion__content usa-prose ${className}`;
const HeadingSizeTag = `h${headingSize}`;
return (
<>
<HeadingSizeTag className={headingClasses}>
<button
type="button"
className="usa-accordion__button"
aria-expanded={expanded}
aria-controls={id}
data-testid={`accordionButton_${id}`}
onClick={handleToggle}
>
{title}
</button>
</HeadingSizeTag>
<div
id={id}
data-testid={`accordionItem_${id}`}
className={contentClasses}
hidden={!expanded}
>
{content}
</div>
</>
);
};

AccordionItem.propTypes = {
title: PropTypes.string.isRequired,
content: PropTypes.string.isRequired,
expanded: PropTypes.bool.isRequired,
id: PropTypes.string.isRequired,
className: PropTypes.string,
handleToggle: PropTypes.func,
headingSize: PropTypes.number.isRequired,
};

AccordionItem.defaultProps = {
className: '',
handleToggle: () => { },
};

export const Accordion = ({
bordered,
items,
multiselectable,
headingSize,
}) => {
const [openItems, setOpenState] = useState(
items.filter((i) => !!i.expanded).map((i) => i.id),
);

const classes = bordered ? 'usa-accordion usa-accordion--bordered' : 'usa-accordion';

const toggleItem = (itemId) => {
const newOpenItems = [...openItems];
const itemIndex = openItems.indexOf(itemId);
const isMultiselectable = multiselectable;

if (itemIndex > -1) {
newOpenItems.splice(itemIndex, 1);
} else if (isMultiselectable) {
newOpenItems.push(itemId);
} else {
newOpenItems.splice(0, newOpenItems.length);
newOpenItems.push(itemId);
}
setOpenState(newOpenItems);
};

return (
<div
className={classes}
data-testid="accordion"
aria-multiselectable={multiselectable || undefined}
>
{items.map((item) => (
<AccordionItem
key={`accordionItem_${item.id}`}
title={item.title}
id={item.id}
content={item.content}
className={item.className}
expanded={openItems.indexOf(item.id) > -1}
handleToggle={() => {
toggleItem(item.id);
}}
headingSize={headingSize}
/>
))}
</div>
);
};

Accordion.propTypes = {
bordered: PropTypes.bool,
multiselectable: PropTypes.bool,
items: PropTypes.arrayOf(PropTypes.shape(AccordionItem)).isRequired,
headingSize: PropTypes.number,
};

Accordion.defaultProps = {
bordered: false,
multiselectable: false,
headingSize: 2,
};

export default Accordion;
26 changes: 0 additions & 26 deletions frontend/src/components/DeleteReportModal.css

This file was deleted.

67 changes: 0 additions & 67 deletions frontend/src/components/DeleteReportModal.js

This file was deleted.

98 changes: 23 additions & 75 deletions frontend/src/components/ExternalResourceModal.js
Original file line number Diff line number Diff line change
@@ -1,75 +1,18 @@
import React, { useCallback, useEffect, useRef } from 'react';
import React, { useRef } from 'react';
import PropTypes from 'prop-types';
import {
Button, Modal, Alert, useModal, connectModal,
} from '@trussworks/react-uswds';

import { Alert } from '@trussworks/react-uswds';
import Modal from './Modal';
import { isValidURL, isInternalGovernmentLink } from '../utils';

const ESCAPE_KEY_CODE = 27;

const ExternalResourceModal = ({ onOpen, onClose }) => (
<Modal
title={<h3>External Resources Disclaimer</h3>}
actions={(
<>
<Button type="button" onClick={onClose}>
Cancel
</Button>

<Button type="button" secondary onClick={onOpen}>
View External Resource
</Button>
</>
)}
>
<Alert role="alert" type="warning">
<b>Note:</b>
{' '}
This link is hosted outside of an OHS-led system.
OHS does not have responsibility for external content or
the privacy policies of non-government websites.
</Alert>
</Modal>
);

ExternalResourceModal.propTypes = {
onOpen: PropTypes.func.isRequired,
onClose: PropTypes.func.isRequired,
};

const ExternalLink = ({ to, children }) => {
const modalRef = useRef(null);
const { isOpen, openModal, closeModal } = useModal();

const onEscape = useCallback((event) => {
if (event.keyCode === ESCAPE_KEY_CODE) {
closeModal();
}
}, [closeModal]);

useEffect(() => {
document.addEventListener('keydown', onEscape, false);
return () => {
document.removeEventListener('keydown', onEscape, false);
};
}, [onEscape]);

useEffect(() => {
if (!modalRef.current) return;

const button = modalRef.current.querySelector('button');
if (button) {
button.focus();
}
});

if (!isValidURL(to)) {
return to;
}

const onClick = () => {
closeModal();
const openResource = () => {
modalRef.current.toggleModal(false);
window.open(to, '_blank');
};

Expand All @@ -78,19 +21,28 @@ const ExternalLink = ({ to, children }) => {
if (isInternalGovernmentLink(to)) {
window.open(to, '_blank');
} else {
openModal();
modalRef.current.toggleModal(true);
}
};

const ConnectModal = connectModal(() => (
<ExternalResourceModal onOpen={onClick} onClose={closeModal} />
));

return (
<>
<div ref={modalRef} aria-modal="true" role="dialog">
<ConnectModal isOpen={isOpen} onClose={closeModal} />
</div>
<Modal
modalRef={modalRef}
onOk={openResource}
modalId="ExternalResourceModal"
title="External Resources Disclaimer"
okButtonText="View External Resource"
okButtonAriaLabel="This button will redirect you to content that is outside of any OHS-led system."
>
<Alert role="alert" type="warning">
<b>Note:</b>
{' '}
This link is hosted outside of an OHS-led system.
OHS does not have responsibility for external content or
the privacy policies of non-government websites.
</Alert>
</Modal>
<a href={to} onClick={onLinkClick}>
{children}
{' '}
Expand All @@ -103,8 +55,4 @@ ExternalLink.propTypes = {
to: PropTypes.string.isRequired,
children: PropTypes.node.isRequired,
};

export {
ExternalResourceModal,
ExternalLink,
};
export default ExternalLink;
Loading

0 comments on commit 3fbe926

Please sign in to comment.