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

Automated copy feat/b3 walder discovery prc 2 #1627

Closed
wants to merge 35 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
44e7a73
new changes for B3 WALDER project to make changes for discovery porta…
urvi-occ Jun 17, 2024
9f93dc4
Merge branch 'uc-cdis:master' into feat/b3_walder_discovery_prc_2
urvi-occ Jul 29, 2024
9cfd4f4
spacing changes for code
urvi-occ Jul 31, 2024
1734c4f
Merge branch 'master' into feat/b3_walder_discovery_prc_2
urvi-occ Oct 15, 2024
9eb64b4
changes suggested by mingfei
urvi-occ Oct 22, 2024
3030cab
Merge branch 'feat/b3_walder_discovery_prc_2' of https://github.com/u…
urvi-occ Oct 22, 2024
99cd275
Merge branch 'uc-cdis:master' into feat/b3_walder_discovery_prc_2
urvi-occ Oct 22, 2024
4bd6079
Merge remote-tracking branch 'origin/feat/b3_walder_discovery_prc_2' …
urvi-occ Oct 22, 2024
51c1e5d
Merge branch 'uc-cdis:master' into feat/b3_walder_discovery_prc_2
urvi-occ Oct 24, 2024
e6698da
Merge branch 'uc-cdis:master' into feat/b3_walder_discovery_prc_2
urvi-occ Oct 31, 2024
4765bd7
changes made after mingfei's comments and meeting
urvi-occ Oct 31, 2024
56b6589
Merge branch 'feat/b3_walder_discovery_prc_2' of https://github.com/u…
urvi-occ Oct 31, 2024
b951783
eslint on openfillrequestformbutton
urvi-occ Nov 4, 2024
07652f2
added missing variables in discovey config
urvi-occ Nov 4, 2024
7bc0143
added null condition and ran eslint
urvi-occ Nov 4, 2024
ebda0b2
Merge branch 'master' into feat/b3_walder_discovery_prc_2
urvi-occ Nov 4, 2024
cf1e07a
added check for null to pass npm test
urvi-occ Nov 4, 2024
444d913
added check for null to pass npm test
urvi-occ Nov 4, 2024
27a9219
Merge remote-tracking branch 'origin/feat/b3_walder_discovery_prc_2' …
urvi-occ Nov 4, 2024
8d54fce
refactor: simplify button logic by removing redundant check
urvi-occ Nov 6, 2024
fefcd59
refactor: remove redundant check from disabled condition
urvi-occ Nov 6, 2024
f0b0974
Merge branch 'master' into feat/b3_walder_discovery_prc_2
urvi-occ Nov 6, 2024
88c751f
changes for failing test
urvi-occ Nov 7, 2024
df82da9
new variable fillRequestFormCheckField added
urvi-occ Nov 7, 2024
4663d91
changes for if condition
urvi-occ Nov 7, 2024
7831fe3
if condition fixes
urvi-occ Nov 7, 2024
c3e57f7
new property added to allow checkboxes if not logged in
urvi-occ Nov 7, 2024
e66e793
revert change
urvi-occ Nov 7, 2024
e0cc0d7
removed extra space
urvi-occ Nov 7, 2024
b1e14b9
changed text for tooltip
urvi-occ Nov 8, 2024
2b46749
fixes for props variable
urvi-occ Nov 8, 2024
2a94589
Update src/Discovery/DiscoveryActionBar/components/OpenFillRequestFor…
urvi-occ Nov 11, 2024
657bd31
changes for tooltip if multiple flags are on
urvi-occ Nov 11, 2024
f82879e
Merge branch 'master' into feat/b3_walder_discovery_prc_2
urvi-occ Nov 11, 2024
3252870
Update src/Discovery/DiscoveryListView.tsx
urvi-occ Nov 11, 2024
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
6 changes: 6 additions & 0 deletions docs/portal_config.md
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,12 @@ Below is an example, with inline comments describing what each JSON block config
"enable": true,
"enableDownloadManifest": true, // enables a button which allows user to download a manifest file for gen3 client
"downloadManifestButtonText": "Download Manifest", // text to be displayed on the download manifest button
"enableFillRequestForm" : true, // enables a button which opens a new form to request access to a resoruce
"fillRequestFormDisplayText": "Request Information", // text to be displayed on fill the request form
"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¸
"fillRequestFormURL" : "https://URL/form", // URL to the new form which would be used to fill the form
"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
"externalWebsiteURL" : "", // URL of external website needed, this variable is used with externalWebsiteName be loaded only if enableFillRequestForm is true
"manifestFieldName": "__manifest", // the field in the Discovery page data that contains the list of GUIDs that link to each study's data files.
"enableDownloadZip": true, // enables a button which allows user to download all the files as a zip file (with pre-set size limits)
"downloadZipButtonText": "Download Zip", // text to be displayed on the download zip file button
Expand Down
4 changes: 4 additions & 0 deletions src/Discovery/DiscoveryActionBar/DiscoveryActionBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { BATCH_EXPORT_JOB_PREFIX, JOB_POLLING_INTERVAL } from './DiscoveryAction
import DownloadZipButton from './components/DownloadZipButton';
import ExportToWorkspaceButton from './components/ExportToWorkspaceButton';
import DownloadManifestButton from './components/DownloadManifestButton';
import OpenFillRequestFormButton from './components/OpenFillRequestFormButton';

