This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | const React = require('react'); |
||
2 | const ReactRedux = require('react-redux'); |
||
3 | |||
4 | const Radio = require('../components/Radio.jsx'); |
||
5 | const Checkbox = require('../components/Checkbox.jsx'); |
||
6 | const Dropdown = require('../components/Dropdown.jsx'); |
||
7 | const BuildStatus = require('../components/BuildStatus.jsx'); |
||
8 | const ButtonGitUpdate = require('./buttons/GitUpdate.jsx'); |
||
9 | const SaveTargetRelease = require('./buttons/SaveTargetRelease.jsx'); |
||
10 | |||
11 | const actions = require('../_actions.js'); |
||
12 | const constants = require('../constants/deployment.js'); |
||
13 | |||
14 | const TargetRelease = React.createClass({ |
||
15 | getInitialState: function() { |
||
16 | return { |
||
17 | options_open: false |
||
18 | }; |
||
19 | }, |
||
20 | |||
21 | toggleOptionsOpen: function() { |
||
22 | this.setState({ |
||
23 | options_open: !this.state.options_open |
||
24 | }); |
||
25 | }, |
||
26 | |||
27 | render: function() { |
||
28 | const props = this.props; |
||
29 | const typeFields = {}; |
||
30 | |||
31 | Object.keys(props.types).forEach(function(key) { |
||
32 | switch (key) { |
||
33 | case '0': // Promote build option |
||
34 | typeFields[key] = ( |
||
35 | <BuildStatus status_box status_ago deployment={props.types[key].promote_build} /> |
||
36 | ); |
||
37 | break; |
||
38 | case '1': // Dropdowns for branch, tags, previously released |
||
39 | case '2': |
||
40 | case '3': |
||
41 | typeFields[key] = ( |
||
42 | <Dropdown |
||
43 | onSelect={props.onRefSelect} |
||
44 | options={props.ref_list} |
||
45 | value={props.selected_ref} |
||
46 | disabled={props.disabled} |
||
47 | name={"ref_selector_" + key} |
||
48 | /> |
||
49 | ); |
||
50 | break; |
||
51 | case '4': // Input SHA option |
||
52 | typeFields[key] = ( |
||
53 | <input |
||
54 | className="field text" |
||
55 | type="text" |
||
56 | name="selected_ref" |
||
57 | onChange={props.onShaChange} |
||
58 | value={props.selected_ref} |
||
59 | disabled={props.disabled} |
||
60 | /> |
||
61 | ); |
||
62 | break; |
||
63 | default: |
||
64 | break; |
||
65 | } |
||
66 | }); |
||
67 | |||
68 | const list = Object.keys(props.types).map(function(key, index) { |
||
69 | let extraFields = null; |
||
70 | if (props.selected_type === props.types[key].id) { |
||
71 | extraFields = typeFields[props.types[key].id]; |
||
72 | } |
||
73 | |||
74 | return ( |
||
75 | <li key={props.types[key].id}> |
||
76 | <Radio |
||
77 | description={props.types[key].description} |
||
78 | name="type" |
||
79 | checked={props.selected_type === props.types[key].id} |
||
80 | id={index} |
||
81 | onClick={() => props.onRadioClick(props.types[key].id, props.types[key])} |
||
82 | disabled={props.disabled} |
||
83 | /> |
||
84 | {extraFields} |
||
85 | </li> |
||
86 | ); |
||
87 | }); |
||
88 | |||
89 | let options_classes = 'checkbox-list'; |
||
90 | let caret = 'up'; |
||
91 | if (!this.state.options_open) { |
||
92 | options_classes += ' hide'; |
||
93 | caret = 'down'; |
||
94 | } |
||
95 | |||
96 | let options_toggle = null; |
||
97 | if (list && list.length > 0) { |
||
98 | options_toggle = ( |
||
99 | <a href={"javascript:void(0);"} onClick={this.toggleOptionsOpen}> |
||
0 ignored issues
–
show
introduced
by
![]() |
|||
100 | Deploy options <i className={"fa fa-caret-" + caret}></i> |
||
101 | </a> |
||
102 | ); |
||
103 | } |
||
104 | |||
105 | const fetchClasses = this.props.git_loading ? 'loading' : ''; |
||
106 | return ( |
||
107 | <div> |
||
108 | {this.props.last_fetched_date && <div className={'fetch ' + fetchClasses} > |
||
109 | <div className="pull-right"> |
||
110 | <ButtonGitUpdate /> |
||
111 | </div> |
||
112 | <div> |
||
113 | <i className="fa fa-code" aria-hidden="true"></i> Last synced {this.props.last_fetched_date} |
||
114 | <span className="small">{this.props.last_fetched_ago}</span> |
||
115 | </div> |
||
116 | <div><i>Ensure you have the most recent code before setting up your deployment</i></div> |
||
117 | </div>} |
||
118 | |||
119 | <div className="section target-release"> |
||
120 | <header id="0">Target release</header> |
||
121 | <div> |
||
122 | Select the release you would like to deploy to {props.environment_name} |
||
123 | </div> |
||
124 | <form className="form" onSubmit={props.onSubmit}> |
||
125 | <ul className="radio-list"> |
||
126 | {list} |
||
127 | </ul> |
||
128 | {options_toggle} |
||
129 | <ul className={options_classes}> |
||
130 | {props.options.map(function(option, index) { |
||
131 | return ( |
||
132 | <li key={index}> |
||
133 | <Checkbox |
||
134 | description={option.title} |
||
135 | name="option" |
||
136 | checked={props.selected_options[option.name] === true} |
||
137 | id={index} |
||
138 | onClick={() => props.onCheckboxClick(option.name)} |
||
139 | disabled={props.disabled} |
||
140 | /> |
||
141 | </li> |
||
142 | ); |
||
143 | })} |
||
144 | </ul> |
||
145 | </form> |
||
146 | </div> |
||
147 | <SaveTargetRelease /> |
||
148 | </div> |
||
149 | ); |
||
150 | } |
||
151 | }); |
||
152 | |||
153 | TargetRelease.propTypes = { |
||
154 | types: React.PropTypes.object.isRequired, |
||
0 ignored issues
–
show
|
|||
155 | selected_type: React.PropTypes.oneOfType([ |
||
156 | React.PropTypes.string, |
||
157 | React.PropTypes.number |
||
158 | ]).isRequired, |
||
159 | options: React.PropTypes.array, |
||
0 ignored issues
–
show
|
|||
160 | selected_options: React.PropTypes.object, |
||
0 ignored issues
–
show
|
|||
161 | ref_list: React.PropTypes.array, |
||
0 ignored issues
–
show
|
|||
162 | selected_ref: React.PropTypes.oneOfType([ |
||
163 | React.PropTypes.string, |
||
164 | React.PropTypes.number |
||
165 | ]).isRequired, |
||
166 | disabled: React.PropTypes.bool.isRequired |
||
167 | }; |
||
168 | |||
169 | function isDisabled(state) { |
||
170 | if (state.plan.is_loading) { |
||
171 | return true; |
||
172 | } |
||
173 | const current = state.deployment.list[state.deployment.current_id] || {}; |
||
174 | if (constants.isSubmitted(current.state)) { |
||
175 | return true; |
||
176 | } |
||
177 | if (constants.isApproved(current.state)) { |
||
178 | return true; |
||
179 | } |
||
180 | if (constants.isRejected(current.state)) { |
||
181 | return true; |
||
182 | } |
||
183 | if (constants.isQueued(current.state)) { |
||
184 | return true; |
||
185 | } |
||
186 | return false; |
||
187 | } |
||
188 | |||
189 | const mapStateToProps = function(state) { |
||
190 | let refs = []; |
||
191 | if (state.git.list[state.git.selected_type]) { |
||
192 | refs = state.git.list[state.git.selected_type].list; |
||
193 | } |
||
194 | |||
195 | return { |
||
196 | environment_name: state.environment.name, |
||
197 | types: state.git.list, |
||
198 | selected_type: state.git.selected_type, |
||
199 | options: state.git.options, |
||
200 | selected_options: state.git.selected_options, |
||
201 | ref_list: refs, |
||
202 | selected_ref: state.git.selected_ref, |
||
203 | last_fetched_date: state.git.last_fetched_date, |
||
204 | last_fetched_ago: state.git.last_fetched_ago, |
||
205 | disabled: isDisabled(state), |
||
206 | git_loading: (state.git.is_fetching || state.git.is_updating) |
||
207 | }; |
||
208 | }; |
||
209 | |||
210 | const mapDispatchToProps = function(dispatch) { |
||
211 | return { |
||
212 | onRadioClick: function(id, type) { |
||
213 | dispatch(actions.setGitRefType(id)); |
||
214 | if (type.promote_build) { |
||
215 | dispatch(actions.setGitRef(type.promote_build.sha)); |
||
216 | } |
||
217 | }, |
||
218 | onCheckboxClick: function(name) { |
||
219 | dispatch(actions.toggleOption(name)); |
||
220 | }, |
||
221 | onRefSelect: function(ref) { |
||
222 | dispatch(actions.setGitRef(ref)); |
||
223 | }, |
||
224 | onShaChange: function(e) { |
||
225 | dispatch(actions.setGitRef(e.target.value)); |
||
226 | }, |
||
227 | onSubmit: function(e) { |
||
228 | e.preventDefault(); |
||
229 | dispatch(actions.getDeploySummary()); |
||
230 | } |
||
231 | }; |
||
232 | }; |
||
233 | |||
234 | module.exports = ReactRedux.connect(mapStateToProps, mapDispatchToProps)(TargetRelease); |
||
235 |