From e0a7ee36084e535b1f73e32ce434998572191823 Mon Sep 17 00:00:00 2001 From: koflaher Date: Tue, 8 Aug 2023 16:49:03 -0400 Subject: [PATCH 1/5] WIP visibility updates --- src/pages/DatasetCatalog.js | 142 +++++++----------------------------- 1 file changed, 26 insertions(+), 116 deletions(-) diff --git a/src/pages/DatasetCatalog.js b/src/pages/DatasetCatalog.js index 7f0a646b0..ea65d7ab3 100644 --- a/src/pages/DatasetCatalog.js +++ b/src/pages/DatasetCatalog.js @@ -27,6 +27,16 @@ const canApplyForDataset = (dataset) => { return dataset.active && !isNil(dataset.dacId); }; + +// add condition based on dac vote decision: +// if vote === true -> disabled = publicVisibility +const isVisible = (dataset) => { + // need to get study? need to get correct study info to get public visibility + //const publicVisibility = dataset.study?.publicVisibility; + // return dataset.dacApproval ? dataset.study?.publicVisibility : false; + return dataset.dacApproval && dataset.active; +}; + export default function DatasetCatalog(props) { const { @@ -61,9 +71,9 @@ export default function DatasetCatalog(props) { // Modal States const [showConnectDataset, setShowConnectDataset] = useState(false); - const [showDatasetDisable, setShowDatasetDisable] = useState(false); + //const [showDatasetDisable, setShowDatasetDisable] = useState(false); const [showDatasetDelete, setShowDatasetDelete] = useState(false); - const [showDatasetEnable, setShowDatasetEnable] = useState(false); + //const [showDatasetEnable, setShowDatasetEnable] = useState(false); const [showDatasetEdit, setShowDatasetEdit] = useState(false); const [showTranslatedDULModal, setShowTranslatedDULModal] = useState(false); @@ -225,16 +235,6 @@ export default function DatasetCatalog(props) { setSelectedDatasetId(datasetId); }; - const openEnable = (datasetId) => () => { - setShowDatasetEnable(true); - setSelectedDatasetId(datasetId); - }; - - const openDisable = (datasetId) => () => { - setShowDatasetDisable(true); - setSelectedDatasetId(datasetId); - }; - const dialogHandlerDelete = async (e) => { const answer = getBooleanFromEventHtmlDataValue(e); if (answer) { @@ -253,42 +253,6 @@ export default function DatasetCatalog(props) { } }; - const dialogHandlerEnable = async(e) => { - const answer = getBooleanFromEventHtmlDataValue(e); - if (answer) { - DataSet.disableDataset(selectedDatasetId, true).then(() => { - getDatasets(); - setShowDatasetEnable(false); - }).catch(() => { - setShowDatasetEnable(true); - setErrorMessage('Please try again later.'); - setErrorTitle('Something went wrong'); - }); - } else { - setShowDatasetEnable(false); - setErrorMessage(undefined); - setErrorTitle(undefined); - } - }; - - const dialogHandlerDisable = async (e) => { - const answer = getBooleanFromEventHtmlDataValue(e); - if (answer) { - DataSet.disableDataset(selectedDatasetId, false).then(() => { - getDatasets(); - setShowDatasetDisable(false); - }).catch(() => { - setShowDatasetDisable(true); - setErrorMessage('Please try again later.'); - setErrorTitle('Something went wrong'); - }); - } else { - setShowDatasetDisable(false); - setErrorMessage(undefined); - setErrorTitle(undefined); - } - }; - const dialogHandlerEdit = async (e) => { const answer = getBooleanFromEventHtmlDataValue(e); if (answer) { @@ -382,7 +346,7 @@ export default function DatasetCatalog(props) { }; const inactiveCheckboxStyle = (dataset) => { - if (!dataset.active) { + if (!isVisible(dataset)) { return {cursor: 'default', opacity: '50%'}; } return {}; @@ -652,28 +616,6 @@ export default function DatasetCatalog(props) { }) ]), - a({ - id: trIndex + '_btnDisable', name: 'btn_disable', isRendered: dataset.active, - onClick: openDisable(dataset.dataSetId), - disabled: !isEditDatasetEnabled(dataset) - }, [ - span({ - className: `cm-icon-button glyphicon glyphicon-ok-circle caret-margin ${color}-color`, 'aria-hidden': 'true', - 'data-tip': 'Disable dataset', 'data-for': 'tip_disable' - }) - ]), - - a({ - id: trIndex + '_btnEnable', name: 'btn_enable', isRendered: !dataset.active, - onClick: openEnable(dataset.dataSetId), - disabled: !isEditDatasetEnabled(dataset) - }, [ - span({ - className: 'cm-icon-button glyphicon glyphicon-ban-circle caret-margin cancel-color', 'aria-hidden': 'true', - 'data-tip': 'Enable dataset', 'data-for': 'tip_enable' - }) - ]), - a({ isRendered: currentUser.isAdmin, id: trIndex + '_btnConnect', name: 'btn_connect', @@ -690,7 +632,7 @@ export default function DatasetCatalog(props) { td({ id: dataset.datasetIdentifier + '_dataset', name: 'datasetIdentifier', - className: 'cell-size ' + (!dataset.active ? 'dataset-disabled' : ''), + className: 'cell-size ' + (!isVisible(dataset) ? 'dataset-disabled' : ''), style: tableBody }, [ dataset['Dataset ID'] @@ -698,39 +640,39 @@ export default function DatasetCatalog(props) { td({ id: trIndex + '_datasetName', name: 'datasetName', - className: 'cell-size ' + (!dataset.active ? !!'dataset-disabled' : ''), + className: 'cell-size ' + (!isVisible(dataset) ? !!'dataset-disabled' : ''), style: tableBody }, [findPropertyValue(dataset, 'Dataset Name')]), td({ id: trIndex + '_dac', name: 'dac', - className: 'cell-size ' + (!dataset.active ? 'dataset-disabled' : ''), + className: 'cell-size ' + (!isVisible(dataset) ? 'dataset-disabled' : ''), style: tableBody }, [ dataset['Data Access Committee'] ]), td({ - className: 'cell-size ' + (!dataset.active ? 'dataset-disabled' : ''), + className: 'cell-size ' + (!isVisible(dataset) ? 'dataset-disabled' : ''), style: tableBody }, [ getLinkDisplay(dataset, trIndex) ]), td({ - className: 'cell-size ' + (!dataset.active ? 'dataset-disabled' : ''), + className: 'cell-size ' + (!isVisible(dataset) ? 'dataset-disabled' : ''), style: tableBody }, [ a({ id: trIndex + '_linkTranslatedDul', name: 'link_translatedDul', onClick: () => openTranslatedDUL(dataset.dataUse), - className: (!dataset.active ? 'dataset-disabled' : 'enabled') + className: (!isVisible(dataset) ? 'dataset-disabled' : 'enabled') }, dataset.codeList) ]), td({ id: trIndex + '_dataType', name: 'dataType', - className: 'cell-size ' + (!dataset.active ? 'dataset-disabled' : ''), + className: 'cell-size ' + (!isVisible(dataset) ? 'dataset-disabled' : ''), style: tableBody }, [ findPropertyValue(dataset, 'Data Type') @@ -738,14 +680,14 @@ export default function DatasetCatalog(props) { td({ id: trIndex + '_phenotype', name: 'phenotype', - className: 'cell-size ' + (!dataset.active ? 'dataset-disabled' : ''), + className: 'cell-size ' + (!isVisible(dataset) ? 'dataset-disabled' : ''), style: tableBody }, [ dataset['Disease Studied'] ]), td({ - id: trIndex + '_pi', name: 'pi', className: 'cell-size ' + (!dataset.active ? 'dataset-disabled' : ''), + id: trIndex + '_pi', name: 'pi', className: 'cell-size ' + (!isVisible(dataset) ? 'dataset-disabled' : ''), style: tableBody }, [ dataset['Principal Investigator (PI)'] @@ -753,7 +695,7 @@ export default function DatasetCatalog(props) { td({ id: trIndex + '_participants', name: 'participants', - className: 'cell-size ' + (!dataset.active ? 'dataset-disabled' : ''), + className: 'cell-size ' + (!isVisible(dataset) ? 'dataset-disabled' : ''), style: tableBody }, [ dataset['# of Participants'] @@ -761,7 +703,7 @@ export default function DatasetCatalog(props) { td({ id: trIndex + '_description', name: 'description', - className: 'cell-size ' + (!dataset.active ? 'dataset-disabled' : ''), + className: 'cell-size ' + (!isVisible(dataset) ? 'dataset-disabled' : ''), style: tableBody }, [ findPropertyValue(dataset, 'Description') @@ -769,7 +711,7 @@ export default function DatasetCatalog(props) { td({ id: trIndex + '_species', name: 'species', - className: 'cell-size ' + (!dataset.active ? 'dataset-disabled' : ''), + className: 'cell-size ' + (!isVisible(dataset) ? 'dataset-disabled' : ''), style: tableBody }, [ findPropertyValue(dataset, 'Species') @@ -777,7 +719,7 @@ export default function DatasetCatalog(props) { td({ id: trIndex + '_depositor', name: 'depositor', - className: 'cell-size ' + (!dataset.active ? 'dataset-disabled' : ''), + className: 'cell-size ' + (!isVisible(dataset) ? 'dataset-disabled' : ''), style: tableBody }, [ dataset['Data Custodian'] @@ -841,24 +783,6 @@ export default function DatasetCatalog(props) { action: { label: 'Yes', handler: () => dialogHandlerDelete } }, [div({ className: 'dialog-description' }, ['Are you sure you want to delete this Dataset?']),]), - ConfirmationDialog({ - title: 'Disable Dataset Confirmation?', - color: 'dataset', - showModal: showDatasetDisable, - alertMessage: errorMessage, - alertTitle: errorTitle, - action: { label: 'Yes', handler: () => dialogHandlerDisable } - }, [div({ className: 'dialog-description' }, ['If you disable a Dataset, Researchers won\'t be able to request access on it from now on. New Access elections related to this dataset won\'t be available but opened ones will continue.']),]), - - ConfirmationDialog({ - title: 'Enable Dataset Confirmation?', - color: 'dataset', - alertMessage: errorMessage, - alertTitle: errorTitle, - showModal: showDatasetEnable, - action: { label: 'Yes', handler: () => dialogHandlerEnable } - }, [div({ className: 'dialog-description' }, ['If you enable a Dataset, Researchers will be able to request access on it from now on.']),]), - ConfirmationDialog({ title: 'Edit Dataset Confirmation?', color: 'dataset', @@ -882,20 +806,6 @@ export default function DatasetCatalog(props) { multiline: true, className: 'tooltip-wrapper' }), - h(ReactTooltip, { - id: 'tip_disable', - place: 'right', - effect: 'solid', - multiline: true, - className: 'tooltip-wrapper' - }), - h(ReactTooltip, { - id: 'tip_enable', - place: 'right', - effect: 'solid', - multiline: true, - className: 'tooltip-wrapper' - }), h(ReactTooltip, { id: 'tip_connect', place: 'right', From 446a74039d988b99093748efa8bbc890833145bf Mon Sep 17 00:00:00 2001 From: koflaher Date: Tue, 8 Aug 2023 16:50:44 -0400 Subject: [PATCH 2/5] remove commented lines --- src/pages/DatasetCatalog.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/pages/DatasetCatalog.js b/src/pages/DatasetCatalog.js index ea65d7ab3..52d166b8a 100644 --- a/src/pages/DatasetCatalog.js +++ b/src/pages/DatasetCatalog.js @@ -71,9 +71,7 @@ export default function DatasetCatalog(props) { // Modal States const [showConnectDataset, setShowConnectDataset] = useState(false); - //const [showDatasetDisable, setShowDatasetDisable] = useState(false); const [showDatasetDelete, setShowDatasetDelete] = useState(false); - //const [showDatasetEnable, setShowDatasetEnable] = useState(false); const [showDatasetEdit, setShowDatasetEdit] = useState(false); const [showTranslatedDULModal, setShowTranslatedDULModal] = useState(false); From a5f2f5456d8727ee10648d1d2c880d37337a21c4 Mon Sep 17 00:00:00 2001 From: koflaher Date: Wed, 9 Aug 2023 09:23:08 -0400 Subject: [PATCH 3/5] dataset visible dac approval & public vis --- src/pages/DatasetCatalog.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/pages/DatasetCatalog.js b/src/pages/DatasetCatalog.js index 52d166b8a..094382c53 100644 --- a/src/pages/DatasetCatalog.js +++ b/src/pages/DatasetCatalog.js @@ -27,14 +27,16 @@ const canApplyForDataset = (dataset) => { return dataset.active && !isNil(dataset.dacId); }; - -// add condition based on dac vote decision: -// if vote === true -> disabled = publicVisibility const isVisible = (dataset) => { - // need to get study? need to get correct study info to get public visibility - //const publicVisibility = dataset.study?.publicVisibility; - // return dataset.dacApproval ? dataset.study?.publicVisibility : false; - return dataset.dacApproval && dataset.active; + if(dataset.dacApproval) { + if(!isNil(dataset.study.publicVisibility)){ + return dataset.study?.publicVisibility && dataset.active; + } else { + return dataset.active; + } + } else { + return false; + } }; export default function DatasetCatalog(props) { From 3eb95eb17768308b8eaa94ffcff38a0a39a58c3d Mon Sep 17 00:00:00 2001 From: koflaher Date: Wed, 9 Aug 2023 10:42:05 -0400 Subject: [PATCH 4/5] update logic --- src/pages/DatasetCatalog.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/pages/DatasetCatalog.js b/src/pages/DatasetCatalog.js index 094382c53..aeea0c63f 100644 --- a/src/pages/DatasetCatalog.js +++ b/src/pages/DatasetCatalog.js @@ -27,15 +27,18 @@ const canApplyForDataset = (dataset) => { return dataset.active && !isNil(dataset.dacId); }; +const extractDatasetProp = (propertyName, dataset) => { + const property = find({ propertyName })(dataset.properties); + return property?.propertyValue; +}; + const isVisible = (dataset) => { - if(dataset.dacApproval) { - if(!isNil(dataset.study.publicVisibility)){ - return dataset.study?.publicVisibility && dataset.active; - } else { - return dataset.active; - } + const openAccess = extractDatasetProp('Open Access', dataset); + if(!isNil(openAccess)){ + // if open Access is false, dac approval required + return openAccess ? dataset.study.publicVisibility : (dataset.dacApproval && dataset.study.publicVisibility); } else { - return false; + return dataset.active; } }; From a7118f5c3485413adfd72b732c2d6d508c8e10b7 Mon Sep 17 00:00:00 2001 From: koflaher Date: Fri, 11 Aug 2023 15:45:55 -0400 Subject: [PATCH 5/5] adding null check on study --- src/pages/DatasetCatalog.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/DatasetCatalog.js b/src/pages/DatasetCatalog.js index aeea0c63f..afc5976d9 100644 --- a/src/pages/DatasetCatalog.js +++ b/src/pages/DatasetCatalog.js @@ -36,7 +36,7 @@ const isVisible = (dataset) => { const openAccess = extractDatasetProp('Open Access', dataset); if(!isNil(openAccess)){ // if open Access is false, dac approval required - return openAccess ? dataset.study.publicVisibility : (dataset.dacApproval && dataset.study.publicVisibility); + return openAccess ? dataset.study?.publicVisibility : (dataset.dacApproval && dataset.study?.publicVisibility); } else { return dataset.active; }