/* eslint react/prop-types: 0 */
interface Props {
Expand Down Expand Up @@ -193,6 +194,9 @@ const DiscoveryActionBar = (props: Props) => {
history={history}
location={location}
/>
<OpenFillRequestFormButton
props={props}
/>
</Space>
</div>
</React.Fragment>
Expand Down
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>
&nbsp;
<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;
6 changes: 6 additions & 0 deletions src/Discovery/DiscoveryConfig.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ export interface DiscoveryConfig {
enableDownloadStudyMetadata?: boolean
variableMetadataFieldName?: string
enableDownloadVariableMetadata?: boolean
enableFillRequestForm?: boolean
fillRequestFormCheckField?: string
fillRequestFormDisplayText?: string
fillRequestFormURL?: string
externalWebsiteName?: string
externalWebsiteURL?: string
},
// explorationIntegration: {
// enabled: boolean // not supported
Expand Down
39 changes: 32 additions & 7 deletions src/Discovery/DiscoveryListView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ interface Props {
setModalVisible: (boolean) => void;
setModalData: (boolean) => void;
selectedResources: any[];
selectedTags: any [];
selectedTags: any[];
onResourcesSelected: (selectedResources: DiscoveryResource[]) => any;
onTagsSelected: (selectedTags: any) => any;
}
Expand Down Expand Up @@ -47,15 +47,28 @@ const DiscoveryListView: React.FunctionComponent<Props> = (props: Props) => {
columns={props.columns}
rowKey={props.config.minimalFieldMapping.uid}
rowSelection={(
props.config.features.exportToWorkspace
&& props.config.features.exportToWorkspace.enabled
(props.config.features.exportToWorkspace
&& props.config.features.exportToWorkspace.enabled) || (props.config.features.exportToWorkspace?.enableFillRequestForm
&& props.config.features.exportToWorkspace.enableFillRequestForm === true)
) && {
selectedRowKeys: props.selectedResources.map(
(r) => r[props.config.minimalFieldMapping.uid],
),
renderCell: (_checked, _record, _index, node) => (
<Tooltip
title={`Click to select item for ${(props.config.features.exportToWorkspace.enableDownloadManifest || props.config.features.exportToWorkspace.enableDownloadZip) ? 'download or ' : ''}open in workspace`}
title={`Click to select item for ${
[
props.config.features.exportToWorkspace.enableFillRequestForm
? props.config.features.exportToWorkspace.fillRequestFormDisplayText?.toLowerCase()
: '',
(props.config.features.exportToWorkspace.enableDownloadManifest || props.config.features.exportToWorkspace.enableDownloadZip)
? 'download'
: '',
'open in workspace'
]
.filter(Boolean)
.join(' or ')
}`}
overlayStyle={{ maxWidth: '150px' }}
>
{node}
Expand All @@ -71,7 +84,19 @@ const DiscoveryListView: React.FunctionComponent<Props> = (props: Props) => {
if (props.config.features.authorization.enabled) {
disabled = (record[props.accessibleFieldName] !== AccessLevel.ACCESSIBLE) && (record[props.accessibleFieldName] !== AccessLevel.MIXED);
}
// disable checkbox if there's no manifest or external file metadata (if metadata handoff is enabled) found for this study

if (props.config.features.exportToWorkspace?.enableFillRequestForm) {
disabled = false;
const fillRequestFormCheckField = props.config.features.exportToWorkspace?.fillRequestFormCheckField;
const fieldValue = fillRequestFormCheckField ? record[fillRequestFormCheckField] : null;

// Disable checkbox if the specified field is empty or missing in the record
if (!fieldValue || fieldValue.length === 0) {
disabled = true;
}
}

// disable checkbox if there's no manifest or git external file metadata (if metadata handoff is enabled) found for this study
const exportToWorkspaceConfig = props.config.features.exportToWorkspace;
const { manifestFieldName, enableExportFullMetadata } = exportToWorkspaceConfig;
if (!record[manifestFieldName] || record[manifestFieldName].length === 0) {
Expand Down Expand Up @@ -135,7 +160,7 @@ const DiscoveryListView: React.FunctionComponent<Props> = (props: Props) => {
}
return (
<React.Fragment key={value}>
{ start > 0 && '...' }
{start > 0 && '...'}
{value.slice(start, matchIndex)}
<span className='matched'>{value.slice(matchIndex,
matchIndex + props.searchTerm.length)}
Expand Down Expand Up @@ -174,7 +199,7 @@ const DiscoveryListView: React.FunctionComponent<Props> = (props: Props) => {
{studyPreviewTextArray.map((item: string | undefined) => renderValue(item))}
</div>
</div>
{ config.features.tagsInDescription?.enabled
{config.features.tagsInDescription?.enabled
? (
<div className='discovery-table__row-horizontal-content'>
{(record[config.minimalFieldMapping.tagsListFieldName] || []).map(({ name, category }) => {
Expand Down
Loading