Skip to content

Commit

Permalink
1140: Case Info Tab - Document Detail Tab Display
Browse files Browse the repository at this point in the history
* setDefaultDocumentDetailTabAction uses the helper to set the default tab
  • Loading branch information
wbyoko committed Mar 18, 2019
1 parent a3d4d2a commit 8ea934f
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 12 deletions.
17 changes: 10 additions & 7 deletions web-client/src/presenter/computeds/documentDetailHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,21 @@ export default get => {
.map(items => formatWorkItem(items));
}

const formattedDocumentIsPetition =
(formattedDocument && formattedDocument.isPetition) || false;
const showCaseDetailsEdit = ['New', 'Recalled'].includes(caseDetail.status);
const showCaseDetailsView = ['Batched for IRS'].includes(caseDetail.status);
const showDocumentInfoTab =
formattedDocumentIsPetition && (showCaseDetailsEdit || showCaseDetailsView);

return {
formattedDocument,
showAction: (action, workItemId) => {
const actions = get(state.workItemActions);
return actions[workItemId] === action;
},
showCaseDetailsEdit: ['New', 'Recalled'].includes(caseDetail.status),
showCaseDetailsView: ['Batched for IRS'].includes(caseDetail.status),
showDocumentInfo: get(state.currentTab) === 'Document Info',
showDocumentInfoTab: formattedDocument
? formattedDocument.isPetition
: false,
showPendingMessages: get(state.currentTab) === 'Pending Messages',
showCaseDetailsEdit,
showCaseDetailsView,
showDocumentInfoTab,
};
};
65 changes: 65 additions & 0 deletions web-client/src/presenter/computeds/documentDetailHelper.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,69 @@ describe('formatted work queue computed', () => {
});
expect(result.showCaseDetailsEdit).toEqual(true);
});

describe('showDocumentInfoTab', () => {
it('should be false if document is not a petition', () => {
const result = runCompute(documentDetailHelper, {
state: {
caseDetail: {
documents: [
{
documentId: 'abc',
documentType: 'NotAPetition',
},
],
status: 'Recalled',
},
documentId: 'abc',
workItemActions: {
abc: 'complete',
},
},
});
expect(result.showDocumentInfoTab).toEqual(false);
});

it('should be true if document is a petition and status is New, Recalled, or Batched for IRS', () => {
const result = runCompute(documentDetailHelper, {
state: {
caseDetail: {
documents: [
{
documentId: 'abc',
documentType: 'Petition',
},
],
status: 'Recalled',
},
documentId: 'abc',
workItemActions: {
abc: 'complete',
},
},
});
expect(result.showDocumentInfoTab).toEqual(true);
});

it('should be false if document is a petition and status is not New, Recalled, or Batched for IRS', () => {
const result = runCompute(documentDetailHelper, {
state: {
caseDetail: {
documents: [
{
documentId: 'abc',
documentType: 'Petition',
},
],
status: 'General',
},
documentId: 'abc',
workItemActions: {
abc: 'complete',
},
},
});
expect(result.showDocumentInfoTab).toEqual(false);
});
});
});
12 changes: 7 additions & 5 deletions web-client/src/views/DocumentDetail.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,13 @@ class DocumentDetailComponent extends React.Component {
<ErrorNotification />

<Tabs className="classic-horizontal-header3" bind="currentTab">
<Tab
tabName="Document Info"
title="Document Info"
id="tab-document-info"
/>
{helper.showDocumentInfoTab && (
<Tab
tabName="Document Info"
title="Document Info"
id="tab-document-info"
/>
)}
<Tab
tabName="Messages"
title="Messages"
Expand Down

0 comments on commit 8ea934f

Please sign in to comment.