Skip to content

Commit

Permalink
Merge pull request #4336 from onursumer/fix-table-page-reset-on-row-c…
Browse files Browse the repository at this point in the history
…lick

Keep table page as is on row click
  • Loading branch information
alisman authored Aug 2, 2022
2 parents bfc9bca + 9f649d1 commit 2655e1a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 28 deletions.
7 changes: 2 additions & 5 deletions src/pages/patientView/PatientViewPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,6 @@ export default class PatientViewPage extends React.Component<

public patientViewPageStore: PatientViewPageStore;

@observable
public activeLocus: string | undefined;

constructor(props: IPatientViewPageProps) {
super(props);
makeObservable(this);
Expand Down Expand Up @@ -245,8 +242,8 @@ export default class PatientViewPage extends React.Component<

@action.bound
public handleLocusChange(locus: string) {
if (this.activeLocus !== locus) {
this.activeLocus = locus;
if (this.patientViewPageStore.activeLocus !== locus) {
this.patientViewPageStore.activeLocus = locus;
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/pages/patientView/PatientViewPageTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ export function tabs(
style={{ top: -10 }}
>
<GenomicOverview
store={pageComponent.patientViewPageStore}
mergedMutations={
pageComponent.patientViewPageStore
.mergedMutationDataFilteredByGene
Expand Down Expand Up @@ -218,8 +219,6 @@ export function tabs(
pageComponent.toggleGenePanelModal
}
disableTooltip={pageComponent.genePanelModal.isOpen}
locus={pageComponent.activeLocus}
handleLocusChange={pageComponent.handleLocusChange}
// assuming that all studies have the same reference genome
genome={
pageComponent.patientViewPageStore.studies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ export class PatientViewPageStore {

public internalClient: CBioPortalAPIInternal;

@observable public activeLocus: string | undefined;
@observable public activeTabId = '';

@observable private _patientId = '';
Expand Down
38 changes: 17 additions & 21 deletions src/pages/patientView/genomicOverview/GenomicOverview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,19 @@ interface IGenomicOverviewProps {
sampleIdToCopyNumberGenePanelId?: { [sampleId: string]: string };
onSelectGenePanel?: (name: string) => void;
disableTooltip?: boolean;
locus?: string;
handleLocusChange?: (locus: string) => void;
store?: IGenomicOverviewStore;
genome?: string;
}

interface IGenomicOverviewStore {
activeLocus: string | undefined;
}

class DefaultGenomicOverviewStore implements IGenomicOverviewStore {
@observable
public activeLocus: string | undefined;
}

function getCnaTrackSampleSummariesForIgvTrack(
features: SegmentTrackFeatures[] = []
) {
Expand Down Expand Up @@ -150,15 +158,15 @@ const ToggleButton: React.FunctionComponent<{
export default class GenomicOverview extends React.Component<
IGenomicOverviewProps
> {
@observable locus: string | undefined;
@observable compactIgvView = true;

private store: IGenomicOverviewStore;
private genePanelManager: GenePanelManager;

constructor(props: IGenomicOverviewProps) {
super(props);
makeObservable(this);
this.locus = props.locus;
this.store = props.store || new DefaultGenomicOverviewStore();
this.genePanelManager = new GenePanelManager(
props.sampleIdToMutationGenePanelId,
props.sampleIdToCopyNumberGenePanelId
Expand Down Expand Up @@ -222,7 +230,7 @@ export default class GenomicOverview extends React.Component<

@computed get igvProps() {
const coreProps = {
locus: this.locus,
locus: this.store.activeLocus,
onLocusChange: this.handleLocusChange,
tracks: this.tracks,
showTrackLabels: false,
Expand Down Expand Up @@ -375,14 +383,6 @@ export default class GenomicOverview extends React.Component<
);
}

componentWillReceiveProps(nextProps: Readonly<IGenomicOverviewProps>) {
// update the observable locus only if nextProps.locus is different than the current one
// no need to update if it is the same as the current one
if (this.locus !== nextProps.locus) {
this.locus = nextProps.locus;
}
}

private get tracksWidth(): number {
return this.props.containerWidth - 40;
}
Expand All @@ -391,16 +391,12 @@ export default class GenomicOverview extends React.Component<
private handleLocusChange(locus: string) {
// update the observable locus only if it is different than the current one
// no need to update (and re-render) if it is same as the current one
if (this.locus !== locus) {
this.locus = locus;
}

if (this.props.handleLocusChange) {
this.props.handleLocusChange(locus);
if (this.store.activeLocus !== locus) {
this.store.activeLocus = locus;
}

// switch to advanced view if locus is updated to anything other than whole genome
if (this.locus !== WHOLE_GENOME) {
if (this.store.activeLocus !== WHOLE_GENOME) {
this.compactIgvView = false;
}
}
Expand All @@ -409,7 +405,7 @@ export default class GenomicOverview extends React.Component<
private handleResetZoom() {
// reset the observable locus to whole genome if it is not set to whole genome already
// no need to reset (and re-render) if it is already set to whole genome
if (this.locus !== WHOLE_GENOME) {
if (this.store.activeLocus !== WHOLE_GENOME) {
this.handleLocusChange(WHOLE_GENOME);
}
}
Expand Down

0 comments on commit 2655e1a

Please sign in to comment.