foreman_acd 0.0.6 → 0.2.1
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/api/v2/app_definitions_controller.rb +1 -2
- data/app/controllers/foreman_acd/app_definitions_controller.rb +29 -1
- data/app/controllers/foreman_acd/app_instances_controller.rb +70 -21
- 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 +0 -1
- data/app/models/foreman_acd/app_definition.rb +0 -1
- data/app/views/foreman_acd/app_definitions/_form.html.erb +6 -14
- 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 +5 -5
- data/app/views/foreman_acd/app_instances/deploy.html.erb +19 -0
- data/app/views/foreman_acd/app_instances/index.html.erb +6 -5
- data/app/views/foreman_acd/app_instances/report.html.erb +19 -0
- data/app/views/ui_acd/app_definition.json.rabl +1 -1
- data/config/routes.rb +7 -0
- data/db/migrate/20190610202252_create_app_definitions.rb +1 -3
- data/db/migrate/20190625140305_create_app_instances.rb +1 -1
- data/lib/foreman_acd/plugin.rb +19 -2
- data/lib/foreman_acd/version.rb +1 -1
- data/webpack/components/ApplicationDefinition/ApplicationDefinition.js +261 -0
- data/webpack/components/ApplicationDefinition/ApplicationDefinition.scss +1 -0
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionActions.js +211 -0
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionConstants.js +9 -0
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionReducer.js +147 -0
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionSelectors.js +6 -0
- data/webpack/components/ApplicationDefinition/index.js +29 -0
- data/webpack/components/ApplicationInstance/ApplicationInstance.js +342 -0
- data/webpack/components/ApplicationInstance/ApplicationInstance.scss +11 -0
- data/webpack/components/ApplicationInstance/ApplicationInstanceActions.js +210 -0
- data/webpack/components/ApplicationInstance/ApplicationInstanceConstants.js +12 -0
- data/webpack/components/ApplicationInstance/ApplicationInstanceReducer.js +223 -0
- data/webpack/components/ApplicationInstance/ApplicationInstanceSelectors.js +8 -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 +33 -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 +65 -161
- data/webpack/components/ParameterSelection/ParameterSelection.scss +9 -0
- data/webpack/components/ParameterSelection/ParameterSelectionActions.js +42 -71
- data/webpack/components/ParameterSelection/ParameterSelectionConstants.js +12 -19
- data/webpack/components/ParameterSelection/ParameterSelectionHelper.js +3 -3
- data/webpack/components/ParameterSelection/ParameterSelectionReducer.js +76 -75
- data/webpack/components/ParameterSelection/ParameterSelectionSelectors.js +2 -6
- 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 +4 -6
- 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 +40 -3
- metadata +47 -46
@@ -26,26 +26,23 @@ import {
|
|
26
26
|
} from './ParameterSelectionHelper';
|
27
27
|
|
28
28
|
import {
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
LOAD_FOREMAN_DATA_REQUEST,
|
42
|
-
LOAD_FOREMAN_DATA_SUCCESS,
|
43
|
-
LOAD_FOREMAN_DATA_FAILURE,
|
29
|
+
PARAMETER_SELECTION_INIT,
|
30
|
+
PARAMETER_SELECTION_TYPES,
|
31
|
+
PARAMETER_SELECTION_DELETE,
|
32
|
+
PARAMETER_SELECTION_ADD,
|
33
|
+
PARAMETER_SELECTION_EDIT_ACTIVATE,
|
34
|
+
PARAMETER_SELECTION_EDIT_CONFIRM,
|
35
|
+
PARAMETER_SELECTION_EDIT_CHANGE,
|
36
|
+
PARAMETER_SELECTION_EDIT_CANCEL,
|
37
|
+
PARAMETER_SELECTION_SORT,
|
38
|
+
PARAMETER_SELECTION_LOAD_FOREMAN_DATA_REQUEST,
|
39
|
+
PARAMETER_SELECTION_LOAD_FOREMAN_DATA_SUCCESS,
|
40
|
+
PARAMETER_SELECTION_LOAD_FOREMAN_DATA_FAILURE,
|
44
41
|
} from './ParameterSelectionConstants';
|
45
42
|
|
46
43
|
export const initParameterSelection = (
|
47
44
|
mode,
|
48
|
-
|
45
|
+
serviceDefinition,
|
49
46
|
parameters,
|
50
47
|
sortingFormatter,
|
51
48
|
sortableTransform,
|
@@ -60,9 +57,9 @@ export const initParameterSelection = (
|
|
60
57
|
position: 0
|
61
58
|
}
|
62
59
|
};
|
63
|
-
initialState.
|
60
|
+
initialState.serviceDefinition = serviceDefinition;
|
64
61
|
|
65
|
-
|
62
|
+
let valueLabel = 'Value';
|
66
63
|
if (isDefinition(mode)) {
|
67
64
|
valueLabel = 'Default value';
|
68
65
|
}
|
@@ -95,7 +92,7 @@ export const initParameterSelection = (
|
|
95
92
|
index: 1,
|
96
93
|
sort: true,
|
97
94
|
style: {
|
98
|
-
width: '
|
95
|
+
width: '20%'
|
99
96
|
}
|
100
97
|
},
|
101
98
|
transforms: [sortableTransform],
|
@@ -125,9 +122,6 @@ export const initParameterSelection = (
|
|
125
122
|
customFormatters: [sortableHeaderCellFormatter]
|
126
123
|
},
|
127
124
|
cell: {
|
128
|
-
props: {
|
129
|
-
index: 2
|
130
|
-
},
|
131
125
|
// we are always using the inlineEditFormatter so that
|
132
126
|
// the well formatted type name is shown
|
133
127
|
formatters: [inlineEditFormatter]
|
@@ -141,7 +135,7 @@ export const initParameterSelection = (
|
|
141
135
|
index: 3,
|
142
136
|
sort: true,
|
143
137
|
style: {
|
144
|
-
width: '
|
138
|
+
width: '20%'
|
145
139
|
}
|
146
140
|
},
|
147
141
|
transforms: [sortableTransform],
|
@@ -149,9 +143,6 @@ export const initParameterSelection = (
|
|
149
143
|
customFormatters: [sortableHeaderCellFormatter]
|
150
144
|
},
|
151
145
|
cell: {
|
152
|
-
props: {
|
153
|
-
index: 3
|
154
|
-
},
|
155
146
|
formatters: [inlineEditFormatter]
|
156
147
|
}
|
157
148
|
},
|
@@ -160,36 +151,36 @@ export const initParameterSelection = (
|
|
160
151
|
header: {
|
161
152
|
label: 'Actions',
|
162
153
|
props: {
|
163
|
-
index: 4
|
154
|
+
index: 4,
|
155
|
+
style: {
|
156
|
+
width: '20%'
|
157
|
+
}
|
164
158
|
},
|
165
159
|
formatters: [actionHeaderCellFormatter]
|
166
160
|
},
|
167
161
|
cell: {
|
168
|
-
props: {
|
169
|
-
index: 4
|
170
|
-
},
|
171
162
|
formatters: [inlineEditButtonsFormatter]
|
172
163
|
}
|
173
164
|
}
|
174
165
|
];
|
175
166
|
|
176
|
-
if (
|
177
|
-
initialState.
|
178
|
-
} else if ((isEditDefinition(mode)) || (
|
179
|
-
initialState.
|
180
|
-
initialState.hostgroupId =
|
167
|
+
if (isNewDefinition(mode)) {
|
168
|
+
initialState.parameters = [];
|
169
|
+
} else if ((isEditDefinition(mode)) || (isInstance(mode))) {
|
170
|
+
initialState.parameters = parameters;
|
171
|
+
initialState.hostgroupId = serviceDefinition.hostgroup_id;
|
181
172
|
} else {
|
182
173
|
// FIXME: should never ever happen
|
183
174
|
}
|
184
175
|
|
185
|
-
if (isNewDefinition(mode)
|
186
|
-
initialState.parameterTypes =
|
176
|
+
if (isNewDefinition(mode)) {
|
177
|
+
initialState.parameterTypes = PARAMETER_SELECTION_TYPES;
|
187
178
|
} else {
|
188
|
-
initialState.parameterTypes = filterUsedParameterTypes(
|
179
|
+
initialState.parameterTypes = filterUsedParameterTypes(PARAMETER_SELECTION_TYPES, parameters);
|
189
180
|
}
|
190
181
|
|
191
182
|
dispatch({
|
192
|
-
type:
|
183
|
+
type: PARAMETER_SELECTION_INIT,
|
193
184
|
payload: initialState,
|
194
185
|
});
|
195
186
|
}
|
@@ -203,42 +194,42 @@ const errorHandler = (msg, err) => {
|
|
203
194
|
};
|
204
195
|
|
205
196
|
export const addParameter = (additionalData) => ({
|
206
|
-
type:
|
197
|
+
type: PARAMETER_SELECTION_ADD,
|
207
198
|
payload: {
|
208
199
|
...additionalData,
|
209
200
|
},
|
210
201
|
});
|
211
202
|
|
212
203
|
export const deleteParameter = (additionalData) => ({
|
213
|
-
type:
|
204
|
+
type: PARAMETER_SELECTION_DELETE,
|
214
205
|
payload: {
|
215
206
|
...additionalData,
|
216
207
|
},
|
217
208
|
});
|
218
209
|
|
219
210
|
export const activateEditParameter = (additionalData) => ({
|
220
|
-
type:
|
211
|
+
type: PARAMETER_SELECTION_EDIT_ACTIVATE,
|
221
212
|
payload: {
|
222
213
|
...additionalData,
|
223
214
|
},
|
224
215
|
});
|
225
216
|
|
226
217
|
export const confirmEditParameter = (rowData) => ({
|
227
|
-
type:
|
218
|
+
type: PARAMETER_SELECTION_EDIT_CONFIRM,
|
228
219
|
payload: {
|
229
220
|
...rowData,
|
230
221
|
},
|
231
222
|
});
|
232
223
|
|
233
224
|
export const cancelEditParameter = (rowData) => ({
|
234
|
-
type:
|
225
|
+
type: PARAMETER_SELECTION_EDIT_CANCEL,
|
235
226
|
payload: {
|
236
227
|
...rowData,
|
237
228
|
},
|
238
229
|
});
|
239
230
|
|
240
231
|
export const changeEditParameter = (value, additionalData) => ({
|
241
|
-
type:
|
232
|
+
type: PARAMETER_SELECTION_EDIT_CHANGE,
|
242
233
|
payload: {
|
243
234
|
value,
|
244
235
|
...additionalData,
|
@@ -246,49 +237,29 @@ export const changeEditParameter = (value, additionalData) => ({
|
|
246
237
|
});
|
247
238
|
|
248
239
|
export const sortParameter = (selectedColumn, defaultSortingOrder) => ({
|
249
|
-
type:
|
240
|
+
type: PARAMETER_SELECTION_SORT,
|
250
241
|
payload: {
|
251
242
|
selectedColumn,
|
252
243
|
defaultSortingOrder,
|
253
244
|
},
|
254
245
|
});
|
255
246
|
|
256
|
-
export const loadParameterSelection = (
|
257
|
-
url,
|
258
|
-
applicationDefinitionId
|
259
|
-
) => dispatch => {
|
260
|
-
dispatch({ type: LOAD_PARAMETER_SELECTION_REQUEST });
|
261
|
-
|
262
|
-
var realUrl = url.replace("__id__", applicationDefinitionId);
|
263
|
-
|
264
|
-
return api
|
265
|
-
.get(realUrl, {}, {})
|
266
|
-
.then(({ data }) =>
|
267
|
-
dispatch({
|
268
|
-
type: LOAD_PARAMETER_SELECTION_SUCCESS,
|
269
|
-
payload: data,
|
270
|
-
})
|
271
|
-
)
|
272
|
-
.catch(error => dispatch(errorHandler(LOAD_PARAMETER_SELECTION_FAILURE, error)));
|
273
|
-
};
|
274
|
-
|
275
247
|
export const loadForemanData = (
|
276
|
-
url,
|
277
248
|
hostgroupId,
|
278
|
-
|
249
|
+
additionalData,
|
279
250
|
) => dispatch => {
|
280
|
-
dispatch({ type:
|
251
|
+
dispatch({ type: PARAMETER_SELECTION_LOAD_FOREMAN_DATA_REQUEST, payload: { clearParameters: additionalData.clearParameters } });
|
281
252
|
|
282
|
-
|
253
|
+
const realUrl = additionalData.url.replace("__id__", hostgroupId);
|
283
254
|
|
284
255
|
return api
|
285
256
|
.get(realUrl, {}, {})
|
286
257
|
.then(({ data }) =>
|
287
258
|
dispatch({
|
288
|
-
type:
|
259
|
+
type: PARAMETER_SELECTION_LOAD_FOREMAN_DATA_SUCCESS,
|
289
260
|
payload: data,
|
290
261
|
})
|
291
262
|
)
|
292
|
-
.catch(error => dispatch(errorHandler(
|
263
|
+
.catch(error => dispatch(errorHandler(PARAMETER_SELECTION_LOAD_FOREMAN_DATA_FAILURE, error)));
|
293
264
|
};
|
294
265
|
|
@@ -1,27 +1,20 @@
|
|
1
|
-
export const
|
2
|
-
|
3
|
-
export const
|
4
|
-
export const
|
5
|
-
export const
|
6
|
-
export const
|
7
|
-
export const
|
8
|
-
export const
|
9
|
-
export const
|
10
|
-
|
11
|
-
export const
|
12
|
-
export const LOAD_PARAMETER_SELECTION_SUCCESS = 'LOAD_PARAMETER_SELECTION_SUCCESS';
|
13
|
-
export const LOAD_PARAMETER_SELECTION_FAILURE = 'LOAD_PARAMETER_SELECTION_FAILURE';
|
14
|
-
|
15
|
-
export const LOAD_FOREMAN_DATA_REQUEST = 'LOAD_FOREMAN_DATA_REQUEST';
|
16
|
-
export const LOAD_FOREMAN_DATA_SUCCESS = 'LOAD_FOREMAN_DATA_SUCCESS';
|
17
|
-
export const LOAD_FOREMAN_DATA_FAILURE = 'LOAD_FOREMAN_DATA_FAILURE';
|
1
|
+
export const PARAMETER_SELECTION_INIT = 'INIT_PARAMETER_SELECTION_INIT';
|
2
|
+
export const PARAMETER_SELECTION_DELETE = 'PARAMETER_SELECTION_DELETE';
|
3
|
+
export const PARAMETER_SELECTION_ADD = 'PARAMETER_SELECTION_ADD';
|
4
|
+
export const PARAMETER_SELECTION_EDIT_ACTIVATE = 'PARAMETER_SELECTION_EDIT_ACTIVATE';
|
5
|
+
export const PARAMETER_SELECTION_EDIT_CONFIRM = 'PARAMETER_SELECTION_EDIT_CONFIRM';
|
6
|
+
export const PARAMETER_SELECTION_EDIT_CHANGE = 'PARAMETER_SELECTION_EDIT_CHANGE';
|
7
|
+
export const PARAMETER_SELECTION_EDIT_CANCEL = 'PARAMETER_SELECTION_EDIT_CANCEL';
|
8
|
+
export const PARAMETER_SELECTION_SORT = 'PARAMETER_SELECTION_SORT';
|
9
|
+
export const PARAMETER_SELECTION_LOAD_FOREMAN_DATA_REQUEST = 'PARAMETER_SELECTION_LOAD_FOREMAN_DATA_REQUEST';
|
10
|
+
export const PARAMETER_SELECTION_LOAD_FOREMAN_DATA_SUCCESS = 'PARAMETER_SELECTION_LOAD_FOREMAN_DATA_SUCCESS';
|
11
|
+
export const PARAMETER_SELECTION_LOAD_FOREMAN_DATA_FAILURE = 'PARAMETER_SELECTION_LOAD_FOREMAN_DATA_FAILURE';
|
18
12
|
|
19
13
|
// Make sure the object is sorted by value
|
20
14
|
// (Compute Profile -> Partition table -> Root password)
|
21
|
-
export const
|
15
|
+
export const PARAMETER_SELECTION_TYPES = {
|
22
16
|
computeprofile: 'Compute profile',
|
23
17
|
domain: 'Domain',
|
24
|
-
hostname: 'Hostname',
|
25
18
|
hostparam: 'Host parameter',
|
26
19
|
ip: 'IP',
|
27
20
|
lifecycleenv: 'Lifecycle environment',
|
@@ -38,15 +38,15 @@ export const transformForemanData = (fdata) => {
|
|
38
38
|
if (fdata === undefined) {
|
39
39
|
return "";
|
40
40
|
}
|
41
|
-
|
41
|
+
const result = {};
|
42
42
|
fdata.map(item => result[item.id] = item.name)
|
43
43
|
return (result);
|
44
44
|
}
|
45
45
|
|
46
46
|
export const filterUsedParameterTypes = (options, parameters) => {
|
47
|
-
|
47
|
+
const newOptions = cloneDeep(options);
|
48
48
|
// hostparam can be used multiple times
|
49
|
-
|
49
|
+
const alreadyUsed = parameters.map(item => item["type"]).filter(item => item != 'hostparam');
|
50
50
|
alreadyUsed.forEach(item => delete newOptions[item])
|
51
51
|
return newOptions;
|
52
52
|
}
|
@@ -13,23 +13,24 @@ import {
|
|
13
13
|
import * as sort from 'sortabular';
|
14
14
|
|
15
15
|
import {
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
LOAD_FOREMAN_DATA_REQUEST,
|
29
|
-
LOAD_FOREMAN_DATA_SUCCESS,
|
30
|
-
LOAD_FOREMAN_DATA_FAILURE,
|
16
|
+
PARAMETER_SELECTION_INIT,
|
17
|
+
PARAMETER_SELECTION_TYPES,
|
18
|
+
PARAMETER_SELECTION_DELETE,
|
19
|
+
PARAMETER_SELECTION_ADD,
|
20
|
+
PARAMETER_SELECTION_EDIT_ACTIVATE,
|
21
|
+
PARAMETER_SELECTION_EDIT_CONFIRM,
|
22
|
+
PARAMETER_SELECTION_EDIT_CHANGE,
|
23
|
+
PARAMETER_SELECTION_EDIT_CANCEL,
|
24
|
+
PARAMETER_SELECTION_SORT,
|
25
|
+
PARAMETER_SELECTION_LOAD_FOREMAN_DATA_REQUEST,
|
26
|
+
PARAMETER_SELECTION_LOAD_FOREMAN_DATA_SUCCESS,
|
27
|
+
PARAMETER_SELECTION_LOAD_FOREMAN_DATA_FAILURE,
|
31
28
|
} from './ParameterSelectionConstants';
|
32
29
|
|
30
|
+
import {
|
31
|
+
APPLICATION_DEFINITION_PARAMETER_SELECTION_MODAL_CLOSE,
|
32
|
+
} from '../ApplicationDefinition/ApplicationDefinitionConstants';
|
33
|
+
|
33
34
|
export const initialState = Immutable({
|
34
35
|
editMode: false,
|
35
36
|
error: { errorMsg: '', status: '', statusText: '' },
|
@@ -39,83 +40,83 @@ const parameterSelectionParameters = (state = initialState, action) => {
|
|
39
40
|
const { payload } = action;
|
40
41
|
|
41
42
|
switch (action.type) {
|
42
|
-
case
|
43
|
+
case PARAMETER_SELECTION_INIT: {
|
43
44
|
return state.merge(payload);
|
44
45
|
}
|
45
|
-
case
|
46
|
-
|
47
|
-
|
46
|
+
case PARAMETER_SELECTION_ADD: {
|
47
|
+
let parameters = [];
|
48
|
+
let index = 1;
|
48
49
|
|
49
|
-
if ('
|
50
|
-
|
51
|
-
index = Math.max(...
|
50
|
+
if ('parameters' in state && state.parameters !== undefined && state.parameters.length > 0) {
|
51
|
+
parameters = cloneDeep(state.parameters);
|
52
|
+
index = Math.max(...parameters.map(e => e.id)) + 1;
|
52
53
|
}
|
53
54
|
|
54
55
|
const newRow = {id: index, name: "", description: '', type: '', value: '', newEntry: true };
|
55
56
|
newRow.backup = cloneDeep(newRow)
|
56
|
-
|
57
|
+
parameters.push(newRow);
|
57
58
|
|
58
59
|
return state.merge({
|
59
60
|
editMode: true,
|
60
|
-
|
61
|
+
parameters: parameters
|
61
62
|
});
|
62
63
|
}
|
63
|
-
case
|
64
|
-
|
64
|
+
case PARAMETER_SELECTION_DELETE: {
|
65
|
+
const parameters = state.parameters.filter(v => v.id !== payload.rowData.id);
|
65
66
|
return state.merge({
|
66
|
-
|
67
|
-
parameterTypes: filterUsedParameterTypes(
|
67
|
+
parameters: parameters,
|
68
|
+
parameterTypes: filterUsedParameterTypes(PARAMETER_SELECTION_TYPES, parameters),
|
68
69
|
})
|
69
70
|
}
|
70
|
-
case
|
71
|
-
const
|
72
|
-
const index = findIndex(
|
71
|
+
case PARAMETER_SELECTION_EDIT_ACTIVATE: {
|
72
|
+
const parameters = cloneDeep(state.parameters);
|
73
|
+
const index = findIndex(parameters, { id: payload.rowData.id });
|
73
74
|
|
74
|
-
|
75
|
+
parameters[index].backup = cloneDeep(parameters[index]);
|
75
76
|
|
76
77
|
return state.merge({
|
77
78
|
editMode: true,
|
78
|
-
|
79
|
+
parameters: parameters
|
79
80
|
});
|
80
81
|
}
|
81
|
-
case
|
82
|
-
const
|
83
|
-
const index = findIndex(
|
82
|
+
case PARAMETER_SELECTION_EDIT_CONFIRM: {
|
83
|
+
const parameters = cloneDeep(state.parameters);
|
84
|
+
const index = findIndex(parameters, { id: payload.rowData.id });
|
84
85
|
|
85
|
-
delete
|
86
|
-
delete
|
86
|
+
delete parameters[index].backup;
|
87
|
+
delete parameters[index].newEntry;
|
87
88
|
|
88
89
|
return state.merge({
|
89
90
|
editMode: false,
|
90
|
-
parameterTypes: filterUsedParameterTypes(
|
91
|
-
|
91
|
+
parameterTypes: filterUsedParameterTypes(PARAMETER_SELECTION_TYPES, parameters),
|
92
|
+
parameters: parameters
|
92
93
|
});
|
93
94
|
}
|
94
|
-
case
|
95
|
-
const
|
96
|
-
const index = findIndex(
|
95
|
+
case PARAMETER_SELECTION_EDIT_CHANGE: {
|
96
|
+
const parameters = cloneDeep(state.parameters);
|
97
|
+
const index = findIndex(parameters, { id: payload.rowData.id });
|
97
98
|
|
98
|
-
|
99
|
+
parameters[index][payload.property] = payload.value;
|
99
100
|
|
100
|
-
return state.set('
|
101
|
+
return state.set('parameters', parameters);
|
101
102
|
}
|
102
|
-
case
|
103
|
-
const
|
104
|
-
const index = findIndex(
|
103
|
+
case PARAMETER_SELECTION_EDIT_CANCEL: {
|
104
|
+
const parameters = cloneDeep(state.parameters);
|
105
|
+
const index = findIndex(parameters, { id: payload.rowData.id });
|
105
106
|
|
106
|
-
|
107
|
-
delete
|
107
|
+
parameters[index] = cloneDeep(parameters[index].backup);
|
108
|
+
delete parameters[index].backup;
|
108
109
|
|
109
|
-
if (
|
110
|
-
|
110
|
+
if (parameters[index].newEntry === true) {
|
111
|
+
parameters.splice(index, 1);
|
111
112
|
}
|
112
113
|
|
113
114
|
return state.merge({
|
114
115
|
editMode: false,
|
115
|
-
|
116
|
+
parameters: parameters
|
116
117
|
});
|
117
118
|
}
|
118
|
-
case
|
119
|
+
case PARAMETER_SELECTION_SORT: {
|
119
120
|
const selectedColumn = payload.selectedColumn;
|
120
121
|
return state.set(
|
121
122
|
'sortingColumns',
|
@@ -126,47 +127,47 @@ const parameterSelectionParameters = (state = initialState, action) => {
|
|
126
127
|
})
|
127
128
|
);
|
128
129
|
}
|
129
|
-
case
|
130
|
-
return state.merge({ error: payload.error, loading: false });
|
131
|
-
}
|
132
|
-
case LOAD_PARAMETER_SELECTION_REQUEST: {
|
133
|
-
return state.set('loading', true);
|
134
|
-
}
|
135
|
-
case LOAD_PARAMETER_SELECTION_SUCCESS: {
|
136
|
-
return state.merge({
|
137
|
-
appDefinition: payload.app_definition,
|
138
|
-
loading: false,
|
139
|
-
rows: JSON.parse(payload.app_definition.parameters),
|
140
|
-
hostgroupId: payload.app_definition.hostgroup_id,
|
141
|
-
foremanData: payload.fdata,
|
142
|
-
});
|
143
|
-
}
|
144
|
-
case LOAD_FOREMAN_DATA_FAILURE: {
|
130
|
+
case PARAMETER_SELECTION_LOAD_FOREMAN_DATA_FAILURE: {
|
145
131
|
return state.merge({
|
146
132
|
error: payload.error,
|
147
133
|
loading: false
|
148
134
|
});
|
149
135
|
}
|
150
|
-
case
|
151
|
-
|
136
|
+
case PARAMETER_SELECTION_LOAD_FOREMAN_DATA_REQUEST: {
|
137
|
+
const newState = {
|
152
138
|
foremanData: {},
|
153
139
|
hostgroupId: -1,
|
154
140
|
loading: true
|
155
141
|
};
|
156
142
|
|
157
|
-
if (payload.
|
158
|
-
Object.assign(newState, {
|
143
|
+
if (payload.clearParameters === true) {
|
144
|
+
Object.assign(newState, { parameters: [] });
|
159
145
|
}
|
160
146
|
|
161
147
|
return state.merge(newState);
|
162
148
|
}
|
163
|
-
case
|
149
|
+
case PARAMETER_SELECTION_LOAD_FOREMAN_DATA_SUCCESS: {
|
164
150
|
return state.merge({
|
165
151
|
loading: false,
|
166
152
|
foremanData: payload,
|
167
153
|
hostgroupId: payload.hostgroup_id,
|
168
154
|
});
|
169
155
|
}
|
156
|
+
case APPLICATION_DEFINITION_PARAMETER_SELECTION_MODAL_CLOSE: {
|
157
|
+
const parameters = cloneDeep(state.parameters);
|
158
|
+
|
159
|
+
parameters.forEach((param, index) => {
|
160
|
+
delete parameters[index].backup;
|
161
|
+
if (parameters[index].newEntry === true) {
|
162
|
+
parameters.splice(index, 1);
|
163
|
+
}
|
164
|
+
});
|
165
|
+
|
166
|
+
return state.merge({
|
167
|
+
editMode: false,
|
168
|
+
parameters: parameters
|
169
|
+
});
|
170
|
+
}
|
170
171
|
default:
|
171
172
|
return state;
|
172
173
|
}
|