From 0b5d90c6c60d061572df8c86b3ac43e0e55d9676 Mon Sep 17 00:00:00 2001 From: Hamsini Malli Sivakumar Date: Wed, 27 Sep 2023 16:00:24 -0400 Subject: [PATCH 1/7] cypress testing error fix --- src/pages/dar_application/DataAccessRequestApplication.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/dar_application/DataAccessRequestApplication.js b/src/pages/dar_application/DataAccessRequestApplication.js index 000771491..cbb55c98a 100644 --- a/src/pages/dar_application/DataAccessRequestApplication.js +++ b/src/pages/dar_application/DataAccessRequestApplication.js @@ -588,13 +588,13 @@ const DataAccessRequestApplication = (props) => {
- {!props.readOnlyMode ? setIsAttested(false)} isAttested={isAttested} attest={attemptSubmit} save={() => setShowDialogSave(true)} - /> :
} + />
{isAttested && From 484a930a83ac98b4b8ac2b5a41c3a1d28275038c Mon Sep 17 00:00:00 2001 From: Hamsini Malli Sivakumar Date: Wed, 27 Sep 2023 16:02:57 -0400 Subject: [PATCH 2/7] removed signing official field --- src/pages/dar_application/ResearcherInfo.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/dar_application/ResearcherInfo.js b/src/pages/dar_application/ResearcherInfo.js index ea3d79baa..3df77f4fc 100644 --- a/src/pages/dar_application/ResearcherInfo.js +++ b/src/pages/dar_application/ResearcherInfo.js @@ -201,7 +201,7 @@ export default function ResearcherInfo(props) { ]), div({className: 'dar-application-row'}, [ - h(FormField, { + includeInstructions && h(FormField, { id: 'signingOfficial', type: FormFieldTypes.SELECT, description: 'I certify that the individual listed below is my Institutional Signing official', From 1cb583b05688d45cc25f9968862acfb8a5bd6d86 Mon Sep 17 00:00:00 2001 From: Hamsini Malli Date: Wed, 27 Sep 2023 16:09:14 -0400 Subject: [PATCH 3/7] revert changes to ajax.js --- src/libs/ajax.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/libs/ajax.js b/src/libs/ajax.js index 3d88b5807..0d1d4a92e 100644 --- a/src/libs/ajax.js +++ b/src/libs/ajax.js @@ -626,12 +626,6 @@ export const User = { return res.json(); }, - // getSOsForGivenUser: async (userId) => { - // const url = `${await getApiUrl()}/api/user/signing-officials/${userId}`; - // const res = await fetchOk(url, fp.mergeAll([Config.authOpts(), { method: 'GET' }])); - // return res.json(); - // }, - getUnassignedUsers: async () => { const url = `${await getApiUrl()}/api/user/institution/unassigned`; const res = await axios.get(url, Config.authOpts()); From 57a99076ca50b69c5745946a7645a7cab49e3023 Mon Sep 17 00:00:00 2001 From: Hamsini Malli Sivakumar Date: Fri, 29 Sep 2023 00:30:18 -0400 Subject: [PATCH 4/7] Revert "fixed typo" This reverts commit 8ec26377315d00e323bd30b5c6190b880b3a4e1c. --- src/pages/dar_collection_review/ApplicationInformation.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/dar_collection_review/ApplicationInformation.js b/src/pages/dar_collection_review/ApplicationInformation.js index eaf65e7b9..d7cbcfaa4 100644 --- a/src/pages/dar_collection_review/ApplicationInformation.js +++ b/src/pages/dar_collection_review/ApplicationInformation.js @@ -153,7 +153,7 @@ export default function ApplicationInformation(props) { ]; return ( - div({className: 'application-information-page', style: {padding: '2% 3%', backgroundColor: 'white'}}, [ + div({className: '', style: {padding: '2% 3%', backgroundColor: 'white'}}, [ div({className: 'applicant-information-container', style: { margin: '0 0 2.5rem 0'}}, [ div({className: 'applicant-information-subheader', style: styles.title}, ['Applicant Information']), div({className: 'information-row', style: styles.row}, [ From 65804f2ff65911a1b0d4effffe53c0ecaf71f2e8 Mon Sep 17 00:00:00 2001 From: Hamsini Malli Sivakumar Date: Fri, 29 Sep 2023 12:19:07 -0400 Subject: [PATCH 5/7] fixed code --- src/components/eRACommons.js | 64 +++++++++++-------- .../dar_application/DataAccessRequest.js | 2 +- .../DataAccessRequestApplication.js | 46 ++++++------- src/pages/dar_application/ResearcherInfo.js | 11 ++-- .../collaborator/CollaboratorList.js | 9 +-- .../DarCollectionReview.js | 4 +- 6 files changed, 68 insertions(+), 68 deletions(-) diff --git a/src/components/eRACommons.js b/src/components/eRACommons.js index b43a0e918..58319d934 100644 --- a/src/components/eRACommons.js +++ b/src/components/eRACommons.js @@ -15,8 +15,7 @@ export const eRACommons = hh(class eRACommons extends React.Component { expirationCount: 0, eraCommonsId: '', nihError: false, - isHovered: false, - isCurrentUser: true + isHovered: false }; componentDidMount = async () => { @@ -49,31 +48,40 @@ export const eRACommons = hh(class eRACommons extends React.Component { }; getUserInfo = async () => { - let response = await User.getMe(); - if (this.props.researcher !== undefined) { - const givenUser = this.props.researcher; - if (givenUser.userId != response.userId) { - this.setState(prev => { - prev.isCurrentUser = false; - return prev; - }); - } - response = givenUser; + if (this.props.researcherProfile === undefined) { + const response = await User.getMe(); + const props = response.researcherProperties; + const authProp = find({'propertyKey':'eraAuthorized'})(props); + const expProp = find({'propertyKey':'eraExpiration'})(props); + const isAuthorized = isNil(authProp) ? false : getOr(false,'propertyValue')(authProp); + const expirationCount = isNil(expProp) ? 0 : AuthenticateNIH.expirationCount(getOr(0,'propertyValue')(expProp)); + const nihValid = isAuthorized && expirationCount > 0; + const eraCommonsId = response.eraCommonsId; + this.props.onNihStatusUpdate(nihValid); + this.setState(prev => { + prev.isAuthorized = isAuthorized; + prev.expirationCount = expirationCount; + prev.eraCommonsId = isNil(eraCommonsId) ? '' : eraCommonsId; + return prev; + }); + } + else { + const response = this.props.researcherProfile; + const props = response.researcherProperties; + const authProp = find({'propertyKey':'eraAuthorized'})(props); + const expProp = find({'propertyKey':'eraExpiration'})(props); + const isAuthorized = isNil(authProp) ? false : getOr(false,'propertyValue')(authProp); + const expirationCount = isNil(expProp) ? 0 : AuthenticateNIH.expirationCount(getOr(0,'propertyValue')(expProp)); + const nihValid = isAuthorized && expirationCount > 0; + const eraCommonsId = response.eraCommonsId; + this.props.onNihStatusUpdate(nihValid); + this.setState(prev => { + prev.isAuthorized = isAuthorized; + prev.expirationCount = expirationCount; + prev.eraCommonsId = isNil(eraCommonsId) ? '' : eraCommonsId; + return prev; + }); } - const props = response.researcherProperties; - const authProp = find({'propertyKey':'eraAuthorized'})(props); - const expProp = find({'propertyKey':'eraExpiration'})(props); - const isAuthorized = isNil(authProp) ? false : getOr(false,'propertyValue')(authProp); - const expirationCount = isNil(expProp) ? 0 : AuthenticateNIH.expirationCount(getOr(0,'propertyValue')(expProp)); - const nihValid = isAuthorized && expirationCount > 0; - const eraCommonsId = response.eraCommonsId; - this.props.onNihStatusUpdate(nihValid); - this.setState(prev => { - prev.isAuthorized = isAuthorized; - prev.expirationCount = expirationCount; - prev.eraCommonsId = isNil(eraCommonsId) ? '' : eraCommonsId; - return prev; - }); }; verifyToken = async (parsedToken) => { @@ -202,10 +210,10 @@ export const eRACommons = hh(class eRACommons extends React.Component { className: 'col-lg-12 col-md-12 col-sm-6 col-xs-12 no-padding' }, [ div({ isRendered: this.state.expirationCount >= 0, className: 'fadein' }, ['Your NIH authentication will expire in ' + this.state.expirationCount + ' days']), - div({ isRendered: this.state.expirationCount < 0, className: 'fadein' }, [this.state.isCurrentUser ? 'Your NIH authentication has expired' : `This user's NIH authentication has expired`]) + div({ isRendered: this.state.expirationCount < 0, className: 'fadein' }, [(this.props.researcherProfile === undefined) ? 'Your NIH authentication has expired' : `This user's NIH authentication has expired`]) ]) ]) ]) ); } -}); +}); \ No newline at end of file diff --git a/src/pages/dar_application/DataAccessRequest.js b/src/pages/dar_application/DataAccessRequest.js index 762f92dd4..b8f1f7ad3 100644 --- a/src/pages/dar_application/DataAccessRequest.js +++ b/src/pages/dar_application/DataAccessRequest.js @@ -413,4 +413,4 @@ export default function DataAccessRequest(props) { ]), ]) ); -} +} \ No newline at end of file diff --git a/src/pages/dar_application/DataAccessRequestApplication.js b/src/pages/dar_application/DataAccessRequestApplication.js index cbb55c98a..326664f0e 100644 --- a/src/pages/dar_application/DataAccessRequestApplication.js +++ b/src/pages/dar_application/DataAccessRequestApplication.js @@ -28,8 +28,7 @@ import UsgOmbText from '../../components/UsgOmbText'; const ApplicationTabs = [ { name: 'Researcher Information' }, { name: 'Data Access Request' }, - { name: 'Research Purpose Statement' }, - { name: 'Data Use Agreement' } + { name: 'Research Purpose Statement' } ]; const fetchAllDatasets = async (dsIds) => { @@ -125,6 +124,9 @@ const DataAccessRequestApplication = (props) => { const [isLoading, setIsLoading] = useState(true); const [isAttested, setIsAttested] = useState(false); + if (!props.readOnlyMode) { + ApplicationTabs.push({ name: 'Data Use Agreement' }); + } const [applicationTabs, setApplicationTabs] = useState(ApplicationTabs); //helper function to coordinate local state changes as well as updates to form data on the parent @@ -227,19 +229,11 @@ const DataAccessRequestApplication = (props) => { const init = useCallback(async () => { const { dataRequestId, collectionId } = props.match.params; let formData = {}; - if (props.researcher === undefined) { - const researcher = await User.getMe(); - const signingOfficials = await User.getSOsForCurrentUser(); - setResearcher(researcher); - setAllSigningOfficials(signingOfficials); - } - else { - const researcher = props.researcher; - // const signingOfficials = await User.getSOsForGivenUser(props.researcher.userId); - setResearcher(researcher); - setAllSigningOfficials(['Hello']); - } + const researcher = await User.getMe(); + const signingOfficials = await User.getSOsForCurrentUser(); + setResearcher(researcher); + setAllSigningOfficials(signingOfficials); setIsLoading(false); if (!isNil(collectionId)) { @@ -267,7 +261,7 @@ const DataAccessRequestApplication = (props) => { batchFormFieldChange(formData); window.addEventListener('scroll', onScroll); // eslint-disable-line -- codacy says event listeners are dangerous - }, [onScroll, props.match.params, props.researcher, researcher]); + }, [onScroll, props.match.params]); useEffect(() => { init(); @@ -538,6 +532,7 @@ const DataAccessRequestApplication = (props) => { { nihValid={nihValid} onNihStatusUpdate={setNihValid} showNihValidationError={showNihValidationError} - researcher={(props.researcher === undefined) ? researcher : props.researcher} + researcher={researcher} allSigningOfficials={allSigningOfficials} setLabCollaboratorsCompleted={setLabCollaboratorsCompleted} setInternalCollaboratorsCompleted={setInternalCollaboratorsCompleted} @@ -587,15 +582,16 @@ const DataAccessRequestApplication = (props) => { />
-
- setIsAttested(false)} - isAttested={isAttested} - attest={attemptSubmit} - save={() => setShowDialogSave(true)} - /> -
+ {!props.readOnlyMode ? +
+ setIsAttested(false)} + isAttested={isAttested} + attest={attemptSubmit} + save={() => setShowDialogSave(true)} + /> +
:
} {isAttested &&
diff --git a/src/pages/dar_application/ResearcherInfo.js b/src/pages/dar_application/ResearcherInfo.js index 3df77f4fc..16a42ce4e 100644 --- a/src/pages/dar_application/ResearcherInfo.js +++ b/src/pages/dar_application/ResearcherInfo.js @@ -19,6 +19,7 @@ export default function ResearcherInfo(props) { const { allSigningOfficials, readOnlyMode, + researcherProfile, includeInstructions, completed, darCode, @@ -78,7 +79,7 @@ export default function ResearcherInfo(props) { title: '1.1 Researcher', validators: [FormValidators.REQUIRED], ariaLevel: ariaLevel + 1, - defaultValue: researcher.displayName, + defaultValue: (researcherProfile === undefined) ? researcher.displayName : researcherProfile.displayName, disabled: true }), ]), @@ -97,7 +98,7 @@ export default function ResearcherInfo(props) { location: location, validationError: showNihValidationError, readOnly: readOnlyMode, - researcher: props.researcher, + researcherProfile: researcherProfile, header: true, required: formData.checkCollaborator !== true, }) @@ -200,8 +201,8 @@ export default function ResearcherInfo(props) { }), ]), - div({className: 'dar-application-row'}, [ - includeInstructions && h(FormField, { + !props.readOnlyMode && div({className: 'dar-application-row'}, [ + h(FormField, { id: 'signingOfficial', type: FormFieldTypes.SELECT, description: 'I certify that the individual listed below is my Institutional Signing official', @@ -392,4 +393,4 @@ export default function ResearcherInfo(props) { ]), ]) ); -} +} \ No newline at end of file diff --git a/src/pages/dar_application/collaborator/CollaboratorList.js b/src/pages/dar_application/collaborator/CollaboratorList.js index be4855d73..10b8e7785 100644 --- a/src/pages/dar_application/collaborator/CollaboratorList.js +++ b/src/pages/dar_application/collaborator/CollaboratorList.js @@ -96,16 +96,11 @@ export default function CollaboratorList(props) { id: `add-${collaboratorKey}-btn`, type: 'button', // default button element type inside a form is "submit". className: 'button button-white', - style: { - marginTop: 25, - marginBottom: 5, - ...(props.disabled ? { cursor: 'not-allowed' } : {}), - }, + style: { marginTop: 25, marginBottom: 5 }, onClick: () => { !props.disabled && setShowNewForm(true); }, - isRendered: !showNewForm, - disabled: props.disabled, + isRendered: !showNewForm }, [`Add ${collaboratorLabel}`]), h(CollaboratorForm, { index: collaborators.length, diff --git a/src/pages/dar_collection_review/DarCollectionReview.js b/src/pages/dar_collection_review/DarCollectionReview.js index cfe6c9531..d017c295c 100644 --- a/src/pages/dar_collection_review/DarCollectionReview.js +++ b/src/pages/dar_collection_review/DarCollectionReview.js @@ -205,8 +205,8 @@ export default function DarCollectionReview(props) { }), h(DataAccessRequestApplication, { isRendered: selectedTab === tabs.fullDAR, - researcher: researcherProfile, readOnlyMode: true, + researcherProfile: researcherProfile, ...props }), h(MultiDatasetVotingTab, { @@ -232,4 +232,4 @@ export default function DarCollectionReview(props) { ] ), ]); -} +} \ No newline at end of file From 70a21f26c86b5c9e20bc159a3949b4984d7dbaf3 Mon Sep 17 00:00:00 2001 From: Hamsini Malli Sivakumar Date: Fri, 29 Sep 2023 12:51:28 -0400 Subject: [PATCH 6/7] fixed typo --- src/pages/dar_collection_review/ApplicationInformation.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/dar_collection_review/ApplicationInformation.js b/src/pages/dar_collection_review/ApplicationInformation.js index d7cbcfaa4..eaf65e7b9 100644 --- a/src/pages/dar_collection_review/ApplicationInformation.js +++ b/src/pages/dar_collection_review/ApplicationInformation.js @@ -153,7 +153,7 @@ export default function ApplicationInformation(props) { ]; return ( - div({className: '', style: {padding: '2% 3%', backgroundColor: 'white'}}, [ + div({className: 'application-information-page', style: {padding: '2% 3%', backgroundColor: 'white'}}, [ div({className: 'applicant-information-container', style: { margin: '0 0 2.5rem 0'}}, [ div({className: 'applicant-information-subheader', style: styles.title}, ['Applicant Information']), div({className: 'information-row', style: styles.row}, [ From f544df2d709823a76a6f075e94b4ed574008112c Mon Sep 17 00:00:00 2001 From: Hamsini Malli Sivakumar Date: Fri, 29 Sep 2023 13:05:01 -0400 Subject: [PATCH 7/7] added collaborator list changes --- .../dar_application/collaborator/CollaboratorList.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/pages/dar_application/collaborator/CollaboratorList.js b/src/pages/dar_application/collaborator/CollaboratorList.js index 10b8e7785..c18fd217d 100644 --- a/src/pages/dar_application/collaborator/CollaboratorList.js +++ b/src/pages/dar_application/collaborator/CollaboratorList.js @@ -96,11 +96,16 @@ export default function CollaboratorList(props) { id: `add-${collaboratorKey}-btn`, type: 'button', // default button element type inside a form is "submit". className: 'button button-white', - style: { marginTop: 25, marginBottom: 5 }, + style: { + marginTop: 25, + marginBottom: 5, + ...(props.disabled ? { cursor: 'not-allowed' } : {}), + }, onClick: () => { !props.disabled && setShowNewForm(true); }, - isRendered: !showNewForm + isRendered: !showNewForm, + disabled: props.disabled, }, [`Add ${collaboratorLabel}`]), h(CollaboratorForm, { index: collaborators.length, @@ -118,4 +123,4 @@ export default function CollaboratorList(props) { ListItems ]) ); -} +} \ No newline at end of file