Unverified Commit e3da31c4 authored by Jyothish's avatar Jyothish Committed by GitHub
Browse files

GB version update - 0.3.1 (#761)

parent e391c768
Pipeline #289048 passed with stages
in 5 minutes and 17 seconds
......@@ -9,7 +9,7 @@
"version": "0.0.1",
"license": "MIT",
"dependencies": {
"@ensembl/ensembl-genome-browser": "0.3.0",
"@ensembl/ensembl-genome-browser": "0.3.1",
"@loadable/component": "5.15.2",
"@loadable/server": "5.15.2",
"@react-spring/web": "9.4.5-beta.1",
......@@ -2348,9 +2348,9 @@
}
},
"node_modules/@ensembl/ensembl-genome-browser": {
"version": "0.3.0",
"resolved": "https://gitlab.ebi.ac.uk/api/v4/projects/3500/packages/npm/@ensembl/ensembl-genome-browser/-/@ensembl/ensembl-genome-browser-0.3.0.tgz",
"integrity": "sha1-x6mdheO3NyM35eLwG6lRZSiuNOY="
"version": "0.3.1",
"resolved": "https://gitlab.ebi.ac.uk/api/v4/projects/3500/packages/npm/@ensembl/ensembl-genome-browser/-/@ensembl/ensembl-genome-browser-0.3.1.tgz",
"integrity": "sha1-6MOEXESmj5TSPtC1ugkaLkuGgCQ="
},
"node_modules/@eslint/eslintrc": {
"version": "1.3.0",
......@@ -42312,9 +42312,9 @@
"dev": true
},
"@ensembl/ensembl-genome-browser": {
"version": "0.3.0",
"resolved": "https://gitlab.ebi.ac.uk/api/v4/projects/3500/packages/npm/@ensembl/ensembl-genome-browser/-/@ensembl/ensembl-genome-browser-0.3.0.tgz",
"integrity": "sha1-x6mdheO3NyM35eLwG6lRZSiuNOY="
"version": "0.3.1",
"resolved": "https://gitlab.ebi.ac.uk/api/v4/projects/3500/packages/npm/@ensembl/ensembl-genome-browser/-/@ensembl/ensembl-genome-browser-0.3.1.tgz",
"integrity": "sha1-6MOEXESmj5TSPtC1ugkaLkuGgCQ="
},
"@eslint/eslintrc": {
"version": "1.3.0",
......@@ -30,7 +30,7 @@
"coverage": "jest --coverage"
},
"dependencies": {
"@ensembl/ensembl-genome-browser": "0.3.0",
"@ensembl/ensembl-genome-browser": "0.3.1",
"@loadable/component": "5.15.2",
"@loadable/server": "5.15.2",
"@react-spring/web": "9.4.5-beta.1",
......
......@@ -43,7 +43,7 @@ const renderComponent = () => {
showSeveralTranscripts: false,
showTranscriptIds: false,
showTrackName: false,
showFeatureLabel: false,
showFeatureLabels: false,
trackType: trackConfigSlice.TrackType.GENE
}
}
......@@ -95,7 +95,7 @@ jest.mock(
() => () => ({
genomeBrowser: mockGenomeBrowser,
toggleTrackName: jest.fn(),
toggleTrackLabel: jest.fn()
toggleFeatureLabels: jest.fn()
})
);
......@@ -154,12 +154,14 @@ describe('<BrowserTrackConfig />', () => {
.find((element) => element.textContent === 'Feature labels')
?.parentElement?.querySelector('svg') as SVGElement;
jest.spyOn(trackConfigSlice, 'updateFeatureLabel');
jest.spyOn(trackConfigSlice, 'updateFeatureLabelsVisibility');
await userEvent.click(toggle);
const updatedState = store.getState();
expect(trackConfigSlice.updateFeatureLabel).toHaveBeenCalledWith({
expect(
trackConfigSlice.updateFeatureLabelsVisibility
).toHaveBeenCalledWith({
genomeId,
isTrackLabelShown: true,
areFeatureLabelsShown: true,
trackId: updatedState.browser.trackConfig.browserTrackCogs.selectedCog
});
const trackInfo =
......@@ -167,7 +169,7 @@ describe('<BrowserTrackConfig />', () => {
selectedTrackId
];
if (trackInfo.trackType === trackConfigSlice.TrackType.GENE) {
expect(trackInfo.showFeatureLabel).toBeTruthy();
expect(trackInfo.showFeatureLabels).toBeTruthy();
}
});
});
......
......@@ -41,7 +41,7 @@ export const GeneTrackConfig = () => {
const {
updateTrackName,
updateTrackLabel,
updateFeatureLabelsVisibility,
updateShowSeveralTranscripts,
updateShowTranscriptIds
} = useBrowserTrackConfig();
......@@ -51,11 +51,26 @@ export const GeneTrackConfig = () => {
}
const shouldShowTrackName = selectedTrackConfig.showTrackName;
const shouldShowTrackLabel = selectedTrackConfig.showFeatureLabel;
const shouldShowFeatureLabels = selectedTrackConfig.showFeatureLabels;
const shouldShowSeveralTranscripts =
selectedTrackConfig.showSeveralTranscripts;
const shouldShowTranscriptIDs = selectedTrackConfig.showTranscriptIds;
const shouldShowTranscriptIds = selectedTrackConfig.showTranscriptIds;
const handleSeveralTranscriptsToggle = () => {
updateShowSeveralTranscripts(!shouldShowSeveralTranscripts);
};
const handleTranscriptIdsToggle = () => {
updateShowTranscriptIds(!shouldShowTranscriptIds);
};
const handleTrackNameToggle = () => {
updateTrackName(!shouldShowTrackName);
};
const handleFeatureLabelsToggle = () => {
updateFeatureLabelsVisibility(!shouldShowFeatureLabels);
};
return (
<div className={styles.section}>
<div className={styles.subLabel}>Show</div>
......@@ -64,17 +79,15 @@ export const GeneTrackConfig = () => {
<label>5 transcripts</label>
<SlideToggle
isOn={shouldShowSeveralTranscripts}
onChange={() =>
updateShowSeveralTranscripts(!shouldShowSeveralTranscripts)
}
onChange={handleSeveralTranscriptsToggle}
className={styles.slideToggle}
/>
</div>
<div className={styles.toggleWrapper}>
<label>Transcript IDs</label>
<SlideToggle
isOn={shouldShowTranscriptIDs}
onChange={() => updateShowTranscriptIds(!shouldShowTranscriptIDs)}
isOn={shouldShowTranscriptIds}
onChange={handleTranscriptIdsToggle}
className={styles.slideToggle}
/>
</div>
......@@ -82,15 +95,15 @@ export const GeneTrackConfig = () => {
<label>Track name</label>
<SlideToggle
isOn={shouldShowTrackName}
onChange={() => updateTrackName(!shouldShowTrackName)}
onChange={handleTrackNameToggle}
className={styles.slideToggle}
/>
</div>
<div className={styles.toggleWrapper}>
<label>Feature labels</label>
<SlideToggle
isOn={shouldShowTrackLabel}
onChange={() => updateTrackLabel(!shouldShowTrackLabel)}
isOn={shouldShowFeatureLabels}
onChange={handleFeatureLabelsToggle}
className={styles.slideToggle}
/>
</div>
......
......@@ -36,12 +36,20 @@ export const TranscriptTrackConfig = () => {
getTrackConfigsForTrackId(state, selectedCog)
);
const shouldShowTrackName = selectedTrackConfigInfo?.showTrackName ?? false;
const shouldShowTrackLabel =
const shouldShowFeatureLabels =
selectedTrackConfigInfo?.trackType === TrackType.GENE &&
selectedTrackConfigInfo.showFeatureLabel;
selectedTrackConfigInfo.showFeatureLabels;
const { updateTrackName, updateTrackLabel } = useBrowserTrackConfig();
const { updateTrackName, updateFeatureLabelsVisibility } =
useBrowserTrackConfig();
const handleTrackNameToggle = () => {
updateTrackName(!shouldShowTrackName);
};
const handleFeatureLabelsToggle = () => {
updateFeatureLabelsVisibility(!shouldShowFeatureLabels);
};
return (
<div className={styles.section}>
<div className={styles.subLabel}>Show</div>
......@@ -50,15 +58,15 @@ export const TranscriptTrackConfig = () => {
<label>Track name</label>
<SlideToggle
isOn={shouldShowTrackName}
onChange={() => updateTrackName(!shouldShowTrackName)}
onChange={handleTrackNameToggle}
className={styles.slideToggle}
/>
</div>
<div className={styles.toggleWrapper}>
<label>Feature labels</label>
<SlideToggle
isOn={shouldShowTrackLabel}
onChange={() => updateTrackLabel(!shouldShowTrackLabel)}
isOn={shouldShowFeatureLabels}
onChange={handleFeatureLabelsToggle}
className={styles.slideToggle}
/>
</div>
......
......@@ -26,7 +26,7 @@ import {
} from 'src/content/app/genome-browser/state/track-config/trackConfigSelectors';
import {
updateTrackName as updateTrackConfigTrackName,
updateFeatureLabel as updateTrackConfigFeatureLabel,
updateFeatureLabelsVisibility as updateTrackConfigFeatureLabelsVisibility,
updateShowSeveralTranscripts as updateTrackConfigShowSeveralTranscripts,
updateShowTranscriptIds as updateTrackConfigShowTranscriptIds,
updateApplyToAll,
......@@ -57,7 +57,7 @@ const useBrowserTrackConfig = () => {
const {
toggleTrackName,
toggleTrackLabel,
toggleFeatureLabels,
toggleSeveralTranscripts,
toggleTranscriptIds
} = useGenomeBrowser();
......@@ -101,7 +101,7 @@ const useBrowserTrackConfig = () => {
});
};
const updateTrackLabel = (isTrackLabelShown: boolean) => {
const updateFeatureLabelsVisibility = (areFeatureLabelsShown: boolean) => {
if (!activeGenomeId) {
return;
}
......@@ -109,28 +109,28 @@ const useBrowserTrackConfig = () => {
if (shouldApplyToAllRef.current) {
Object.keys(browserCogList).forEach((trackId) => {
dispatch(
updateTrackConfigFeatureLabel({
updateTrackConfigFeatureLabelsVisibility({
genomeId: activeGenomeId,
trackId,
isTrackLabelShown
areFeatureLabelsShown
})
);
toggleTrackLabel({
toggleFeatureLabels({
trackId,
shouldShowFeatureLabel: isTrackLabelShown
shouldShowFeatureLabels: areFeatureLabelsShown
});
});
} else {
dispatch(
updateTrackConfigFeatureLabel({
updateTrackConfigFeatureLabelsVisibility({
genomeId: activeGenomeId,
trackId: selectedCog,
isTrackLabelShown
areFeatureLabelsShown
})
);
toggleTrackLabel({
toggleFeatureLabels({
trackId: selectedCog,
shouldShowFeatureLabel: isTrackLabelShown
shouldShowFeatureLabels: areFeatureLabelsShown
});
}
......@@ -139,7 +139,7 @@ const useBrowserTrackConfig = () => {
analyticsTracking.trackEvent({
category: 'track_settings',
label: selectedCog,
action: 'feature_label_' + (isTrackLabelShown ? 'on' : 'off')
action: 'feature_labels_' + (areFeatureLabelsShown ? 'on' : 'off')
});
};
......@@ -185,7 +185,7 @@ const useBrowserTrackConfig = () => {
});
};
const updateShowTranscriptIds = (isTranscriptIdsShown: boolean) => {
const updateShowTranscriptIds = (shouldShowTranscriptIds: boolean) => {
if (!activeGenomeId) {
return;
}
......@@ -195,12 +195,12 @@ const useBrowserTrackConfig = () => {
updateTrackConfigShowTranscriptIds({
genomeId: activeGenomeId,
trackId,
isTranscriptIdsShown
shouldShowTranscriptIds
})
);
toggleTranscriptIds({
trackId,
shouldShowTranscriptIds: isTranscriptIdsShown
shouldShowTranscriptIds
});
});
} else {
......@@ -208,12 +208,12 @@ const useBrowserTrackConfig = () => {
updateTrackConfigShowTranscriptIds({
genomeId: activeGenomeId,
trackId: selectedCog,
isTranscriptIdsShown
shouldShowTranscriptIds
})
);
toggleTranscriptIds({
trackId: selectedCog,
shouldShowTranscriptIds: isTranscriptIdsShown
shouldShowTranscriptIds
});
}
......@@ -222,7 +222,7 @@ const useBrowserTrackConfig = () => {
analyticsTracking.trackEvent({
category: 'track_settings',
label: selectedCog,
action: 'several_transcripts_' + (isTranscriptIdsShown ? 'on' : 'off')
action: 'transcript_labels_' + (shouldShowTranscriptIds ? 'on' : 'off')
});
};
......@@ -232,9 +232,9 @@ const useBrowserTrackConfig = () => {
}
const shouldShowTrackName = selectedTrackConfigs.showTrackName;
const shouldShowFeatureLabel =
const shouldShowFeatureLabels =
selectedTrackConfigs.trackType === TrackType.GENE
? selectedTrackConfigs.showFeatureLabel
? selectedTrackConfigs.showFeatureLabels
: false;
const shouldShowSeveralTranscripts =
......@@ -242,6 +242,11 @@ const useBrowserTrackConfig = () => {
? selectedTrackConfigs.showSeveralTranscripts
: false;
const shouldShowTranscriptIds =
selectedTrackConfigs.trackType === TrackType.GENE
? selectedTrackConfigs.showTranscriptIds
: false;
dispatch(
updateApplyToAll({
genomeId: activeGenomeId,
......@@ -252,8 +257,9 @@ const useBrowserTrackConfig = () => {
shouldApplyToAllRef.current = value === 'all_tracks';
updateTrackName(shouldShowTrackName);
updateTrackLabel(shouldShowFeatureLabel);
updateFeatureLabelsVisibility(shouldShowFeatureLabels);
updateShowSeveralTranscripts(shouldShowSeveralTranscripts);
updateShowTranscriptIds(shouldShowTranscriptIds);
analyticsTracking.trackEvent({
category: 'track_settings',
......@@ -264,7 +270,7 @@ const useBrowserTrackConfig = () => {
return {
updateTrackName,
updateTrackLabel,
updateFeatureLabelsVisibility,
updateShowSeveralTranscripts,
updateShowTranscriptIds,
toggleApplyToAll
......
......@@ -169,6 +169,7 @@ const useGenomeBrowser = () => {
};
const trackStateForSeveralTranscripts = cloneDeep(emptyOnOffLists);
const trackStateForTranscriptIds = cloneDeep(emptyOnOffLists);
const trackStateForNames = cloneDeep(emptyOnOffLists);
const trackStateForLabels = cloneDeep(emptyOnOffLists);
......@@ -186,13 +187,17 @@ const useGenomeBrowser = () => {
: trackStateForNames.off.push(trackId);
if (config.trackType === TrackType.GENE) {
config.showFeatureLabel
config.showFeatureLabels
? trackStateForLabels.on.push(trackId)
: trackStateForLabels.off.push(trackId);
config.showSeveralTranscripts
? trackStateForSeveralTranscripts.on.push(trackId)
: trackStateForSeveralTranscripts.off.push(trackId);
config.showTranscriptIds
? trackStateForTranscriptIds.on.push(trackId)
: trackStateForTranscriptIds.off.push(trackId);
}
});
......@@ -237,6 +242,20 @@ const useGenomeBrowser = () => {
track_ids: trackStateForSeveralTranscripts.off
}
});
genomeBrowser.send({
type: OutgoingActionType.TURN_ON_TRANSCRIPT_LABELS,
payload: {
track_ids: trackStateForTranscriptIds.on
}
});
genomeBrowser.send({
type: OutgoingActionType.TURN_OFF_TRANSCRIPT_LABELS,
payload: {
track_ids: trackStateForTranscriptIds.off
}
});
};
const changeBrowserLocation = (locationData: {
......@@ -286,18 +305,18 @@ const useGenomeBrowser = () => {
});
};
const toggleTrackLabel = (params: {
const toggleFeatureLabels = (params: {
trackId: string;
shouldShowFeatureLabel: boolean;
shouldShowFeatureLabels: boolean;
}) => {
const { trackId, shouldShowFeatureLabel } = params;
const { trackId, shouldShowFeatureLabels } = params;
const trackIdWithoutPrefix = trackId.replace('track:', '');
const trackIdToSend =
trackIdWithoutPrefix === GENE_TRACK_ID ? 'focus' : trackIdWithoutPrefix;
genomeBrowser?.send({
type: shouldShowFeatureLabel
type: shouldShowFeatureLabels
? OutgoingActionType.TURN_ON_LABELS
: OutgoingActionType.TURN_OFF_LABELS,
payload: {
......@@ -325,7 +344,6 @@ const useGenomeBrowser = () => {
});
};
/* eslint-disable @typescript-eslint/no-unused-vars */
const toggleTranscriptIds = (params: {
trackId: string;
shouldShowTranscriptIds: boolean;
......@@ -335,17 +353,15 @@ const useGenomeBrowser = () => {
const trackIdToSend =
trackIdWithoutPrefix === GENE_TRACK_ID ? 'focus' : trackIdWithoutPrefix;
// Below lines will be enabled when we have the relevant functionality in genome browser.
// genomeBrowser?.send({
// type: shouldShowTranscriptIds
// ? OutgoingActionType.TURN_ON_TRANSCRIPT_IDS
// : OutgoingActionType.TURN_OFF_TRANSCRIPT_IDS,
// payload: {
// track_ids: [trackIdToSend]
// }
// });
genomeBrowser?.send({
type: shouldShowTranscriptIds
? OutgoingActionType.TURN_ON_TRANSCRIPT_LABELS
: OutgoingActionType.TURN_OFF_TRANSCRIPT_LABELS,
payload: {
track_ids: [trackIdToSend]
}
});
};
/* eslint-enable @typescript-eslint/no-unused-vars */
const toggleTrack = (params: { trackId: string; status: Status }) => {
const { trackId, status } = params;
......@@ -366,9 +382,9 @@ const useGenomeBrowser = () => {
const trackInfo = trackConfigs && trackConfigs[trackId];
if (trackInfo && 'showFeatureLabel' in trackInfo && isTurnedOn) {
if (trackInfo && 'showFeatureLabels' in trackInfo && isTurnedOn) {
genomeBrowser?.send({
type: trackInfo?.showFeatureLabel
type: trackInfo?.showFeatureLabels
? OutgoingActionType.TURN_ON_LABELS
: OutgoingActionType.TURN_OFF_LABELS,
payload: {
......@@ -402,7 +418,7 @@ const useGenomeBrowser = () => {
setZmenus,
toggleTrack,
toggleTrackName,
toggleTrackLabel,
toggleFeatureLabels,
toggleSeveralTranscripts,
toggleTranscriptIds,
genomeBrowser,
......
......@@ -45,7 +45,7 @@ export type GeneTrackConfig = {
showSeveralTranscripts: boolean;
showTranscriptIds: boolean;
showTrackName: boolean;
showFeatureLabel: boolean;
showFeatureLabels: boolean;
trackType: TrackType.GENE;
};
......@@ -95,7 +95,7 @@ export const getDefaultGeneTrackConfig = (): GeneTrackConfig => ({
showSeveralTranscripts: false,
showTranscriptIds: false,
showTrackName: false,
showFeatureLabel: true,
showFeatureLabels: true,
trackType: TrackType.GENE
});
......@@ -192,22 +192,22 @@ const browserTrackConfigSlice = createSlice({
const trackConfigState = state.configs[genomeId].tracks[trackId];
trackConfigState.showTrackName = isTrackNameShown;
},
updateFeatureLabel(
updateFeatureLabelsVisibility(
state,
action: PayloadAction<{
genomeId: string;
trackId: string;
isTrackLabelShown: boolean;
areFeatureLabelsShown: boolean;
}>
) {
const { genomeId, trackId, isTrackLabelShown } = action.payload;
const { genomeId, trackId, areFeatureLabelsShown } = action.payload;
const trackConfigState = state.configs[genomeId].tracks[trackId];
if (trackConfigState.trackType !== TrackType.GENE) {
return;
}
trackConfigState.showFeatureLabel = isTrackLabelShown;
trackConfigState.showFeatureLabels = areFeatureLabelsShown;
},
updateShowSeveralTranscripts(
state,
......@@ -231,17 +231,17 @@ const browserTrackConfigSlice = createSlice({
action: PayloadAction<{
genomeId: string;
trackId: string;
isTranscriptIdsShown: boolean;
shouldShowTranscriptIds: boolean;
}>
) {
const { genomeId, trackId, isTranscriptIdsShown } = action.payload;
const { genomeId, trackId, shouldShowTranscriptIds } = action.payload;
const trackConfigState = state.configs[genomeId].tracks[trackId];
if (trackConfigState.trackType !== TrackType.GENE) {
return;
}
trackConfigState.showTranscriptIds = isTranscriptIdsShown;
trackConfigState.showTranscriptIds = shouldShowTranscriptIds;
},
deleteTrackConfigsForGenome(state, action: PayloadAction<string>) {
const genomeId = action.payload;
......@@ -256,7 +256,7 @@ export const {
updateSelectedCog,
updateApplyToAll,
updateTrackName,
updateFeatureLabel,
updateFeatureLabelsVisibility,
updateShowSeveralTranscripts,
updateShowTranscriptIds,
deleteTrackConfigsForGenome
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment