-
Notifications
You must be signed in to change notification settings - Fork 129
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
VACMS-10851 Find Forms code cleanup #34628
base: main
Are you sure you want to change the base?
Conversation
@@ -1,36 +1,35 @@ | |||
import PropTypes from 'prop-types'; |
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.
Alphabetized / organized to mirror the structure of the Facility Locator types.
@@ -1,73 +0,0 @@ | |||
import cloneDeep from 'lodash/cloneDeep'; |
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.
Having a separate file for this code with an index
file to import it seemed unnecessary, so I moved this into the index
file.
@@ -1,11 +0,0 @@ | |||
import * as Sentry from '@sentry/browser'; |
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.
Moved this out of the download-widget
folder and into the main app's helpers
folder
@@ -0,0 +1,37 @@ | |||
import * as Sentry from '@sentry/browser'; |
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.
This content was moved in here because now the form detail page and the form search results are both going to check validity of the form URL/PDF before rendering the download modal. If the form is invalid on either page, we need to do Sentry logging.
@@ -1,103 +0,0 @@ | |||
import React from 'react'; |
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.
The download-widget
code was simplified down to a single file.
@@ -1,53 +0,0 @@ | |||
import React, { useEffect, useState } from 'react'; |
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.
The download-widget
code was simplified down to a single file, and now the download widget (on the detail page) shares its PDF code with the search results page.
export const updatePaginationAction = (page = 1, startIndex = 0) => ({ | ||
page, | ||
startIndex, | ||
type: UPDATE_PAGINATION, | ||
}); | ||
|
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.
Added some of this code directly into SearchForm
and then directly connected that component to the fetchFormsApi
call to (mostly) mirror the way the download widget is calling it.
const mockRequest = options?.mockRequest || false; | ||
// Form URLs can be entered incorrectly, or the forms themselves can be deleted | ||
// by forms managers. This guards against sending users to 404 pages | ||
export const checkFormValidity = async (form, page) => { |
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.
This function represents what is now shared functionality between the search results page and the form detail pages. We need to double check that the form URL coming from the forms DB is a valid URL. If it isn't, we show an error banner with messaging on how to contact the forms managers (instead of the download button that shows the modal).
3a656fa
to
0b98ddf
Compare
@@ -44,7 +47,7 @@ const deriveLanguageTranslation = (lang = 'en', whichNode, formName) => { | |||
}, | |||
en: { | |||
goToOnlineTool: `Fill out VA Form ${formName} online`, | |||
downloadVaForm: `Download VA Form ${formName}`, | |||
downloadVaForm: `Download VA Form ${formName} (PDF)`, |
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.
Added (PDF)
here to make this consistent with the form detail page (Slack thread).
d69c1f7
to
8310375
Compare
Are you removing, renaming or moving a folder in this PR?
Did you change site-wide styles, platform utilities or other infrastructure?
Summary
Our Find Forms application is two-sided. We have the search results page that is essentially a full-page takeover, but still technically a React widget. Then we have the form detail pages that are almost 100% Drupal, the one exception being the "Download VA Form XXX" link on those pages.
The "Download VA Form XXX" link on both a search result and a form detail page functionally do the same thing. When clicked, they show a modal that warns the user to use Adobe Acrobat to view the PDF, and the modal has a link to download the form. Until now, the difference in the technical implementation is largely that the form detail pages ping the form URL with an HTTP HEAD call to ensure its validity (as URLs can be entered incorrectly in the DB, or forms moved, etc.). For some reason, the form search results download links did not do this check. We don't have the paper trail to explain why this gap existed, but because the data for both pages is from the same source (forms DB), the margin for human error is the same. We should check for URL validity on both pages.
This PR consolidates the code for both types of download links (form search results and form detail pages) to align them to the same functionality:
In addition to code changes in support of getting both sides of the Find Forms app to use mostly the same code, I did a lot of renaming and culling old code that wasn't being used anymore.
Related issue(s)
department-of-veterans-affairs/va.gov-cms#10851
Testing done & screenshots
1. Searching for forms and clicking download with a failed HTTP request
Note: in order to reproduce this scenario, you will need to change
src/applications/static-pages/find-forms/api/index.js
-> line 21:to:
This will produce a CORS error trying to make the network call and then you will be able to see the error banner.
/find-forms
1010
)view_search_results
analytics event with the correct data:Note that it is expected that the counts differ across environments because the forms data is not consistent across envs.
Download VA Form {form number} (PDF)
e.g. for the result for Form 10-1086, the button should sayDownload VA Form 10-1086 (PDF)
.10-1086
)email the forms managers
URL to validate that the form URL is correct:10-10M
)email the forms managers
URL to validate the correct URL for this banner2. Looking at a form detail page and clicking download with a failed HTTP request
Note: in order to reproduce this scenario, you will need to change
src/applications/static-pages/find-forms/api/index.js
-> line 21:to:
This will produce a CORS error trying to make the network call and then you will be able to see the error banner.
/find-forms/about-form-10-1086/
)Download VA Form {form number} (PDF)
e.g. for form 10-1086, the button should sayDownload VA Form 10-1086 (PDF)
email the forms managers
URL to validate that the form URL is correct:3. Searching for forms and clicking download with a successful HTTP request (modal appears)
/find-forms
1010
)Download VA Form {form number} (PDF)
e.g. for the result for Form 10-1086, the button should sayDownload VA Form 10-1086 (PDF)
.10-1086
)Download VA Form {form number} (PDF)
4. Looking at a form detail page and clicking download with a successful HTTP request (modal appears)
/find-forms/about-form-10-1086/
)Download VA Form {form number} (PDF)
e.g. for form 10-1086, the button should sayDownload VA Form 10-1086 (PDF)
Download VA Form {form number} (PDF)