Skip to content

Commit

Permalink
Add empty object check and null, undefined function and update tab va…
Browse files Browse the repository at this point in the history
…lidations
  • Loading branch information
upendrakumbham committed Feb 19, 2024
1 parent 1f9aa46 commit 2c05e1a
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,29 +30,37 @@ function isThistabType(tab,tabType) {
return tab.type === tabType;
}

const isObjectEmpty = (objectName) => {
return (
objectName &&
Object.keys(objectName).length === 0 &&
objectName.constructor === Object
);
};

function enableExperimentPageTab(tab) {
const resultTab = 'results'
const experimentDesignTab = 'experiment-design'
const supplementaryInformationTab = 'supplementary-information'
const downloadTab = 'resources'

if (isThistabType(tab, resultTab)) {
if (Array.isArray(tab.props.ks) && (tab.props.plotTypesAndOptions)) {
if (!isObjectEmpty(tab.props.ks) && Array.isArray(tab.props.ks) && !isObjectEmpty(tab.props.plotTypesAndOptions)) {
tabTypeComponent.push({resultTab : TSnePlotViewRoute})
return tab.name;
}
} else if (isThistabType(tab, experimentDesignTab)) {
if (Array.isArray(tab.props.table.data)) {
if (!isObjectEmpty(tab.props.table.data) && Array.isArray(tab.props.table.data)) {
tabTypeComponent.push({experimentDesignTab : ExperimentDesignRoute})
return tab.name;
}
} else if (isThistabType(tab, supplementaryInformationTab)) {
if (Array.isArray(tab.props.sections)) {
if (!isObjectEmpty(tab.props.sections) && Array.isArray(tab.props.sections)) {
tabTypeComponent.push({supplementaryInformationTab : SupplementaryInformationRoute})
return tab.name;
}
} else if (isThistabType(tab, downloadTab)) {
if (Array.isArray(tab.props.data)) {
if (!isObjectEmpty(tab.props.data) && Array.isArray(tab.props.data)) {
tabTypeComponent.push({'resources': DownloadsRoute})
return tab.name;
}
Expand Down

0 comments on commit 2c05e1a

Please sign in to comment.