@teselagen/ove 0.3.11 → 0.3.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. package/index.js +529 -422
  2. package/index.mjs +530 -423
  3. package/index.umd.js +532 -402
  4. package/package.json +2 -2
  5. package/src/AlignmentView/AlignmentVisibilityTool.js +1 -1
  6. package/src/AlignmentView/EditTrackNameDialog.js +1 -5
  7. package/src/AlignmentView/HorizontalPanelDragHandle.js +2 -2
  8. package/src/AlignmentView/Minimap.js +12 -12
  9. package/src/AlignmentView/PairwiseAlignmentView.js +1 -1
  10. package/src/AlignmentView/getGapMap.js +1 -1
  11. package/src/AlignmentView/getTrackFromEvent.js +1 -1
  12. package/src/AlignmentView/index.js +32 -37
  13. package/src/AutoAnnotate.js +48 -48
  14. package/src/CircularView/Cutsites.js +3 -3
  15. package/src/CircularView/Labels/index.js +7 -7
  16. package/src/CircularView/Labels/relaxLabels_DEPRECATED.js +5 -5
  17. package/src/CircularView/RotateCircularViewSlider.js +1 -1
  18. package/src/CircularView/SelectionLayer.js +2 -2
  19. package/src/CircularView/drawAnnotations.js +3 -3
  20. package/src/CircularView/getAngleForPositionMidpoint.js +1 -1
  21. package/src/CircularView/index.d.ts +11 -11
  22. package/src/CircularView/index.js +9 -9
  23. package/src/CreateAnnotationsPage.js +7 -5
  24. package/src/CreateCustomEnzyme/index.js +1 -5
  25. package/src/CutsiteFilter/AdditionalCutsiteInfoDialog.js +11 -11
  26. package/src/CutsiteFilter/index.js +12 -12
  27. package/src/DigestTool/AddLaddersDialog.js +1 -1
  28. package/src/DigestTool/DigestTool.js +3 -3
  29. package/src/DigestTool/Ladder.js +8 -8
  30. package/src/DigestTool/ladderDefaults.js +1 -2
  31. package/src/Editor/CommandHotkeyHandler.js +1 -1
  32. package/src/Editor/DropHandler.js +2 -2
  33. package/src/Editor/index.js +15 -15
  34. package/src/Editor/userDefinedHandlersAndOpts.js +3 -1
  35. package/src/FindBar/index.js +6 -6
  36. package/src/GlobalDialogUtils.js +6 -0
  37. package/src/LinearView/ZoomLinearView.js +1 -1
  38. package/src/LinearView/index.js +7 -7
  39. package/src/MenuBar/index.js +1 -1
  40. package/src/MenuBar/viewSubmenu.js +1 -1
  41. package/src/PCRTool/PCRTool.js +19 -19
  42. package/src/Reflex/Browser.js +4 -5
  43. package/src/Reflex/ReflexContainer.js +3 -3
  44. package/src/Reflex/ReflexElement.js +2 -2
  45. package/src/RowItem/Axis.js +1 -1
  46. package/src/RowItem/Caret/index.js +1 -1
  47. package/src/RowItem/Chromatograms/Chromatogram.js +3 -3
  48. package/src/RowItem/CutsiteSelectionLayers.js +1 -1
  49. package/src/RowItem/Cutsites.js +1 -1
  50. package/src/RowItem/Labels.js +2 -2
  51. package/src/RowItem/Orfs.js +2 -2
  52. package/src/RowItem/Sequence.js +4 -4
  53. package/src/RowItem/StackedAnnotations/PointedAnnotation.js +3 -3
  54. package/src/RowItem/StackedAnnotations/getStructuredBases.js +1 -1
  55. package/src/RowItem/Translations/AASliver.js +71 -75
  56. package/src/RowItem/Translations/index.js +1 -1
  57. package/src/RowItem/getCutsiteLabelHeights.js +1 -1
  58. package/src/RowItem/index.js +14 -8
  59. package/src/RowView/estimateRowHeight.js +5 -5
  60. package/src/RowView/index.d.ts +7 -7
  61. package/src/RowView/index.js +11 -12
  62. package/src/SimpleCircularOrLinearView.js +6 -6
  63. package/src/StatusBar/MeltingTemp.js +3 -3
  64. package/src/StatusBar/index.js +29 -33
  65. package/src/ToolBar/ToolbarItem.js +2 -2
  66. package/src/ToolBar/alignmentTool.js +9 -9
  67. package/src/ToolBar/editTool.js +41 -37
  68. package/src/ToolBar/findTool.js +2 -2
  69. package/src/ToolBar/importTool.js +1 -1
  70. package/src/ToolBar/index.js +2 -2
  71. package/src/ToolBar/oligoTool.js +1 -1
  72. package/src/ToolBar/orfTool.js +1 -6
  73. package/src/ToolBar/printTool.js +2 -2
  74. package/src/ToolBar/visibilityTool.js +1 -1
  75. package/src/VersionHistoryView/index.js +2 -2
  76. package/src/commands/index.js +237 -230
  77. package/src/createVectorEditor/index.js +4 -4
  78. package/src/fileUtils.js +18 -18
  79. package/src/helperComponents/AddOrEditAnnotationDialog/index.js +22 -15
  80. package/src/helperComponents/AddOrEditFeatureDialog/index.js +2 -2
  81. package/src/helperComponents/AddOrEditPartDialog/index.js +2 -2
  82. package/src/helperComponents/AddOrEditPrimerDialog/index.js +5 -5
  83. package/src/helperComponents/EnzymesDialog/index.js +17 -22
  84. package/src/helperComponents/GoToDialog.js +5 -1
  85. package/src/helperComponents/MergeFeaturesDialog/index.js +3 -3
  86. package/src/helperComponents/PinchHelper/PinchHelper.js +1 -1
  87. package/src/helperComponents/PrintDialog/index.js +4 -4
  88. package/src/helperComponents/PropertiesDialog/CutsiteProperties.js +3 -3
  89. package/src/helperComponents/PropertiesDialog/GenbankView.js +1 -1
  90. package/src/helperComponents/PropertiesDialog/GeneralProperties.js +10 -8
  91. package/src/helperComponents/PropertiesDialog/GenericAnnotationProperties.js +136 -138
  92. package/src/helperComponents/PropertiesDialog/OrfProperties.js +3 -3
  93. package/src/helperComponents/PropertiesDialog/PrimerProperties.js +1 -1
  94. package/src/helperComponents/PropertiesDialog/TranslationProperties.js +2 -2
  95. package/src/helperComponents/PropertiesDialog/index.js +3 -3
  96. package/src/helperComponents/RemoveDuplicates/index.js +3 -3
  97. package/src/helperComponents/SelectDialog.js +3 -3
  98. package/src/helperComponents/UncontrolledSliderWithPlusMinusBtns.js +5 -5
  99. package/src/helperComponents/createSimpleDialog.js +1 -1
  100. package/src/helperComponents/partTagSearch.js +2 -5
  101. package/src/helperComponents/withHover.js +3 -3
  102. package/src/redux/alignments.js +6 -6
  103. package/src/redux/annotationVisibility.js +4 -4
  104. package/src/redux/featureLengthsToHide.js +1 -1
  105. package/src/redux/frameTranslations.js +3 -3
  106. package/src/redux/middleware.js +2 -2
  107. package/src/redux/panelsShown.js +19 -19
  108. package/src/redux/partLengthsToHide.js +1 -1
  109. package/src/redux/primerLengthsToHide.js +1 -1
  110. package/src/redux/readOnly.js +1 -4
  111. package/src/redux/selectionLayer.js +1 -1
  112. package/src/redux/sequenceData/features.js +1 -1
  113. package/src/redux/sequenceData/upsertDeleteActionGenerator.js +1 -1
  114. package/src/redux/sequenceDataHistory.js +5 -5
  115. package/src/redux/toolBar.js +2 -4
  116. package/src/redux/utils/createMetaAction.js +2 -2
  117. package/src/redux/versionHistory.js +1 -2
  118. package/src/selectors/annotationSearchSelector.js +4 -4
  119. package/src/selectors/circularSelector.js +1 -1
  120. package/src/selectors/cutsiteLabelColorSelector.js +1 -1
  121. package/src/selectors/filteredCutsitesSelector.js +6 -6
  122. package/src/selectors/filteredFeaturesSelector.js +4 -4
  123. package/src/selectors/filteredPartsSelector.js +5 -5
  124. package/src/selectors/filteredPrimersSelector.js +3 -3
  125. package/src/selectors/isEnzymeFilterAndSelector.js +1 -1
  126. package/src/selectors/orfsSelector.js +1 -1
  127. package/src/selectors/restrictionEnzymesSelector.js +2 -2
  128. package/src/selectors/searchLayersSelector.js +7 -7
  129. package/src/selectors/sequenceLengthSelector.js +1 -1
  130. package/src/selectors/sequenceSelector.js +1 -1
  131. package/src/selectors/tagsToBoldSelector.js +1 -1
  132. package/src/selectors/translationsSelector.js +7 -7
  133. package/src/updateEditor.js +1 -1
  134. package/src/utils/PassThrough.js +1 -1
  135. package/src/utils/addWrappedAddons.js +1 -1
  136. package/src/utils/annotationTypes.js +2 -2
  137. package/src/utils/combineReducersDontIgnoreKeys.js +1 -1
  138. package/src/utils/editorUtils.js +2 -2
  139. package/src/utils/massageTickSpacing.js +1 -1
  140. package/src/utils/onlyUpdateForKeysDeep.js +1 -1
  141. package/src/utils/pureNoFunc.js +1 -1
  142. package/src/utils/shouldRerender.js +1 -1
  143. package/src/utils/showFileDialog.js +6 -7
  144. package/src/utils/updateLabelsForInViewFeatures.js +1 -1
  145. package/src/utils/useAnnotationLimits.js +1 -1
  146. package/src/withEditorInteractions/Keyboard.js +2 -3
  147. package/src/withEditorInteractions/createSequenceInputPopup.js +4 -4
  148. package/src/withEditorInteractions/index.js +93 -55
  149. package/src/withEditorProps/index.js +39 -37
  150. package/style.css +138 -138
