This repository has been archived by the owner on Jan 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 73
/
index.js
145 lines (140 loc) · 3.7 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
import React from "react";
import { reduxForm } from "redux-form";
import {
SelectField,
NumericInputField,
withDialog
} from "teselagen-react-components";
import { compose } from "redux";
import { Button, Intent, Classes } from "@blueprintjs/core";
import classNames from "classnames";
import withEditorProps from "../../withEditorProps";
import pamSites from "../../constants/pamSites";
export class FindGuideDialog extends React.Component {
render() {
const {
// editorName,
hideModal,
sequenceData = { sequence: "" },
handleSubmit,
updateGuides,
findGuides,
createGuideToolTab,
partId
} = this.props;
const sequenceLength = sequenceData.sequence.length;
const partName = sequenceData.parts[partId].name;
return (
<div
className={classNames(
Classes.DIALOG_BODY,
"tg-min-width-dialog",
"tg-upsert-Primer"
)}
>
<NumericInputField
inlineLabel
defaultValue={20}
min={1}
max={sequenceLength}
name="guideLength"
label="Guide Length:"
/>
<SelectField
inlineLabel
defaultValue="NGG"
name="pamSite"
label="PAM site"
options={pamSites}
/>
<NumericInputField
inlineLabel
defaultValue={1}
min={1}
max={sequenceLength}
name="start"
label="Start:"
/>
<NumericInputField
inlineLabel
defaultValue={1}
min={1}
max={sequenceLength}
name="end"
label="End:"
/>
<div
style={{ display: "flex", justifyContent: "flex-end" }}
className="width100"
>
<Button
style={{ marginRight: 15 }}
onMouseDown={e => {
//use onMouseDown to prevent issues with redux form errors popping in and stopping the dialog from closing
e.preventDefault();
e.stopPropagation();
hideModal();
}}
>
Cancel
</Button>
<Button
onClick={handleSubmit(async data => {
const guides = await findGuides({
data: [
{
sequence: sequenceData.sequence,
start: data.start - 1,
end: data.end - 1,
partId: partId
}
],
options: {
guideLength: data.guideLength,
pamSite: data.pamSite,
// we set this so that off target score is not calculated for all gRNAs
// TODO: user should select gRNAs that they want the off-target score to be calculated for
mode: "single-gene"
}
});
if (guides && guides.length) {
createGuideToolTab({ guides });
guides.forEach(function(g) {
g.target = partName;
});
updateGuides(guides);
}
hideModal();
})}
intent={Intent.PRIMARY}
disabled={!findGuides}
>
Search
</Button>
</div>
</div>
);
}
}
const validate = values => {
const errors = {};
if (!values.guideLength) {
errors.guideLength = "Required";
}
if (!values.pamSite) {
errors.pamSite = "Required";
}
return errors;
};
export default compose(
withDialog({
isDraggable: true,
height: 360,
width: 400
}),
withEditorProps,
reduxForm({
form: "FindGuideDialog",
validate
})
)(FindGuideDialog);