Skip to content
This repository has been archived by the owner on Jan 22, 2024. It is now read-only.

Commit

Permalink
improving passing of alignmentAnnotationVisibility to keep the defaul…
Browse files Browse the repository at this point in the history
…t values unless explicitly overridden
  • Loading branch information
tnrich committed Jun 4, 2021
1 parent ce25936 commit 9110008
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
8 changes: 8 additions & 0 deletions cypress/integration/standaloneAlignment.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
describe("StandaloneAlignment", function () {
it("it should have both parts and features shown by default (via passed in alignmentAnnotationVisibility) and still show the sequence", function () {
cy.visit("#/StandaloneAlignment");
cy.get(".veRowViewPart").should("exist");
cy.get(".veRowViewFeature").should("exist");
cy.get(".rowViewTextContainer").should("exist");
});
});
4 changes: 4 additions & 0 deletions demo/src/StandaloneAlignmentDemo.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ export default class StandaloneAlignmentDemo extends React.Component {
handleAlignmentRename: () => {
console.info("alignment being renamed!");
}, //this does nothing right now
alignmentAnnotationVisibility: {
features: true,
parts: true
},
linearViewOptions: () => {
return {
selectionLayerRightClicked: ({ event }) => {
Expand Down
15 changes: 9 additions & 6 deletions src/redux/alignments.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const alignmentAnnotationSettings = {
primers: false
};

let defaultVisibilities = {
const defaultVisibilities = {
alignmentAnnotationVisibility: alignmentAnnotationSettings,
pairwise_alignmentAnnotationVisibility: alignmentAnnotationSettings,
alignmentAnnotationLabelVisibility: {
Expand Down Expand Up @@ -138,18 +138,21 @@ export default (state = {}, { payload = {}, type }) => {
}

if (type === "UPSERT_ALIGNMENT_RUN") {
let payloadToUse = {
const payloadToUse = {
...payload,
//assign default visibilities
...defaultVisibilityTypes.reduce((acc, type) => {
if (
(type.startsWith("pairwise_") && payload.pairwiseAlignments) ||
(!type.startsWith("pairwise_") && !payload.pairwiseAlignments)
) {
acc[type.replace("pairwise_", "")] = defaultVisibilities[type];
acc[type.replace("pairwise_", "")] = {
...defaultVisibilities[type],
...payload[type.replace("pairwise_", "")]
};
}
return acc;
}, {}),
...payload
}, {})
};
if (payloadToUse.pairwiseAlignments) {
if (
Expand Down Expand Up @@ -287,7 +290,7 @@ function checkForIssues(alignmentTracks, alignmentType) {
return;
}

let alignmentTrackLength = alignmentTracks[0].alignmentData.sequence.length;
const alignmentTrackLength = alignmentTracks[0].alignmentData.sequence.length;
let hasError;
alignmentTracks.some((track) => {
if (track.alignmentData.sequence.length !== alignmentTrackLength) {
Expand Down

0 comments on commit 9110008

Please sign in to comment.