Skip to content

Commit

Permalink
Add fubctions to validate tabs and it's props
Browse files Browse the repository at this point in the history
  • Loading branch information
upendrakumbham committed Jan 30, 2024
1 parent aa55ced commit 585972d
Showing 1 changed file with 34 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,47 @@ 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}) =>
<ul className={`tabs`}>
{
tabs.map((tab) =>
<li title={tab.name} key={tab.type} className={`tabs-title`}>
{
tab.type === 'results' && Array.isArray(tab.props.ks) ? console.log("result1 **************", tabTypeComponent.push({'results' : TSnePlotViewRoute})) :
tab.type === 'experiment-design' && Array.isArray(tab.props.table.data) ? console.log("result2 **************",tabTypeComponent.push({'experiment-design' : ExperimentDesignRoute})) :
tab.type === 'supplementary-information' && Array.isArray(tab.props.sections) ? console.log("result3 **************", tabTypeComponent.push({'supplementary-information' : SupplementaryInformationRoute})) :
tab.type === 'resources'&& Array.isArray(tab.props.data)? console.log('result4********', tabTypeComponent.push({'resources' : DownloadsRoute})): ""
validateTab(tab.type)
}
<NavLink to={{pathname:`/${tab.type}`, search: routeProps.location.search, hash: routeProps.location.hash}}
activeClassName={`active`}>
Expand Down

0 comments on commit 585972d

Please sign in to comment.