Skip to content
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

Alert for VVA and VBMS document list retrievals #8276

Merged
merged 24 commits into from Dec 21, 2018
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
98718e7
Re-add Reader document list VBMS/VVA timestamps
hschallh Dec 7, 2018
48a4dd6
Add alert for documents not fetched from VBMS/VVA
hschallh Dec 7, 2018
1fac553
Break alert out into its own component
hschallhorn Dec 12, 2018
fea01db
Add testing for stale manifest warning
hschallhorn Dec 12, 2018
b08f804
Finish logic for warning alert on stale manifests
hschallhorn Dec 12, 2018
d7bfe87
Linting
hschallhorn Dec 13, 2018
7dacc0a
Add verbiage from design to errors
hschallhorn Dec 13, 2018
3de2bba
Merge branch 'master' into hschallhorn/reader/6049-vbms-vva-download-…
hschallhorn Dec 14, 2018
fec4d0c
Merge branch 'master' into hschallhorn/reader/6049-vbms-vva-download-…
hschallhorn Dec 17, 2018
f121050
Update the message displayed in the stale retreival warning.
hschallhorn Dec 17, 2018
4def5e2
const over let
hschallhorn Dec 17, 2018
cfdd819
Alert styling with glamour
hschallhorn Dec 17, 2018
befa07e
Use moment for all dates and comparisons
hschallhorn Dec 17, 2018
e26b8a4
Remove testing focus: trues
hschallhorn Dec 17, 2018
6fed358
Initialize manifest timestamps in dev env.
hschallhorn Dec 20, 2018
501d36e
Format timestamps to be parsable by moment
hschallhorn Dec 20, 2018
f544454
Reintroduce readable zone for displayed timestamps
hschallhorn Dec 20, 2018
64533df
Fix error on null retrieval times
hschallhorn Dec 20, 2018
c9c0353
Update to less ominous version of warning text
hschallhorn Dec 21, 2018
6faa17a
Merge branch 'master' into hschallhorn/reader/6049-vbms-vva-download-…
hschallhorn Dec 21, 2018
3f3c5f1
Merge branch 'master' into hschallhorn/reader/6049-vbms-vva-download-…
Dec 21, 2018
de30763
Merge branch 'master' into hschallhorn/reader/6049-vbms-vva-download-…
Dec 21, 2018
0501505
Merge branch 'master' into hschallhorn/reader/6049-vbms-vva-download-…
Dec 21, 2018
b81c91a
Merge branch 'master' into hschallhorn/reader/6049-vbms-vva-download-…
Dec 21, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
65 changes: 65 additions & 0 deletions client/app/reader/LastRetrievalAlert.jsx
@@ -0,0 +1,65 @@
import _ from 'lodash';
import moment from 'moment';
import React from 'react';
import { connect } from 'react-redux';
import Alert from '../components/Alert';

const CACHE_TIMEOUT_HOURS = 3;
const TIMEZONES = {
' GMT': ' +0000',
' EDT': ' -0400',
' EST': ' -0500',
' CDT': ' -0500',
' CST': ' -0600',
' MDT': ' -0600',
' MST': ' -0700',
' PDT': ' -0700',
' PST': ' -0800'
};

class LastRetrievalAlert extends React.PureComponent {

render() {

// Check that document manifests have been recieved from VVA and VBMS
if (!this.props.manifestVbmsFetchedAt || !this.props.manifestVvaFetchedAt) {
return <Alert title="Error" type="error">
Some of {this.props.appeal.veteran_full_name}'s documents are not available at the moment due to
a loading error from VBMS or VVA. As a result, you may be viewing a partial list of claims folder documents.
<br />
<br />
Please refresh your browser at a later point to view a complete list of documents in the claims
folder.
</Alert>;
}

let staleCacheTime = new Date();

staleCacheTime.setHours(staleCacheTime.getHours() - CACHE_TIMEOUT_HOURS);
hschallhorn marked this conversation as resolved.
Show resolved Hide resolved

let staleCacheTimestamp = staleCacheTime.getTime() / 1000,
hschallhorn marked this conversation as resolved.
Show resolved Hide resolved
vbmsManifestTimeString = this.props.manifestVbmsFetchedAt,
vvaManifestTimeString = this.props.manifestVvaFetchedAt;

let parsableVbmsManifestTimeString = vbmsManifestTimeString.slice(0, -4) +
TIMEZONES[vbmsManifestTimeString.slice(-4)],
parsableVvaManifestTimeString = vvaManifestTimeString.slice(0, -4) +
TIMEZONES[vvaManifestTimeString.slice(-4)],
vbmsManifestTimestamp = moment(parsableVbmsManifestTimeString, 'MM/DD/YY HH:mma Z').unix(),
hschallhorn marked this conversation as resolved.
Show resolved Hide resolved
vvaManifestTimestamp = moment(parsableVvaManifestTimeString, 'MM/DD/YY HH:mma Z').unix();

// Check that manifest results are fresh
if (vbmsManifestTimestamp < staleCacheTimestamp || vvaManifestTimestamp < staleCacheTimestamp) {
hschallhorn marked this conversation as resolved.
Show resolved Hide resolved
return <Alert title="Warning" type="warning">
You may be viewing an outdated list of claims folder documents. Please refresh the page to load
the most up to date documents.
</Alert>;
}

return null;
}
}

export default connect(
(state) => _.pick(state.documentList, ['manifestVvaFetchedAt', 'manifestVbmsFetchedAt'])
)(LastRetrievalAlert);
8 changes: 3 additions & 5 deletions client/app/reader/LastRetrievalInfo.jsx
Expand Up @@ -4,12 +4,10 @@ import { connect } from 'react-redux';

