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

Option to disable data download but still allow figure download #4662

Merged
merged 1 commit into from
Jul 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions end-to-end-test/local/specs/hide-download-controls.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ describe('hide download controls feature', function() {

before(() => {
openAndSetProperty(CBIOPORTAL_URL, {
skin_hide_download_controls: true,
skin_hide_download_controls: 'hide',
});
// browser.debug();
waitForStudyQueryPage();
Expand Down Expand Up @@ -126,7 +126,7 @@ describe('hide download controls feature', function() {

openAndSetProperty(
`${CBIOPORTAL_URL}/results/oncoprint?genetic_profile_ids_PROFILE_MUTATION_EXTENDED=study_es_0_mutations&genetic_profile_ids_PROFILE_COPY_NUMBER_ALTERATION=study_es_0_gistic&cancer_study_list=study_es_0&Z_SCORE_THRESHOLD=2.0&RPPA_SCORE_THRESHOLD=2.0&data_priority=0&profileFilter=mutations%2Cgistic&case_set_id=study_es_0_cnaseq&gene_list=CREB3L1%2520RPS11%2520PNMA1%2520MMP2%2520ZHX3%2520ERCC5%2520TP53&geneset_list=%20&tab_index=tab_visualize&Action=Submit&comparison_subtab=mrna`,
{ skin_hide_download_controls: true }
{ skin_hide_download_controls: 'hide' }
);
waitForOncoprint();
waitForTabs(expectedTabNames.length);
Expand Down Expand Up @@ -379,7 +379,7 @@ describe('hide download controls feature', function() {
before(() => {
openAndSetProperty(
`${CBIOPORTAL_URL}/patient?studyId=study_es_0&caseId=TCGA-A1-A0SK`,
{ skin_hide_download_controls: true }
{ skin_hide_download_controls: 'hide' }
);
waitForPatientView();
waitForTabs(expectedTabNames.length);
Expand Down Expand Up @@ -461,7 +461,7 @@ describe('hide download controls feature', function() {
before(() => {
openAndSetProperty(
`${CBIOPORTAL_URL}/study/summary?id=study_es_0`,
{ skin_hide_download_controls: true }
{ skin_hide_download_controls: 'hide' }
);
waitForStudyView();
waitForTabs(expectedTabNames.length);
Expand Down Expand Up @@ -563,7 +563,7 @@ describe('hide download controls feature', function() {
];
before(() => {
openAndSetProperty(browser.getUrl(), {
skin_hide_download_controls: false,
skin_hide_download_controls: 'show',
});
openGroupComparison(
`${CBIOPORTAL_URL}/study/summary?id=study_es_0`,
Expand All @@ -572,7 +572,7 @@ describe('hide download controls feature', function() {
30000
);
openAndSetProperty(browser.getUrl(), {
skin_hide_download_controls: true,
skin_hide_download_controls: 'hide',
});
waitForTabs(expectedTabNames.length);
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import React, { Context } from 'react';

export enum DownloadControlOption {
SHOW_ALL = 'show',
HIDE_DATA = 'data',
HIDE_ALL = 'hide',
}

export interface IAppContext {
showDownloadControls: boolean;
showDownloadControls: DownloadControlOption;
}

export const AppContext: Context<IAppContext> = React.createContext<
IAppContext
>({
showDownloadControls: true,
showDownloadControls: DownloadControlOption.SHOW_ALL,
});
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { saveSvg, saveSvgAsPng } from 'save-svg-as-png';
import svgToPdfDownload from '../../lib/svgToPdfDownload';
import { CSSProperties } from 'react';
import { isPromiseLike } from 'cbioportal-utils';
import { AppContext } from '../appContext/AppContext';
import { AppContext, DownloadControlOption } from '../appContext/AppContext';

type ButtonSpec = {
key: string;
Expand Down Expand Up @@ -44,6 +44,7 @@ interface IDownloadControlsProps {
style?: CSSProperties;
className?: any;
dataExtension?: string;
showDownload?: boolean;
}

function makeButton(spec: ButtonSpec) {
Expand Down Expand Up @@ -245,41 +246,51 @@ export default class DownloadControls extends React.Component<
onClick: this.downloadData,
disabled: !this.props.getData,
},
'Summary Data': {
key: 'Summary Data',
'Full Data': {
key: 'Full Data',
content: (
<span>
Summary Data{' '}
Full Data{' '}
<i
className="fa fa-cloud-download"
aria-hidden="true"
/>
</span>
),
onClick: () => this.downloadData('summary'),
onClick: () => this.downloadData('full'),
disabled: !this.props.getData,
},
'Full Data': {
key: 'Full Data',
'Summary Data': {
key: 'Summary Data',
content: (
<span>
Full Data{' '}
Summary Data{' '}
<i
className="fa fa-cloud-download"
aria-hidden="true"
/>
</span>
),
onClick: () => this.downloadData('full'),
onClick: () => this.downloadData('summary'),
disabled: !this.props.getData,
},
};
}

@computed get showDownload() {
return this.props.showDownload !== undefined
? this.props.showDownload
: true;
}

@computed get buttonSpecs() {
const middleButtons = (this.props.buttons || ['SVG', 'PNG', 'PDF']).map(
x => this.downloadControlsButtons[x]
);
const middleButtons = this.showDownload
? (this.props.buttons || ['SVG', 'PNG', 'PDF']).map(
x => this.downloadControlsButtons[x]
)
: (this.props.buttons || ['SVG', 'PNG', 'PDF'])
.filter(x => x !== 'Data' && x !== 'Full Data')
.map(x => this.downloadControlsButtons[x]);
return (this.props.additionalLeftButtons || [])
.concat(middleButtons)
.concat(this.props.additionalRightButtons || []);
Expand All @@ -291,7 +302,9 @@ export default class DownloadControls extends React.Component<
}

render() {
if (this.context.showDownloadControls === false) {
if (
this.context.showDownloadControls === DownloadControlOption.HIDE_ALL
) {
return null;
}

Expand Down Expand Up @@ -375,7 +388,7 @@ export default class DownloadControls extends React.Component<
</div>
);
} else if (this.props.type === 'dropdown') {
element = (
element = this.buttonSpecs.length > 0 && (
<ul
className={classnames(
'dropdown-menu',
Expand All @@ -387,7 +400,7 @@ export default class DownloadControls extends React.Component<
</ul>
);
} else {
element = (
element = this.buttonSpecs.length > 0 && (
<div
role="group"
className="btn-group chartDownloadButtons"
Expand Down
5 changes: 3 additions & 2 deletions src/appShell/App/Container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
import makeRoutes from 'routes';
import { AppContext } from 'cbioportal-frontend-commons';
import { IAppContext } from 'cbioportal-frontend-commons';
import { DownloadControlOption } from 'cbioportal-frontend-commons';
import { ErrorAlert } from 'shared/components/errorScreen/ErrorAlert';
import { ErrorInfo } from 'react';
import { observable } from 'mobx';
Expand Down Expand Up @@ -69,8 +70,8 @@ export default class Container extends React.Component<IContainerProps, {}> {

get appContext(): IAppContext {
return {
showDownloadControls: !getServerConfig()
.skin_hide_download_controls,
showDownloadControls: getServerConfig()
.skin_hide_download_controls as DownloadControlOption,
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/config/IAppConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,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;
skin_hide_download_controls: string;
show_mdacc_heatmap: boolean;
quick_search_enabled: boolean;
default_cross_cancer_study_list: string; // this has a default
Expand Down
2 changes: 1 addition & 1 deletion src/config/serverConfigDefaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ export 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,
skin_hide_download_controls: 'show',

oncoprint_clinical_tracks_config_json: '',

Expand Down
9 changes: 8 additions & 1 deletion src/pages/groupComparison/ClinicalDataEnrichmentsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import { ClinicalDataEnrichmentStore } from './ClinicalData';
import { ClinicalDataEnrichmentWithQ } from './GroupComparisonUtils';
import { toConditionalPrecisionWithMinimum } from '../../shared/lib/FormatUtils';
import { makeObservable, observable } from 'mobx';
import { toggleColumnVisibility } from 'cbioportal-frontend-commons';
import {
DownloadControlOption,
toggleColumnVisibility,
} from 'cbioportal-frontend-commons';
import { IColumnVisibilityDef } from 'shared/components/columnVisibilityControls/ColumnVisibilityControls';
import { getServerConfig } from 'config/config';

Expand Down Expand Up @@ -194,6 +197,10 @@ export default class ClinicalDataEnrichmentsTable extends React.Component<
}
initialSortDirection="asc"
showColumnVisibility={true}
showCopyDownload={
getServerConfig().skin_hide_download_controls ===
DownloadControlOption.SHOW_ALL
}
columnVisibility={this.columnVisibility}
columnVisibilityProps={{
onColumnToggled: this.onColumnToggled,
Expand Down
11 changes: 10 additions & 1 deletion src/pages/groupComparison/Overlap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import { action, computed, makeObservable, observable } from 'mobx';
import Venn from './OverlapVenn';
import _ from 'lodash';
import autobind from 'autobind-decorator';
import { DownloadControls, remoteData } from 'cbioportal-frontend-commons';
import {
DownloadControlOption,
DownloadControls,
remoteData,
} from 'cbioportal-frontend-commons';
import { MakeMobxView } from '../../shared/components/MobxView';
import Loader from '../../shared/components/loadingIndicator/LoadingIndicator';
import ErrorMessage from '../../shared/components/ErrorMessage';
Expand All @@ -20,6 +24,7 @@ import { getPatientIdentifiers } from '../studyView/StudyViewUtils';
import OverlapExclusionIndicator from './OverlapExclusionIndicator';
import OverlapUpset from './OverlapUpset';
import ComparisonStore from '../../shared/lib/comparison/ComparisonStore';
import { getServerConfig } from 'config/config';

export interface IOverlapProps {
store: ComparisonStore;
Expand Down Expand Up @@ -387,6 +392,10 @@ export default class Overlap extends React.Component<IOverlapProps, {}> {
dontFade={true}
style={{ position: 'absolute', right: 10, top: 10 }}
type="button"
showDownload={
getServerConfig().skin_hide_download_controls ===
DownloadControlOption.SHOW_ALL
}
/>
)}
<div style={{ position: 'relative', display: 'inline-block' }}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import _ from 'lodash';
import { observer } from 'mobx-react';
import { computed, makeObservable } from 'mobx';
import { MUTATIONAL_SIGNATURES_SIGNIFICANT_PVALUE_THRESHOLD } from 'shared/lib/GenericAssayUtils/MutationalSignaturesUtils';
import { DownloadControlOption } from 'cbioportal-frontend-commons';
import { getServerConfig } from 'config/config';

export interface IClinicalInformationMutationalSignatureTableProps {
data: IMutationalSignature[];
Expand Down Expand Up @@ -151,6 +153,10 @@ export default class ClinicalInformationMutationalSignatureTable extends React.C
showColumnVisibility={false}
initialSortColumn={this.uniqueSamples[0].id}
initialSortDirection="desc"
showCopyDownload={
getServerConfig().skin_hide_download_controls ===
DownloadControlOption.SHOW_ALL
}
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import LazyMobXTable from 'shared/components/lazyMobXTable/LazyMobXTable';
import styles from './style/patientTable.module.scss';
import { SHOW_ALL_PAGE_SIZE } from '../../../shared/components/paginationControls/PaginationControls';
import { sortByClinicalAttributePriorityThenName } from '../../../shared/lib/SortUtils';
import { isUrl } from 'cbioportal-frontend-commons';
import { DownloadControlOption, isUrl } from 'cbioportal-frontend-commons';
import autobind from 'autobind-decorator';
import { formatPercentValue } from 'cbioportal-utils';
import { getServerConfig } from 'config/config';

export interface IClinicalInformationPatientTableProps {
data: ClinicalData[];
Expand Down Expand Up @@ -142,7 +143,8 @@ export default class ClinicalInformationPatientTable extends React.Component<
initialItemsPerPage={SHOW_ALL_PAGE_SIZE}
showFilter={this.props.showFilter === false ? false : true}
showCopyDownload={
this.props.showCopyDownload === false ? false : true
getServerConfig().skin_hide_download_controls ===
DownloadControlOption.SHOW_ALL
}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import {
import styles from './style/sampleTable.module.scss';
import { SHOW_ALL_PAGE_SIZE } from '../../../shared/components/paginationControls/PaginationControls';
import { sortByClinicalAttributePriorityThenName } from '../../../shared/lib/SortUtils';
import { isUrl } from 'cbioportal-frontend-commons';
import { DownloadControlOption, isUrl } from 'cbioportal-frontend-commons';
import { getServerConfig } from 'config/config';

interface IClinicalInformationSamplesTableProps {
samples?: ClinicalDataBySampleId[];
Expand Down Expand Up @@ -68,6 +69,10 @@ export default class ClinicalInformationSamplesTable extends React.Component<
showPagination={false}
initialItemsPerPage={SHOW_ALL_PAGE_SIZE}
showColumnVisibility={false}
showCopyDownload={
getServerConfig().skin_hide_download_controls ===
DownloadControlOption.SHOW_ALL
}
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import autobind from 'autobind-decorator';
import SampleNotProfiledAlert from 'shared/components/SampleNotProfiledAlert';
import { NamespaceColumnConfig } from 'shared/components/namespaceColumns/NamespaceColumnConfig';
import { createNamespaceColumns } from 'shared/components/namespaceColumns/namespaceColumnsUtils';
import { DownloadControlOption } from 'cbioportal-frontend-commons';

export const TABLE_FEATURE_INSTRUCTION =
'Click on a CNA row to zoom in on the gene in the IGV browser above';
Expand Down Expand Up @@ -445,6 +446,11 @@ export default class CopyNumberTableWrapper extends React.Component<
onRowClick={this.props.onRowClick}
onRowMouseEnter={this.props.onRowMouseEnter}
onRowMouseLeave={this.props.onRowMouseLeave}
showCopyDownload={
getServerConfig()
.skin_hide_download_controls ===
DownloadControlOption.SHOW_ALL
}
/>
</FeatureInstruction>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import AnnotationColumnFormatter from './column/AnnotationColumnFormatter';
import { getServerConfig } from 'config/config';
import { ServerConfigHelpers } from 'config/config';
import ChromosomeColumnFormatter from 'shared/components/mutationTable/column/ChromosomeColumnFormatter';
import { remoteData } from 'cbioportal-frontend-commons';
import { DownloadControlOption, remoteData } from 'cbioportal-frontend-commons';
import {
calculateOncoKbContentPadding,
calculateOncoKbContentWidthWithInterval,
Expand Down Expand Up @@ -540,6 +540,11 @@ export default class StructuralVariantTableWrapper extends React.Component<
itemsLabel="Structural Variants"
itemsLabelPlural="Structural Variants"
showCountHeader={true}
showCopyDownload={
getServerConfig()
.skin_hide_download_controls ===
DownloadControlOption.SHOW_ALL
}
/>
)}
</>
Expand Down
Loading