-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MR-3573: Download all contracts button does not generate zip file on first click #1859
Merged
JasonLin0991
merged 11 commits into
main
from
jl-3573-Download-all-contracts-button-does-not-generate-zip-file-on-first-click
Aug 16, 2023
Merged
Changes from 9 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
cb9fbe7
Log out the bulk url errors.
JasonLin0991 c76934b
Inline warning component for documents.
JasonLin0991 873d82d
Display inline document warning.
JasonLin0991 220e2ad
Fix action button flickering and size change when loading.
JasonLin0991 b63f2d8
Update download button to use ActionButton component with loading state.
JasonLin0991 64dfa90
Remove unused download button scss.
JasonLin0991 b542daa
Document warning banner.
JasonLin0991 d25b3dd
Show warning messages on bulk download URL error and skip zipping doc…
JasonLin0991 394d528
Remove duplicate test
JasonLin0991 71e22db
Move renderDownloadButton.
JasonLin0991 661665a
Change download button back to link. Update tests.
JasonLin0991 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
33 changes: 33 additions & 0 deletions
33
services/app-web/src/components/Banner/DocumentWarningBanner/DocumentWarningBanner.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,33 @@ | ||
import React from 'react' | ||
import styles from '../Banner.module.scss' | ||
import { Alert } from '@trussworks/react-uswds' | ||
import { useStringConstants } from '../../../hooks/useStringConstants' | ||
import classnames from 'classnames' | ||
|
||
export const DocumentWarningBanner = (): React.ReactElement => { | ||
const stringConstants = useStringConstants() | ||
const MAIL_TO_SUPPORT = stringConstants.MAIL_TO_SUPPORT | ||
return ( | ||
<Alert | ||
role="alert" | ||
type="warning" | ||
heading={`Document download unavailable`} | ||
headingLevel="h4" | ||
data-testid="warning-alert" | ||
className={classnames(styles.bannerBodyText, 'usa-alert__text')} | ||
> | ||
<span> | ||
Some documents aren’t available right now. Refresh the page to | ||
try again. If you still see this message, | ||
</span> | ||
<a | ||
href={`mailto: ${MAIL_TO_SUPPORT}, mc-review-team@truss.works`} | ||
className="usa-link" | ||
target="_blank" | ||
rel="noreferrer" | ||
> | ||
email the help desk. | ||
</a> | ||
</Alert> | ||
) | ||
} |
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
8 changes: 8 additions & 0 deletions
8
...eb/src/components/DocumentWarning/InlineDocumentWarning/InlineDocumentWarning.module.scss
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,8 @@ | ||
@import '../../../styles/uswdsImports.scss'; | ||
@import '../../../styles/custom.scss'; | ||
|
||
.missingInfo { | ||
color: $theme-color-warning-darker; | ||
font-weight: 700; | ||
display: flex; | ||
} |
34 changes: 34 additions & 0 deletions
34
...es/app-web/src/components/DocumentWarning/InlineDocumentWarning/InlineDocumentWarning.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,34 @@ | ||
import { Icon as UswdsIcon } from '@trussworks/react-uswds' | ||
import styles from './InlineDocumentWarning.module.scss' | ||
|
||
interface USWDSIconProps { | ||
focusable?: boolean | ||
role?: string | ||
size?: 3 | 4 | 5 | 6 | 7 | 8 | 9 | ||
className?: string | ||
} | ||
|
||
type IconProps = USWDSIconProps & React.JSX.IntrinsicElements['svg'] | ||
|
||
type IconType = keyof typeof UswdsIcon | ||
export const InlineDocumentWarning = ({ | ||
message, | ||
iconType, | ||
}: { | ||
message?: string | ||
iconType?: IconType | ||
}): React.ReactElement | null => { | ||
const requiredFieldMissingText = | ||
message || 'Document download is unavailable' | ||
const type = iconType || 'Warning' | ||
const Icon = UswdsIcon[type] as React.ComponentType<IconProps> | ||
|
||
return ( | ||
<span className={styles.missingInfo}> | ||
<span> | ||
<Icon aria-label={`An ${type} icon`} size={3} /> | ||
</span> | ||
<span>{requiredFieldMissingText}</span> | ||
</span> | ||
) | ||
} |
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 @@ | ||
export { InlineDocumentWarning } from './InlineDocumentWarning/InlineDocumentWarning' |
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
27 changes: 15 additions & 12 deletions
27
services/app-web/src/components/DownloadButton/DownloadButton.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 |
---|---|---|
@@ -1,25 +1,28 @@ | ||
import React from 'react' | ||
import { Link } from '@trussworks/react-uswds' | ||
import { ActionButton } from '../ActionButton' | ||
|
||
type DownloadButtonProps = { | ||
text: string | ||
zippedFilesURL: string | ||
zippedFilesURL: string | undefined | ||
} | ||
|
||
export const DownloadButton = ({ | ||
text, | ||
zippedFilesURL, | ||
}: DownloadButtonProps): React.ReactElement => { | ||
const handleClick = () => { | ||
if (zippedFilesURL) { | ||
window.open(zippedFilesURL) | ||
} | ||
} | ||
|
||
return ( | ||
<div> | ||
<Link | ||
className="usa-button usa-button--small" | ||
variant="unstyled" | ||
href={zippedFilesURL} | ||
target="_blank" | ||
> | ||
{text} | ||
</Link> | ||
</div> | ||
<ActionButton | ||
onClick={handleClick} | ||
loading={zippedFilesURL === undefined} | ||
type="button" | ||
children={text} | ||
animationTimeout={0} | ||
/> | ||
) | ||
} |
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are we opening the link with JS? Shouldn't it be a simple Link in the end? Id worry about screen readers here going outside the normal semantics
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh! Good call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@macrael I updated this to use the
Link
component again. From this blog, disabling the link might not be the way to go, so I'm rendering just a div with the loading spinner until the link is ready. Could use you're eyes on this again.