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

Commit

Permalink
adding a molecule type field to the status bar #805
Browse files Browse the repository at this point in the history
  • Loading branch information
tnrich committed Jan 7, 2022
1 parent cb4d9e6 commit ba519d1
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 3 deletions.
15 changes: 15 additions & 0 deletions cypress/integration/statusBar.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
describe("statusBar", function () {
it("molcule type should be an option in the menu bar", function () {
cy.visit("");
cy.contains(`[data-test="veStatusBar-type"]`, "DNA");
cy.get(`[data-test="moleculeType"]`).select("Protein");
cy.contains(`[data-test="veStatusBar-type"]`, "Protein");
cy.get(`[data-test="moleculeType"]`).select("RNA");
cy.contains(`[data-test="veStatusBar-type"]`, "RNA");
cy.get(`[data-test="moleculeType"]`).select("Oligo");
cy.contains(`[data-test="veStatusBar-type"]`, "Oligo");
cy.get(`[data-test="moleculeType"]`).select("mixedRnaAndDna");
cy.contains(`[data-test="veStatusBar-type"]`, "Mixed RNA/DNA");

cy.tgToggle("showMoleculeType", false);
cy.get(`[data-test="veStatusBar-type"]`).should("not.exist");
});
it("melting temp should be an option in the menu bar", function () {
cy.visit("");
cy.selectRange(10, 30);
Expand Down
9 changes: 8 additions & 1 deletion demo/src/EditorDemo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const defaultState = {
disableSetReadOnly: false,
showReadOnly: true,
showCircularity: true,
showMoleculeType: true,
showGCContentByDefault: false,
GCDecimalDigits: 1,
onlyShowLabelsThatDoNotFit: true,
Expand Down Expand Up @@ -1454,6 +1455,11 @@ clickOverrides: {
type: "showCircularity",
info: `pass showCircularity=false to the <Editor> to not display the circularity toggle`
})}
{renderToggle({
that: this,
type: "showMoleculeType",
info: `pass showMoleculeType=false to the <Editor> to not display the molecule type status item`
})}
{renderToggle({
that: this,
type: "showAvailability",
Expand Down Expand Up @@ -2001,7 +2007,8 @@ clickOverrides: {
disableSetReadOnly={this.state.disableSetReadOnly}
withRotateCircularView={this.state.withRotateCircularView}
showReadOnly={this.state.showReadOnly}
showCircularity={this.state.showCircularity}
showCircularity={!!this.state.showCircularity}
showMoleculeType={this.state.showMoleculeType}
showGCContentByDefault={this.state.showGCContentByDefault}
onlyShowLabelsThatDoNotFit={this.state.onlyShowLabelsThatDoNotFit}
GCDecimalDigits={this.state.GCDecimalDigits}
Expand Down
1 change: 1 addition & 0 deletions src/Editor/userDefinedHandlersAndOpts.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const userDefinedHandlersAndOpts = [
"disableSetReadOnly",
"showReadOnly",
"showCircularity",
"showMoleculeType",
"showAvailability",
"showGCContentByDefault",
"GCDecimalDigits",
Expand Down
24 changes: 22 additions & 2 deletions src/StatusBar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,10 @@ const ShowSelectionItem = compose(
}) => {
const [showMeltingTemp] = useMeltingTemp();

const sequence = getSequenceDataBetweenRange(sequenceData, selectionLayer)
.sequence;
const sequence = getSequenceDataBetweenRange(
sequenceData,
selectionLayer
).sequence;

return (
<React.Fragment>
Expand Down Expand Up @@ -136,6 +138,20 @@ const ShowLengthItem = connectToEditor(
)} ${isProtein ? "AAs" : "bps"}`}</StatusBarItem>
));

const ShowTypeItem = connectToEditor(({ sequenceData }) => ({
isProtein: sequenceData.isProtein,
isOligo: sequenceData.isOligo,
isRna: sequenceData.isRna,
isMixedRnaAndDna: sequenceData.isMixedRnaAndDna
}))(({ isProtein, isOligo, isRna, isMixedRnaAndDna }) => {
let type = "DNA";
if (isProtein) type = "Protein";
if (isRna) type = "RNA";
if (isOligo) type = "Oligo";
if (isMixedRnaAndDna) type = "Mixed RNA/DNA";
return <StatusBarItem dataTest="veStatusBar-type">{type}</StatusBarItem>;
});

const EditCircularityItem = compose(
connectToEditor(
({
Expand Down Expand Up @@ -210,6 +226,7 @@ export function StatusBar({
onSave,
editorName,
showCircularity = true,
showMoleculeType = true,
showReadOnly = true,
showAvailability = false,
showGCContentByDefault,
Expand All @@ -219,6 +236,9 @@ export function StatusBar({
}) {
return (
<div className="veStatusBar">
{showMoleculeType && (
<ShowTypeItem editorName={editorName}></ShowTypeItem>
)}
<EditReadOnlyItem
editorName={editorName}
{...{
Expand Down

0 comments on commit ba519d1

Please sign in to comment.