@@ -26,7 +26,6 @@ import {
26
26
  import { defaultMemoize } from "reselect";
27
27
  import { connect } from "react-redux";
28
28
 
29
-
30
29
  const rowJumpButtonStyle = {
31
30
  height: rowHeights.rowJumpButtons.height
32
31
  };
@@ -285,7 +284,7 @@ class _RowView extends React.Component {
285
284
 
286
285
  cache = {};
287
286
 
288
- renderItem = (index) => {
287
+ renderItem = index => {
289
288
  // if (this.cache[index]) return this.cache[index];
290
289
  const {
291
290
  //currently found in props
@@ -319,7 +318,7 @@ class _RowView extends React.Component {
319
318
  icon="arrow-down"
320
319
  minimal
321
320
  data-test="jumpToEndButton"
322
- onClick={(e) => {
321
+ onClick={e => {
323
322
  e.stopPropagation();
324
323
  this.InfiniteScroller &&
325
324
  this.InfiniteScroller.scrollTo(rowData.length);
@@ -338,7 +337,7 @@ class _RowView extends React.Component {
338
337
  icon="arrow-up"
339
338
  minimal
340
339
  data-test="jumpToStartButton"
341
- onClick={(e) => {
340
+ onClick={e => {
342
341
  e.stopPropagation();
343
342
  this.InfiniteScroller && this.InfiniteScroller.scrollTo(0);
344
343
  }}
@@ -362,7 +361,7 @@ class _RowView extends React.Component {
362
361
  truncateLabelsThatDoNotFit,
363
362
  rowBottomComp,
364
363
  scalePct: this.state?.scalePct,
365
- setScalePct: (scalePct) => {
364
+ setScalePct: scalePct => {
366
365
  this.setState({ scalePct });
367
366
  },
368
367
  isRowView: true,
@@ -389,11 +388,11 @@ class _RowView extends React.Component {
389
388
  return null;
390
389
  }
391
390
  };
392
- onDrag = (event) => {
391
+ onDrag = event => {
393
392
  if (isMobile({ tablet: true })) {
394
393
  if (
395
394
  //only allow dragging on mobile if the user is grabbing the cursor
396
- !some(draggableClassnames, (cn) => {
395
+ !some(draggableClassnames, cn => {
397
396
  if (event.target.classList.contains(cn)) {
398
397
  return true;
399
398
  }
@@ -407,7 +406,7 @@ class _RowView extends React.Component {
407
406
  const rowData = this.rowData;
408
407
  this.getNearestCursorPositionToMouseEvent(rowData, event, editorDragged);
409
408
  };
410
- onStart = (event) => {
409
+ onStart = event => {
411
410
  this.dragging = true;
412
411
  const rowData = this.rowData;
413
412
  this.getNearestCursorPositionToMouseEvent(
@@ -422,16 +421,16 @@ class _RowView extends React.Component {
422
421
  editorDragStopped();
423
422
  };
424
423
 
425
- getRef = (ref) => (this.node = ref);
424
+ getRef = ref => (this.node = ref);
426
425
 
427
- onContextMenu = (event) => {
426
+ onContextMenu = event => {
428
427
  this.getNearestCursorPositionToMouseEvent(
429
428
  this.rowData,
430
429
  event,
431
430
  this.props.backgroundRightClicked
432
431
  );
433
432
  };
434
- onClick = (event) => {
433
+ onClick = event => {
435
434
  this.getNearestCursorPositionToMouseEvent(
436
435
  this.rowData,
437
436
  event,
@@ -439,7 +438,7 @@ class _RowView extends React.Component {
439
438
  );
440
439
  };
441
440
 
442
- getReactListRef = (c) => {
441
+ getReactListRef = c => {
443
442
  this.InfiniteScroller = c;
444
443
  !this.calledUpdateScrollOnce && this.updateScrollPosition({}, this.props); //trigger the scroll here as well because now we actually have the infinite scroller component accessible
445
444
  };
@@ -31,7 +31,7 @@ import {
31
31
  } from "./withEditorInteractions/clickAndDragUtils";
32
32
 
33
33
  //this view is meant to be a helper for showing a simple (non-redux connected) circular or linear view!
34
- export default (props) => {
34
+ export default props => {
35
35
  let {
36
36
  sequenceData: _sequenceData,
37
37
  annotationVisibility: _annotationVisibility = {},
@@ -281,13 +281,13 @@ export default (props) => {
281
281
  return inner({});
282
282
  };
283
283
 
284
- const DownloadBtn = withHandlers({ exportSequenceToFile })((props) => {
284
+ const DownloadBtn = withHandlers({ exportSequenceToFile })(props => {
285
285
  return (
286
286
  <Tooltip content="Download">
287
287
  <Button
288
288
  className="veDownloadButton"
289
289
  style={{ marginRight: 10 }}
290
- onClick={(event) =>
290
+ onClick={event =>
291
291
  showContextMenu(
292
292
  [
293
293
  "exportSequenceAsGenbank",
@@ -337,7 +337,7 @@ const VisibilityOptions = ({
337
337
  <Tooltip disabled={isPopoverOpen} content="Visibility Options">
338
338
  <Popover
339
339
  minimal
340
- onInteraction={(isOpen) => {
340
+ onInteraction={isOpen => {
341
341
  setPopoverOpen(isOpen);
342
342
  }}
343
343
  isOpen={isPopoverOpen}
@@ -345,11 +345,11 @@ const VisibilityOptions = ({
345
345
  <Menu>
346
346
  {flatMap(
347
347
  ["features", "parts", "primers", "translations", "cutsites"],
348
- (name) => {
348
+ name => {
349
349
  if (!map(sequenceData[name]).length) return [];
350
350
  return (
351
351
  <MenuItem
352
- onClick={(e) => {
352
+ onClick={e => {
353
353
  setVisibilityOptions({
354
354
  ...annotationVisibility,
355
355
  [name]: !annotationVisibility[name]
@@ -9,8 +9,8 @@ import useTmType from "../utils/useTmType";
9
9
 
10
10
  export default function MeltingTemp({
11
11
  sequence,
12
- WrapperToUse = (p) => <div>{p.children}</div>,
13
- InnerWrapper = (p) => (
12
+ WrapperToUse = p => <div>{p.children}</div>,
13
+ InnerWrapper = p => (
14
14
  <Button minimal small>
15
15
  {p.children}
16
16
  </Button>
@@ -46,7 +46,7 @@ export default function MeltingTemp({
46
46
  { value: "default", label: "Default Tm" },
47
47
  { value: "neb_tm", label: "NEB Tm" }
48
48
  ]}
49
- onChange={(e) => setTmType(e.target.value)}
49
+ onChange={e => setTmType(e.target.value)}
50
50
  selectedValue={tmType}
51
51
  ></RadioGroup>
52
52
  {hasWarning && (
@@ -14,41 +14,35 @@ import { getSelectionMessage } from "../utils/editorUtils";
14
14
  import useMeltingTemp from "../utils/useMeltingTemp";
15
15
  import MeltingTemp from "./MeltingTemp";
16
16
  import { getSequenceWithinRange } from "@teselagen/range-utils";
17
+ import { handleReadOnlyChange } from "../ToolBar/editTool";
17
18
 
18
19
  const EditReadOnlyItem = connectToEditor(({ readOnly }) => ({
19
20
  readOnly
20
- }))(
21
- ({
22
- onSave,
23
- readOnly,
24
- showReadOnly,
25
- disableSetReadOnly,
26
- updateReadOnlyMode
27
- }) => {
28
- return showReadOnly ? (
29
- <StatusBarItem dataTest="veStatusBar-readOnly">
30
- {onSave ? (
31
- <HTMLSelect
32
- options={[
33
- { label: "Read Only", value: "readOnly" },
34
- { label: "Editable", value: "editable" }
35
- ]}
36
- disabled={disableSetReadOnly || !onSave} //the !onSave here is redundant
37
- className={Classes.MINIMAL}
38
- value={readOnly ? "readOnly" : "editable"}
39
- onChange={({ target: { value } }) => {
40
- updateReadOnlyMode(value === "readOnly");
41
- }}
42
- />
43
- ) : readOnly ? (
44
- "Read Only"
45
- ) : (
46
- "Editable"
47
- )}
48
- </StatusBarItem>
49
- ) : null;
50
- }
51
- );
21
+ }))(props => {
22
+ const { onSave, readOnly, showReadOnly, disableSetReadOnly } = props;
23
+ return showReadOnly ? (
24
+ <StatusBarItem dataTest="veStatusBar-readOnly">
25
+ {onSave ? (
26
+ <HTMLSelect
27
+ options={[
28
+ { label: "Read Only", value: "readOnly" },
29
+ { label: "Editable", value: "editable" }
30
+ ]}
31
+ disabled={disableSetReadOnly || !onSave} //the !onSave here is redundant
32
+ className={Classes.MINIMAL}
33
+ value={readOnly ? "readOnly" : "editable"}
34
+ onChange={({ target: { value } }) =>
35
+ handleReadOnlyChange(value === "readOnly", props)
36
+ }
37
+ />
38
+ ) : readOnly ? (
39
+ "Read Only"
40
+ ) : (
41
+ "Editable"
42
+ )}
43
+ </StatusBarItem>
44
+ ) : null;
45
+ });
52
46
 
53
47
  const ShowSelectionItem = compose(
54
48
  connectToEditor(
@@ -226,7 +220,8 @@ export function StatusBar({
226
220
  showGCContentByDefault,
227
221
  onSelectionOrCaretChanged,
228
222
  GCDecimalDigits = 1,
229
- isProtein
223
+ isProtein,
224
+ beforeReadOnlyChange
230
225
  }) {
231
226
  return (
232
227
  <div className="veStatusBar">
@@ -234,6 +229,7 @@ export function StatusBar({
234
229
  <ShowTypeItem editorName={editorName}></ShowTypeItem>
235
230
  )}
236
231
  <EditReadOnlyItem
232
+ beforeReadOnlyChange={beforeReadOnlyChange}
237
233
  editorName={editorName}
238
234
  onSave={onSave}
239
235
  disableSetReadOnly={disableSetReadOnly}
@@ -125,7 +125,7 @@ class ToolbarItem extends React.Component {
125
125
  );
126
126
  const content = (
127
127
  <div
128
- ref={(n) => {
128
+ ref={n => {
129
129
  if (n) this.dropdownNode = n;
130
130
  }}
131
131
  style={{ padding: 10, minWidth: 250, maxWidth: 350 }}
@@ -160,7 +160,7 @@ class ToolbarItem extends React.Component {
160
160
  <Popover
161
161
  disabled={popoverDisabled}
162
162
  isOpen={!!Dropdown && isOpen}
163
- onClose={(e) => {
163
+ onClose={e => {
164
164
  let srcElement;
165
165
  if (e) {
166
166
  srcElement = e.srcElement || e.target;
@@ -100,7 +100,7 @@ class AlignmentTool extends React.Component {
100
100
  state = {
101
101
  templateSeqIndex: 0
102
102
  };
103
- sendSelectedDataToBackendForAlignment = async (values) => {
103
+ sendSelectedDataToBackendForAlignment = async values => {
104
104
  const {
105
105
  addedSequences,
106
106
  isPairwiseAlignment,
@@ -175,7 +175,7 @@ class AlignmentTool extends React.Component {
175
175
  // const j5server = process.env.REMOTE_J5 || "http://j5server.teselagen.com"
176
176
 
177
177
  window.toastr.success("Alignment submitted.");
178
- const replaceProtocol = (url) => {
178
+ const replaceProtocol = url => {
179
179
  return url.replace("http://", window.location.protocol + "//");
180
180
  };
181
181
 
@@ -227,7 +227,7 @@ class AlignmentTool extends React.Component {
227
227
  }),
228
228
  alignmentTracks:
229
229
  alignedSequences &&
230
- alignedSequences.map((alignmentData) => {
230
+ alignedSequences.map(alignmentData => {
231
231
  return {
232
232
  sequenceData:
233
233
  seqsToAlign[
@@ -254,12 +254,12 @@ class AlignmentTool extends React.Component {
254
254
 
255
255
  handleFileUpload = (files, onChange) => {
256
256
  const { array } = this.props;
257
- flatMap(files, async (file) => {
257
+ flatMap(files, async file => {
258
258
  const results = await anyToJson(file.originalFileObj, {
259
259
  fileName: file.name,
260
260
  acceptParts: true
261
261
  });
262
- return results.forEach((result) => {
262
+ return results.forEach(result => {
263
263
  if (result.success) {
264
264
  array.push("addedSequences", result.parsedSequence);
265
265
  } else {
@@ -278,7 +278,7 @@ class AlignmentTool extends React.Component {
278
278
  <h6>Or enter sequences in plain text format</h6>
279
279
  <div>
280
280
  <AddYourOwnSeqForm
281
- addSeq={(newSeq) => {
281
+ addSeq={newSeq => {
282
282
  fields.push(newSeq);
283
283
  }}
284
284
  />
@@ -327,7 +327,7 @@ class AlignmentTool extends React.Component {
327
327
  )}
328
328
 
329
329
  <Button
330
- onClick={(e) => {
330
+ onClick={e => {
331
331
  e.stopPropagation();
332
332
  e.preventDefault();
333
333
  fields.remove(index);
@@ -443,7 +443,7 @@ const AddYourOwnSeqForm = reduxForm({
443
443
  })(({ pristine, error, handleSubmit, reset, addSeq }) => {
444
444
  return (
445
445
  <form
446
- onSubmit={handleSubmit((vals) => {
446
+ onSubmit={handleSubmit(vals => {
447
447
  reset();
448
448
  addSeq(vals);
449
449
  })}
@@ -490,7 +490,7 @@ function mottTrim(qualNums) {
490
490
  totalScore = 0;
491
491
  }
492
492
  }
493
- const firstPositiveValue = totalScoreInfo.find((e) => {
493
+ const firstPositiveValue = totalScoreInfo.find(e => {
494
494
  return e > 0;
495
495
  });
496
496
  startPos = totalScoreInfo.indexOf(firstPositiveValue);
@@ -2,45 +2,49 @@ import React, { useState } from "react";
2
2
  import { Icon } from "@blueprintjs/core";
3
3
  import ToolbarItem from "./ToolbarItem";
4
4
  import { connectToEditor } from "../withEditorProps";
5
+ import { func } from "prop-types";
5
6
 
6
- export default connectToEditor((editorState) => {
7
+ export default connectToEditor(editorState => {
7
8
  return {
8
9
  readOnly: editorState.readOnly
9
10
  };
10
- })(
11
- ({
12
- toolbarItemProps,
13
- readOnly,
14
- toggleReadOnlyMode,
15
- disableSetReadOnly,
16
- onChangeEditLock
17
- }) => {
18
- const [isLoading, setIsLoading] = useState(false);
19
- const readOnlyTooltip = ({ readOnly, disableSetReadOnly }) => {
20
- if (isLoading) {
21
- return "Loading...";
22
- } else if (disableSetReadOnly) {
23
- return "You do not have permission to edit locks on this sequence";
24
- }
25
- return readOnly ? "Click to enable editing" : "Click to disable editing";
26
- };
27
- return (
28
- <ToolbarItem
29
- {...{
30
- disabled: isLoading || disableSetReadOnly,
31
- Icon: <Icon icon={readOnly ? "lock" : "unlock"} />,
32
- onIconClick: async () => {
33
- if (onChangeEditLock) {
34
- setIsLoading(true);
35
- await onChangeEditLock(!readOnly);
36
- setIsLoading(false);
37
- }
38
- toggleReadOnlyMode();
39
- },
40
- tooltip: readOnlyTooltip({ readOnly, disableSetReadOnly }),
41
- ...toolbarItemProps
42
- }}
43
- />
44
- );
11
+ })(props => {
12
+ const { toolbarItemProps, readOnly, disableSetReadOnly } = props;
13
+ const [isLoading, setIsLoading] = useState(false);
14
+ const readOnlyTooltip = ({ readOnly, disableSetReadOnly }) => {
15
+ if (isLoading) {
16
+ return "Loading...";
17
+ } else if (disableSetReadOnly) {
18
+ return "You do not have permission to edit locks on this sequence";
19
+ }
20
+ return readOnly ? "Click to enable editing" : "Click to disable editing";
21
+ };
22
+ return (
23
+ <ToolbarItem
24
+ {...{
25
+ disabled: isLoading || disableSetReadOnly,
26
+ Icon: <Icon icon={readOnly ? "lock" : "unlock"} />,
27
+ onIconClick: () =>
28
+ handleReadOnlyChange(!readOnly, { ...props, setIsLoading }),
29
+ tooltip: readOnlyTooltip({ readOnly, disableSetReadOnly }),
30
+ ...toolbarItemProps
31
+ }}
32
+ />
33
+ );
34
+ });
35
+
36
+ export async function handleReadOnlyChange(
37
+ newVal,
38
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
39
+ { beforeReadOnlyChange, updateReadOnlyMode, setIsLoading = () => {} }
40
+ ) {
41
+ if (beforeReadOnlyChange) {
42
+ setIsLoading(true);
43
+ const shouldChange = await beforeReadOnlyChange(newVal);
44
+ setIsLoading(false);
45
+ if (shouldChange === false) {
46
+ return;
47
+ }
45
48
  }
46
- );
49
+ updateReadOnlyMode(newVal);
50
+ }
@@ -1,2 +1,2 @@
1
- import inlineFindTool from './inlineFindTool'
2
- export default inlineFindTool
1
+ import inlineFindTool from "./inlineFindTool";
2
+ export default inlineFindTool;
@@ -17,7 +17,7 @@ export default compose(
17
17
  IconWrapperProps: {
18
18
  multiple: false,
19
19
  style: {},
20
- onDrop: (files) => importSequenceFromFile(files[0])
20
+ onDrop: files => importSequenceFromFile(files[0])
21
21
  },
22
22
  tooltip: "Click or drag to import and view files (.fasta .gb .dna)",
23
23
  ...toolbarItemProps
@@ -66,7 +66,7 @@ export function ToolBar(props) {
66
66
  };
67
67
 
68
68
  const toolListToUse = useMemo(() => {
69
- return flatMap(toolList, (toolNameOrOverrides) => {
69
+ return flatMap(toolList, toolNameOrOverrides => {
70
70
  let toolName;
71
71
  let toolOverride;
72
72
  if (isString(toolNameOrOverrides)) {
@@ -196,7 +196,7 @@ export function ToolBar(props) {
196
196
  </div>
197
197
  );
198
198
  }
199
- const CloseFullscreenButton = (props) => {
199
+ const CloseFullscreenButton = props => {
200
200
  return (
201
201
  <Tooltip content="Close Fullscreen Mode">
202
202
  <Button
@@ -16,7 +16,7 @@ export default connectToEditor(editorState => {
16
16
  <ToolbarItem
17
17
  {...{
18
18
  Icon: <Icon icon="swap-horizontal" />,
19
- onIconClick: function() {
19
+ onIconClick: function () {
20
20
  annotationVisibilityToggle("primers");
21
21
  },
22
22
  isHidden,
@@ -1,11 +1,6 @@
1
1
  import { Icon } from "@blueprintjs/core";
2
2
  import React from "react";
3
- import {
4
- orfIcon,
5
- CmdCheckbox,
6
- CmdDiv,
7
- InfoHelper
8
- } from "@teselagen/ui";
3
+ import { orfIcon, CmdCheckbox, CmdDiv, InfoHelper } from "@teselagen/ui";
9
4
  import ToolbarItem from "./ToolbarItem";
10
5
  import { connectToEditor } from "../withEditorProps";
11
6
  import withEditorProps from "../withEditorProps";
@@ -1,11 +1,11 @@
1
- //TNRTODO this needs to be fixed and implemented
1
+ //TNRTODO this needs to be fixed and implemented
2
2
  import React from "react";
3
3
  import print from "./veToolbarIcons/print.png";
4
4
 
5
5
  export default () => {
6
6
  return {
7
7
  Icon: <img src={print} alt="Print Vector" />,
8
- onIconClick: function() {
8
+ onIconClick: function () {
9
9
  // var myPrintContent = document.getElementById('printdiv');
10
10
  // var myPrintWindow = window.open(windowUrl, windowName, 'left=300,top=100,width=400,height=400');
11
11
  // myPrintWindow.document.write(myPrintContent.innerHTML);
@@ -27,7 +27,7 @@ export default connectToEditor(({ toolBar = {} }) => {
27
27
  );
28
28
  });
29
29
 
30
- const VisibilityOptions = withEditorProps(function(props) {
30
+ const VisibilityOptions = withEditorProps(function (props) {
31
31
  return (
32
32
  <Menu>
33
33
  {createCommandMenu(viewSubmenu, getCommands({ props }), {
@@ -38,7 +38,7 @@ export class VersionHistoryView extends React.Component {
38
38
  // ];
39
39
  // }
40
40
  // };
41
- updateSeqData = (sequenceData) => {
41
+ updateSeqData = sequenceData => {
42
42
  this.activeSeqData = sequenceData;
43
43
  this.props.vectorEditorInitialize(
44
44
  {
@@ -81,7 +81,7 @@ export class VersionHistoryView extends React.Component {
81
81
  this.setState({
82
82
  versionList: [
83
83
  currentVersion,
84
- ...versionList.map((r) => {
84
+ ...versionList.map(r => {
85
85
  return { ...r, id: r.versionId };
86
86
  })
87
87
  ] //currentVersion should always come first