foreman_acd 0.0.3 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/foreman_acd/ansible_playbooks_controller.rb +122 -0
- data/app/controllers/foreman_acd/api/v2/ansible_playbooks_controller.rb +54 -0
- data/app/controllers/foreman_acd/api/v2/app_definitions_controller.rb +1 -2
- data/app/controllers/foreman_acd/api/v2/app_instances_controller.rb +54 -0
- data/app/controllers/foreman_acd/api/v2/app_playbooks_controller.rb +0 -0
- data/app/controllers/foreman_acd/app_definitions_controller.rb +35 -4
- data/app/controllers/foreman_acd/app_instances_controller.rb +43 -87
- data/app/controllers/foreman_acd/concerns/ansible_playbook_parameters.rb +23 -0
- data/app/controllers/foreman_acd/concerns/app_definition_parameters.rb +1 -1
- data/app/controllers/foreman_acd/concerns/app_instance_parameters.rb +1 -1
- data/app/controllers/ui_acd_controller.rb +11 -4
- data/app/models/foreman_acd/ansible_playbook.rb +50 -0
- data/app/models/foreman_acd/app_definition.rb +2 -1
- data/app/models/foreman_acd/app_instance.rb +7 -0
- data/app/services/foreman_acd/app_configurator.rb +70 -0
- data/app/services/foreman_acd/app_deployer.rb +143 -0
- data/app/services/foreman_acd/inventory_creator.rb +67 -0
- data/app/views/foreman_acd/ansible_playbooks/_form.html.erb +21 -0
- data/app/views/foreman_acd/ansible_playbooks/edit.html.erb +3 -0
- data/app/views/foreman_acd/ansible_playbooks/index.html.erb +30 -0
- data/app/views/foreman_acd/ansible_playbooks/new.html.erb +3 -0
- data/app/views/foreman_acd/api/v2/ansible_playbooks/base.json.rabl +3 -0
- data/app/views/foreman_acd/api/v2/ansible_playbooks/index.json.rabl +3 -0
- data/app/views/foreman_acd/api/v2/ansible_playbooks/show.json.rabl +3 -0
- data/app/views/foreman_acd/api/v2/app_definitions/base.json.rabl +3 -0
- data/app/views/foreman_acd/api/v2/app_definitions/index.json.rabl +3 -0
- data/app/views/foreman_acd/api/v2/app_definitions/show.json.rabl +3 -0
- data/app/views/foreman_acd/api/v2/app_instances/base.json.rabl +3 -0
- data/app/views/foreman_acd/api/v2/app_instances/index.json.rabl +3 -0
- data/app/views/foreman_acd/api/v2/app_instances/show.json.rabl +3 -0
- data/app/views/foreman_acd/app_definitions/_form.html.erb +25 -19
- data/app/views/foreman_acd/app_definitions/edit.html.erb +5 -0
- data/app/views/foreman_acd/app_definitions/import.html.erb +18 -0
- data/app/views/foreman_acd/app_definitions/index.html.erb +9 -5
- data/app/views/foreman_acd/app_instances/_form.html.erb +10 -8
- data/app/views/foreman_acd/app_instances/deploy.html.erb +19 -0
- data/app/views/foreman_acd/app_instances/index.html.erb +10 -5
- data/app/views/foreman_acd/app_instances/report.html.erb +19 -0
- data/app/views/templates/job/run_acd_ansible_playbook.erb +49 -0
- data/app/views/ui_acd/ansible_data.json.rabl +6 -0
- data/app/views/ui_acd/app.json.rabl +6 -2
- data/app/views/ui_acd/app_definition.json.rabl +1 -1
- data/app/views/ui_acd/{fdata.json.rabl → foreman_data.json.rabl} +1 -1
- data/config/routes.rb +31 -1
- data/db/migrate/20190610202252_create_app_definitions.rb +1 -3
- data/db/migrate/20190625140305_create_app_instances.rb +1 -1
- data/db/migrate/20200916091018_create_ansible_playbooks.rb +20 -0
- data/db/migrate/20200917120220_add_ansible_playbook_id.rb +14 -0
- data/db/migrate/20201016002819_add_ansible_vars_all_to_app_definitions.rb +5 -0
- data/db/migrate/20201016104338_add_ansible_vars_all_to_app_instances.rb +5 -0
- data/db/seeds.d/75-job_templates.rb +8 -0
- data/lib/foreman_acd/engine.rb +3 -0
- data/lib/foreman_acd/plugin.rb +72 -4
- data/lib/foreman_acd/version.rb +1 -1
- data/package.json +2 -1
- data/webpack/components/ApplicationDefinition/ApplicationDefinition.js +376 -0
- data/webpack/components/ApplicationDefinition/ApplicationDefinition.scss +1 -0
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionActions.js +295 -0
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionConstants.js +14 -0
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionHelper.js +26 -0
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionReducer.js +243 -0
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionSelectors.js +8 -0
- data/webpack/components/ApplicationDefinition/components/AnsiblePlaybookSelector.js +49 -0
- data/webpack/components/ApplicationDefinition/index.js +33 -0
- data/webpack/components/ApplicationInstance/ApplicationInstance.js +412 -0
- data/webpack/components/ApplicationInstance/ApplicationInstance.scss +11 -0
- data/webpack/components/ApplicationInstance/ApplicationInstanceActions.js +239 -0
- data/webpack/components/ApplicationInstance/ApplicationInstanceConstants.js +14 -0
- data/webpack/components/ApplicationInstance/ApplicationInstanceReducer.js +295 -0
- data/webpack/components/ApplicationInstance/ApplicationInstanceSelectors.js +9 -0
- data/webpack/components/ApplicationInstance/components/AppDefinitionSelector.js +49 -0
- data/webpack/components/ApplicationInstance/components/Service.js +30 -0
- data/webpack/components/ApplicationInstance/components/ServiceCounter.js +37 -0
- data/webpack/components/ApplicationInstance/index.js +35 -0
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.js +155 -0
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.scss +27 -0
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportActions.js +86 -0
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportConstants.js +4 -0
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportReducer.js +52 -0
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportSelectors.js +5 -0
- data/webpack/components/ApplicationInstanceReport/components/ReportViewer.js +26 -0
- data/webpack/components/ApplicationInstanceReport/index.js +27 -0
- data/webpack/components/ParameterSelection/ParameterSelection.js +96 -183
- data/webpack/components/ParameterSelection/ParameterSelection.scss +10 -3
- data/webpack/components/ParameterSelection/ParameterSelectionActions.js +72 -104
- data/webpack/components/ParameterSelection/ParameterSelectionConstants.js +14 -19
- data/webpack/components/ParameterSelection/ParameterSelectionHelper.js +3 -35
- data/webpack/components/ParameterSelection/ParameterSelectionReducer.js +100 -83
- data/webpack/components/ParameterSelection/ParameterSelectionSelectors.js +3 -7
- data/webpack/components/ParameterSelection/__fixtures__/parameterSelection.fixtures.js +12 -21
- data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionData_1.fixtures.js +1 -1
- data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionReducer.fixtures.js +3 -45
- data/webpack/components/ParameterSelection/__tests__/ParameterSelection.test.js +20 -0
- data/webpack/components/ParameterSelection/__tests__/ParameterSelectionReducer.test.js +22 -46
- data/webpack/components/ParameterSelection/__tests__/ParameterSelectionSelectors.test.js +6 -6
- data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelection.test.js.snap +40 -265
- data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionReducer.test.js.snap +11 -96
- data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionSelectors.test.js.snap +3 -9
- data/webpack/components/ParameterSelection/index.js +6 -8
- data/webpack/components/common/AddTableEntry.js +30 -0
- data/webpack/components/common/DeleteTableEntry.js +39 -0
- data/webpack/components/common/ExtSelect.js +43 -0
- data/webpack/components/common/RailsData.js +27 -0
- data/webpack/components/common/__tests__/AddTableEntry.test.js +26 -0
- data/webpack/components/common/__tests__/DeleteTableEntry.test.js +29 -0
- data/webpack/components/common/__tests__/ExtSelect.test.js +38 -0
- data/webpack/components/common/__tests__/RailsData.test.js +16 -0
- data/webpack/components/common/__tests__/__snapshots__/AddParameter.test.js.snap +35 -0
- data/webpack/components/common/__tests__/__snapshots__/AddTableEntry.test.js.snap +35 -0
- data/webpack/components/common/__tests__/__snapshots__/DeleteParameter.test.js.snap +41 -0
- data/webpack/components/common/__tests__/__snapshots__/DeleteTableEntry.test.js.snap +41 -0
- data/webpack/components/common/__tests__/__snapshots__/ExtSelect.test.js.snap +18 -0
- data/webpack/components/common/__tests__/__snapshots__/RailsData.test.js.snap +10 -0
- data/webpack/helper.js +20 -0
- data/webpack/index.js +6 -0
- data/webpack/reducer.js +43 -3
- metadata +85 -39
@@ -0,0 +1,5 @@
|
|
1
|
+
const applicationInstanceReport = state => state.foremanAcd.applicationInstanceReport;
|
2
|
+
|
3
|
+
export const selectHosts = state => applicationInstanceReport(state).hosts;
|
4
|
+
export const selectReport = state => applicationInstanceReport(state).report;
|
5
|
+
export const selectActiveHostId = state => applicationInstanceReport(state).activeHostId;
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import PropTypes from 'prop-types';
|
3
|
+
|
4
|
+
const ReportViewer= ({
|
5
|
+
hidden,
|
6
|
+
report,
|
7
|
+
}) =>{
|
8
|
+
if (hidden) {
|
9
|
+
return null;
|
10
|
+
}
|
11
|
+
|
12
|
+
if (report === undefined) {
|
13
|
+
return null;
|
14
|
+
}
|
15
|
+
|
16
|
+
return report.map((task, id) => (
|
17
|
+
<div key={"report_task_"+id} className="report_task">{task.name}</div>
|
18
|
+
));
|
19
|
+
};
|
20
|
+
|
21
|
+
ReportViewer.propTypes = {
|
22
|
+
hidden: PropTypes.bool,
|
23
|
+
report: PropTypes.array,
|
24
|
+
};
|
25
|
+
|
26
|
+
export default ReportViewer;
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import { bindActionCreators } from 'redux';
|
2
|
+
import { connect } from 'react-redux';
|
3
|
+
|
4
|
+
import './ApplicationInstanceReport.scss';
|
5
|
+
import ApplicationInstanceReport from './ApplicationInstanceReport';
|
6
|
+
import * as ApplicationInstanceReportActions from './ApplicationInstanceReportActions';
|
7
|
+
|
8
|
+
import {
|
9
|
+
selectHosts,
|
10
|
+
selectReport,
|
11
|
+
selectActiveHostId,
|
12
|
+
} from './ApplicationInstanceReportSelectors';
|
13
|
+
|
14
|
+
const mapStateToProps = state => ({
|
15
|
+
hosts: selectHosts(state),
|
16
|
+
report: selectReport(state),
|
17
|
+
activeHostId: selectActiveHostId(state),
|
18
|
+
});
|
19
|
+
|
20
|
+
const mapDispatchToProps = dispatch =>
|
21
|
+
bindActionCreators(ApplicationInstanceReportActions, dispatch);
|
22
|
+
|
23
|
+
export default connect(
|
24
|
+
mapStateToProps,
|
25
|
+
mapDispatchToProps
|
26
|
+
)(ApplicationInstanceReport);
|
27
|
+
|
@@ -5,14 +5,11 @@ import * as sort from 'sortabular';
|
|
5
5
|
import { orderBy } from 'lodash';
|
6
6
|
import * as resolve from 'table-resolver';
|
7
7
|
import Select from 'foremanReact/components/common/forms/Select';
|
8
|
+
import AddTableEntry from '../common/AddTableEntry';
|
9
|
+
import DeleteTableEntry from '../common/DeleteTableEntry';
|
10
|
+
import ExtSelect from '../common/ExtSelect';
|
8
11
|
|
9
12
|
import {
|
10
|
-
isNewDefinition,
|
11
|
-
isEditDefinition,
|
12
|
-
isDefinition,
|
13
|
-
isNewInstance,
|
14
|
-
isEditInstance,
|
15
|
-
isInstance,
|
16
13
|
transformForemanData,
|
17
14
|
} from './ParameterSelectionHelper';
|
18
15
|
|
@@ -22,9 +19,10 @@ import {
|
|
22
19
|
cloneDeep,
|
23
20
|
} from 'lodash';
|
24
21
|
|
25
|
-
|
26
22
|
import {
|
27
|
-
|
23
|
+
PARAMETER_SELECTION_TYPES,
|
24
|
+
PARAMETER_SELECTION_PARAM_TYPE_FOREMAN,
|
25
|
+
PARAMETER_SELECTION_PARAM_TYPE_ANSIBLE,
|
28
26
|
} from './ParameterSelectionConstants';
|
29
27
|
|
30
28
|
import {
|
@@ -43,86 +41,12 @@ const theme = {
|
|
43
41
|
base00: 'rgba(0, 0, 0, 0)',
|
44
42
|
};
|
45
43
|
|
46
|
-
|
47
44
|
class ParameterSelection extends React.Component {
|
48
45
|
|
49
46
|
constructor(props) {
|
50
47
|
super(props);
|
51
48
|
}
|
52
49
|
|
53
|
-
renderAddButton(mode, addParameter) {
|
54
|
-
if (isInstance(mode))
|
55
|
-
return null;
|
56
|
-
|
57
|
-
return (
|
58
|
-
<Button bsStyle="default" disabled={ this.props.editMode || this.props.hostgroupId <= 0 } onClick={() => addParameter()}>
|
59
|
-
<Icon type="fa" name="plus" />
|
60
|
-
</Button>
|
61
|
-
);
|
62
|
-
}
|
63
|
-
|
64
|
-
renderDeleteButton(mode, deleteParameter, additionalData, disabled=false) {
|
65
|
-
if (isInstance(mode))
|
66
|
-
return null;
|
67
|
-
|
68
|
-
return (
|
69
|
-
<span>
|
70
|
-
|
71
|
-
<Button
|
72
|
-
bsStyle="default"
|
73
|
-
disabled={disabled}
|
74
|
-
onClick={() => window.confirm("Are you sure you wish to delete this item?") && deleteParameter(additionalData) }
|
75
|
-
>
|
76
|
-
<Icon type="pf" name="delete" />
|
77
|
-
</Button>
|
78
|
-
</span>
|
79
|
-
);
|
80
|
-
}
|
81
|
-
|
82
|
-
renderSelectApplication(applications, url, loadParameterSelection, appDefinition) {
|
83
|
-
return (
|
84
|
-
<Select
|
85
|
-
value={appDefinition.id.toString()}
|
86
|
-
onChange={e => loadParameterSelection(url, e.target.value) }
|
87
|
-
options={applications}
|
88
|
-
allowClear
|
89
|
-
key="key"
|
90
|
-
/>
|
91
|
-
);
|
92
|
-
}
|
93
|
-
|
94
|
-
renderSelectHostgroup(hostgroups, url, loadForemanData, hostgroupId) {
|
95
|
-
return (
|
96
|
-
<Select
|
97
|
-
value={hostgroupId.toString()}
|
98
|
-
onChange={e => loadForemanData(url, e.target.value, true) }
|
99
|
-
options={hostgroups}
|
100
|
-
allowClear
|
101
|
-
key="key"
|
102
|
-
/>
|
103
|
-
);
|
104
|
-
}
|
105
|
-
|
106
|
-
renderRailsInputHidden(view, parameter, value) {
|
107
|
-
var id = "foreman_acd_"+ view +"_"+ parameter;
|
108
|
-
var name = "foreman_acd_"+ view +"["+ parameter +"]";
|
109
|
-
|
110
|
-
return (
|
111
|
-
<input
|
112
|
-
id={id}
|
113
|
-
name={name}
|
114
|
-
value={value}
|
115
|
-
type="hidden"
|
116
|
-
/>
|
117
|
-
);
|
118
|
-
}
|
119
|
-
|
120
|
-
renderShowDivText(text) {
|
121
|
-
return (
|
122
|
-
<div>{text}</div>
|
123
|
-
);
|
124
|
-
}
|
125
|
-
|
126
50
|
isEditing({rowData}) {
|
127
51
|
return (rowData.backup !== undefined);
|
128
52
|
}
|
@@ -130,31 +54,29 @@ class ParameterSelection extends React.Component {
|
|
130
54
|
// enables our custom header formatters extensions to reactabular
|
131
55
|
customHeaderFormatters = customHeaderFormattersDefinition;
|
132
56
|
|
133
|
-
validateRows() {
|
134
|
-
var result = (this.props.rows.map(e => e.value).filter(i => i == "").length == 0);
|
135
|
-
if (result === false) {
|
136
|
-
window.alert("All parameters need to have a value!");
|
137
|
-
}
|
138
|
-
return result;
|
139
|
-
}
|
140
|
-
|
141
57
|
componentDidMount() {
|
142
58
|
const {
|
143
|
-
data: {
|
59
|
+
data: { useDefaultValue, allowRowAdjustment, allowNameAdjustment, allowDescriptionAdjustment, parameters, paramDefinition },
|
60
|
+
location,
|
61
|
+
organization,
|
62
|
+
paramType,
|
63
|
+
paramDataUrl,
|
144
64
|
initParameterSelection,
|
145
65
|
sortParameter,
|
146
66
|
deleteParameter,
|
147
67
|
activateEditParameter,
|
148
68
|
changeEditParameter,
|
149
|
-
|
69
|
+
loadParamData,
|
150
70
|
} = this.props;
|
151
71
|
|
152
|
-
if (
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
72
|
+
if (paramDataUrl !== undefined) {
|
73
|
+
switch (paramType) {
|
74
|
+
case PARAMETER_SELECTION_PARAM_TYPE_FOREMAN: {
|
75
|
+
loadParamData({ paramDefinition: paramDefinition, url: paramDataUrl, dataType: paramType, clearParameters: false });
|
76
|
+
break;
|
77
|
+
}
|
78
|
+
default: { }
|
79
|
+
}
|
158
80
|
}
|
159
81
|
|
160
82
|
const inlineEditButtonsFormatter = inlineEditFormatterFactory({
|
@@ -167,7 +89,12 @@ class ParameterSelection extends React.Component {
|
|
167
89
|
>
|
168
90
|
<Icon type="pf" name="edit" />
|
169
91
|
</Button>
|
170
|
-
|
92
|
+
<DeleteTableEntry
|
93
|
+
hidden={!allowRowAdjustment}
|
94
|
+
disabled={false}
|
95
|
+
onDeleteTableEntry={deleteParameter}
|
96
|
+
additionalData={additionalData}
|
97
|
+
/>
|
171
98
|
</td>
|
172
99
|
),
|
173
100
|
renderEdit: (value, additionalData) => (
|
@@ -175,7 +102,12 @@ class ParameterSelection extends React.Component {
|
|
175
102
|
<Button bsStyle="default" disabled>
|
176
103
|
<Icon type="pf" name="edit" />
|
177
104
|
</Button>
|
178
|
-
|
105
|
+
<DeleteTableEntry
|
106
|
+
hidden={!allowRowAdjustment}
|
107
|
+
disabled={true}
|
108
|
+
onDeleteTableEntry={deleteParameter}
|
109
|
+
additionalData={additionalData}
|
110
|
+
/>
|
179
111
|
</td>
|
180
112
|
)
|
181
113
|
});
|
@@ -225,28 +157,36 @@ class ParameterSelection extends React.Component {
|
|
225
157
|
),
|
226
158
|
};
|
227
159
|
|
160
|
+
// TODO: should we differentiate between paramType FOREMAN and ANSIBLE?
|
161
|
+
|
228
162
|
const inlineEditFormatter = inlineEditFormatterFactory({
|
229
163
|
isEditing: additionalData => this.isEditing(additionalData),
|
230
164
|
renderValue: (value, additionalData) => {
|
231
|
-
|
165
|
+
let prettyValue = value;
|
232
166
|
if (additionalData.property == 'type') {
|
233
|
-
prettyValue =
|
167
|
+
prettyValue = PARAMETER_SELECTION_TYPES[value];
|
234
168
|
} else if (additionalData.property == 'value') {
|
235
169
|
switch (additionalData.rowData.type) {
|
236
170
|
case 'computeprofile':
|
237
|
-
prettyValue = transformForemanData(this.props.
|
171
|
+
prettyValue = transformForemanData(this.props.paramData['computeprofiles'])[value]
|
238
172
|
break;
|
239
173
|
case 'domain':
|
240
|
-
prettyValue = transformForemanData(this.props.
|
174
|
+
prettyValue = transformForemanData(this.props.paramData['domains'])[value]
|
241
175
|
break;
|
242
176
|
case 'lifecycleenv':
|
243
|
-
prettyValue = transformForemanData(this.props.
|
177
|
+
prettyValue = transformForemanData(this.props.paramData['lifecycle_environments'])[value]
|
244
178
|
break;
|
245
179
|
case 'ptable':
|
246
|
-
prettyValue = transformForemanData(this.props.
|
180
|
+
prettyValue = transformForemanData(this.props.paramData['ptables'])[value]
|
181
|
+
break;
|
182
|
+
case 'password':
|
183
|
+
prettyValue = '****************'
|
247
184
|
break;
|
248
185
|
case 'puppetenv':
|
249
|
-
prettyValue = transformForemanData(this.props.
|
186
|
+
prettyValue = transformForemanData(this.props.paramData['environments'])[value]
|
187
|
+
break;
|
188
|
+
case 'text':
|
189
|
+
prettyValue = value
|
250
190
|
break;
|
251
191
|
}
|
252
192
|
}
|
@@ -258,19 +198,21 @@ class ParameterSelection extends React.Component {
|
|
258
198
|
if (additionalData.rowData.newEntry === true) {
|
259
199
|
return inlineEditFormatterImpl.renderEditSelect(value, additionalData, this.props.parameterTypes);
|
260
200
|
}
|
261
|
-
return inlineEditFormatterImpl.renderValue(
|
201
|
+
return inlineEditFormatterImpl.renderValue(PARAMETER_SELECTION_TYPES[value], additionalData)
|
262
202
|
case 'value':
|
263
203
|
switch (additionalData.rowData.type) {
|
264
204
|
case 'computeprofile':
|
265
|
-
return inlineEditFormatterImpl.renderEditSelect(value, additionalData, transformForemanData(this.props.
|
205
|
+
return inlineEditFormatterImpl.renderEditSelect(value, additionalData, transformForemanData(this.props.paramData['computeprofiles']));
|
266
206
|
case 'domain':
|
267
|
-
return inlineEditFormatterImpl.renderEditSelect(value, additionalData, transformForemanData(this.props.
|
207
|
+
return inlineEditFormatterImpl.renderEditSelect(value, additionalData, transformForemanData(this.props.paramData['domains']));
|
268
208
|
case 'lifecycleenv':
|
269
|
-
return inlineEditFormatterImpl.renderEditSelect(value, additionalData, transformForemanData(this.props.
|
209
|
+
return inlineEditFormatterImpl.renderEditSelect(value, additionalData, transformForemanData(this.props.paramData['lifecycle_environments']));
|
270
210
|
case 'puppetenv':
|
271
|
-
return inlineEditFormatterImpl.renderEditSelect(value, additionalData, transformForemanData(this.props.
|
211
|
+
return inlineEditFormatterImpl.renderEditSelect(value, additionalData, transformForemanData(this.props.paramData['environments']));
|
272
212
|
case 'ptable':
|
273
|
-
return inlineEditFormatterImpl.renderEditSelect(value, additionalData, transformForemanData(this.props.
|
213
|
+
return inlineEditFormatterImpl.renderEditSelect(value, additionalData, transformForemanData(this.props.paramData['ptables']));
|
214
|
+
case 'password':
|
215
|
+
return inlineEditFormatterImpl.renderEditText(value, additionalData, 'password');
|
274
216
|
case 'text':
|
275
217
|
default:
|
276
218
|
return inlineEditFormatterImpl.renderEditText(value, additionalData);
|
@@ -283,9 +225,12 @@ class ParameterSelection extends React.Component {
|
|
283
225
|
this.inlineEditFormatter = inlineEditFormatter;
|
284
226
|
|
285
227
|
initParameterSelection(
|
286
|
-
|
287
|
-
|
228
|
+
paramType,
|
229
|
+
paramDefinition,
|
288
230
|
parameters,
|
231
|
+
useDefaultValue,
|
232
|
+
allowNameAdjustment,
|
233
|
+
allowDescriptionAdjustment,
|
289
234
|
this.sortingFormatter,
|
290
235
|
this.sortableTransform,
|
291
236
|
this.inlineEditFormatter,
|
@@ -298,84 +243,56 @@ class ParameterSelection extends React.Component {
|
|
298
243
|
|
299
244
|
render() {
|
300
245
|
const {
|
301
|
-
data: {
|
302
|
-
|
246
|
+
data: { allowRowAdjustment, applications },
|
247
|
+
location,
|
248
|
+
organization,
|
249
|
+
parameters,
|
303
250
|
columns,
|
304
251
|
sortingColumns,
|
305
252
|
loading,
|
306
253
|
addParameter,
|
307
254
|
confirmEditParameter,
|
308
255
|
cancelEditParameter,
|
309
|
-
loadParameterSelection,
|
310
|
-
loadForemanData,
|
311
|
-
appDefinition,
|
312
|
-
hostgroupId,
|
313
256
|
} = this.props;
|
314
257
|
|
315
|
-
|
316
|
-
|
258
|
+
let sortedParameters;
|
259
|
+
const newEntryIndex = findIndex(parameters, 'newEntry');
|
317
260
|
|
318
261
|
if (newEntryIndex >= 0) {
|
319
|
-
|
262
|
+
const newEntry = parameters[newEntryIndex];
|
320
263
|
// sort all elements, besides the newEntry which will be
|
321
264
|
// added to the end of the Array
|
322
|
-
|
323
|
-
|
324
|
-
|
265
|
+
const tmpParameters = cloneDeep(parameters);
|
266
|
+
tmpParameters.splice(newEntryIndex, 1);
|
267
|
+
sortedParameters = this.compose(
|
325
268
|
sort.sorter({
|
326
269
|
columns,
|
327
270
|
sortingColumns,
|
328
271
|
sort: orderBy,
|
329
272
|
strategy: sort.strategies.byProperty
|
330
273
|
})
|
331
|
-
)(
|
332
|
-
|
274
|
+
)(tmpParameters);
|
275
|
+
sortedParameters.push(newEntry);
|
333
276
|
} else {
|
334
|
-
|
277
|
+
sortedParameters = this.compose(
|
335
278
|
sort.sorter({
|
336
279
|
columns,
|
337
280
|
sortingColumns,
|
338
281
|
sort: orderBy,
|
339
282
|
strategy: sort.strategies.byProperty
|
340
283
|
})
|
341
|
-
)(
|
284
|
+
)(parameters);
|
342
285
|
}
|
343
286
|
|
344
287
|
return(
|
345
288
|
<div>
|
346
|
-
{isDefinition(mode) ? (
|
347
|
-
<div className="clearfix">
|
348
|
-
<div className="form-group">
|
349
|
-
<label className="col-md-2 control-label">Host Group</label>
|
350
|
-
<div className="col-md-4">
|
351
|
-
{isNewDefinition(mode) && this.renderSelectHostgroup(hostgroups, loadForemanDataUrl, loadForemanData, hostgroupId) }
|
352
|
-
{isEditDefinition(mode) && this.renderShowDivText(hostgroups[hostgroupId]) }
|
353
|
-
{this.renderRailsInputHidden('app_definition', 'hostgroup_id', hostgroupId) }
|
354
|
-
</div>
|
355
|
-
</div>
|
356
|
-
</div>
|
357
|
-
) : (
|
358
|
-
<div className="clearfix">
|
359
|
-
<div className="form-group">
|
360
|
-
<label className="col-md-2 control-label">Application Definition</label>
|
361
|
-
<div className="col-md-4">
|
362
|
-
{isNewInstance(mode) && this.renderSelectApplication(applications, loadParameterSelectionUrl, loadParameterSelection, appDefinition)}
|
363
|
-
{isEditInstance(mode) && this.renderShowDivText(appDefinition.name)}
|
364
|
-
{isInstance(mode) && this.renderRailsInputHidden('app_instance', 'app_definition_id', appDefinition.id)}
|
365
|
-
</div>
|
366
|
-
</div>
|
367
|
-
</div>
|
368
|
-
)}
|
369
|
-
<div className="clearfix">
|
370
|
-
<div className="form-group">
|
371
|
-
<label className="col-md-1 control-label">Application parameters</label>
|
372
|
-
<div className="col-md-5"> </div>
|
373
|
-
</div>
|
374
|
-
</div>
|
375
|
-
|
376
289
|
<div className="clearfix">
|
377
290
|
<div className="form-group">
|
378
|
-
|
291
|
+
<AddTableEntry
|
292
|
+
hidden={!allowRowAdjustment}
|
293
|
+
disabled={ this.props.editMode }
|
294
|
+
onAddTableEntry={ addParameter }
|
295
|
+
/>
|
379
296
|
<Table.PfProvider
|
380
297
|
striped
|
381
298
|
bordered
|
@@ -400,20 +317,23 @@ class ParameterSelection extends React.Component {
|
|
400
317
|
>
|
401
318
|
<Table.Header headerRows={resolve.headerRows({ columns })} />
|
402
319
|
<Table.Body
|
403
|
-
rows={
|
320
|
+
rows={sortedParameters}
|
404
321
|
rowKey="id"
|
405
322
|
onRow={(rowData, { rowIndex }) => ({
|
406
323
|
role: 'row',
|
407
324
|
isEditing: () => this.isEditing({ rowData }),
|
408
325
|
onCancel: () => cancelEditParameter({ rowData, rowIndex }),
|
409
326
|
onConfirm: () => confirmEditParameter({ rowData, rowIndex }),
|
410
|
-
last: rowIndex ===
|
327
|
+
last: rowIndex === sortedParameters.length - 1
|
411
328
|
})}
|
412
329
|
/>
|
413
330
|
</Table.PfProvider>
|
414
|
-
|
331
|
+
<AddTableEntry
|
332
|
+
hidden={!allowRowAdjustment}
|
333
|
+
disabled={ this.props.editMode }
|
334
|
+
onAddTableEntry={ addParameter }
|
335
|
+
/>
|
415
336
|
</div>
|
416
|
-
{this.renderRailsInputHidden(isDefinition(mode) ? 'app_definition' : 'app_instance', 'parameters', JSON.stringify(this.props.rows))}
|
417
337
|
</div>
|
418
338
|
</div>
|
419
339
|
);
|
@@ -424,32 +344,27 @@ ParameterSelection.defaultProps = {
|
|
424
344
|
error: {},
|
425
345
|
editMode: false,
|
426
346
|
loading: false,
|
427
|
-
|
428
|
-
|
347
|
+
paramData: {},
|
348
|
+
parameters: [],
|
429
349
|
columns: [],
|
430
350
|
sortingColumns: {},
|
431
|
-
appDefinition: { "id": '', "name": '', "hostgroup_id": '', "parameters": [] },
|
432
|
-
hostgroupId: -1,
|
433
351
|
};
|
434
352
|
|
435
353
|
ParameterSelection.propTypes = {
|
436
354
|
data: PropTypes.shape({
|
437
|
-
mode: PropTypes.string.isRequired,
|
438
|
-
location: PropTypes.string.isRequired,
|
439
|
-
organization: PropTypes.string.isRequired,
|
440
355
|
parameters: PropTypes.array,
|
441
|
-
|
356
|
+
paramDefinition: PropTypes.object,
|
442
357
|
applications: PropTypes.object,
|
443
|
-
hostgroups: PropTypes.object,
|
444
|
-
loadParameterSelectionUrl: PropTypes.string,
|
445
|
-
loadForemanDataUrl: PropTypes.string,
|
446
358
|
}).isRequired,
|
359
|
+
location: PropTypes.string.isRequired,
|
360
|
+
organization: PropTypes.string.isRequired,
|
361
|
+
paramDataUrl: PropTypes.string,
|
447
362
|
initParameterSelection: PropTypes.func,
|
448
363
|
editMode: PropTypes.bool.isRequired,
|
449
364
|
loading: PropTypes.bool.isRequired,
|
450
|
-
|
365
|
+
paramData: PropTypes.object.isRequired,
|
451
366
|
parameterTypes: PropTypes.object,
|
452
|
-
|
367
|
+
parameters: PropTypes.array,
|
453
368
|
sortingColumns: PropTypes.object,
|
454
369
|
columns: PropTypes.array,
|
455
370
|
sortParameter: PropTypes.func,
|
@@ -459,10 +374,8 @@ ParameterSelection.propTypes = {
|
|
459
374
|
confirmEditParameter: PropTypes.func,
|
460
375
|
cancelEditParameter: PropTypes.func,
|
461
376
|
changeEditParameter: PropTypes.func,
|
462
|
-
|
463
|
-
|
464
|
-
appDefinition: PropTypes.object,
|
465
|
-
hostgroupId: PropTypes.number,
|
377
|
+
loadParamData: PropTypes.func,
|
378
|
+
paramDefinition: PropTypes.object,
|
466
379
|
};
|
467
380
|
|
468
381
|
export default ParameterSelection;
|