-
Notifications
You must be signed in to change notification settings - Fork 5
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
Decoupling tabs in the experiment page and display them after validating #375
base: develop
Are you sure you want to change the base?
Decoupling tabs in the experiment page and display them after validating #375
Conversation
…validate-before-displaying
The conditional operator hierachy looks good and we need to apply more props check for each tab I think. |
Sure, thanks for the review and comment. |
|
||
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})) : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@upendrakumbham Could you clean this code please? We are watching Uncle Bob's Clean Code videos to apply his teaching in our every day coding.
I would like you to find yourself why this code is not clean and I would like you to change it. It is not that hard.
If you struggle with it, then please ping me and I can help, but I would really like to see that you can do it yourself.
Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as per @lingyun1010 review comment, I have created JS functions to validate tabs and it's props.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please review and provide comments
'downloads' : DownloadsRoute | ||
let tabTypeComponent = [] | ||
|
||
function validateCommonRequiredProps({speciesName},{atlasUrl},{experimentAccession}) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am a bit confused why we need this function at all.
We defined the types of the props in the definition of the prop types and we also defined whether they are required or not.
Why do we need another way to validate all of these again?
@karoy, please review this PR. My local setup has throwing 8000 port already bind issue when I try to test this PR. I will fix it and test, meanwhile suggest issue local experiment. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added 2 comments that I would like to consider.
Thanks for your work on this
|
||
function enableExperimentPageTab(tab) { | ||
if (tab.type === 'results') { | ||
if (Array.isArray(tab.props.ks) && (tab.props.plotTypesAndOptions)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be cleaned a bit more:
- it is repetitive
- part of the validation can be extracted to a well named function to make it clean what it is doing and hide the details
tabTypeComponent.push({'supplementary-information': SupplementaryInformationRoute}) | ||
return tab.name; | ||
} | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if we are going to have a new tab.type
?
For example this experiment also has a Plots
tab.
With this current code it is going to be a download
tab.
Could you please think it over if that's exactly we want here or something else?
Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got what you mean, I will work on this and let you know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check my comments regarding the array tabTypeComponent
app/src/main/javascript/bundles/experiment-page/src/ExperimentPageRouter.js
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a longish comment.
Could you please consider them?
Ping me if you don't understand me.
Thanks
app/src/main/javascript/bundles/experiment-page/src/ExperimentPageRouter.js
Outdated
Show resolved
Hide resolved
const supplementaryInformationTab = 'supplementary-information' | ||
const downloadTab = 'resources' | ||
|
||
if (isThisTabType(tab, resultTab)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like you to change/refactor this conditional if
statement and NOT using any conditional statements at all.
There is a much better way to do it and the code would be much sorter and cleaner.
Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I will improve it.
const downloadTab = 'resources' | ||
|
||
if (isThisTabType(tab, resultTab)) { | ||
if (!isObjectEmpty(tab.props.ks) && Array.isArray(tab.props.ks) && !isObjectEmpty(tab.props.plotTypesAndOptions)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest to add these kind of checks to the prop types definition.
That is true in the below lines, too.
Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added 2 requests that I would like you to change to make the code cleaner.
Many thanks
Hi both, I improved the code. Please re-review and add your comments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added some comments. Could you please review and consider them?
Thanks
match: PropTypes.object.isRequired, | ||
location: PropTypes.object.isRequired, | ||
history: PropTypes.object.isRequired | ||
match: PropTypes.object.isRequired, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To clean the code and make this file smaller, I would externalise all the proptypes
to another file.
|
||
const getNestedProperty = (obj, path) => path.split('.').reduce((acc, key) => acc?.[key], obj); | ||
|
||
const isNonEmptyArray = (value) => !isObjectEmpty(value) && Array.isArray(value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we move this code: Array.isArray(value)
into its relevant proptype
definition?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is one of the validation checks before displaying a relevant tab. We are getting empty for some experiments.
const propValue = getNestedProperty(tab.props, key); | ||
const optionsValue = optionsKey ? getNestedProperty(tab.props, optionsKey) : true; | ||
|
||
if (isNonEmptyArray(propValue) && (!optionsKey || !isObjectEmpty(optionsValue))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens in isObjectEmpty(optionsValue)
if the optionsValue
is true
?
|
||
const isNonEmptyArray = (value) => !isObjectEmpty(value) && Array.isArray(value); | ||
|
||
const enableExperimentPageTab = (tab) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole function is a bit too complex for me and hard to understand what is happening inside this function. It is really hard to follow.
I am happy to work together on this code and make it more simpler, more understandable.
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, we will. Thanks. We will do Monday. I will try to improve variable naming.
search: PropTypes.string.isRequired, | ||
hash: PropTypes.string.isRequired | ||
}).isRequired | ||
pathname: PropTypes.string.isRequired, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The proptypes
are all over this JS file.
As I already mentioned, I would externalise them to a separate file and import them into this one.
That would make this file more clear.
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with you, I will try to do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
proptypes
are all over this JS file.
As I already mentioned, I would externalise them to a separate file and import them into this one.
That would make this file more clear.
What do you think?
This one is fixed. Please have a look.
…ageRouter.js file cleanup
…s file cleanup to reduce it's size for the future maintenance
Good work and I have a few comments listed below:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the current implementation, you are just considering decoupling from the top ribbon tabs, i.e., Results
, Supplementary Infomation
and Download
, but I think we should also consider to decouple the tabs in Results
page, i.e. Cell-plots
, Maker Genes
and Anatomogram
. If one of the side-tabs has missing props, we should still keep the others and leave Results
top tab alive. If all the side tabs have missing props, then we remove the Results
top tab as you implemented now.
Hi @lingyun1010, gathered all the required validation fields to validate and display their corresponding tabs. Here is the document: Frontend_tab_validations.docx |
Decoupling tabs in the experiment page and display them after validating