Skip to content

Commit 2af582b

Browse files
urvi-occmfshao
andauthored
new changes for B3 WALDER project to make changes for discovery porta… (#1551)
* new changes for B3 WALDER project to make changes for discovery portal in PRC * spacing changes for code * changes suggested by mingfei * changes made after mingfei's comments and meeting * eslint on openfillrequestformbutton * added missing variables in discovey config * added null condition and ran eslint * added check for null to pass npm test * added check for null to pass npm test * refactor: simplify button logic by removing redundant check * refactor: remove redundant check from disabled condition * changes for failing test * new variable fillRequestFormCheckField added * changes for if condition * if condition fixes * new property added to allow checkboxes if not logged in * revert change * removed extra space * changed text for tooltip * fixes for props variable * Update src/Discovery/DiscoveryActionBar/components/OpenFillRequestFormButton.tsx Co-authored-by: Mingfei Shao <2475897+mfshao@users.noreply.github.com> * changes for tooltip if multiple flags are on * Update src/Discovery/DiscoveryListView.tsx Co-authored-by: Mingfei Shao <2475897+mfshao@users.noreply.github.com> --------- Co-authored-by: Mingfei Shao <2475897+mfshao@users.noreply.github.com>
1 parent 31e2bd8 commit 2af582b

File tree

5 files changed

+111
-7
lines changed

5 files changed

+111
-7
lines changed

docs/portal_config.md

+6
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,12 @@ Below is an example, with inline comments describing what each JSON block config
465465
"enable": true,
466466
"enableDownloadManifest": true, // enables a button which allows user to download a manifest file for gen3 client
467467
"downloadManifestButtonText": "Download Manifest", // text to be displayed on the download manifest button
468+
"enableFillRequestForm" : true, // enables a button which opens a new form to request access to a resoruce
469+
"fillRequestFormDisplayText": "Request Information", // text to be displayed on fill the request form
470+
"fillRequestFormCheckField" : "_medical_sample_id", // field defiend in MDS which is related to checkbox, this fiels is use to validate if the entry in discovery portal have unique¸
471+
"fillRequestFormURL" : "https://URL/form", // URL to the new form which would be used to fill the form
472+
"externalWebsiteName" : "", // Name of external website needed, this variable at development is used for showing an external website in a popover for chicagoland pandemic response commons, in commons this will be loaded only if enableFillRequestForm is true
473+
"externalWebsiteURL" : "", // URL of external website needed, this variable is used with externalWebsiteName be loaded only if enableFillRequestForm is true
468474
"manifestFieldName": "__manifest", // the field in the Discovery page data that contains the list of GUIDs that link to each study's data files.
469475
"enableDownloadZip": true, // enables a button which allows user to download all the files as a zip file (with pre-set size limits)
470476
"downloadZipButtonText": "Download Zip", // text to be displayed on the download zip file button

src/Discovery/DiscoveryActionBar/DiscoveryActionBar.tsx

+4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { BATCH_EXPORT_JOB_PREFIX, JOB_POLLING_INTERVAL } from './DiscoveryAction
1414
import DownloadZipButton from './components/DownloadZipButton';
1515
import ExportToWorkspaceButton from './components/ExportToWorkspaceButton';
1616
import DownloadManifestButton from './components/DownloadManifestButton';
17+
import OpenFillRequestFormButton from './components/OpenFillRequestFormButton';
1718

1819
/* eslint react/prop-types: 0 */
1920
interface Props {
@@ -193,6 +194,9 @@ const DiscoveryActionBar = (props: Props) => {
193194
history={history}
194195
location={location}
195196
/>
197+
<OpenFillRequestFormButton
198+
props={props}
199+
/>
196200
</Space>
197201
</div>
198202
</React.Fragment>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import React from 'react';
2+
import { FileTextOutlined } from '@ant-design/icons';
3+
import { Popover, Button } from 'antd';
4+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
5+
6+
const OpenFillRequestFormButton = (props) => {
7+
const { config, discovery } = props.props;
8+
9+
// Check if Fill Request Form button should be disabled based on configuration
10+
const isFillRequestFormDisabled = !config?.features?.exportToWorkspace?.enableFillRequestForm
11+
|| !config.features.exportToWorkspace.fillRequestFormURL?.trim()
12+
|| !config.features.exportToWorkspace.externalWebsiteURL?.trim()
13+
|| !config.features.exportToWorkspace.externalWebsiteName?.trim();
14+
15+
if (isFillRequestFormDisabled) {
16+
return null; // Return early if any required config values are missing
17+
}
18+
19+
// Define URLs and text for use in the popover and button
20+
const {
21+
fillRequestFormURL, externalWebsiteURL, externalWebsiteName, fillRequestFormDisplayText,
22+
} = config.features.exportToWorkspace;
23+
const { selectedResources } = discovery;
24+
25+
return (
26+
<Popover
27+
className='discovery-popover'
28+
arrowPointAtCenter
29+
title={(
30+
<React.Fragment>
31+
&nbsp;
32+
<a target='_blank' rel='noreferrer' href={externalWebsiteURL}>
33+
{externalWebsiteName}
34+
</a>
35+
<FontAwesomeIcon icon={'external-link-alt'} />
36+
</React.Fragment>
37+
)}
38+
content={(
39+
<span className='discovery-popover__text'>
40+
After filling the request form, once your search selection is approved, you can use the Gen3 Client
41+
to download the data from the selected studies to your local computer.
42+
</span>
43+
)}
44+
>
45+
<Button
46+
onClick={() => {
47+
const combinedIds = selectedResources.map((item) => item[config.features.exportToWorkspace.fillRequestFormCheckField]).join(',');
48+
const url = `${fillRequestFormURL}?query=${encodeURIComponent(combinedIds)}`;
49+
window.open(url, '_blank');
50+
}}
51+
type='default'
52+
className={`discovery-action-bar-button${(selectedResources.length === 0) ? '--disabled' : ''}`}
53+
disabled={selectedResources.length === 0}
54+
icon={<FileTextOutlined />}
55+
>
56+
{`Click Here to ${fillRequestFormDisplayText || 'Request Information'}`}
57+
</Button>
58+
59+
</Popover>
60+
);
61+
};
62+
63+
export default OpenFillRequestFormButton;

src/Discovery/DiscoveryConfig.d.ts

+6
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ export interface DiscoveryConfig {
1515
enableDownloadStudyMetadata?: boolean
1616
variableMetadataFieldName?: string
1717
enableDownloadVariableMetadata?: boolean
18+
enableFillRequestForm?: boolean
19+
fillRequestFormCheckField?: string
20+
fillRequestFormDisplayText?: string
21+
fillRequestFormURL?: string
22+
externalWebsiteName?: string
23+
externalWebsiteURL?: string
1824
},
1925
// explorationIntegration: {
2026
// enabled: boolean // not supported

src/Discovery/DiscoveryListView.tsx

+32-7
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ interface Props {
1818
setModalVisible: (boolean) => void;
1919
setModalData: (boolean) => void;
2020
selectedResources: any[];
21-
selectedTags: any [];
21+
selectedTags: any[];
2222
onResourcesSelected: (selectedResources: DiscoveryResource[]) => any;
2323
onTagsSelected: (selectedTags: any) => any;
2424
}
@@ -47,15 +47,28 @@ const DiscoveryListView: React.FunctionComponent<Props> = (props: Props) => {
4747
columns={props.columns}
4848
rowKey={props.config.minimalFieldMapping.uid}
4949
rowSelection={(
50-
props.config.features.exportToWorkspace
51-
&& props.config.features.exportToWorkspace.enabled
50+
(props.config.features.exportToWorkspace
51+
&& props.config.features.exportToWorkspace.enabled) || (props.config.features.exportToWorkspace?.enableFillRequestForm
52+
&& props.config.features.exportToWorkspace.enableFillRequestForm === true)
5253
) && {
5354
selectedRowKeys: props.selectedResources.map(
5455
(r) => r[props.config.minimalFieldMapping.uid],
5556
),
5657
renderCell: (_checked, _record, _index, node) => (
5758
<Tooltip
58-
title={`Click to select item for ${(props.config.features.exportToWorkspace.enableDownloadManifest || props.config.features.exportToWorkspace.enableDownloadZip) ? 'download or ' : ''}open in workspace`}
59+
title={`Click to select item for ${
60+
[
61+
props.config.features.exportToWorkspace.enableFillRequestForm
62+
? props.config.features.exportToWorkspace.fillRequestFormDisplayText?.toLowerCase()
63+
: '',
64+
(props.config.features.exportToWorkspace.enableDownloadManifest || props.config.features.exportToWorkspace.enableDownloadZip)
65+
? 'download'
66+
: '',
67+
'open in workspace'
68+
]
69+
.filter(Boolean)
70+
.join(' or ')
71+
}`}
5972
overlayStyle={{ maxWidth: '150px' }}
6073
>
6174
{node}
@@ -71,7 +84,19 @@ const DiscoveryListView: React.FunctionComponent<Props> = (props: Props) => {
7184
if (props.config.features.authorization.enabled) {
7285
disabled = (record[props.accessibleFieldName] !== AccessLevel.ACCESSIBLE) && (record[props.accessibleFieldName] !== AccessLevel.MIXED);
7386
}
74-
// disable checkbox if there's no manifest or external file metadata (if metadata handoff is enabled) found for this study
87+
88+
if (props.config.features.exportToWorkspace?.enableFillRequestForm) {
89+
disabled = false;
90+
const fillRequestFormCheckField = props.config.features.exportToWorkspace?.fillRequestFormCheckField;
91+
const fieldValue = fillRequestFormCheckField ? record[fillRequestFormCheckField] : null;
92+
93+
// Disable checkbox if the specified field is empty or missing in the record
94+
if (!fieldValue || fieldValue.length === 0) {
95+
disabled = true;
96+
}
97+
}
98+
99+
// disable checkbox if there's no manifest or git external file metadata (if metadata handoff is enabled) found for this study
75100
const exportToWorkspaceConfig = props.config.features.exportToWorkspace;
76101
const { manifestFieldName, enableExportFullMetadata } = exportToWorkspaceConfig;
77102
if (!record[manifestFieldName] || record[manifestFieldName].length === 0) {
@@ -135,7 +160,7 @@ const DiscoveryListView: React.FunctionComponent<Props> = (props: Props) => {
135160
}
136161
return (
137162
<React.Fragment key={value}>
138-
{ start > 0 && '...' }
163+
{start > 0 && '...'}
139164
{value.slice(start, matchIndex)}
140165
<span className='matched'>{value.slice(matchIndex,
141166
matchIndex + props.searchTerm.length)}
@@ -174,7 +199,7 @@ const DiscoveryListView: React.FunctionComponent<Props> = (props: Props) => {
174199
{studyPreviewTextArray.map((item: string | undefined) => renderValue(item))}
175200
</div>
176201
</div>
177-
{ config.features.tagsInDescription?.enabled
202+
{config.features.tagsInDescription?.enabled
178203
? (
179204
<div className='discovery-table__row-horizontal-content'>
180205
{(record[config.minimalFieldMapping.tagsListFieldName] || []).map(({ name, category }) => {

0 commit comments

Comments
 (0)