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

Update download tab study access text #1465

Merged
merged 1 commit into from
Nov 10, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 44 additions & 35 deletions src/lib/workspace/DownloadTab/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { useWdkService } from '@veupathdb/wdk-client/lib/Hooks/WdkServiceHook';
import { Action } from '@veupathdb/study-data-access/lib/data-restriction/DataRestrictionUiActions';
import { getStudyRequestNeedsApproval } from '@veupathdb/study-data-access/lib/shared/studies';
import { useLocalBackedState } from '@veupathdb/wdk-client/lib/Hooks/LocalBackedState';
import { H5, Paragraph } from '@veupathdb/coreui';

type DownloadsTabProps = {
downloadClient: DownloadClient;
Expand Down Expand Up @@ -121,7 +122,7 @@ export default function DownloadTab({
?.actionAuthorization['resultsAll'];
const requestElement = (
<button className="link" style={{ padding: 0 }} onClick={handleClick}>
Click here to request access.
request access
</button>
);

Expand All @@ -146,17 +147,13 @@ export default function DownloadTab({
></Banner>
)}
{/* End temporary solution section */}
<em>
{getDataAccessDeclaration(
studyAccess,
requestNeedsApproval,
user.isGuest,
hasPermission ?? false
)}
{studyAccess !== 'Public' &&
(user.isGuest || !hasPermission) &&
requestElement}
</em>
{getDataAccessDeclaration(
studyAccess,
requestNeedsApproval,
user.isGuest,
hasPermission ?? false,
requestElement
)}
</span>
);
}, [
Expand Down Expand Up @@ -282,32 +279,44 @@ function getDataAccessDeclaration(
studyAccess: string,
requestNeedsApproval: boolean,
isGuest: boolean,
hasPermission: boolean = false
): string {
const DATA_ACCESS_STUB = `Data downloads for this study are ${studyAccess.toLowerCase()}. `;
const PUBLIC_ACCESS_STUB = 'You can download the data without logging in.';
const LOGIN_REQUEST_STUB =
'You must register or log in and request access to download data;';
hasPermission: boolean = false,
requestElement: JSX.Element
): JSX.Element {
const PUBLIC_ACCESS_STUB =
'Data downloads for this study are public. Data is available without logging in.';
const LOGIN_REQUEST_STUB = (
<span>
To download data please register or log in and {requestElement}.
</span>
);
const CONTROLLED_ACCESS_STUB =
' data can be downloaded immediately following request submission. ';
' Data will be available immediately following request submission.';
const PROTECTED_ACCESS_STUB =
' data can be downloaded after the study team reviews your request and grants you access. ';
' Data will be available upon study team review and approval.';
const ACCESS_GRANTED_STUB =
'You have been granted access to download the data.';
' You have been granted access to download the data.';
// const ACCESS_PENDING_STUB = 'Your data access request is pending.';

let dataAccessDeclaration = DATA_ACCESS_STUB;
if (studyAccess === 'Public') {
return (dataAccessDeclaration += PUBLIC_ACCESS_STUB);
} else if (isGuest || !hasPermission) {
dataAccessDeclaration += LOGIN_REQUEST_STUB;
return (dataAccessDeclaration += !requestNeedsApproval
? CONTROLLED_ACCESS_STUB
: PROTECTED_ACCESS_STUB);
} else if (!isGuest && hasPermission) {
return (dataAccessDeclaration += ACCESS_GRANTED_STUB);
} else {
// dataAccessDeclaration += ACCESS_PENDING_STUB;
return dataAccessDeclaration;
}
return (
<div>
<H5>
Data Accessibility:{' '}
<span style={{ fontWeight: 'normal' }}>{studyAccess}</span>
</H5>
<Paragraph styleOverrides={{ margin: 0 }}>
{studyAccess === 'Public' ? (
<span>{PUBLIC_ACCESS_STUB}</span>
) : isGuest || !hasPermission ? (
<span>
{LOGIN_REQUEST_STUB}
{requestNeedsApproval
? PROTECTED_ACCESS_STUB
: CONTROLLED_ACCESS_STUB}
</span>
) : (
<span>{ACCESS_GRANTED_STUB}</span>
)}
</Paragraph>
</div>
);
}