-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <[email protected]> * changes for tooltip if multiple flags are on * Update src/Discovery/DiscoveryListView.tsx Co-authored-by: Mingfei Shao <[email protected]> --------- Co-authored-by: Mingfei Shao <[email protected]>
- Loading branch information
Showing
5 changed files
with
111 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
src/Discovery/DiscoveryActionBar/components/OpenFillRequestFormButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import React from 'react'; | ||
import { FileTextOutlined } from '@ant-design/icons'; | ||
import { Popover, Button } from 'antd'; | ||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; | ||
|
||
const OpenFillRequestFormButton = (props) => { | ||
const { config, discovery } = props.props; | ||
|
||
// Check if Fill Request Form button should be disabled based on configuration | ||
const isFillRequestFormDisabled = !config?.features?.exportToWorkspace?.enableFillRequestForm | ||
|| !config.features.exportToWorkspace.fillRequestFormURL?.trim() | ||
|| !config.features.exportToWorkspace.externalWebsiteURL?.trim() | ||
|| !config.features.exportToWorkspace.externalWebsiteName?.trim(); | ||
|
||
if (isFillRequestFormDisabled) { | ||
return null; // Return early if any required config values are missing | ||
} | ||
|
||
// Define URLs and text for use in the popover and button | ||
const { | ||
fillRequestFormURL, externalWebsiteURL, externalWebsiteName, fillRequestFormDisplayText, | ||
} = config.features.exportToWorkspace; | ||
const { selectedResources } = discovery; | ||
|
||
return ( | ||
<Popover | ||
className='discovery-popover' | ||
arrowPointAtCenter | ||
title={( | ||
<React.Fragment> | ||
| ||
<a target='_blank' rel='noreferrer' href={externalWebsiteURL}> | ||
{externalWebsiteName} | ||
</a> | ||
<FontAwesomeIcon icon={'external-link-alt'} /> | ||
</React.Fragment> | ||
)} | ||
content={( | ||
<span className='discovery-popover__text'> | ||
After filling the request form, once your search selection is approved, you can use the Gen3 Client | ||
to download the data from the selected studies to your local computer. | ||
</span> | ||
)} | ||
> | ||
<Button | ||
onClick={() => { | ||
const combinedIds = selectedResources.map((item) => item[config.features.exportToWorkspace.fillRequestFormCheckField]).join(','); | ||
const url = `${fillRequestFormURL}?query=${encodeURIComponent(combinedIds)}`; | ||
window.open(url, '_blank'); | ||
}} | ||
type='default' | ||
className={`discovery-action-bar-button${(selectedResources.length === 0) ? '--disabled' : ''}`} | ||
disabled={selectedResources.length === 0} | ||
icon={<FileTextOutlined />} | ||
> | ||
{`Click Here to ${fillRequestFormDisplayText || 'Request Information'}`} | ||
</Button> | ||
|
||
</Popover> | ||
); | ||
}; | ||
|
||
export default OpenFillRequestFormButton; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters