From 585972d081fe88cd8f91e6dfa62675b1bb259724 Mon Sep 17 00:00:00 2001 From: Upendra Kumbham Date: Tue, 30 Jan 2024 11:22:42 +0000 Subject: [PATCH] Add fubctions to validate tabs and it's props --- .../src/ExperimentPageRouter.js | 38 +++++++++++++++++-- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/app/src/main/javascript/bundles/experiment-page/src/ExperimentPageRouter.js b/app/src/main/javascript/bundles/experiment-page/src/ExperimentPageRouter.js index 9878c50e7..ffe859b19 100644 --- a/app/src/main/javascript/bundles/experiment-page/src/ExperimentPageRouter.js +++ b/app/src/main/javascript/bundles/experiment-page/src/ExperimentPageRouter.js @@ -26,6 +26,39 @@ const TabCommonPropTypes = { // What component each tab type should render, coupled to ExperimentController.java let tabTypeComponent = [] +function validateCommonRequiredProps({speciesName},{atlasUrl},{experimentAccession}) { + if ( (typeof speciesName == 'string' && speciesName instanceof String) && + (typeof atlasUrl == 'string' && atlasUrl instanceof String) && + (typeof experimentAccession == 'string' && experimentAccession instanceof String)) { + return true; + } + else return false; +} + +function validateTab({tabType}) { + if (tabType === 'results') { + if ( validateCommonRequiredProps({speciesName},atlasUrl,experimentAccession) && Array.isArray(tab.props.ks)) { + console.log("result **************",tabTypeComponent.push({'results' : TSnePlotViewRoute})) + } + } + else if (tabType === 'experiment-design') { + if (Array.isArray(tab.props.table.data) && validateCommonRequiredProps({speciesName},{atlasUrl},{experimentAccession})) { + console.log("experiment-design **************",tabTypeComponent.push({'experiment-design' : ExperimentDesignRoute})); + } + } + else if(tabType === 'supplementary-information') { + if (Array.isArray(tab.props.sections) && validateCommonRequiredProps({speciesName},{atlasUrl},{experimentAccession})) { + console.log("supplementary-information **************", tabTypeComponent.push({'supplementary-information' : SupplementaryInformationRoute})) + } + } + else { + if (Array.isArray(tab.props.data) && validateCommonRequiredProps({speciesName},{atlasUrl},{experimentAccession})) { + console.log('download********', tabTypeComponent.push({'resources' : DownloadsRoute})) + } + } +} + + const TopRibbon = ({tabs, routeProps}) =>