foreman_acd 0.2.1 → 0.7.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 +107 -56
- data/app/controllers/foreman_acd/ansible_playbooks_controller.rb +199 -0
- data/app/controllers/foreman_acd/api/v2/ansible_playbooks_controller.rb +72 -0
- data/app/controllers/foreman_acd/api/v2/app_definitions_controller.rb +1 -0
- data/app/controllers/foreman_acd/api/v2/app_instances_controller.rb +62 -0
- data/app/controllers/foreman_acd/app_definitions_controller.rb +19 -10
- data/app/controllers/foreman_acd/app_instances_controller.rb +111 -137
- 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/foreman_acd/remote_execution_controller.rb +62 -0
- data/app/controllers/ui_acd_controller.rb +20 -3
- data/app/lib/actions/foreman_acd/deploy_all_hosts.rb +47 -0
- data/app/lib/actions/foreman_acd/run_configurator.rb +44 -0
- data/app/models/concerns/foreman_acd/host_managed_extensions.rb +51 -0
- data/app/models/foreman_acd/acd_provider.rb +36 -0
- data/app/models/foreman_acd/ansible_playbook.rb +68 -0
- data/app/models/foreman_acd/app_definition.rb +25 -0
- data/app/models/foreman_acd/app_instance.rb +42 -0
- data/app/models/foreman_acd/foreman_host.rb +23 -0
- data/app/models/foreman_acd/taxonomy_extensions.rb +17 -0
- data/app/services/foreman_acd/acd_proxy_proxy_selector.rb +17 -0
- data/app/services/foreman_acd/app_configurator.rb +98 -0
- data/app/services/foreman_acd/app_deployer.rb +157 -0
- data/app/services/foreman_acd/inventory_creator.rb +68 -0
- data/app/views/foreman_acd/ansible_playbooks/_form.html.erb +64 -0
- data/app/views/foreman_acd/ansible_playbooks/edit.html.erb +11 -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 +5 -0
- data/app/views/foreman_acd/api/v2/ansible_playbooks/index.json.rabl +5 -0
- data/app/views/foreman_acd/api/v2/ansible_playbooks/show.json.rabl +9 -0
- data/app/views/foreman_acd/api/v2/app_definitions/base.json.rabl +5 -0
- data/app/views/foreman_acd/api/v2/app_definitions/index.json.rabl +5 -0
- data/app/views/foreman_acd/api/v2/app_definitions/show.json.rabl +9 -0
- data/app/views/foreman_acd/api/v2/app_instances/base.json.rabl +5 -0
- data/app/views/foreman_acd/api/v2/app_instances/index.json.rabl +5 -0
- data/app/views/foreman_acd/api/v2/app_instances/show.json.rabl +5 -0
- data/app/views/foreman_acd/app_definitions/_form.html.erb +34 -12
- data/app/views/foreman_acd/app_definitions/edit.html.erb +10 -0
- data/app/views/foreman_acd/app_definitions/index.html.erb +4 -4
- data/app/views/foreman_acd/app_instances/_form.html.erb +11 -9
- data/app/views/foreman_acd/app_instances/edit.html.erb +10 -0
- data/app/views/foreman_acd/app_instances/index.html.erb +89 -10
- data/app/views/foreman_acd/app_instances/report.html.erb +6 -3
- data/app/views/templates/job/run_acd_ansible_playbook.erb +62 -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 +32 -2
- 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 +8 -0
- data/db/migrate/20201016104338_add_ansible_vars_all_to_app_instances.rb +8 -0
- data/db/migrate/20210112111548_add_organization_to_app_instance.rb +22 -0
- data/db/migrate/20210112113853_add_location_to_app_instance.rb +8 -0
- data/db/migrate/20210202141658_create_foreman_hosts.rb +24 -0
- data/db/migrate/20210204111306_remove_hosts_from_app_instances.rb +8 -0
- data/db/migrate/20210209091014_rename_acd_tables.rb +16 -0
- data/db/migrate/20210216083522_add_last_progress_report.rb +8 -0
- data/db/migrate/20210216091529_add_last_deploy_task.rb +8 -0
- data/db/migrate/20210316151145_add_git_commit_to_ansible_playbooks.rb +8 -0
- data/db/migrate/20210503122809_add_git_url_to_ansible_playbooks.rb +8 -0
- data/db/seeds.d/62_acd_proxy_feature.rb +4 -0
- data/db/seeds.d/75-job_templates.rb +13 -0
- data/lib/foreman_acd.rb +12 -0
- data/lib/foreman_acd/engine.rb +43 -3
- data/lib/foreman_acd/plugin.rb +88 -22
- data/lib/foreman_acd/version.rb +1 -1
- data/lib/tasks/foreman_acd_tasks.rake +0 -12
- data/locale/en/foreman_acd.edit.po +326 -0
- data/locale/en/foreman_acd.po +232 -2
- data/locale/en/foreman_acd.po.time_stamp +0 -0
- data/locale/foreman_acd.pot +343 -8
- data/package.json +9 -9
- data/test/controllers/ansible_playbooks_controller_test.rb +27 -0
- data/test/controllers/app_instances_controller_test.rb +8 -3
- data/test/controllers/ui_acd_controller_test.rb +22 -6
- data/test/factories/foreman_acd_factories.rb +18 -4
- data/test/models/acd_provider_test.rb +37 -0
- data/test/models/ansible_playbook_test.rb +11 -0
- data/test/models/app_definition_test.rb +1 -1
- data/test/models/app_instance_test.rb +2 -0
- data/test/models/concerns/host_extensions_test.rb +26 -0
- data/test/models/foreman_host_test.rb +12 -0
- data/webpack/__mocks__/foremanReact/API.js +2 -0
- data/webpack/__mocks__/foremanReact/common/I18n.js +3 -0
- data/webpack/__mocks__/foremanReact/common/helpers.js +2 -0
- data/webpack/__mocks__/foremanReact/components/ForemanModal.js +7 -0
- data/webpack/__mocks__/foremanReact/components/common/forms/CommonForm.js +2 -0
- data/webpack/__mocks__/foremanReact/components/common/forms/TextInput.js +2 -0
- data/webpack/__mocks__/foremanReact/components/hosts/powerStatus.js +1 -0
- data/webpack/__snapshots__/helper.test.js.snap +14 -0
- data/webpack/components/ApplicationDefinition/ApplicationDefinition.js +159 -29
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionActions.js +106 -14
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionConstants.js +8 -2
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionHelper.js +26 -0
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionReducer.js +143 -21
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionSelectors.js +3 -0
- data/webpack/components/ApplicationDefinition/__fixtures__/applicationDefinitionConfData_1.fixtures.js +288 -0
- data/webpack/components/ApplicationDefinition/__fixtures__/applicationDefinitionReducer.fixtures.js +79 -0
- data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinition.test.js +25 -0
- data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinitionReducer.test.js +119 -0
- data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinitionSelectors.test.js +41 -0
- data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinition.test.js.snap +200 -0
- data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinitionReducer.test.js.snap +3033 -0
- data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinitionSelectors.test.js.snap +299 -0
- data/webpack/components/ApplicationDefinition/components/AnsiblePlaybookSelector.js +50 -0
- data/webpack/components/ApplicationDefinition/components/__tests__/AnsiblePlaybookSelector.test.js +41 -0
- data/webpack/components/ApplicationDefinition/components/__tests__/__snapshots__/AnsiblePlaybookSelector.test.js.snap +121 -0
- data/webpack/components/ApplicationDefinition/index.js +6 -0
- data/webpack/components/ApplicationInstance/ApplicationInstance.js +151 -44
- data/webpack/components/ApplicationInstance/ApplicationInstanceActions.js +47 -10
- data/webpack/components/ApplicationInstance/ApplicationInstanceConstants.js +5 -2
- data/webpack/components/ApplicationInstance/ApplicationInstanceReducer.js +114 -28
- data/webpack/components/ApplicationInstance/ApplicationInstanceSelectors.js +3 -1
- data/webpack/components/ApplicationInstance/__fixtures__/applicationInstanceConfData_1.fixtures.js +263 -0
- data/webpack/components/ApplicationInstance/__fixtures__/applicationInstanceReducer.fixtures.js +78 -0
- data/webpack/components/ApplicationInstance/__tests__/ApplicationInstance.test.js +23 -0
- data/webpack/components/ApplicationInstance/__tests__/ApplicationInstanceReducer.test.js +119 -0
- data/webpack/components/ApplicationInstance/__tests__/ApplicationInstanceSelectors.test.js +44 -0
- data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstance.test.js.snap +209 -0
- data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstanceReducer.test.js.snap +2719 -0
- data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstanceSelectors.test.js.snap +276 -0
- data/webpack/components/ApplicationInstance/components/Service.js +1 -1
- data/webpack/components/ApplicationInstance/index.js +4 -0
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.js +53 -60
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.scss +17 -0
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportActions.js +7 -51
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportConstants.js +2 -4
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportReducer.js +4 -18
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportSelectors.js +0 -1
- data/webpack/components/ApplicationInstanceReport/__fixtures__/applicationInstanceReportData_1.fixtures.js +349 -0
- data/webpack/components/ApplicationInstanceReport/__fixtures__/applicationInstanceReportReducer.fixtures.js +20 -0
- data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReport.test.js +47 -0
- data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReportReducer.test.js +41 -0
- data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReportSelectors.test.js +26 -0
- data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReport.test.js.snap +130 -0
- data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReportReducer.test.js.snap +718 -0
- data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReportSelectors.test.js.snap +347 -0
- data/webpack/components/ApplicationInstanceReport/components/ReportViewer.js +1 -1
- data/webpack/components/ApplicationInstanceReport/components/__tests__/ReportViewer.test.js +24 -0
- data/webpack/components/ApplicationInstanceReport/components/__tests__/__snapshots__/ReportViewer.test.js.snap +24 -0
- data/webpack/components/ApplicationInstanceReport/index.js +0 -2
- data/webpack/components/ParameterSelection/ParameterSelection.js +85 -50
- data/webpack/components/ParameterSelection/ParameterSelectionActions.js +68 -62
- data/webpack/components/ParameterSelection/ParameterSelectionConstants.js +6 -3
- data/webpack/components/ParameterSelection/ParameterSelectionHelper.js +0 -32
- data/webpack/components/ParameterSelection/ParameterSelectionReducer.js +47 -35
- data/webpack/components/ParameterSelection/ParameterSelectionSelectors.js +2 -2
- data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionData_1.fixtures.js +116 -84
- data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionReducer.fixtures.js +10 -4
- data/webpack/components/ParameterSelection/__tests__/ParameterSelection.test.js +36 -46
- data/webpack/components/ParameterSelection/__tests__/ParameterSelectionReducer.test.js +31 -25
- data/webpack/components/ParameterSelection/__tests__/ParameterSelectionSelectors.test.js +6 -6
- data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelection.test.js.snap +2 -126
- data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionReducer.test.js.snap +1483 -872
- data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionSelectors.test.js.snap +117 -79
- data/webpack/components/ParameterSelection/index.js +4 -4
- data/webpack/components/SyncGitRepo/SyncGitRepo.js +210 -0
- data/webpack/components/SyncGitRepo/SyncGitRepo.scss +1 -0
- data/webpack/components/SyncGitRepo/SyncGitRepoActions.js +124 -0
- data/webpack/components/SyncGitRepo/SyncGitRepoConstants.js +9 -0
- data/webpack/components/SyncGitRepo/SyncGitRepoReducer.js +80 -0
- data/webpack/components/SyncGitRepo/SyncGitRepoSelectors.js +6 -0
- data/webpack/components/SyncGitRepo/__fixtures__/syncGitRepoConfData_1.fixtures.js +7 -0
- data/webpack/components/SyncGitRepo/__fixtures__/syncGitRepoReducer.fixtures.js +44 -0
- data/webpack/components/SyncGitRepo/__tests__/SyncGitRepo.test.js +27 -0
- data/webpack/components/SyncGitRepo/__tests__/SyncGitRepoReducer.test.js +95 -0
- data/webpack/components/SyncGitRepo/__tests__/SyncGitRepoSelectors.test.js +32 -0
- data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepo.test.js.snap +30 -0
- data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepoReducer.test.js.snap +137 -0
- data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepoSelectors.test.js.snap +13 -0
- data/webpack/components/SyncGitRepo/components/FormTextInput.js +42 -0
- data/webpack/components/SyncGitRepo/components/ScmTypeSelector.js +46 -0
- data/webpack/components/SyncGitRepo/index.js +28 -0
- data/webpack/components/common/DeleteTableEntry.js +3 -3
- data/webpack/components/common/EditTableEntry.js +50 -0
- data/webpack/components/common/ExtTextInput.js +43 -0
- data/webpack/components/common/LockTableEntry.js +60 -0
- data/webpack/components/common/__tests__/EditTableEntry.test.js +53 -0
- data/webpack/components/common/__tests__/LockTableEntry.test.js +35 -0
- data/webpack/components/common/__tests__/__snapshots__/DeleteTableEntry.test.js.snap +2 -2
- data/webpack/components/common/__tests__/__snapshots__/EditTableEntry.test.js.snap +81 -0
- data/webpack/components/common/__tests__/__snapshots__/LockTableEntry.test.js.snap +60 -0
- data/webpack/helper.js +15 -1
- data/webpack/helper.test.js +37 -0
- data/webpack/index.js +2 -0
- data/webpack/reducer.js +18 -11
- metadata +184 -10
- data/app/views/foreman_acd/app_instances/deploy.html.erb +0 -19
- data/webpack/components/common/__tests__/__snapshots__/AddParameter.test.js.snap +0 -35
- data/webpack/components/common/__tests__/__snapshots__/DeleteParameter.test.js.snap +0 -41
@@ -1,5 +1,6 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import * as sort from 'sortabular';
|
3
|
+
import { translate as __ } from 'foremanReact/common/I18n';
|
3
4
|
|
4
5
|
import {
|
5
6
|
actionHeaderCellFormatter,
|
@@ -16,18 +17,13 @@ import {
|
|
16
17
|
} from 'foremanReact/common/helpers';
|
17
18
|
|
18
19
|
import {
|
19
|
-
isNewDefinition,
|
20
|
-
isEditDefinition,
|
21
|
-
isDefinition,
|
22
|
-
isNewInstance,
|
23
|
-
isEditInstance,
|
24
|
-
isInstance,
|
25
20
|
filterUsedParameterTypes,
|
26
21
|
} from './ParameterSelectionHelper';
|
27
22
|
|
28
23
|
import {
|
29
24
|
PARAMETER_SELECTION_INIT,
|
30
25
|
PARAMETER_SELECTION_TYPES,
|
26
|
+
PARAMETER_SELECTION_LOCK,
|
31
27
|
PARAMETER_SELECTION_DELETE,
|
32
28
|
PARAMETER_SELECTION_ADD,
|
33
29
|
PARAMETER_SELECTION_EDIT_ACTIVATE,
|
@@ -35,15 +31,20 @@ import {
|
|
35
31
|
PARAMETER_SELECTION_EDIT_CHANGE,
|
36
32
|
PARAMETER_SELECTION_EDIT_CANCEL,
|
37
33
|
PARAMETER_SELECTION_SORT,
|
38
|
-
|
39
|
-
|
40
|
-
|
34
|
+
PARAMETER_SELECTION_PARAM_TYPE_FOREMAN,
|
35
|
+
PARAMETER_SELECTION_PARAM_TYPE_ANSIBLE,
|
36
|
+
PARAMETER_SELECTION_LOAD_PARAM_DATA_REQUEST,
|
37
|
+
PARAMETER_SELECTION_LOAD_PARAM_DATA_SUCCESS,
|
38
|
+
PARAMETER_SELECTION_LOAD_PARAM_DATA_FAILURE,
|
41
39
|
} from './ParameterSelectionConstants';
|
42
40
|
|
43
41
|
export const initParameterSelection = (
|
44
|
-
|
45
|
-
|
42
|
+
paramType,
|
43
|
+
paramDefinition,
|
46
44
|
parameters,
|
45
|
+
useDefaultValue,
|
46
|
+
allowNameAdjustment,
|
47
|
+
allowDescriptionAdjustment,
|
47
48
|
sortingFormatter,
|
48
49
|
sortableTransform,
|
49
50
|
inlineEditFormatter,
|
@@ -57,23 +58,28 @@ export const initParameterSelection = (
|
|
57
58
|
position: 0
|
58
59
|
}
|
59
60
|
};
|
60
|
-
initialState.
|
61
|
+
initialState.paramDefinition = paramDefinition;
|
61
62
|
|
62
|
-
let valueLabel = 'Value';
|
63
|
-
if (
|
64
|
-
valueLabel = 'Default value';
|
63
|
+
let valueLabel = __('Value');
|
64
|
+
if (useDefaultValue) {
|
65
|
+
valueLabel = __('Default value');
|
65
66
|
}
|
66
67
|
|
67
|
-
initialState.columns = [
|
68
|
-
|
68
|
+
initialState.columns = []
|
69
|
+
const addToColumns = (obj, idx) => {
|
70
|
+
obj.header.props.index = idx;
|
71
|
+
initialState.columns.push(obj);
|
72
|
+
}
|
73
|
+
|
74
|
+
let idx = 0;
|
75
|
+
addToColumns( {
|
69
76
|
property: 'name',
|
70
77
|
header: {
|
71
|
-
label: 'Name',
|
78
|
+
label: __('Name'),
|
72
79
|
props: {
|
73
|
-
index: 0,
|
74
80
|
sort: true,
|
75
81
|
style: {
|
76
|
-
width: '
|
82
|
+
width: '25%'
|
77
83
|
}
|
78
84
|
},
|
79
85
|
transforms: [sortableTransform],
|
@@ -81,18 +87,18 @@ export const initParameterSelection = (
|
|
81
87
|
customFormatters: [sortableHeaderCellFormatter]
|
82
88
|
},
|
83
89
|
cell: {
|
84
|
-
formatters: [
|
90
|
+
formatters: [allowNameAdjustment ? inlineEditFormatter : tableCellFormatter]
|
85
91
|
}
|
86
|
-
},
|
87
|
-
|
92
|
+
}, idx++);
|
93
|
+
|
94
|
+
addToColumns( {
|
88
95
|
property: 'description',
|
89
96
|
header: {
|
90
|
-
label: 'Description',
|
97
|
+
label: __('Description'),
|
91
98
|
props: {
|
92
|
-
index: 1,
|
93
99
|
sort: true,
|
94
100
|
style: {
|
95
|
-
width: '
|
101
|
+
width: '25%'
|
96
102
|
}
|
97
103
|
},
|
98
104
|
transforms: [sortableTransform],
|
@@ -103,15 +109,16 @@ export const initParameterSelection = (
|
|
103
109
|
props: {
|
104
110
|
index: 1
|
105
111
|
},
|
106
|
-
formatters: [
|
112
|
+
formatters: [allowDescriptionAdjustment ? inlineEditFormatter : tableCellFormatter]
|
107
113
|
}
|
108
|
-
},
|
109
|
-
|
114
|
+
}, idx++);
|
115
|
+
|
116
|
+
if (paramType == PARAMETER_SELECTION_PARAM_TYPE_FOREMAN) {
|
117
|
+
addToColumns( {
|
110
118
|
property: 'type',
|
111
119
|
header: {
|
112
|
-
label: 'Type',
|
120
|
+
label: __('Type'),
|
113
121
|
props: {
|
114
|
-
index: 2,
|
115
122
|
sort: true,
|
116
123
|
style: {
|
117
124
|
width: '20%'
|
@@ -126,13 +133,14 @@ export const initParameterSelection = (
|
|
126
133
|
// the well formatted type name is shown
|
127
134
|
formatters: [inlineEditFormatter]
|
128
135
|
}
|
129
|
-
},
|
130
|
-
|
136
|
+
}, idx++);
|
137
|
+
}
|
138
|
+
|
139
|
+
addToColumns( {
|
131
140
|
property: 'value',
|
132
141
|
header: {
|
133
142
|
label: valueLabel,
|
134
143
|
props: {
|
135
|
-
index: 3,
|
136
144
|
sort: true,
|
137
145
|
style: {
|
138
146
|
width: '20%'
|
@@ -145,15 +153,15 @@ export const initParameterSelection = (
|
|
145
153
|
cell: {
|
146
154
|
formatters: [inlineEditFormatter]
|
147
155
|
}
|
148
|
-
},
|
149
|
-
|
156
|
+
}, idx++);
|
157
|
+
|
158
|
+
addToColumns( {
|
150
159
|
property: 'actions',
|
151
160
|
header: {
|
152
|
-
label: 'Actions',
|
161
|
+
label: __('Actions'),
|
153
162
|
props: {
|
154
|
-
index: 4,
|
155
163
|
style: {
|
156
|
-
width: '
|
164
|
+
width: '10%'
|
157
165
|
}
|
158
166
|
},
|
159
167
|
formatters: [actionHeaderCellFormatter]
|
@@ -161,21 +169,11 @@ export const initParameterSelection = (
|
|
161
169
|
cell: {
|
162
170
|
formatters: [inlineEditButtonsFormatter]
|
163
171
|
}
|
164
|
-
}
|
165
|
-
];
|
172
|
+
}, idx++);
|
166
173
|
|
167
|
-
|
168
|
-
initialState.parameters = [];
|
169
|
-
} else if ((isEditDefinition(mode)) || (isInstance(mode))) {
|
170
|
-
initialState.parameters = parameters;
|
171
|
-
initialState.hostgroupId = serviceDefinition.hostgroup_id;
|
172
|
-
} else {
|
173
|
-
// FIXME: should never ever happen
|
174
|
-
}
|
174
|
+
initialState.parameters = parameters;
|
175
175
|
|
176
|
-
if (
|
177
|
-
initialState.parameterTypes = PARAMETER_SELECTION_TYPES;
|
178
|
-
} else {
|
176
|
+
if ((paramType == PARAMETER_SELECTION_PARAM_TYPE_FOREMAN) && (parameters)) {
|
179
177
|
initialState.parameterTypes = filterUsedParameterTypes(PARAMETER_SELECTION_TYPES, parameters);
|
180
178
|
}
|
181
179
|
|
@@ -187,12 +185,19 @@ export const initParameterSelection = (
|
|
187
185
|
|
188
186
|
const errorHandler = (msg, err) => {
|
189
187
|
const error = {
|
190
|
-
errorMsg: 'Failed to fetch data from server.',
|
188
|
+
errorMsg: __('Failed to fetch data from server.'),
|
191
189
|
statusText: err,
|
192
190
|
};
|
193
191
|
return { type: msg, payload: { error } };
|
194
192
|
};
|
195
193
|
|
194
|
+
export const lockParameter = (additionalData) => ({
|
195
|
+
type: PARAMETER_SELECTION_LOCK,
|
196
|
+
payload: {
|
197
|
+
...additionalData,
|
198
|
+
},
|
199
|
+
});
|
200
|
+
|
196
201
|
export const addParameter = (additionalData) => ({
|
197
202
|
type: PARAMETER_SELECTION_ADD,
|
198
203
|
payload: {
|
@@ -244,22 +249,23 @@ export const sortParameter = (selectedColumn, defaultSortingOrder) => ({
|
|
244
249
|
},
|
245
250
|
});
|
246
251
|
|
247
|
-
export const
|
248
|
-
|
249
|
-
additionalData,
|
250
|
-
) => dispatch => {
|
251
|
-
dispatch({ type: PARAMETER_SELECTION_LOAD_FOREMAN_DATA_REQUEST, payload: { clearParameters: additionalData.clearParameters } });
|
252
|
+
export const loadParamData = (attr) => dispatch => {
|
253
|
+
dispatch( { type: PARAMETER_SELECTION_LOAD_PARAM_DATA_REQUEST, payload: { dataType: attr.dataType, clearParameters: attr.clearParameters } });
|
252
254
|
|
253
|
-
|
255
|
+
let realUrl = attr.url.replace("__id__", attr.paramDefinition.dataId);
|
256
|
+
|
257
|
+
if (attr.paramDefinition.hasOwnProperty('dataSubId')) {
|
258
|
+
realUrl = realUrl.replace("__subid__", attr.paramDefinition.dataSubId);
|
259
|
+
}
|
254
260
|
|
255
261
|
return api
|
256
262
|
.get(realUrl, {}, {})
|
257
263
|
.then(({ data }) =>
|
258
264
|
dispatch({
|
259
|
-
type:
|
260
|
-
payload: data,
|
265
|
+
type: PARAMETER_SELECTION_LOAD_PARAM_DATA_SUCCESS,
|
266
|
+
payload: { ...data, dataType: attr.dataType }
|
261
267
|
})
|
262
268
|
)
|
263
|
-
.catch(error => dispatch(errorHandler(
|
269
|
+
.catch(error => dispatch(errorHandler(PARAMETER_SELECTION_LOAD_PARAM_DATA_FAILURE, error)));
|
264
270
|
};
|
265
271
|
|
@@ -1,4 +1,5 @@
|
|
1
1
|
export const PARAMETER_SELECTION_INIT = 'INIT_PARAMETER_SELECTION_INIT';
|
2
|
+
export const PARAMETER_SELECTION_LOCK = 'PARAMETER_SELECTION_LOCK';
|
2
3
|
export const PARAMETER_SELECTION_DELETE = 'PARAMETER_SELECTION_DELETE';
|
3
4
|
export const PARAMETER_SELECTION_ADD = 'PARAMETER_SELECTION_ADD';
|
4
5
|
export const PARAMETER_SELECTION_EDIT_ACTIVATE = 'PARAMETER_SELECTION_EDIT_ACTIVATE';
|
@@ -6,9 +7,11 @@ export const PARAMETER_SELECTION_EDIT_CONFIRM = 'PARAMETER_SELECTION_EDIT_CONFIR
|
|
6
7
|
export const PARAMETER_SELECTION_EDIT_CHANGE = 'PARAMETER_SELECTION_EDIT_CHANGE';
|
7
8
|
export const PARAMETER_SELECTION_EDIT_CANCEL = 'PARAMETER_SELECTION_EDIT_CANCEL';
|
8
9
|
export const PARAMETER_SELECTION_SORT = 'PARAMETER_SELECTION_SORT';
|
9
|
-
export const
|
10
|
-
export const
|
11
|
-
export const
|
10
|
+
export const PARAMETER_SELECTION_LOAD_PARAM_DATA_REQUEST = 'PARAMETER_SELECTION_LOAD_PARAM_DATA_REQUEST';
|
11
|
+
export const PARAMETER_SELECTION_LOAD_PARAM_DATA_SUCCESS = 'PARAMETER_SELECTION_LOAD_PARAM_DATA_SUCCESS';
|
12
|
+
export const PARAMETER_SELECTION_LOAD_PARAM_DATA_FAILURE = 'PARAMETER_SELECTION_LOAD_PARAM_DATA_FAILURE';
|
13
|
+
export const PARAMETER_SELECTION_PARAM_TYPE_FOREMAN = 'PARAMETER_SELECTION_PARAM_TYPE_FOREMAN';
|
14
|
+
export const PARAMETER_SELECTION_PARAM_TYPE_ANSIBLE = 'PARAMETER_SELECTION_PARAM_TYPE_ANSIBLE';
|
12
15
|
|
13
16
|
// Make sure the object is sorted by value
|
14
17
|
// (Compute Profile -> Partition table -> Root password)
|
@@ -2,38 +2,6 @@ import {
|
|
2
2
|
cloneDeep,
|
3
3
|
} from 'lodash';
|
4
4
|
|
5
|
-
export const isNewDefinition = (mode) => {
|
6
|
-
if (mode == "newDefinition")
|
7
|
-
return true;
|
8
|
-
return false;
|
9
|
-
}
|
10
|
-
|
11
|
-
export const isEditDefinition = (mode) => {
|
12
|
-
if (mode == "editDefinition")
|
13
|
-
return true;
|
14
|
-
return false;
|
15
|
-
}
|
16
|
-
|
17
|
-
export const isDefinition = (mode) => {
|
18
|
-
return (isNewDefinition(mode) || isEditDefinition(mode))
|
19
|
-
}
|
20
|
-
|
21
|
-
export const isNewInstance = (mode) => {
|
22
|
-
if (mode == "newInstance")
|
23
|
-
return true;
|
24
|
-
return false;
|
25
|
-
}
|
26
|
-
|
27
|
-
export const isEditInstance = (mode) => {
|
28
|
-
if (mode == "editInstance")
|
29
|
-
return true;
|
30
|
-
return false;
|
31
|
-
}
|
32
|
-
|
33
|
-
export const isInstance = (mode) => {
|
34
|
-
return (isNewInstance(mode) || isEditInstance(mode))
|
35
|
-
}
|
36
|
-
|
37
5
|
export const transformForemanData = (fdata) => {
|
38
6
|
if (fdata === undefined) {
|
39
7
|
return "";
|
@@ -15,6 +15,7 @@ import * as sort from 'sortabular';
|
|
15
15
|
import {
|
16
16
|
PARAMETER_SELECTION_INIT,
|
17
17
|
PARAMETER_SELECTION_TYPES,
|
18
|
+
PARAMETER_SELECTION_LOCK,
|
18
19
|
PARAMETER_SELECTION_DELETE,
|
19
20
|
PARAMETER_SELECTION_ADD,
|
20
21
|
PARAMETER_SELECTION_EDIT_ACTIVATE,
|
@@ -22,15 +23,13 @@ import {
|
|
22
23
|
PARAMETER_SELECTION_EDIT_CHANGE,
|
23
24
|
PARAMETER_SELECTION_EDIT_CANCEL,
|
24
25
|
PARAMETER_SELECTION_SORT,
|
25
|
-
|
26
|
-
|
27
|
-
|
26
|
+
PARAMETER_SELECTION_LOAD_PARAM_DATA_REQUEST,
|
27
|
+
PARAMETER_SELECTION_LOAD_PARAM_DATA_SUCCESS,
|
28
|
+
PARAMETER_SELECTION_LOAD_PARAM_DATA_FAILURE,
|
29
|
+
PARAMETER_SELECTION_PARAM_TYPE_FOREMAN,
|
30
|
+
PARAMETER_SELECTION_PARAM_TYPE_ANSIBLE,
|
28
31
|
} from './ParameterSelectionConstants';
|
29
32
|
|
30
|
-
import {
|
31
|
-
APPLICATION_DEFINITION_PARAMETER_SELECTION_MODAL_CLOSE,
|
32
|
-
} from '../ApplicationDefinition/ApplicationDefinitionConstants';
|
33
|
-
|
34
33
|
export const initialState = Immutable({
|
35
34
|
editMode: false,
|
36
35
|
error: { errorMsg: '', status: '', statusText: '' },
|
@@ -52,7 +51,7 @@ const parameterSelectionParameters = (state = initialState, action) => {
|
|
52
51
|
index = Math.max(...parameters.map(e => e.id)) + 1;
|
53
52
|
}
|
54
53
|
|
55
|
-
const newRow = {id: index, name: "", description: '', type: '', value: '', newEntry: true };
|
54
|
+
const newRow = {id: index, locked: false, name: "", description: '', type: '', value: '', newEntry: true };
|
56
55
|
newRow.backup = cloneDeep(newRow)
|
57
56
|
parameters.push(newRow);
|
58
57
|
|
@@ -61,6 +60,20 @@ const parameterSelectionParameters = (state = initialState, action) => {
|
|
61
60
|
parameters: parameters
|
62
61
|
});
|
63
62
|
}
|
63
|
+
case PARAMETER_SELECTION_LOCK: {
|
64
|
+
const parameters = cloneDeep(state.parameters);
|
65
|
+
const index = findIndex(parameters, { id: payload.rowData.id });
|
66
|
+
|
67
|
+
if (parameters[index].locked !== undefined) {
|
68
|
+
parameters[index].locked = !parameters[index].locked;
|
69
|
+
} else {
|
70
|
+
parameters[index].locked = true;
|
71
|
+
}
|
72
|
+
|
73
|
+
return state.merge({
|
74
|
+
parameters: parameters
|
75
|
+
});
|
76
|
+
}
|
64
77
|
case PARAMETER_SELECTION_DELETE: {
|
65
78
|
const parameters = state.parameters.filter(v => v.id !== payload.rowData.id);
|
66
79
|
return state.merge({
|
@@ -127,18 +140,26 @@ const parameterSelectionParameters = (state = initialState, action) => {
|
|
127
140
|
})
|
128
141
|
);
|
129
142
|
}
|
130
|
-
case
|
143
|
+
case PARAMETER_SELECTION_LOAD_PARAM_DATA_FAILURE: {
|
131
144
|
return state.merge({
|
132
145
|
error: payload.error,
|
133
146
|
loading: false
|
134
147
|
});
|
135
148
|
}
|
136
|
-
case
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
149
|
+
case PARAMETER_SELECTION_LOAD_PARAM_DATA_REQUEST: {
|
150
|
+
let newState = {};
|
151
|
+
|
152
|
+
if (payload.dataType == PARAMETER_SELECTION_PARAM_TYPE_FOREMAN) {
|
153
|
+
newState = {
|
154
|
+
paramData: {},
|
155
|
+
hostgroupId: -1,
|
156
|
+
loading: true
|
157
|
+
};
|
158
|
+
} else if (payload.dataType == PARAMETER_SELECTION_PARAM_TYPE_ANSIBLE) {
|
159
|
+
newState = {
|
160
|
+
loading: true
|
161
|
+
};
|
162
|
+
}
|
142
163
|
|
143
164
|
if (payload.clearParameters === true) {
|
144
165
|
Object.assign(newState, { parameters: [] });
|
@@ -146,27 +167,18 @@ const parameterSelectionParameters = (state = initialState, action) => {
|
|
146
167
|
|
147
168
|
return state.merge(newState);
|
148
169
|
}
|
149
|
-
case
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
parameters.forEach((param, index) => {
|
160
|
-
delete parameters[index].backup;
|
161
|
-
if (parameters[index].newEntry === true) {
|
162
|
-
parameters.splice(index, 1);
|
163
|
-
}
|
164
|
-
});
|
170
|
+
case PARAMETER_SELECTION_LOAD_PARAM_DATA_SUCCESS: {
|
171
|
+
let newState = {};
|
172
|
+
|
173
|
+
if (payload.dataType == PARAMETER_SELECTION_PARAM_TYPE_FOREMAN) {
|
174
|
+
newState = {
|
175
|
+
loading: false,
|
176
|
+
paramData: payload,
|
177
|
+
hostgroupId: payload.hostgroup_id,
|
178
|
+
};
|
179
|
+
}
|
165
180
|
|
166
|
-
return state.merge(
|
167
|
-
editMode: false,
|
168
|
-
parameters: parameters
|
169
|
-
});
|
181
|
+
return state.merge(newState);
|
170
182
|
}
|
171
183
|
default:
|
172
184
|
return state;
|
@@ -2,10 +2,10 @@ const parameterState = state => state.foremanAcd.parameterSelectionParameters;
|
|
2
2
|
|
3
3
|
export const selectLoading = state => parameterState(state).loading;
|
4
4
|
export const selectEditMode = state => parameterState(state).editMode;
|
5
|
-
export const
|
5
|
+
export const selectParamData = state => parameterState(state).paramData;
|
6
6
|
export const selectParameterTypes = state => parameterState(state).parameterTypes;
|
7
7
|
export const selectParameters = state => parameterState(state).parameters;
|
8
8
|
export const selectSortingColumns = state => parameterState(state).sortingColumns;
|
9
9
|
export const selectColumns = state => parameterState(state).columns;
|
10
|
-
export const
|
10
|
+
export const selectParamDefinition = state => parameterState(state).paramDefinition;
|
11
11
|
export const selectHostgroupId = state => parameterState(state).hostgroupId;
|