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 20 commits into
base: develop
Choose a base branch
from

Conversation

upendrakumbham
Copy link
Contributor

Decoupling tabs in the experiment page and display them after validating

@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

const supplementaryInformationTab = 'supplementary-information'
const downloadTab = 'resources'

if (isThisTabType(tab, resultTab)) {
Copy link
Contributor

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

Copy link
Contributor Author

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

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

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 requests that I would like you to change to make the code cleaner.
Many thanks

@upendrakumbham
Copy link
Contributor Author

Hi both, I improved the code. Please re-review and add your comments.

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

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

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?

Copy link
Contributor Author

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

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

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?

Copy link
Contributor Author

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

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?

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 agree with you, I will try to do that.

Copy link
Contributor Author

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.

@lingyun1010
Copy link
Contributor

lingyun1010 commented Jun 11, 2024

Good work and I have a few comments listed below:

  1. Code format: we do not use ; to end any javascript code line
  2. In the current implementation, we only check one key and one optionsKey, firstly can you explain what is the difference between these two props? Are they required and non-required? As far as I know, we have more than one required props at least for the Result tab. Please double check the other tabs and add more possible checks.
  3. Given the above issue solved, we should remove the corresponding top ribbon fully, not only the ribbon title, here is a screenshot while I tested locally by removing ks from result tab, which may give you some clues about my comment.

Screenshot 2024-06-11 at 14 41 32

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.

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.

@upendrakumbham
Copy link
Contributor Author

Hi @lingyun1010, gathered all the required validation fields to validate and display their corresponding tabs.

Here is the document: Frontend_tab_validations.docx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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