Skip to content
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

Open
wants to merge 40 commits into
base: develop
Choose a base branch
from

Conversation

upendrakumbham
Copy link
Contributor

@upendrakumbham upendrakumbham commented Dec 12, 2023

Decoupling tabs in the experiment page and display them after validating

Requirements:

- Result, supplementary and download

  • tabs validate based on required props and common props
  • Display a tab if all the validations are passed
  • Don't display a tab if the validations failed and give a message to the user about why the tab is not visible to the user

Cell-plots part of the Results tab

  • Validate as above tabs, and display or hide based on validation status.
  • E-ANND- (AnnData)- inferred cell type ontology and authors labels should available, cell-plots should display otherwise display an error message to the user and hide tab. Unsupervised clusters are optional for the validation.

MarkerGenes and Anatomogram tabs

  • If marker genes are unavailable for E-ANND- (AnnData) experiments, don’t show the marker genes tab to the user.
  • If anatomograms are not available for the experiments, hide the tab from the user. Don't give any information to the user, about why we are hiding the tab.
  • Cell-plots tab for the (AnnData) experiments , ks clusters not available, we should enable tab without these ks (skip validation for the ks for Anndata experiments)

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).

@upendrakumbham upendrakumbham self-assigned this Dec 12, 2023
@lingyun1010
Copy link
Contributor

The conditional operator hierachy looks good and we need to apply more props check for each tab I think.

@upendrakumbham
Copy link
Contributor Author

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})) :
Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor Author

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}) {
Copy link
Contributor

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?

@upendrakumbham upendrakumbham marked this pull request as ready for review February 13, 2024 10:32
@upendrakumbham
Copy link
Contributor Author

@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.

Copy link
Contributor

@ke4 ke4 left a 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)) {
Copy link
Contributor

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 {
Copy link
Contributor

@ke4 ke4 Feb 15, 2024

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

Copy link
Contributor Author

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.

@lingyun1010
Copy link
Contributor

lingyun1010 commented Feb 20, 2024

Please check the variable tabTypeComponent push logic, if you check/console log tabTypeComponent after each time you push a new item. You may find duplicate items as shown in my screenshot below. Secondly, when you try to click each tab the size of tabTypeComponent will increase too.

Screenshot 2024-02-20 at 18 35 25

@lingyun1010 lingyun1010 reopened this Feb 20, 2024
Copy link
Contributor

@lingyun1010 lingyun1010 left a 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

Copy link
Contributor

@ke4 ke4 left a 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

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]>
…tab validation of Annadata experiment

Signed-off-by: upendrakumbham <[email protected]>
Copy link
Contributor

@lingyun1010 lingyun1010 left a 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.

Copy link
Contributor

@ke4 ke4 left a 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

search: PropTypes.string.isRequired,
hash: PropTypes.string.isRequired
}).isRequired
pathname: PropTypes.string.isRequired,
Copy link
Contributor

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.

@lingyun1010
Copy link
Contributor

lingyun1010 commented Sep 10, 2024

I had a deeper review and I think it's better to leave some commets asap.

  1. I tested the Results tab props, including ks, ksWithMarkerGenes, metadata, plotTypesAndOptions, defaultPlotMethodAndParameterisation and anatomogram, by setting them as empty individually. As far as what I can see, the props plotTypesAndOptions and defaultPlotMethodAndParameterisation are not working properly. What we expect is if they are empty, we still show the anatomogram tab in Results tab, and the other horizontal tabs too. Please double check it and fix the senario.
  2. In the console, some logs are found but I don't think it's necessary for debugging or reporting, please take a look.
Screenshot 2024-09-10 at 11 59 38
  1. I made some changes on TSnePlotViewRoute.js for inferred cell type marker gene features, please pull the latest develop branch changes and install the latest version packages and also pay attention to the conflicts please.

Copy link
Contributor

@lingyun1010 lingyun1010 left a 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
}
}
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

; nearby here, please remove.

Copy link
Contributor Author

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

Copy link
Contributor Author

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)


Copy link
Contributor

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.

Copy link
Contributor Author

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)
Copy link
Contributor

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){
Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor

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([
Copy link
Contributor

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:
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

@upendrakumbham
Copy link
Contributor Author

I had a deeper review and I think it's better to leave some commets asap.

  1. I tested the Results tab props, including ks, ksWithMarkerGenes, metadata, plotTypesAndOptions, defaultPlotMethodAndParameterisation and anatomogram, by setting them as empty individually. As far as what I can see, the props plotTypesAndOptions and defaultPlotMethodAndParameterisation are not working properly. What we expect is if they are empty, we still show the anatomogram tab in Results tab, and the other horizontal tabs too. Please double check it and fix the senario.
  2. In the console, some logs are found but I don't think it's necessary for debugging or reporting, please take a look.
Screenshot 2024-09-10 at 11 59 38 3. I made some changes on `TSnePlotViewRoute.js` for inferred cell type marker gene features, please pull the latest develop branch changes and install the latest version packages and also pay attention to the conflicts please.

For point 1: the props defaultPlotMethodAndParameterisation are not working properly. I have some doubts about showing some existing code issues. Can we have a call around 1:30 pm if you are free to discuss.

@upendrakumbham
Copy link
Contributor Author

I had a deeper review and I think it's better to leave some commets asap.

  1. I tested the Results tab props, including ks, ksWithMarkerGenes, metadata, plotTypesAndOptions, defaultPlotMethodAndParameterisation and anatomogram, by setting them as empty individually. As far as what I can see, the props plotTypesAndOptions and defaultPlotMethodAndParameterisation are not working properly. What we expect is if they are empty, we still show the anatomogram tab in Results tab, and the other horizontal tabs too. Please double check it and fix the senario.
  2. In the console, some logs are found but I don't think it's necessary for debugging or reporting, please take a look.
Screenshot 2024-09-10 at 11 59 38 3. I made some changes on `TSnePlotViewRoute.js` for inferred cell type marker gene features, please pull the latest develop branch changes and install the latest version packages and also pay attention to the conflicts please.

For point 1: the props defaultPlotMethodAndParameterisation are not working properly. I have some doubts about showing some existing code issues. Can we have a call around 1:30 pm if you are free to discuss.

plotTypesAndOptions is not a required field as per our validations doc, so I didn't add it as a validation field. Do you want me to include that as well?

Copy link
Contributor

@ke4 ke4 left a 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,
Copy link
Contributor

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;
Copy link
Contributor

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;
Copy link
Contributor

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)) {
Copy link
Contributor

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)) {
Copy link
Contributor

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`);
Copy link
Contributor

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");
Copy link
Contributor

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;
Copy link
Contributor

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;
Copy link
Contributor

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)
Copy link
Contributor

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?

@ke4 ke4 added bug Something isn't working and removed scxa labels Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None of the tabs appearing on the experiment page when plotTypesAndOptions empty in the content payload
3 participants