class UnconnectedLastRetrievalInfo extends React.PureComponent {
render() {
if (!this.props.manifestVbmsFetchedAt) {
return null;
}

return [
<div id="vbms-manifest-retrieved-at" key="vbms">Last VBMS retrieval: {this.props.manifestVbmsFetchedAt}</div>,
this.props.manifestVbmsFetchedAt ?
hschallhorn marked this conversation as resolved.
Show resolved Hide resolved
<div id="vbms-manifest-retrieved-at" key="vbms">Last VBMS retrieval: {this.props.manifestVbmsFetchedAt}</div> :
<div className="cf-red-text" key="vbms">Unable to display VBMS documents at this time</div>,
this.props.manifestVvaFetchedAt ?
<div id="vva-manifest-retrieved-at" key="vva">Last VVA retrieval: {this.props.manifestVvaFetchedAt}</div> :
<div className="cf-red-text" key="vva">Unable to display VVA documents at this time</div>
Expand Down
9 changes: 6 additions & 3 deletions client/app/reader/PdfListView.jsx
Expand Up @@ -5,6 +5,7 @@ import { connect } from 'react-redux';
import _ from 'lodash';

import BackToQueueLink from './BackToQueueLink';
import LastRetrievalAlert from './LastRetrievalAlert';
import LastRetrievalInfo from './LastRetrievalInfo';
import AppSegment from '@department-of-veterans-affairs/caseflow-frontend-toolkit/components/AppSegment';
import DocumentListHeader from './DocumentListHeader';
Expand Down Expand Up @@ -59,14 +60,15 @@ export class PdfListView extends React.Component {
}

return <div>
{ this.props.queueRedirectUrl && <BackToQueueLink
{this.props.queueRedirectUrl && <BackToQueueLink
queueRedirectUrl={this.props.queueRedirectUrl}
queueTaskType={this.props.queueTaskType}
veteranFullName={this.props.appeal.veteran_full_name}
vbmsId={this.props.appeal.vbms_id} /> }
vbmsId={this.props.appeal.vbms_id} />}
<AppSegment filledBackground>
<div className="section--document-list">
<ClaimsFolderDetails appeal={this.props.appeal} documents={this.props.documents} />
<LastRetrievalAlert appeal={this.props.appeal} />
<DocumentListHeader
documents={this.props.documents}
noDocuments={noDocuments}
Expand All @@ -80,7 +82,8 @@ export class PdfListView extends React.Component {
}

const mapStateToProps = (state, props) => {
return { documents: getFilteredDocuments(state),
return {
documents: getFilteredDocuments(state),
..._.pick(state.documentList, 'docFilterCriteria', 'viewingDocumentsOrComments'),
appeal: _.find(state.caseSelect.assignments, { vacols_id: props.match.params.vacolsId }) ||
state.pdfViewer.loadedAppeal,
Expand Down
4 changes: 4 additions & 0 deletions client/app/styles/reader/_document_list.scss
Expand Up @@ -242,6 +242,10 @@
background: inherit;
}
}

.usa-alert {
hschallhorn marked this conversation as resolved.
Show resolved Hide resolved
margin-bottom: 20px;
}
}

.document-list-filter-message {
Expand Down
26 changes: 24 additions & 2 deletions spec/feature/reader/reader_spec.rb
Expand Up @@ -235,19 +235,41 @@ def add_comment(text)
end

context "When both document source manifest retrieval times are set" do
scenario "Both times display on the page" do
scenario "Both times display on the page and there are no document alerts" do
visit "/reader/appeal/#{appeal.vacols_id}/documents"
expect(find("#vbms-manifest-retrieved-at").text).to have_content(vbms_ts_string)
expect(find("#vva-manifest-retrieved-at").text).to have_content(vva_ts_string)
expect(page).to_not have_css(".section--document-list .usa-alert")
end
end

context "When VVA manifest retrieval time is older, but within the eFolder cache limit" do
let(:vva_fetched_ts) { Time.zone.now - 2.hours }
scenario "Both times display on the page and there are no document alerts" do
visit "/reader/appeal/#{appeal.vacols_id}/documents"
expect(find("#vbms-manifest-retrieved-at").text).to have_content(vbms_ts_string)
expect(find("#vva-manifest-retrieved-at").text).to have_content(vva_ts_string)
expect(page).to_not have_css(".section--document-list .usa-alert")
end
end

context "When VVA manifest retrieval time is olde and outside of the eFolder cache limit" do
let(:vva_fetched_ts) { Time.zone.now - 4.hours }
scenario "Both times display on the page and a warning alert is shown" do
visit "/reader/appeal/#{appeal.vacols_id}/documents"
expect(find("#vbms-manifest-retrieved-at").text).to have_content(vbms_ts_string)
expect(find("#vva-manifest-retrieved-at").text).to have_content(vva_ts_string)
expect(page).to have_css(".section--document-list .usa-alert-warning")
end
end

context "When VVA manifest retrieval time is nil" do
let(:vva_fetched_ts) { nil }
scenario "Only VBMS time displays on the page" do
scenario "Only VBMS time displays on the page and error alert is shown" do
visit "/reader/appeal/#{appeal.vacols_id}/documents"
expect(find("#vbms-manifest-retrieved-at").text).to have_content(vbms_ts_string)
expect(page).to_not have_css("#vva-manifest-retrieved-at")
expect(page).to have_css(".section--document-list .usa-alert-error")
end
end

Expand Down