foreman_acd 0.9.7 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -19
- data/app/controllers/ui_acd_controller.rb +1 -1
- data/db/migrate/20210503122809_add_git_url_to_ansible_playbooks.rb +1 -1
- data/lib/foreman_acd/engine.rb +4 -10
- data/lib/foreman_acd/plugin.rb +1 -1
- data/lib/foreman_acd/version.rb +1 -1
- data/package.json +5 -3
- data/test/controllers/ui_acd_controller_test.rb +1 -1
- data/webpack/components/ApplicationDefinition/ApplicationDefinition.js +210 -121
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionActions.js +79 -91
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionConstants.js +30 -15
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionHelper.js +15 -15
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionReducer.js +96 -63
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionSelectors.js +22 -11
- data/webpack/components/ApplicationDefinition/__fixtures__/{applicationDefinitionConfData_1.fixtures.js → applicationDefinitionConfData1.fixtures.js} +77 -105
- data/webpack/components/ApplicationDefinition/__fixtures__/applicationDefinitionReducer.fixtures.js +49 -29
- data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinition.test.js +4 -4
- data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinitionHelper.test.js +16 -0
- data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinitionReducer.test.js +0 -5
- data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinitionSelectors.test.js +25 -25
- data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinitionReducer.test.js.snap +9 -1
- data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinitionSelectors.test.js.snap +11 -11
- data/webpack/components/ApplicationDefinition/components/AnsiblePlaybookSelector.js +30 -25
- data/webpack/components/ApplicationDefinition/components/__tests__/AnsiblePlaybookSelector.test.js +3 -3
- data/webpack/components/ApplicationDefinition/index.js +0 -1
- data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImport.js +91 -105
- data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportActions.js +59 -84
- data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportConstants.js +12 -6
- data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportReducer.js +21 -27
- data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportSelectors.js +14 -7
- data/webpack/components/ApplicationDefinitionImport/__fixtures__/{applicationDefinitionImportConfData_1.fixtures.js → applicationDefinitionImportConfData1.fixtures.js} +32 -40
- data/webpack/components/ApplicationDefinitionImport/__fixtures__/applicationDefinitionImportReducer.fixtures.js +14 -16
- data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImport.test.js +38 -8
- data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImportReducer.test.js +0 -2
- data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImportSelectors.test.js +9 -9
- data/webpack/components/ApplicationDefinitionImport/__tests__/__snapshots__/ApplicationDefinitionImport.test.js.snap +116 -2
- data/webpack/components/ApplicationDefinitionImport/__tests__/__snapshots__/ApplicationDefinitionImportSelectors.test.js.snap +3 -3
- data/webpack/components/ApplicationInstance/ApplicationInstance.js +344 -193
- data/webpack/components/ApplicationInstance/ApplicationInstanceActions.js +92 -105
- data/webpack/components/ApplicationInstance/ApplicationInstanceConstants.js +34 -17
- data/webpack/components/ApplicationInstance/ApplicationInstanceHelper.js +4 -7
- data/webpack/components/ApplicationInstance/ApplicationInstanceReducer.js +114 -74
- data/webpack/components/ApplicationInstance/ApplicationInstanceSelectors.js +18 -9
- data/webpack/components/ApplicationInstance/__fixtures__/{applicationInstanceConfData_1.fixtures.js → applicationInstanceConfData1.fixtures.js} +68 -86
- data/webpack/components/ApplicationInstance/__fixtures__/applicationInstanceReducer.fixtures.js +24 -32
- data/webpack/components/ApplicationInstance/__tests__/ApplicationInstance.test.js +75 -10
- data/webpack/components/ApplicationInstance/__tests__/ApplicationInstanceReducer.test.js +0 -8
- data/webpack/components/ApplicationInstance/__tests__/ApplicationInstanceSelectors.test.js +27 -27
- data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstance.test.js.snap +606 -2
- data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstanceSelectors.test.js.snap +12 -12
- data/webpack/components/ApplicationInstance/components/AppDefinitionSelector.js +32 -25
- data/webpack/components/ApplicationInstance/components/Service.js +7 -18
- data/webpack/components/ApplicationInstance/components/ServiceCounter.js +25 -18
- data/webpack/components/ApplicationInstance/index.js +0 -1
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.js +167 -110
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportActions.js +20 -25
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportConstants.js +10 -5
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportReducer.js +9 -12
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportSelectors.js +12 -6
- data/webpack/components/ApplicationInstanceReport/__fixtures__/{applicationInstanceReportData_1.fixtures.js → applicationInstanceReportData1.fixtures.js} +154 -101
- data/webpack/components/ApplicationInstanceReport/__fixtures__/applicationInstanceReportReducer.fixtures.js +3 -10
- data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReport.test.js +28 -22
- data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReportSelectors.test.js +5 -7
- data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReportReducer.test.js.snap +0 -1
- data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReportSelectors.test.js.snap +2 -2
- data/webpack/components/ApplicationInstanceReport/components/ReportViewer.js +9 -5
- data/webpack/components/ApplicationInstanceReport/components/__tests__/ReportViewer.test.js +1 -3
- data/webpack/components/ExistingHostSelection/ExistingHostSelection.js +35 -56
- data/webpack/components/ExistingHostSelection/ExistingHostSelectionActions.js +21 -28
- data/webpack/components/ExistingHostSelection/ExistingHostSelectionConstants.js +6 -3
- data/webpack/components/ExistingHostSelection/ExistingHostSelectionReducer.js +16 -19
- data/webpack/components/ExistingHostSelection/ExistingHostSelectionSelectors.js +8 -4
- data/webpack/components/ExistingHostSelection/__fixtures__/existingHostSelectionConfData1.fixtures.js +187 -0
- data/webpack/components/ExistingHostSelection/__fixtures__/existingHostSelectionReducer.fixtures.js +13 -24
- data/webpack/components/ExistingHostSelection/__tests__/ExistingHostSelection.test.js +3 -2
- data/webpack/components/ExistingHostSelection/__tests__/ExistingHostSelectionSelectors.test.js +11 -14
- data/webpack/components/ExistingHostSelection/__tests__/__snapshots__/ExistingHostSelectionSelectors.test.js.snap +5 -5
- data/webpack/components/ExistingHostSelection/components/ServiceSelector.js +31 -25
- data/webpack/components/ExistingHostSelection/components/__tests__/ServiceSelector.test.js +3 -9
- data/webpack/components/ParameterSelection/ParameterSelection.js +258 -174
- data/webpack/components/ParameterSelection/ParameterSelectionActions.js +110 -100
- data/webpack/components/ParameterSelection/ParameterSelectionConstants.js +22 -11
- data/webpack/components/ParameterSelection/ParameterSelectionHelper.js +13 -11
- data/webpack/components/ParameterSelection/ParameterSelectionReducer.js +63 -49
- data/webpack/components/ParameterSelection/ParameterSelectionSelectors.js +10 -5
- data/webpack/components/ParameterSelection/__fixtures__/{parameterSelectionData_1.fixtures.js → parameterSelectionData1.fixtures.js} +67 -104
- data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionReducer.fixtures.js +22 -26
- data/webpack/components/ParameterSelection/__tests__/ParameterSelection.test.js +50 -36
- data/webpack/components/ParameterSelection/__tests__/ParameterSelectionHelper.test.js +76 -0
- data/webpack/components/ParameterSelection/__tests__/ParameterSelectionReducer.test.js +0 -2
- data/webpack/components/ParameterSelection/__tests__/ParameterSelectionSelectors.test.js +23 -25
- data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelection.test.js.snap +100 -0
- data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionReducer.test.js.snap +99 -112
- data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionSelectors.test.js.snap +18 -19
- data/webpack/components/ParameterSelection/index.js +1 -4
- data/webpack/components/SyncGitRepo/SyncGitRepo.js +124 -117
- data/webpack/components/SyncGitRepo/SyncGitRepoActions.js +64 -74
- data/webpack/components/SyncGitRepo/SyncGitRepoReducer.js +17 -17
- data/webpack/components/SyncGitRepo/__fixtures__/syncGitRepoConfData1.fixtures.js +7 -0
- data/webpack/components/SyncGitRepo/__fixtures__/syncGitRepoReducer.fixtures.js +10 -18
- data/webpack/components/SyncGitRepo/__tests__/SyncGitRepo.test.js +80 -6
- data/webpack/components/SyncGitRepo/__tests__/SyncGitRepoSelectors.test.js +9 -11
- data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepo.test.js.snap +192 -1
- data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepoSelectors.test.js.snap +4 -4
- data/webpack/components/SyncGitRepo/components/FormTextInput.js +26 -21
- data/webpack/components/SyncGitRepo/components/ScmTypeSelector.js +29 -24
- data/webpack/components/SyncGitRepo/index.js +2 -5
- data/webpack/components/common/AddTableEntry.js +3 -10
- data/webpack/components/common/DeleteTableEntry.js +7 -15
- data/webpack/components/common/EditTableEntry.js +7 -7
- data/webpack/components/common/ExtSelect.js +12 -8
- data/webpack/components/common/ExtTextInput.js +12 -7
- data/webpack/components/common/LockTableEntry.js +6 -6
- data/webpack/components/common/RailsData.js +6 -16
- data/webpack/components/common/__tests__/ExtSelect.test.js +2 -2
- data/webpack/components/common/__tests__/RailsData.test.js +0 -2
- data/webpack/global_test_setup.js +11 -0
- data/webpack/helper.js +10 -21
- data/webpack/helper.test.js +17 -29
- data/webpack/index.js +25 -7
- data/webpack/js-yaml.js +1563 -1135
- data/webpack/reducer.js +52 -27
- metadata +16 -14
- data/webpack/components/ExistingHostSelection/__fixtures__/existingHostSelectionConfData_1.fixtures.js +0 -191
- data/webpack/components/ParameterSelection/__fixtures__/parameterSelection.fixtures.js +0 -153
- data/webpack/components/SyncGitRepo/__fixtures__/syncGitRepoConfData_1.fixtures.js +0 -7
@@ -1,30 +1,21 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import * as sort from 'sortabular';
|
3
1
|
import { translate as __ } from 'foremanReact/common/I18n';
|
4
2
|
|
5
3
|
import {
|
6
4
|
actionHeaderCellFormatter,
|
7
5
|
sortableHeaderCellFormatter,
|
8
6
|
tableCellFormatter,
|
9
|
-
TABLE_SORT_DIRECTION
|
7
|
+
TABLE_SORT_DIRECTION,
|
10
8
|
} from 'patternfly-react';
|
11
9
|
|
12
10
|
import api from 'foremanReact/API';
|
13
11
|
|
14
|
-
import {
|
15
|
-
propsToSnakeCase,
|
16
|
-
propsToCamelCase,
|
17
|
-
} from 'foremanReact/common/helpers';
|
18
|
-
|
19
|
-
import {
|
20
|
-
filterParameterTypes,
|
21
|
-
} from './ParameterSelectionHelper';
|
22
|
-
|
23
12
|
import {
|
24
13
|
setModalOpen,
|
25
14
|
setModalClosed,
|
26
15
|
} from 'foremanReact/components/ForemanModal/ForemanModalActions';
|
27
16
|
|
17
|
+
import { filterParameterTypes } from './ParameterSelectionHelper';
|
18
|
+
|
28
19
|
import {
|
29
20
|
PARAMETER_SELECTION_INIT,
|
30
21
|
PARAMETER_SELECTION_TYPES,
|
@@ -37,7 +28,6 @@ import {
|
|
37
28
|
PARAMETER_SELECTION_EDIT_CANCEL,
|
38
29
|
PARAMETER_SELECTION_SORT,
|
39
30
|
PARAMETER_SELECTION_PARAM_TYPE_FOREMAN,
|
40
|
-
PARAMETER_SELECTION_PARAM_TYPE_ANSIBLE,
|
41
31
|
PARAMETER_SELECTION_LOAD_PARAM_DATA_REQUEST,
|
42
32
|
PARAMETER_SELECTION_LOAD_PARAM_DATA_SUCCESS,
|
43
33
|
PARAMETER_SELECTION_LOAD_PARAM_DATA_FAILURE,
|
@@ -56,15 +46,15 @@ export const initParameterSelection = (
|
|
56
46
|
sortingFormatter,
|
57
47
|
sortableTransform,
|
58
48
|
inlineEditFormatter,
|
59
|
-
inlineEditButtonsFormatter
|
49
|
+
inlineEditButtonsFormatter
|
60
50
|
) => dispatch => {
|
61
51
|
const initialState = {};
|
62
52
|
|
63
53
|
initialState.sortingColumns = {
|
64
54
|
name: {
|
65
55
|
direction: TABLE_SORT_DIRECTION.ASC,
|
66
|
-
|
67
|
-
}
|
56
|
+
position: 0,
|
57
|
+
},
|
68
58
|
};
|
69
59
|
initialState.paramDefinition = paramDefinition;
|
70
60
|
|
@@ -73,117 +63,136 @@ export const initParameterSelection = (
|
|
73
63
|
valueLabel = __('Default value');
|
74
64
|
}
|
75
65
|
|
76
|
-
initialState.columns = []
|
66
|
+
initialState.columns = [];
|
77
67
|
const addToColumns = (obj, idx) => {
|
78
68
|
obj.header.props.index = idx;
|
79
69
|
initialState.columns.push(obj);
|
80
|
-
}
|
70
|
+
};
|
81
71
|
|
82
72
|
let idx = 0;
|
83
|
-
addToColumns(
|
73
|
+
addToColumns(
|
74
|
+
{
|
84
75
|
property: 'name',
|
85
76
|
header: {
|
86
77
|
label: __('Name'),
|
87
78
|
props: {
|
88
79
|
sort: true,
|
89
80
|
style: {
|
90
|
-
width: '25%'
|
91
|
-
}
|
81
|
+
width: '25%',
|
82
|
+
},
|
92
83
|
},
|
93
84
|
transforms: [sortableTransform],
|
94
85
|
formatters: [sortingFormatter],
|
95
|
-
customFormatters: [sortableHeaderCellFormatter]
|
86
|
+
customFormatters: [sortableHeaderCellFormatter],
|
96
87
|
},
|
97
88
|
cell: {
|
98
|
-
formatters: [
|
99
|
-
|
100
|
-
|
89
|
+
formatters: [
|
90
|
+
allowNameAdjustment ? inlineEditFormatter : tableCellFormatter,
|
91
|
+
],
|
92
|
+
},
|
93
|
+
},
|
94
|
+
idx++
|
95
|
+
);
|
101
96
|
|
102
|
-
addToColumns(
|
97
|
+
addToColumns(
|
98
|
+
{
|
103
99
|
property: 'description',
|
104
100
|
header: {
|
105
101
|
label: __('Description'),
|
106
102
|
props: {
|
107
103
|
sort: true,
|
108
104
|
style: {
|
109
|
-
width: '25%'
|
110
|
-
}
|
105
|
+
width: '25%',
|
106
|
+
},
|
111
107
|
},
|
112
108
|
transforms: [sortableTransform],
|
113
109
|
formatters: [sortingFormatter],
|
114
|
-
customFormatters: [sortableHeaderCellFormatter]
|
110
|
+
customFormatters: [sortableHeaderCellFormatter],
|
115
111
|
},
|
116
112
|
cell: {
|
117
113
|
props: {
|
118
|
-
index: 1
|
114
|
+
index: 1,
|
119
115
|
},
|
120
|
-
formatters: [
|
121
|
-
|
122
|
-
|
116
|
+
formatters: [
|
117
|
+
allowDescriptionAdjustment ? inlineEditFormatter : tableCellFormatter,
|
118
|
+
],
|
119
|
+
},
|
120
|
+
},
|
121
|
+
idx++
|
122
|
+
);
|
123
123
|
|
124
|
-
if (paramType
|
125
|
-
addToColumns(
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
124
|
+
if (paramType === PARAMETER_SELECTION_PARAM_TYPE_FOREMAN) {
|
125
|
+
addToColumns(
|
126
|
+
{
|
127
|
+
property: 'type',
|
128
|
+
header: {
|
129
|
+
label: __('Type'),
|
130
|
+
props: {
|
131
|
+
sort: true,
|
132
|
+
style: {
|
133
|
+
width: '20%',
|
134
|
+
},
|
135
|
+
},
|
136
|
+
transforms: [sortableTransform],
|
137
|
+
formatters: [sortingFormatter],
|
138
|
+
customFormatters: [sortableHeaderCellFormatter],
|
139
|
+
},
|
140
|
+
cell: {
|
141
|
+
// we are always using the inlineEditFormatter so that
|
142
|
+
// the well formatted type name is shown
|
143
|
+
formatters: [inlineEditFormatter],
|
134
144
|
},
|
135
|
-
transforms: [sortableTransform],
|
136
|
-
formatters: [sortingFormatter],
|
137
|
-
customFormatters: [sortableHeaderCellFormatter]
|
138
145
|
},
|
139
|
-
|
140
|
-
|
141
|
-
// the well formatted type name is shown
|
142
|
-
formatters: [inlineEditFormatter]
|
143
|
-
}
|
144
|
-
}, idx++);
|
146
|
+
idx++
|
147
|
+
);
|
145
148
|
}
|
146
149
|
|
147
|
-
addToColumns(
|
150
|
+
addToColumns(
|
151
|
+
{
|
148
152
|
property: 'value',
|
149
153
|
header: {
|
150
154
|
label: valueLabel,
|
151
155
|
props: {
|
152
156
|
sort: true,
|
153
157
|
style: {
|
154
|
-
width: '20%'
|
155
|
-
}
|
158
|
+
width: '20%',
|
159
|
+
},
|
156
160
|
},
|
157
161
|
transforms: [sortableTransform],
|
158
162
|
formatters: [sortingFormatter],
|
159
|
-
customFormatters: [sortableHeaderCellFormatter]
|
163
|
+
customFormatters: [sortableHeaderCellFormatter],
|
160
164
|
},
|
161
165
|
cell: {
|
162
|
-
formatters: [inlineEditFormatter]
|
163
|
-
}
|
164
|
-
},
|
166
|
+
formatters: [inlineEditFormatter],
|
167
|
+
},
|
168
|
+
},
|
169
|
+
idx++
|
170
|
+
);
|
165
171
|
|
166
|
-
addToColumns(
|
172
|
+
addToColumns(
|
173
|
+
{
|
167
174
|
property: 'actions',
|
168
175
|
header: {
|
169
176
|
label: __('Actions'),
|
170
177
|
props: {
|
171
178
|
style: {
|
172
|
-
width: '10%'
|
173
|
-
}
|
179
|
+
width: '10%',
|
180
|
+
},
|
174
181
|
},
|
175
|
-
formatters: [actionHeaderCellFormatter]
|
182
|
+
formatters: [actionHeaderCellFormatter],
|
176
183
|
},
|
177
184
|
cell: {
|
178
|
-
formatters: [inlineEditButtonsFormatter]
|
179
|
-
}
|
180
|
-
},
|
185
|
+
formatters: [inlineEditButtonsFormatter],
|
186
|
+
},
|
187
|
+
},
|
188
|
+
idx++
|
189
|
+
);
|
181
190
|
|
182
191
|
initialState.parameters = parameters;
|
183
|
-
initialState.allowedParameterTypes =
|
192
|
+
initialState.allowedParameterTypes = {};
|
184
193
|
|
185
|
-
if (
|
186
|
-
|
194
|
+
if (paramType === PARAMETER_SELECTION_PARAM_TYPE_FOREMAN && parameters) {
|
195
|
+
const pTypes = PARAMETER_SELECTION_TYPES;
|
187
196
|
|
188
197
|
// filter hidden parameters
|
189
198
|
hiddenParameterTypes.forEach(item => delete pTypes[item]);
|
@@ -199,7 +208,7 @@ export const initParameterSelection = (
|
|
199
208
|
type: PARAMETER_SELECTION_INIT,
|
200
209
|
payload: initialState,
|
201
210
|
});
|
202
|
-
}
|
211
|
+
};
|
203
212
|
|
204
213
|
const errorHandler = (msg, err) => {
|
205
214
|
const error = {
|
@@ -209,68 +218,63 @@ const errorHandler = (msg, err) => {
|
|
209
218
|
return { type: msg, payload: { error } };
|
210
219
|
};
|
211
220
|
|
212
|
-
export const lockParameter =
|
221
|
+
export const lockParameter = additionalData => ({
|
213
222
|
type: PARAMETER_SELECTION_LOCK,
|
214
223
|
payload: {
|
215
224
|
...additionalData,
|
216
225
|
},
|
217
226
|
});
|
218
227
|
|
219
|
-
export const openParameterSelectionDialogBox =
|
228
|
+
export const openParameterSelectionDialogBox = additionalData => dispatch => {
|
220
229
|
dispatch({
|
221
230
|
type: PARAMETER_SELECTION_COMPLEX_DATA_MODAL_OPEN,
|
222
231
|
payload: {
|
223
232
|
...additionalData,
|
224
|
-
}
|
233
|
+
},
|
225
234
|
});
|
226
|
-
dispatch(
|
227
|
-
setModalOpen({ id: 'ParameterSelectionComplexDataModal' })
|
228
|
-
);
|
235
|
+
dispatch(setModalOpen({ id: 'ParameterSelectionComplexDataModal' }));
|
229
236
|
};
|
230
237
|
|
231
|
-
export const closeParameterSelectionDialogBox =
|
238
|
+
export const closeParameterSelectionDialogBox = additionalData => dispatch => {
|
232
239
|
dispatch({
|
233
240
|
type: PARAMETER_SELECTION_COMPLEX_DATA_MODAL_CLOSE,
|
234
241
|
payload: {
|
235
242
|
...additionalData,
|
236
|
-
}
|
243
|
+
},
|
237
244
|
});
|
238
245
|
|
239
|
-
dispatch(
|
240
|
-
setModalClosed({ id: 'ParameterSelectionComplexDataModal' })
|
241
|
-
);
|
246
|
+
dispatch(setModalClosed({ id: 'ParameterSelectionComplexDataModal' }));
|
242
247
|
};
|
243
248
|
|
244
|
-
export const addParameter =
|
245
|
-
{
|
249
|
+
export const addParameter = additionalData => ({
|
246
250
|
type: PARAMETER_SELECTION_ADD,
|
247
251
|
payload: {
|
248
252
|
...additionalData,
|
249
253
|
},
|
250
254
|
});
|
251
255
|
|
252
|
-
export const deleteParameter =
|
256
|
+
export const deleteParameter = additionalData => ({
|
253
257
|
type: PARAMETER_SELECTION_DELETE,
|
254
258
|
payload: {
|
255
259
|
...additionalData,
|
256
260
|
},
|
257
261
|
});
|
258
262
|
|
259
|
-
export const activateEditParameter =
|
263
|
+
export const activateEditParameter = additionalData => ({
|
260
264
|
type: PARAMETER_SELECTION_EDIT_ACTIVATE,
|
261
265
|
payload: {
|
262
266
|
...additionalData,
|
263
267
|
},
|
264
268
|
});
|
265
269
|
|
266
|
-
export const confirmEditParameter =
|
270
|
+
export const confirmEditParameter = rowData => ({
|
267
271
|
type: PARAMETER_SELECTION_EDIT_CONFIRM,
|
268
272
|
payload: {
|
269
273
|
...rowData,
|
270
274
|
},
|
271
275
|
});
|
272
276
|
|
273
|
-
export const cancelEditParameter =
|
277
|
+
export const cancelEditParameter = rowData => ({
|
274
278
|
type: PARAMETER_SELECTION_EDIT_CANCEL,
|
275
279
|
payload: {
|
276
280
|
...rowData,
|
@@ -293,22 +297,28 @@ export const sortParameter = (selectedColumn, defaultSortingOrder) => ({
|
|
293
297
|
},
|
294
298
|
});
|
295
299
|
|
296
|
-
export const loadParamData =
|
297
|
-
dispatch(
|
300
|
+
export const loadParamData = attr => async dispatch => {
|
301
|
+
dispatch({
|
302
|
+
type: PARAMETER_SELECTION_LOAD_PARAM_DATA_REQUEST,
|
303
|
+
payload: { dataType: attr.dataType, clearParameters: attr.clearParameters },
|
304
|
+
});
|
298
305
|
|
299
|
-
let realUrl = attr.url.replace(
|
306
|
+
let realUrl = attr.url.replace('__id__', attr.paramDefinition.dataId);
|
300
307
|
|
301
308
|
if (attr.paramDefinition.hasOwnProperty('dataSubId')) {
|
302
|
-
realUrl = realUrl.replace(
|
309
|
+
realUrl = realUrl.replace('__subid__', attr.paramDefinition.dataSubId);
|
303
310
|
}
|
304
311
|
|
305
|
-
|
306
|
-
.get(realUrl, {}, {})
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
312
|
+
try {
|
313
|
+
const { data } = await api.get(realUrl, {}, {});
|
314
|
+
|
315
|
+
return dispatch({
|
316
|
+
type: PARAMETER_SELECTION_LOAD_PARAM_DATA_SUCCESS,
|
317
|
+
payload: { ...data, dataType: attr.dataType },
|
318
|
+
});
|
319
|
+
} catch (error) {
|
320
|
+
return dispatch(
|
321
|
+
errorHandler(PARAMETER_SELECTION_LOAD_PARAM_DATA_FAILURE, error)
|
322
|
+
);
|
323
|
+
}
|
314
324
|
};
|
@@ -2,18 +2,29 @@ export const PARAMETER_SELECTION_INIT = 'INIT_PARAMETER_SELECTION_INIT';
|
|
2
2
|
export const PARAMETER_SELECTION_LOCK = 'PARAMETER_SELECTION_LOCK';
|
3
3
|
export const PARAMETER_SELECTION_DELETE = 'PARAMETER_SELECTION_DELETE';
|
4
4
|
export const PARAMETER_SELECTION_ADD = 'PARAMETER_SELECTION_ADD';
|
5
|
-
export const PARAMETER_SELECTION_EDIT_ACTIVATE =
|
6
|
-
|
7
|
-
export const
|
8
|
-
|
5
|
+
export const PARAMETER_SELECTION_EDIT_ACTIVATE =
|
6
|
+
'PARAMETER_SELECTION_EDIT_ACTIVATE';
|
7
|
+
export const PARAMETER_SELECTION_EDIT_CONFIRM =
|
8
|
+
'PARAMETER_SELECTION_EDIT_CONFIRM';
|
9
|
+
export const PARAMETER_SELECTION_EDIT_CHANGE =
|
10
|
+
'PARAMETER_SELECTION_EDIT_CHANGE';
|
11
|
+
export const PARAMETER_SELECTION_EDIT_CANCEL =
|
12
|
+
'PARAMETER_SELECTION_EDIT_CANCEL';
|
9
13
|
export const PARAMETER_SELECTION_SORT = 'PARAMETER_SELECTION_SORT';
|
10
|
-
export const PARAMETER_SELECTION_LOAD_PARAM_DATA_REQUEST =
|
11
|
-
|
12
|
-
export const
|
13
|
-
|
14
|
-
export const
|
15
|
-
|
16
|
-
export const
|
14
|
+
export const PARAMETER_SELECTION_LOAD_PARAM_DATA_REQUEST =
|
15
|
+
'PARAMETER_SELECTION_LOAD_PARAM_DATA_REQUEST';
|
16
|
+
export const PARAMETER_SELECTION_LOAD_PARAM_DATA_SUCCESS =
|
17
|
+
'PARAMETER_SELECTION_LOAD_PARAM_DATA_SUCCESS';
|
18
|
+
export const PARAMETER_SELECTION_LOAD_PARAM_DATA_FAILURE =
|
19
|
+
'PARAMETER_SELECTION_LOAD_PARAM_DATA_FAILURE';
|
20
|
+
export const PARAMETER_SELECTION_PARAM_TYPE_FOREMAN =
|
21
|
+
'PARAMETER_SELECTION_PARAM_TYPE_FOREMAN';
|
22
|
+
export const PARAMETER_SELECTION_PARAM_TYPE_ANSIBLE =
|
23
|
+
'PARAMETER_SELECTION_PARAM_TYPE_ANSIBLE';
|
24
|
+
export const PARAMETER_SELECTION_COMPLEX_DATA_MODAL_OPEN =
|
25
|
+
'PARAMETER_SELECTION_COMPLEX_DATA_MODAL_OPEN';
|
26
|
+
export const PARAMETER_SELECTION_COMPLEX_DATA_MODAL_CLOSE =
|
27
|
+
'PARAMETER_SELECTION_COMPLEX_DATA_MODAL_CLOSE';
|
17
28
|
|
18
29
|
// Make sure the object is sorted by value
|
19
30
|
// (Compute Profile -> Partition table -> Root password)
|
@@ -1,24 +1,26 @@
|
|
1
|
-
import {
|
2
|
-
cloneDeep,
|
3
|
-
} from 'lodash';
|
1
|
+
import { cloneDeep } from 'lodash';
|
4
2
|
|
5
|
-
export const transformForemanData =
|
3
|
+
export const transformForemanData = fdata => {
|
6
4
|
if (fdata === undefined) {
|
7
|
-
return
|
5
|
+
return '';
|
8
6
|
}
|
9
7
|
const result = {};
|
10
|
-
fdata.
|
11
|
-
|
12
|
-
}
|
8
|
+
fdata.forEach(item => {
|
9
|
+
result[item.id] = item.name;
|
10
|
+
});
|
11
|
+
return result;
|
12
|
+
};
|
13
13
|
|
14
14
|
export const filterParameterTypes = (options, parameters) => {
|
15
15
|
const newOptions = cloneDeep(options);
|
16
16
|
|
17
17
|
// hostparam can be used multiple times
|
18
|
-
const alreadyUsed = parameters
|
18
|
+
const alreadyUsed = parameters
|
19
|
+
.map(item => item.type)
|
20
|
+
.filter(item => item !== 'hostparam');
|
19
21
|
|
20
22
|
// remove already used items
|
21
|
-
alreadyUsed.forEach(item => delete newOptions[item])
|
23
|
+
alreadyUsed.forEach(item => delete newOptions[item]);
|
22
24
|
|
23
25
|
return newOptions;
|
24
|
-
}
|
26
|
+
};
|
@@ -1,20 +1,13 @@
|
|
1
1
|
import Immutable from 'seamless-immutable';
|
2
2
|
|
3
|
-
import {
|
4
|
-
cloneDeep,
|
5
|
-
findIndex,
|
6
|
-
findLastIndex,
|
7
|
-
} from 'lodash';
|
8
|
-
|
9
|
-
import {
|
10
|
-
filterParameterTypes,
|
11
|
-
} from './ParameterSelectionHelper';
|
3
|
+
import { cloneDeep, findIndex } from 'lodash';
|
12
4
|
|
13
5
|
import * as sort from 'sortabular';
|
14
6
|
|
7
|
+
import { filterParameterTypes } from './ParameterSelectionHelper';
|
8
|
+
|
15
9
|
import {
|
16
10
|
PARAMETER_SELECTION_INIT,
|
17
|
-
PARAMETER_SELECTION_TYPES,
|
18
11
|
PARAMETER_SELECTION_LOCK,
|
19
12
|
PARAMETER_SELECTION_DELETE,
|
20
13
|
PARAMETER_SELECTION_ADD,
|
@@ -33,6 +26,7 @@ import {
|
|
33
26
|
} from './ParameterSelectionConstants';
|
34
27
|
|
35
28
|
export const initialState = Immutable({
|
29
|
+
loading: true,
|
36
30
|
editMode: false,
|
37
31
|
error: { errorMsg: '', status: '', statusText: '' },
|
38
32
|
});
|
@@ -48,20 +42,33 @@ const parameterSelectionParameters = (state = initialState, action) => {
|
|
48
42
|
let parameters = [];
|
49
43
|
let index = 1;
|
50
44
|
|
51
|
-
if (
|
45
|
+
if (
|
46
|
+
'parameters' in state &&
|
47
|
+
state.parameters !== undefined &&
|
48
|
+
state.parameters.length > 0
|
49
|
+
) {
|
52
50
|
parameters = cloneDeep(state.parameters);
|
53
51
|
index = Math.max(...parameters.map(e => e.id)) + 1;
|
54
52
|
}
|
55
53
|
|
56
|
-
const newRow = {
|
57
|
-
|
58
|
-
|
54
|
+
const newRow = {
|
55
|
+
id: index,
|
56
|
+
locked: false,
|
57
|
+
name: '',
|
58
|
+
description: '',
|
59
|
+
type: '',
|
60
|
+
value: '',
|
61
|
+
isYaml: false,
|
62
|
+
newEntry: true,
|
63
|
+
};
|
64
|
+
if (state.paramType === 'PARAMETER_SELECTION_PARAM_TYPE_ANSIBLE') {
|
65
|
+
newRow.type = 'complex';
|
59
66
|
}
|
60
|
-
newRow.backup = cloneDeep(newRow)
|
67
|
+
newRow.backup = cloneDeep(newRow);
|
61
68
|
parameters.push(newRow);
|
62
69
|
return state.merge({
|
63
70
|
editMode: true,
|
64
|
-
parameters
|
71
|
+
parameters,
|
65
72
|
editParamsRowIndex: index,
|
66
73
|
});
|
67
74
|
}
|
@@ -76,15 +83,20 @@ const parameterSelectionParameters = (state = initialState, action) => {
|
|
76
83
|
}
|
77
84
|
|
78
85
|
return state.merge({
|
79
|
-
parameters
|
86
|
+
parameters,
|
80
87
|
});
|
81
88
|
}
|
82
89
|
case PARAMETER_SELECTION_DELETE: {
|
83
|
-
const parameters = state.parameters.filter(
|
90
|
+
const parameters = state.parameters.filter(
|
91
|
+
v => v.id !== payload.rowData.id
|
92
|
+
);
|
84
93
|
return state.merge({
|
85
|
-
parameters
|
86
|
-
parameterTypes: filterParameterTypes(
|
87
|
-
|
94
|
+
parameters,
|
95
|
+
parameterTypes: filterParameterTypes(
|
96
|
+
state.allowedParameterTypes,
|
97
|
+
parameters
|
98
|
+
),
|
99
|
+
});
|
88
100
|
}
|
89
101
|
case PARAMETER_SELECTION_EDIT_ACTIVATE: {
|
90
102
|
const parameters = cloneDeep(state.parameters);
|
@@ -93,7 +105,7 @@ const parameterSelectionParameters = (state = initialState, action) => {
|
|
93
105
|
parameters[index].backup = cloneDeep(parameters[index]);
|
94
106
|
return state.merge({
|
95
107
|
editMode: true,
|
96
|
-
parameters
|
108
|
+
parameters,
|
97
109
|
editParamsRowIndex: index,
|
98
110
|
});
|
99
111
|
}
|
@@ -106,22 +118,25 @@ const parameterSelectionParameters = (state = initialState, action) => {
|
|
106
118
|
|
107
119
|
return state.merge({
|
108
120
|
editMode: false,
|
109
|
-
parameterTypes: filterParameterTypes(
|
110
|
-
|
121
|
+
parameterTypes: filterParameterTypes(
|
122
|
+
state.allowedParameterTypes,
|
123
|
+
parameters
|
124
|
+
),
|
125
|
+
parameters,
|
111
126
|
});
|
112
127
|
}
|
113
128
|
case PARAMETER_SELECTION_EDIT_CHANGE: {
|
114
129
|
const parameters = cloneDeep(state.parameters);
|
115
130
|
const index = findIndex(parameters, { id: payload.rowData.id });
|
116
131
|
|
117
|
-
if (!parameters[index]
|
118
|
-
parameters[index]
|
119
|
-
} else if (payload.property
|
132
|
+
if (!parameters[index].isYaml && payload.property === 'value') {
|
133
|
+
parameters[index].value = payload.value;
|
134
|
+
} else if (payload.property !== 'value') {
|
120
135
|
parameters[index][payload.property] = payload.value;
|
121
136
|
}
|
122
137
|
return state.merge({
|
123
|
-
parameters
|
124
|
-
editParamsRowIndex: index
|
138
|
+
parameters,
|
139
|
+
editParamsRowIndex: index,
|
125
140
|
});
|
126
141
|
}
|
127
142
|
case PARAMETER_SELECTION_EDIT_CANCEL: {
|
@@ -137,38 +152,38 @@ const parameterSelectionParameters = (state = initialState, action) => {
|
|
137
152
|
|
138
153
|
return state.merge({
|
139
154
|
editMode: false,
|
140
|
-
parameters
|
155
|
+
parameters,
|
141
156
|
});
|
142
157
|
}
|
143
158
|
case PARAMETER_SELECTION_SORT: {
|
144
|
-
const selectedColumn = payload
|
159
|
+
const { selectedColumn } = payload;
|
145
160
|
return state.set(
|
146
161
|
'sortingColumns',
|
147
162
|
sort.byColumn({
|
148
163
|
sortingColumns: state.sortingColumns,
|
149
164
|
sortingOrder: payload.defaultSortingOrder,
|
150
|
-
selectedColumn
|
165
|
+
selectedColumn,
|
151
166
|
})
|
152
167
|
);
|
153
168
|
}
|
154
169
|
case PARAMETER_SELECTION_LOAD_PARAM_DATA_FAILURE: {
|
155
170
|
return state.merge({
|
156
171
|
error: payload.error,
|
157
|
-
loading: false
|
172
|
+
loading: false,
|
158
173
|
});
|
159
174
|
}
|
160
175
|
case PARAMETER_SELECTION_LOAD_PARAM_DATA_REQUEST: {
|
161
176
|
let newState = {};
|
162
177
|
|
163
|
-
if (payload.dataType
|
178
|
+
if (payload.dataType === PARAMETER_SELECTION_PARAM_TYPE_FOREMAN) {
|
164
179
|
newState = {
|
165
180
|
paramData: {},
|
166
181
|
hostgroupId: -1,
|
167
|
-
loading: true
|
182
|
+
loading: true,
|
168
183
|
};
|
169
|
-
} else if (payload.dataType
|
184
|
+
} else if (payload.dataType === PARAMETER_SELECTION_PARAM_TYPE_ANSIBLE) {
|
170
185
|
newState = {
|
171
|
-
loading: true
|
186
|
+
loading: true,
|
172
187
|
};
|
173
188
|
}
|
174
189
|
|
@@ -181,7 +196,7 @@ const parameterSelectionParameters = (state = initialState, action) => {
|
|
181
196
|
case PARAMETER_SELECTION_LOAD_PARAM_DATA_SUCCESS: {
|
182
197
|
let newState = {};
|
183
198
|
|
184
|
-
if (payload.dataType
|
199
|
+
if (payload.dataType === PARAMETER_SELECTION_PARAM_TYPE_FOREMAN) {
|
185
200
|
newState = {
|
186
201
|
loading: false,
|
187
202
|
paramData: payload,
|
@@ -196,25 +211,24 @@ const parameterSelectionParameters = (state = initialState, action) => {
|
|
196
211
|
}
|
197
212
|
case PARAMETER_SELECTION_COMPLEX_DATA_MODAL_CLOSE: {
|
198
213
|
let str;
|
199
|
-
|
200
|
-
if (element
|
214
|
+
const element = document.getElementById('yamlData');
|
215
|
+
if (element !== null) {
|
201
216
|
str = element.value;
|
202
|
-
}
|
203
|
-
else {
|
217
|
+
} else {
|
204
218
|
str = '';
|
205
219
|
}
|
206
220
|
let newState = {};
|
207
|
-
|
221
|
+
const index = state.editParamsRowIndex;
|
208
222
|
const parameters = cloneDeep(state.parameters);
|
209
|
-
if (payload.mode
|
210
|
-
parameters[index]
|
211
|
-
if (str
|
212
|
-
parameters[index]
|
223
|
+
if (payload.mode === 'save') {
|
224
|
+
parameters[index].value = str;
|
225
|
+
if (str === '') {
|
226
|
+
parameters[index].isYaml = false;
|
213
227
|
} else {
|
214
|
-
parameters[index]
|
228
|
+
parameters[index].isYaml = true;
|
215
229
|
}
|
216
230
|
newState = {
|
217
|
-
parameters
|
231
|
+
parameters,
|
218
232
|
};
|
219
233
|
} else {
|
220
234
|
newState = {};
|