Skip to content

Commit db53b47

Browse files
feat(downloadVariableMetadataButton): reverted login button changes to ActionButtons per discussion with stakeholders
1 parent df69887 commit db53b47

File tree

1 file changed

+59
-97
lines changed

1 file changed

+59
-97
lines changed

src/Discovery/DiscoveryDetails/DataDownloadList/ActionButtons/ActionButtons.tsx

+59-97
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import React, { useEffect, useState } from 'react';
2-
import { Col, Row, Button, Popover } from 'antd';
2+
import {
3+
Col, Row, Button, Popover,
4+
} from 'antd';
35
import { useHistory, useLocation } from 'react-router-dom';
46
import { DiscoveryConfig } from '../../../DiscoveryConfig';
57
import { DiscoveryResource } from '../../../Discovery';
@@ -34,28 +36,26 @@ const ActionButtons = ({
3436
const history = useHistory();
3537
const location = useLocation();
3638

37-
const studyMetadataFieldNameReference: string | undefined =
38-
discoveryConfig?.features.exportToWorkspace.studyMetadataFieldName;
39-
const manifestFieldName: string | undefined =
40-
discoveryConfig?.features.exportToWorkspace.manifestFieldName;
39+
const studyMetadataFieldNameReference: string | undefined = discoveryConfig?.features.exportToWorkspace.studyMetadataFieldName;
40+
const manifestFieldName: string | undefined = discoveryConfig?.features.exportToWorkspace.manifestFieldName;
4141
const showDownloadStudyLevelMetadataButton = Boolean(
42-
discoveryConfig?.features.exportToWorkspace.enableDownloadStudyMetadata &&
43-
studyMetadataFieldNameReference &&
44-
resourceInfo?.[studyMetadataFieldNameReference]
42+
discoveryConfig?.features.exportToWorkspace.enableDownloadStudyMetadata
43+
&& studyMetadataFieldNameReference
44+
&& resourceInfo?.[studyMetadataFieldNameReference],
4545
);
4646
const showDownloadFileManifestButtons = Boolean(
47-
discoveryConfig?.features.exportToWorkspace.enableDownloadManifest
47+
discoveryConfig?.features.exportToWorkspace.enableDownloadManifest,
4848
);
4949
const showDownloadAllFilesButtons = Boolean(
50-
discoveryConfig?.features.exportToWorkspace.enableDownloadZip
50+
discoveryConfig?.features.exportToWorkspace.enableDownloadZip,
5151
);
5252
const verifyExternalLoginsNeeded = Boolean(
53-
discoveryConfig?.features.exportToWorkspace.verifyExternalLogins
53+
discoveryConfig?.features.exportToWorkspace.verifyExternalLogins,
5454
);
5555

5656
const showDownloadVariableMetadataButton = Boolean(
57-
discoveryConfig.features.exportToWorkspace.variableMetadataFieldName &&
58-
discoveryConfig.features.exportToWorkspace.enableDownloadVariableMetadata
57+
discoveryConfig.features.exportToWorkspace.variableMetadataFieldName
58+
&& discoveryConfig.features.exportToWorkspace.enableDownloadVariableMetadata,
5959
);
6060
const [dataDictionaryInfo, setDataDictionaryInfo] = useState({
6161
noVariableLevelMetadata: true,
@@ -67,18 +67,17 @@ const ActionButtons = ({
6767
discoveryConfig,
6868
resourceInfo,
6969
showDownloadVariableMetadataButton,
70-
setDataDictionaryInfo
70+
setDataDictionaryInfo,
7171
);
7272
}, [resourceInfo]);
7373

74-
const ConditionalPopover = ({ children }) =>
75-
noData ? (
76-
<Popover title={'This file is not available for the selected study'}>
77-
{children}
78-
</Popover>
79-
) : (
80-
children
81-
);
74+
const ConditionalPopover = ({ children }) => (noData ? (
75+
<Popover title={'This file is not available for the selected study'}>
76+
{children}
77+
</Popover>
78+
) : (
79+
children
80+
));
8281

8382
return (
8483
<div className='discovery-modal_buttons-row' data-testid='actionButtons'>
@@ -89,77 +88,42 @@ const ActionButtons = ({
8988
<Row className='row'>
9089
{showDownloadVariableMetadataButton && (
9190
<Col flex='1 0 auto'>
92-
{isUserLoggedIn && !healLoginNeeded && (
93-
<Button
94-
className='discovery-action-bar-button'
95-
disabled={Boolean(
96-
downloadStatus.inProgress ||
97-
dataDictionaryInfo.noVariableLevelMetadata
98-
)}
99-
loading={
100-
downloadStatus.inProgress === 'DownloadVariableMetadata'
101-
}
102-
onClick={() => {
103-
DownloadVariableMetadata(
104-
dataDictionaryInfo.dataDictionaries,
105-
resourceInfo,
106-
setDownloadStatus
107-
);
108-
}}
109-
>
110-
Download <br />
111-
Variable-Level Metadata
112-
</Button>
113-
)}
114-
{!dataDictionaryInfo.noVariableLevelMetadata &&
115-
(!isUserLoggedIn || healLoginNeeded) && (
116-
<Button
117-
className='discovery-action-bar-button'
118-
disabled={Boolean(noData || downloadStatus.inProgress)}
119-
onClick={() => {
120-
HandleRedirectToLoginClick(resourceInfo, discoveryConfig);
121-
}}
122-
>
123-
Login to Download
124-
<br />
125-
Variable Level Metadata
126-
</Button>
91+
<Button
92+
className='discovery-action-bar-button'
93+
disabled={Boolean(
94+
downloadStatus.inProgress
95+
|| dataDictionaryInfo.noVariableLevelMetadata,
12796
)}
97+
loading={downloadStatus.inProgress === 'DownloadVariableMetadata'}
98+
onClick={() => {
99+
DownloadVariableMetadata(
100+
dataDictionaryInfo.dataDictionaries,
101+
resourceInfo,
102+
setDownloadStatus,
103+
);
104+
}}
105+
>
106+
Download <br />
107+
Variable-Level Metadata
108+
</Button>
128109
</Col>
129110
)}
130111
{showDownloadStudyLevelMetadataButton && (
131112
<Col flex='1 0 auto'>
132-
{isUserLoggedIn && !healLoginNeeded && (
133-
<ConditionalPopover>
134-
<Button
135-
className='discovery-action-bar-button'
136-
disabled={Boolean(noData || downloadStatus.inProgress)}
137-
onClick={() =>
138-
DownloadJsonFile(
139-
'study-level-metadata',
140-
studyMetadataFieldNameReference &&
141-
resourceInfo[studyMetadataFieldNameReference]
142-
)
143-
}
144-
>
145-
Download <br />
146-
Study-Level Metadata
147-
</Button>
148-
</ConditionalPopover>
149-
)}
150-
{(!isUserLoggedIn || healLoginNeeded) && (
113+
<ConditionalPopover>
151114
<Button
152115
className='discovery-action-bar-button'
153116
disabled={Boolean(noData || downloadStatus.inProgress)}
154-
onClick={() => {
155-
HandleRedirectToLoginClick(resourceInfo, discoveryConfig);
156-
}}
117+
onClick={() => DownloadJsonFile(
118+
'study-level-metadata',
119+
studyMetadataFieldNameReference
120+
&& resourceInfo[studyMetadataFieldNameReference],
121+
)}
157122
>
158-
Login to Download
159-
<br />
123+
Download <br />
160124
Study-Level Metadata
161125
</Button>
162-
)}
126+
</ConditionalPopover>
163127
</Col>
164128
)}
165129
{showDownloadFileManifestButtons && (
@@ -173,7 +137,7 @@ const ActionButtons = ({
173137
HandleDownloadManifestClick(
174138
discoveryConfig,
175139
[resourceInfo],
176-
healLoginNeeded
140+
healLoginNeeded,
177141
);
178142
}}
179143
>
@@ -189,7 +153,7 @@ const ActionButtons = ({
189153
HandleRedirectToLoginClick(
190154
resourceInfo,
191155
discoveryConfig,
192-
'manifest'
156+
'manifest',
193157
);
194158
}}
195159
>
@@ -207,18 +171,16 @@ const ActionButtons = ({
207171
className='discovery-action-bar-button'
208172
disabled={Boolean(noData || downloadStatus.inProgress)}
209173
loading={downloadStatus.inProgress === 'DownloadAllFiles'}
210-
onClick={() =>
211-
DownloadAllFiles(
212-
resourceInfo,
213-
downloadStatus,
214-
setDownloadStatus,
215-
history,
216-
location,
217-
healLoginNeeded,
218-
verifyExternalLoginsNeeded,
219-
manifestFieldName
220-
)
221-
}
174+
onClick={() => DownloadAllFiles(
175+
resourceInfo,
176+
downloadStatus,
177+
setDownloadStatus,
178+
history,
179+
location,
180+
healLoginNeeded,
181+
verifyExternalLoginsNeeded,
182+
manifestFieldName,
183+
)}
222184
>
223185
Download All Files
224186
</Button>
@@ -232,7 +194,7 @@ const ActionButtons = ({
232194
HandleRedirectToLoginClick(
233195
resourceInfo,
234196
discoveryConfig,
235-
'download'
197+
'download',
236198
);
237199
}}
238200
>

0 commit comments

Comments
 (0)