Skip to content

Commit

Permalink
properly adjust oncokb content within annotation column (fix cBioPort…
Browse files Browse the repository at this point in the history
  • Loading branch information
onursumer committed Jan 18, 2022
1 parent 68f978f commit 1ed6bed
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export type AnnotationProps = {
oncoKbCancerGenes?: RemoteData<CancerGene[] | Error | undefined>;
usingPublicOncoKbInstance: boolean;
mergeOncoKbIcons?: boolean;
oncoKbContentPadding?: number;
pubMedCache?: MobxCache;
resolveEntrezGeneId?: (mutation: Mutation) => number;
resolveTumorType?: (mutation: Mutation) => string;
Expand All @@ -61,6 +62,7 @@ export type GenericAnnotationProps = {
enableMyCancerGenome: boolean;
enableOncoKb: boolean;
mergeOncoKbIcons?: boolean;
oncoKbContentPadding?: number;
pubMedCache?: MobxCache;
userEmailAddress?: string;
};
Expand Down Expand Up @@ -303,6 +305,7 @@ export function GenericAnnotation(props: GenericAnnotationProps): JSX.Element {
pubMedCache,
userEmailAddress,
mergeOncoKbIcons,
oncoKbContentPadding,
} = props;

return (
Expand All @@ -321,6 +324,7 @@ export function GenericAnnotation(props: GenericAnnotationProps): JSX.Element {
mergeAnnotationIcons={mergeOncoKbIcons}
pubMedCache={pubMedCache}
userEmailAddress={userEmailAddress}
contentPadding={oncoKbContentPadding}
/>
)}
{enableCivic && (
Expand Down
21 changes: 8 additions & 13 deletions packages/react-mutation-mapper/src/component/oncokb/OncoKB.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export interface IOncoKbProps {
hugoGeneSymbol: string;
userEmailAddress?: string;
disableFeedback?: boolean;
contentPadding?: number;
}

export function sortValue(
Expand Down Expand Up @@ -112,10 +113,11 @@ function findDefaultDataTypeForTooltip(

@observer
export default class OncoKB extends React.Component<IOncoKbProps, {}> {
constructor(props: any) {
constructor(props: IOncoKbProps) {
super(props);
makeObservable(this);
}

@observable showFeedback: boolean = false;
@observable tooltipDataLoadComplete: boolean = false;

Expand Down Expand Up @@ -194,18 +196,11 @@ export default class OncoKB extends React.Component<IOncoKbProps, {}> {
</>
);
} else {
// TODO This doesn't always work, in some cases it adds unnecessary empty icons, we need a better solution.
// we still need to draw empty icons even if there is no indicator data.
// this is to keep the icon alignment consistent with the rest of the column
// return (
// <>
// {this.props.availableDataTypes?.map(() => (
// <AnnotationIconWithTooltip icon={<i />} />
// ))}
// </>
// );

return null;
// workaround: use content padding value to draw an empty icon when there is no indicator data.
// this is to keep the icon alignment consistent with the rest of the column.
// ideally we should implement grouped columns to avoid these kind of workarounds
// (see https://github.com/cBioPortal/cbioportal/issues/8723)
return <i style={{ paddingRight: this.props.contentPadding }} />;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import {
} from 'cbioportal-utils';
import { CancerGene } from 'oncokb-ts-api-client';
import {
calculateOncoKbContentPadding,
calculateOncoKbContentWidthOnNextFrame,
calculateOncoKbContentWidthWithInterval,
DEFAULT_ONCOKB_CONTENT_WIDTH,
Expand Down Expand Up @@ -251,6 +252,9 @@ export default class CopyNumberTableWrapper extends React.Component<
usingPublicOncoKbInstance: this.props
.usingPublicOncoKbInstance,
mergeOncoKbIcons: this.mergeOncoKbIcons,
oncoKbContentPadding: calculateOncoKbContentPadding(
this.oncokbWidth
),
enableOncoKb: this.props.enableOncoKb as boolean,
pubMedCache: this.props.pubMedCache,
civicGenes: this.props.cnaCivicGenes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { ServerConfigHelpers } from 'config/config';
import ChromosomeColumnFormatter from 'shared/components/mutationTable/column/ChromosomeColumnFormatter';
import { remoteData } from 'cbioportal-frontend-commons';
import {
calculateOncoKbContentPadding,
calculateOncoKbContentWidthOnNextFrame,
calculateOncoKbContentWidthWithInterval,
DEFAULT_ONCOKB_CONTENT_WIDTH,
Expand Down Expand Up @@ -244,6 +245,9 @@ export default class PatientViewStructuralVariantTable extends React.Component<
usingPublicOncoKbInstance: this.props.store
.usingPublicOncoKbInstance,
mergeOncoKbIcons: this.mergeOncoKbIcons,
oncoKbContentPadding: calculateOncoKbContentPadding(
this.oncokbWidth
),
enableOncoKb: getServerConfig()
.show_oncokb as boolean,
pubMedCache: this.props.store.pubMedCache,
Expand Down
4 changes: 4 additions & 0 deletions src/shared/components/mutationTable/MutationTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ export interface IMutationTableProps {
import MobxPromise from 'mobxpromise';
import { getServerConfig } from 'config/config';
import {
calculateOncoKbContentPadding,
calculateOncoKbContentWidthOnNextFrame,
calculateOncoKbContentWidthWithInterval,
DEFAULT_ONCOKB_CONTENT_WIDTH,
Expand Down Expand Up @@ -866,6 +867,9 @@ export default class MutationTable<
usingPublicOncoKbInstance: this.props
.usingPublicOncoKbInstance,
mergeOncoKbIcons: this.props.mergeOncoKbIcons,
oncoKbContentPadding: calculateOncoKbContentPadding(
this.oncokbWidth
),
pubMedCache: this.props.pubMedCache,
civicGenes: this.props.civicGenes,
civicVariants: this.props.civicVariants,
Expand Down
4 changes: 4 additions & 0 deletions src/shared/lib/AnnotationColumnUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ export function calculateOncoKbContentWidthWithInterval(
return interval;
}

export function calculateOncoKbContentPadding(oncoKbContentWidth?: number) {
return oncoKbContentWidth || 0 > 22 ? oncoKbContentWidth! - 22 : 0;
}

export function updateOncoKbIconStyle(style: { mergeIcons: boolean }) {
getBrowserWindow().localStorage.setItem(
'mergeOncoKbIcons',
Expand Down

0 comments on commit 1ed6bed

Please sign in to comment.