-
Notifications
You must be signed in to change notification settings - Fork 501
/
Copy pathAddKeyRequest.js
50 lines (42 loc) · 1.28 KB
/
AddKeyRequest.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
import React from 'react';
import dispatcher from './../../helpers/dispatcher';
import ObjectAttributes from './../../stores/ObjectAttributes';
import ObjectKeyModal from './ObjectKeyModal';
//global theme
import Theme from './../../themes/getStyle';
//this input appears when adding a new value to an object
export default class extends React.PureComponent {
render() {
const {active, theme, rjvId} = this.props;
return active ? (
<ObjectKeyModal
rjvId={rjvId}
theme={theme}
isValid={this.isValid}
submit={this.submit}
/>
) : null;
}
isValid = (input) => {
const {rjvId} = this.props;
const request = ObjectAttributes.get(
rjvId, 'action', 'new-key-request'
);
return (
input != ''
);
}
submit = (input) => {
const {rjvId} = this.props;
let request = ObjectAttributes.get(
rjvId, 'action', 'new-key-request'
);
request.new_value = {...request.existing_value};
request.new_value[input] = this.props.defaultValue;
dispatcher.dispatch({
name: 'VARIABLE_ADDED',
rjvId: rjvId,
data: request
});
}
}