Skip to content

Commit

Permalink
Impl. conditional rendering of download controls
Browse files Browse the repository at this point in the history
  • Loading branch information
pvannierop authored and alisman committed May 24, 2022
1 parent d2440fb commit 2169f41
Show file tree
Hide file tree
Showing 25 changed files with 906 additions and 116 deletions.
681 changes: 681 additions & 0 deletions end-to-end-test/local/specs/hide-download-controls.spec.js

Large diffs are not rendered by default.

11 changes: 2 additions & 9 deletions end-to-end-test/remote/specs/config.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ var goToUrlAndSetLocalStorage = require('../../shared/specUtils')
.goToUrlAndSetLocalStorage;
var executeInBrowser = require('../../shared/specUtils').executeInBrowser;
var useExternalFrontend = require('../../shared/specUtils').useExternalFrontend;
var setServerConfiguration = require('../../shared/specUtils')
.setServerConfiguration;

const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, '');

Expand Down Expand Up @@ -103,12 +105,3 @@ describe('homepage', function() {
$('#blurbDiv').waitForExist();
});
});

function setServerConfiguration(serverConfig) {
browser.execute(function(_serverConfig) {
this.localStorage.setItem(
'frontendConfig',
JSON.stringify({ serverConfig: _serverConfig })
);
}, serverConfig);
}
9 changes: 9 additions & 0 deletions end-to-end-test/shared/specUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,15 @@ function jq(selector) {
}, selector);
}

function setServerConfiguration(serverConfig) {
browser.execute(function(_serverConfig) {
this.localStorage.setItem(
'frontendConfig',
JSON.stringify({ serverConfig: _serverConfig })
);
}, serverConfig);
}

