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

Add async hide/show check for custom tabs #4167

Merged
merged 3 commits into from
Feb 28, 2022

Conversation

alisman
Copy link
Collaborator

@alisman alisman commented Feb 3, 2022

Introduce a way to configure custom tabs such that an async check can be run to see whether or not the tab should show for a given view of the page. E.g. we should rerun this check when the query changes on the result page or when the patient/sample change on patient page.

The hideAsync property is a function which MUST return a promise. When the promise resolves with a boolean value, we will either show or hide the tab button. Note that if the user is already routed to the tab, we should always show the button even if the hydeAsync function returns false. In that case we should render some N/A placeholder for the tab content.

 {
     title: 'Async Tab 2',
     id: 'customTab2',
     location: 'RESULTS_PAGE',
     hideAsync: `()=>{
                return new Promise((resolve)=>{
                     setTimeout(()=>{
                         resolve(true);
                     }, 2000);
                });
     }`,
 },

@alisman alisman force-pushed the custom_tabs branch 2 times, most recently from 1d0c3ee to 20d38ec Compare February 7, 2022 21:39
@alisman alisman changed the title Custom tabs Async hide/show check for custom tabs Feb 15, 2022
Copy link
Contributor

@pvannierop pvannierop left a comment

Choose a reason for hiding this comment

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

Wow, this was quite the project! Looks good. I have some remarks and questions.

my-index.ejs Outdated
Comment on lines 17 to 25

// serverConfig:{
//
// // custom_tabs:[
// // {
// // "title": "Custom Tab",
// // "location": "RESULTS_PAGE",
// // "mountCallbackName": "renderCustomTab1",
// // "hide":false,
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this file be committed?

@computed get customTabs() {
return prepareCustomTabConfigurations(
getServerConfig().custom_tabs,
'COMPARISON_PAGE'
Copy link
Contributor

Choose a reason for hiding this comment

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

So, you extended the custom tabs to Comparison Page? Nice would be good to make that clean in docs and release notes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

agreed

Comment on lines +748 to +766
// {getServerConfig().custom_tabs &&
// getServerConfig()
// .custom_tabs.filter(
// (tab: any) =>
// tab.location === 'PATIENT_PAGE'
// )
// .map((tab: any, i: number) => {
// return (
// <MSKTab
// key={getPatientViewResourceTabId(
// 'customTab' + i
// )}
// id={getPatientViewResourceTabId(
// 'customTab' + i
// )}
// unmountOnHide={
// tab.unmountOnHide ===
// true
// }
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove commented lines?

Comment on lines +273 to +274
studyViewRegex.test(location.pathname) ||
customTabRegex.test(location.pathname)
Copy link
Contributor

Choose a reason for hiding this comment

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

Just asking, but should there not be a comparisonView test as well?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

probably yes : )

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

i'll make a ticket for it and do it separately


runTests('ResultsView', resultsUrl, 'RESULTS_PAGE');

runTests('PatientView', patientUrl, 'PATIENT_PAGE');
Copy link
Contributor

Choose a reason for hiding this comment

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

I noticed that Comparison View is also supported not. Should we not include a test for it?

@alisman alisman force-pushed the custom_tabs branch 3 times, most recently from 3ed77c5 to 1bcaa6b Compare February 17, 2022 15:37
Copy link
Contributor

@pvannierop pvannierop left a comment

Choose a reason for hiding this comment

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

Nice work, and thanks again for doing this.

@alisman alisman changed the title Async hide/show check for custom tabs Add async hide/show check for custom tabs Feb 28, 2022
@alisman alisman merged commit 56c4b2a into cBioPortal:master Feb 28, 2022
@alisman alisman deleted the custom_tabs branch February 28, 2022 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants