-
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
Signed-off-by: upendrakumbham <[email protected]>
…validate-before-displaying
Signed-off-by: upendrakumbham <[email protected]>
Signed-off-by: upendrakumbham <[email protected]>
Signed-off-by: upendrakumbham <[email protected]>
Signed-off-by: upendrakumbham <[email protected]>
…nload' tabs Signed-off-by: upendrakumbham <[email protected]>
Signed-off-by: upendrakumbham <[email protected]>
…n any one of the inner tabs visibility Signed-off-by: upendrakumbham <[email protected]>
Signed-off-by: upendrakumbham <[email protected]>
Signed-off-by: upendrakumbham <[email protected]>
Signed-off-by: upendrakumbham <[email protected]>
Signed-off-by: upendrakumbham <[email protected]>
…tab validation of Annadata experiment Signed-off-by: upendrakumbham <[email protected]>
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.
A general review comment first: please remove any developing test codes, such as console.log
, and remove ;
after command to keep the same coding style.
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 I started to review this PR, but I think either I don't really understand the intention of your code or it has some misunderstanding from your side. I have not finished the review as we need to clear the above mentioned misunderstanding.
Overall: the code is not very clean. It needs a lot of refactoring.
I would like to have a call to discuss how to go further with this PR.
Thanks
app/src/main/javascript/bundles/experiment-page/src/ExperimentPageRouter.js
Outdated
Show resolved
Hide resolved
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.
I don't know what you meant by This one is fixed
. Sadly nothing has changed here.
Signed-off-by: upendrakumbham <[email protected]>
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.
Some code formats and data type improvements, apart from the functionality fix I commented before. Besides, we don't have to push any changes to package-lock.json
, or we don't need to have them in the repo at all actually, so please also remove any commits on pakcage-lock.json
to keep your PR more clean and slim.
return false | ||
} | ||
} | ||
}); |
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.
;
nearby here, please remove.
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.
Sorry, I didn't commit TsnePlotViewRouter
before your review. Now I fixed all format issues as you mentioned here for both files
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 search for ;
, so no more
|
||
const [enableResultTab, setEnableResultTab] = useState(false) | ||
|
||
|
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.
Extra empty lines. Please check your codes and make it as clean as possible, I also noticed, you've changed some original codes indention. Please double check the commands you've modified, maybe it's easier to be observed in github.
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.
Removed
@@ -48,10 +49,20 @@ class TSnePlotViewRoute extends React.Component { | |||
} | |||
|
|||
render() { | |||
|
|||
console.log(this.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 deleted testing logs while developing.
const { location, match, history } = this.props | ||
const { atlasUrl, suggesterEndpoint, defaultPlotMethodAndParameterisation } = this.props | ||
const { species, experimentAccession, accessKey, ks, ksWithMarkerGenes, plotTypesAndOptions, metadata, anatomogram } = this.props | ||
const search = URI(location.search).search(true) | ||
if(species === `homo sapiens` && Object.keys(anatomogram).length >0){ |
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 add a space after >
for better coding style.
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.
Also we would use spece before (
and after )
with if condition. Please fix the same code format like this.
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.
Many ;
has not been removed in this file at least, please double check for all files.
|
||
export const isEmptyArray = (value) => isObjectEmpty(value) && Array.isArray(value); | ||
|
||
export const tabValidations = new Map([ |
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.
You can use object
data type for tabValidations
, tabCommonValidations
and innerTabValidations
, which is more common and easier for implementing and understanding.
@@ -15,8 +15,6 @@ services: | |||
extends: | |||
service: gradle | |||
file: docker-compose-gradle.yml | |||
ports: |
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.
Is this a mistake? Please revert it back. And Line 32, 33.
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.
We don't need ports snippet in this build-all yml file , ok I can revert to remove confusion.
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.
If we have this, we getting error while running SCXA containers in my Laptop at least.
Signed-off-by: upendrakumbham <[email protected]>
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 lot of change requests.
It is probably the 1st round. If the code is getting cleaner, we might need another refactor.
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.
Could you group together the code parts that belongs to PropTypes
?
Thanks
const propValue = commonProps.valueOf(commonProp); | ||
if (propValue === 'undefined' || propValue == '' || propValue == null) { | ||
console.log(`${tab.type} data missing the required value for the attribute ${commonProp}`); | ||
shouldRender = false; |
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 unnecessary, in the next line we return with false
and the local variable shouldRender
won't be used.
if (propValue === 'undefined' || propValue == '' || propValue == null) { | ||
console.log(`${tab.type} data missing the required value for the attribute ${commonProp}`); | ||
shouldRender = false; | ||
return false; |
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 going to return false
and this tab won't be rendered, but there is no message for the user why that tab is not rendered.
Is that what we want?
If yes, then this validation is already happening with the PropTypes
required
parameter, AFAIK.
I am a bit confused why we need this.
let tableHeader = []; | ||
let TableData = []; | ||
|
||
if (isEmptyArray(table)) { |
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 you just defined table
as an empty array: [] this should be always true.
Please remove this line.
Thanks
return false; // Early return on failure | ||
} | ||
} | ||
if (isEmptyArray(tableHeader)) { |
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 same as with the table
var.
As you just defined tableHeader
as an empty array: [] this should be always true.
Please remove this line.
Thanks
if (requiredProp === 'defaultPlotMethodAndParameterisation') { | ||
console.log("defaultPlotMethodAndParameterisation"+JSON.stringify(defaultPlotMethodAndParameterisation)) | ||
if (defaultPlotMethodAndParameterisation.length == 0) { | ||
console.log(`${route.title}: Missing selectedPlotOption and selectedPlotType data`); |
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.
Could you remove this line, please?
|
||
if (requiredProp === 'suggesterEndpoint') { | ||
if (suggesterEndpoint.length == 0) { | ||
console.log(route.title + " suggesterEndpoint doesn't have data"); |
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.
Could you remove this line, please?
if (suggesterEndpoint.length == 0) { | ||
console.log(route.title + " suggesterEndpoint doesn't have data"); | ||
shouldHideTab = true | ||
return false; |
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.
Is it not true
?
|
||
function shouldHideMarkerGenesTab(route, props) { | ||
const requiredProps = innerTabValidations.get(route.title); | ||
let shouldHideTab = false; |
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.
We don't need this shouldHideTab
variable.
If we got to line 342 (if (shouldHideTab == false)), then this variable is false anyway as nothing changed it from its initial value.
You can remove it without any effect.
Thanks
} | ||
} | ||
}); | ||
console.log("Marker genes tab: " + shouldHideTab) |
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.
Could you remove this line, please?
Signed-off-by: upendrakumbham <[email protected]>
Signed-off-by: upendrakumbham <[email protected]>
…validate-before-displaying
Decoupling tabs in the experiment page and display them after validating
Requirements:
- Result, supplementary and download
Cell-plots part of the Results tab
MarkerGenes and Anatomogram tabs
Error message: Error-Something went wrong. There is no data to display. Please contact the team - ](https://www.ebi.ac.uk/about/contact/support/gxasc).