var openAlterationTypeSelectionMenu = () => {
$('[data-test=AlterationEnrichmentTypeSelectorButton]').waitForExist();
$('[data-test=AlterationEnrichmentTypeSelectorButton]').click();
Expand Down
2 changes: 1 addition & 1 deletion env/custom.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#export CBIOPORTAL_URL="http://www.cbioportal.org"
export CBIOPORTAL_URL="http://localhost:8080"
export GENOME_NEXUS_URL="https://www.genomenexus.org"
2 changes: 2 additions & 0 deletions env/hide_download_options.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export CBIOPORTAL_URL="${CBIOPORTAL_URL:-https://www.cbioportal.org}"
export GENOME_NEXUS_URL="${GENOME_NEXUS_URL:-https://www.genomenexus.org}"
2 changes: 1 addition & 1 deletion packages/cbioportal-frontend-commons/src/lib/PlotUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export function makeTooltipMouseEvents(self: {
clearTimeout(disappearTimeout);
}

disappearTimeout = setTimeout(
disappearTimeout = global.setTimeout(
action(() => {
self.pointHovered = false;
}),
Expand Down
8 changes: 5 additions & 3 deletions src/appShell/App/Container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
} from 'appShell/App/usageAgreements/GenieAgreement';
import makeRoutes from 'routes';
import { AppContext } from 'cbioportal-frontend-commons';
import { IAppContext } from 'cbioportal-frontend-commons/src';
import { IAppContext } from 'cbioportal-frontend-commons';

interface IContainerProps {
location: Location;
Expand Down Expand Up @@ -63,8 +63,10 @@ export default class Container extends React.Component<IContainerProps, {}> {
}

get appContext(): IAppContext {
//return { showDownloadControls: this.appStore.getServerConfig.some_prop }
return { showDownloadControls: true };
return {
showDownloadControls: !getServerConfig()
.skin_hide_download_controls,
};
}

render() {
Expand Down
1 change: 1 addition & 0 deletions src/config/IAppConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ export interface IServerConfig {
skin_title: string;
skin_authorization_message: string | null;
skin_patientview_filter_genes_profiled_all_samples: boolean;
skin_hide_download_controls: boolean;
show_mdacc_heatmap: boolean;
quick_search_enabled: boolean;
default_cross_cancer_study_list: string; // this has a default
Expand Down
1 change: 1 addition & 0 deletions src/config/serverConfigDefaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ const ServerConfigDefaults: Partial<IServerConfig> = {
skin_home_page_unauthorized_studies_global_message:
'The study is unauthorized. You need to request access.',
comparison_categorical_na_values: 'NA',
skin_hide_download_controls: false,
};

export default ServerConfigDefaults;
50 changes: 32 additions & 18 deletions src/pages/resultsView/ResultsViewPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
action,
computed,
observable,
reaction,
runInAction,
makeObservable,
autorun,
Expand All @@ -28,7 +27,7 @@ import { MSKTab, MSKTabs } from '../../shared/components/MSKTabs/MSKTabs';
import { PageLayout } from '../../shared/components/PageLayout/PageLayout';
import autobind from 'autobind-decorator';
import { ITabConfiguration } from '../../shared/model/ITabConfiguration';
import { remoteData } from 'cbioportal-frontend-commons';
import { getBrowserWindow, remoteData } from 'cbioportal-frontend-commons';
import CoExpressionTab from './coExpression/CoExpressionTab';
import Helmet from 'react-helmet';
import {
Expand Down Expand Up @@ -70,6 +69,7 @@ import {
} from 'shared/lib/customTabs/customTabHelpers';
import { buildCBioPortalPageUrl } from 'shared/api/urls';
import IFrameLoader from 'shared/components/iframeLoader/IFrameLoader';
import { AppContext } from 'cbioportal-frontend-commons';

export function initStore(
appStore: AppStore,
Expand Down Expand Up @@ -101,12 +101,9 @@ function addOnBecomeVisibleListener(callback: () => void) {
}

export interface IResultsViewPageProps {
routing: ExtendedRouterStore;
appStore: AppStore;
params: any; // from react router
}

@inject('appStore', 'routing')
@observer
export default class ResultsViewPage extends React.Component<
IResultsViewPageProps,
Expand All @@ -127,7 +124,7 @@ export default class ResultsViewPage extends React.Component<

makeObservable(this);

this.urlWrapper = new ResultsViewURLWrapper(props.routing);
this.urlWrapper = new ResultsViewURLWrapper(this.routing);

handleLegacySubmission(this.urlWrapper);

Expand All @@ -138,18 +135,30 @@ export default class ResultsViewPage extends React.Component<
if (this.urlWrapper.hasSessionId) {
onMobxPromise(this.urlWrapper.remoteSessionData, () => {
this.resultsViewPageStore = initStore(
props.appStore,
this.appStore,
this.urlWrapper
);
});
} else {
this.resultsViewPageStore = initStore(
props.appStore,
this.appStore,
this.urlWrapper
);
}
}

// this is temporary to allow us to
// get rid of @inject, which is conflicting
// with react context
// ultimately should be replaced with react context
private get appStore(): AppStore {
return getBrowserWindow().globalStores.appStore as AppStore;
}

private get routing(): ExtendedRouterStore {
return getBrowserWindow().globalStores.routing as ExtendedRouterStore;
}

componentWillUnmount() {
this.resultsViewPageStore.destroy();
this.urlWrapper.destroy();
Expand Down Expand Up @@ -255,7 +264,7 @@ export default class ResultsViewPage extends React.Component<
>
<Mutations
store={store}
appStore={this.props.appStore}
appStore={this.appStore}
urlWrapper={this.urlWrapper}
/>
</MSKTab>
Expand Down Expand Up @@ -313,7 +322,7 @@ export default class ResultsViewPage extends React.Component<
>
<ComparisonTab
urlWrapper={this.urlWrapper}
appStore={this.props.appStore}
appStore={this.appStore}
store={this.resultsViewPageStore}
/>
</MSKTab>
Expand Down Expand Up @@ -456,7 +465,7 @@ export default class ResultsViewPage extends React.Component<
>
<ResultsViewPathwayMapper
store={store}
appStore={this.props.appStore}
appStore={this.appStore}
urlWrapper={this.urlWrapper}
/>
</MSKTab>
Expand Down Expand Up @@ -529,7 +538,10 @@ export default class ResultsViewPage extends React.Component<
);
},
},
{
];

if (this.context.showDownloadControls === true) {
tabMap.push({
id: ResultsViewTab.DOWNLOAD,
getTab: () => {
return (
Expand All @@ -542,8 +554,8 @@ export default class ResultsViewPage extends React.Component<
</MSKTab>
);
},
},
];
});
}

let filteredTabs = tabMap
.filter(this.evaluateTabInclusion)
Expand Down Expand Up @@ -629,8 +641,8 @@ export default class ResultsViewPage extends React.Component<
private getTabHref(tabId: string) {
return URL.format({
pathname: buildCBioPortalPageUrl(`./results/${tabId}`),
query: this.props.routing.query,
hash: this.props.routing.location.hash,
query: this.routing.query,
hash: this.routing.location.hash,
});
}

Expand Down Expand Up @@ -726,7 +738,7 @@ export default class ResultsViewPage extends React.Component<
<div>
<div className={'headBlock'}>
<QuerySummary
routingStore={this.props.routing}
routingStore={this.routing}
store={this.resultsViewPageStore}
onToggleQueryFormVisibility={visible => {
runInAction(() => {
Expand Down Expand Up @@ -789,7 +801,7 @@ export default class ResultsViewPage extends React.Component<
contentWindowExtra={
<HelpWidget
path={
this.props.routing.location
this.routing.location
.pathname
}
/>
Expand Down Expand Up @@ -852,3 +864,5 @@ export default class ResultsViewPage extends React.Component<
}
}
}

ResultsViewPage.contextType = AppContext;
6 changes: 2 additions & 4 deletions src/pages/resultsView/survival/SurvivalPrefixTable.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import * as React from 'react';
import { observer } from 'mobx-react';
import { ClinicalDataEnrichmentWithQ } from 'pages/groupComparison/GroupComparisonUtils';
import LazyMobXTable, {
Column,
} from 'shared/components/lazyMobXTable/LazyMobXTable';
import { ClinicalDataEnrichmentTableColumnType } from 'pages/groupComparison/ClinicalDataEnrichmentsTable';
import autobind from 'autobind-decorator';
import {
getSortedFilteredData,
Expand All @@ -16,7 +14,6 @@ import { filterNumericalColumn } from 'shared/components/lazyMobXTable/utils';
import _ from 'lodash';
import {
EditableSpan,
pluralize,
toggleColumnVisibility,
} from 'cbioportal-frontend-commons';
import { IColumnVisibilityDef } from 'shared/components/columnVisibilityControls/ColumnVisibilityControls';
Expand Down Expand Up @@ -269,7 +266,8 @@ export default class SurvivalPrefixTable extends React.Component<
> {
private dataStore: SurvivalPrefixTableStore;
@observable private columnVisibility: { [group: string]: boolean };
@observable private patientMinThreshold = getServerConfig().survival_min_group_threshold;
@observable private patientMinThreshold = getServerConfig()
.survival_min_group_threshold;

constructor(props: ISurvivalPrefixTableProps) {
super(props);
Expand Down
18 changes: 13 additions & 5 deletions src/pages/studyView/chartHeader/ChartHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { StudyViewPageStore } from 'pages/studyView/StudyViewPageStore';
import { ISurvivalDescription } from 'pages/resultsView/survival/SurvivalDescriptionTable';
import ComparisonVsIcon from 'shared/components/ComparisonVsIcon';
import { getComparisonParamsForTable } from 'pages/studyView/StudyViewComparisonUtils';
import { AppContext } from 'cbioportal-frontend-commons';

export interface IChartHeaderProps {
chartMeta: ChartMeta;
Expand Down Expand Up @@ -261,6 +262,15 @@ export class ChartHeader extends React.Component<IChartHeaderProps, {}> {
}
}

@computed get showDownload() {
return (
this.props.chartControls &&
this.props.downloadTypes &&
this.props.downloadTypes.length > 0 &&
this.context.showDownloadControls === true
);
}

@computed get menuItems() {
const items = [];
if (
Expand Down Expand Up @@ -549,11 +559,7 @@ export class ChartHeader extends React.Component<IChartHeaderProps, {}> {
}
}

if (
this.props.chartControls &&
this.props.downloadTypes &&
this.props.downloadTypes.length > 0
) {
if (this.showDownload) {
const downloadSubmenuWidth = 70;
items.push(
<li style={{ position: 'relative' }}>
Expand Down Expand Up @@ -821,3 +827,5 @@ export class ChartHeader extends React.Component<IChartHeaderProps, {}> {
);
}
}

ChartHeader.contextType = AppContext;
Loading

0 comments on commit 2169f41

Please sign in to comment.