foreman_acd 0.4.0 → 0.9.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 +84 -84
- data/app/controllers/foreman_acd/ansible_playbooks_controller.rb +103 -11
- data/app/controllers/foreman_acd/api/v2/ansible_playbooks_controller.rb +21 -3
- data/app/controllers/foreman_acd/api/v2/app_definitions_controller.rb +1 -0
- data/app/controllers/foreman_acd/api/v2/app_instances_controller.rb +9 -1
- data/app/controllers/foreman_acd/app_definitions_controller.rb +117 -15
- data/app/controllers/foreman_acd/app_instances_controller.rb +104 -30
- data/app/controllers/foreman_acd/concerns/ansible_playbook_parameters.rb +1 -1
- data/app/controllers/foreman_acd/concerns/app_definition_parameters.rb +1 -1
- data/app/controllers/foreman_acd/concerns/app_instance_mixins.rb +36 -0
- data/app/controllers/foreman_acd/concerns/app_instance_parameters.rb +1 -1
- data/app/controllers/foreman_acd/remote_execution_controller.rb +36 -23
- data/app/controllers/ui_acd_controller.rb +46 -0
- data/app/lib/actions/foreman_acd/deploy_all_hosts.rb +47 -0
- data/app/lib/actions/foreman_acd/run_configurator.rb +45 -0
- data/app/models/concerns/foreman_acd/host_managed_extensions.rb +39 -0
- data/app/models/foreman_acd/acd_provider.rb +36 -0
- data/app/models/foreman_acd/ansible_playbook.rb +32 -14
- data/app/models/foreman_acd/app_definition.rb +24 -1
- data/app/models/foreman_acd/app_instance.rb +85 -5
- data/app/models/foreman_acd/foreman_host.rb +31 -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 +64 -36
- data/app/services/foreman_acd/app_deployer.rb +83 -48
- data/app/services/foreman_acd/inventory_creator.rb +36 -25
- data/app/views/foreman_acd/ansible_playbooks/_form.html.erb +50 -7
- data/app/views/foreman_acd/ansible_playbooks/edit.html.erb +9 -1
- data/app/views/foreman_acd/ansible_playbooks/index.html.erb +3 -3
- data/app/views/foreman_acd/api/v2/ansible_playbooks/base.json.rabl +2 -0
- data/app/views/foreman_acd/api/v2/ansible_playbooks/index.json.rabl +2 -0
- data/app/views/foreman_acd/api/v2/ansible_playbooks/show.json.rabl +6 -0
- data/app/views/foreman_acd/api/v2/app_definitions/base.json.rabl +2 -0
- data/app/views/foreman_acd/api/v2/app_definitions/index.json.rabl +2 -0
- data/app/views/foreman_acd/api/v2/app_definitions/show.json.rabl +6 -0
- data/app/views/foreman_acd/api/v2/app_instances/base.json.rabl +3 -1
- data/app/views/foreman_acd/api/v2/app_instances/index.json.rabl +2 -0
- data/app/views/foreman_acd/api/v2/app_instances/show.json.rabl +2 -0
- data/app/views/foreman_acd/app_definitions/_form.html.erb +9 -1
- data/app/views/foreman_acd/app_definitions/edit.html.erb +10 -5
- data/app/views/foreman_acd/app_definitions/import.html.erb +20 -1
- data/app/views/foreman_acd/app_definitions/index.html.erb +5 -8
- data/app/views/foreman_acd/app_instances/_form.html.erb +4 -4
- data/app/views/foreman_acd/app_instances/edit.html.erb +10 -0
- data/app/views/foreman_acd/app_instances/index.html.erb +93 -14
- data/app/views/foreman_acd/app_instances/report.html.erb +12 -4
- data/app/views/templates/job/run_acd_ansible_playbook.erb +28 -15
- data/app/views/ui_acd/app_definition.json.rabl +1 -1
- data/app/views/ui_acd/host_report.json.rabl +4 -0
- data/app/views/ui_acd/report_data.json.rabl +10 -0
- data/app/views/ui_acd/validate_hostname.json.rabl +6 -0
- data/config/routes.rb +12 -3
- data/db/migrate/20200917120220_add_ansible_playbook_id.rb +1 -1
- data/db/migrate/20201016002819_add_ansible_vars_all_to_app_definitions.rb +3 -0
- data/db/migrate/20201016104338_add_ansible_vars_all_to_app_instances.rb +3 -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/migrate/20210818125913_add_is_existing_host_to_foreman_host.rb +8 -0
- data/db/migrate/20210902110645_add_initial_configure_task.rb +8 -0
- data/db/seeds.d/62_acd_proxy_feature.rb +4 -0
- data/db/seeds.d/75-job_templates.rb +6 -1
- data/lib/foreman_acd/engine.rb +40 -3
- data/lib/foreman_acd/plugin.rb +60 -45
- data/lib/foreman_acd/version.rb +1 -1
- data/lib/foreman_acd.rb +30 -0
- 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/{app/controllers/foreman_acd/api/v2/app_playbooks_controller.rb → locale/en/foreman_acd.po.time_stamp} +0 -0
- data/locale/foreman_acd.pot +343 -8
- data/package.json +8 -8
- 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/ForemanModalActions.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 +55 -21
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionActions.js +14 -0
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionConstants.js +2 -0
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionReducer.js +48 -1
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionSelectors.js +4 -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 +26 -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 +225 -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 +2 -1
- 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 +8 -0
- data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImport.js +214 -0
- data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImport.scss +1 -0
- data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportActions.js +161 -0
- data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportConstants.js +6 -0
- data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportReducer.js +79 -0
- data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportSelectors.js +8 -0
- data/webpack/components/ApplicationDefinitionImport/__fixtures__/applicationDefinitionImportConfData_1.fixtures.js +129 -0
- data/webpack/components/ApplicationDefinitionImport/__fixtures__/applicationDefinitionImportReducer.fixtures.js +29 -0
- data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImport.test.js +20 -0
- data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImportReducer.test.js +43 -0
- data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImportSelectors.test.js +29 -0
- data/webpack/components/ApplicationDefinitionImport/__tests__/__snapshots__/ApplicationDefinitionImport.test.js.snap +62 -0
- data/webpack/components/ApplicationDefinitionImport/__tests__/__snapshots__/ApplicationDefinitionImportReducer.test.js.snap +362 -0
- data/webpack/components/ApplicationDefinitionImport/__tests__/__snapshots__/ApplicationDefinitionImportSelectors.test.js.snap +130 -0
- data/webpack/components/ApplicationDefinitionImport/index.js +32 -0
- data/webpack/components/ApplicationInstance/ApplicationInstance.js +153 -45
- data/webpack/components/ApplicationInstance/ApplicationInstanceActions.js +120 -6
- data/webpack/components/ApplicationInstance/ApplicationInstanceConstants.js +5 -0
- data/webpack/components/ApplicationInstance/ApplicationInstanceHelper.js +15 -0
- data/webpack/components/ApplicationInstance/ApplicationInstanceReducer.js +77 -22
- data/webpack/components/ApplicationInstance/ApplicationInstanceSelectors.js +4 -0
- data/webpack/components/ApplicationInstance/__fixtures__/applicationInstanceConfData_1.fixtures.js +263 -0
- data/webpack/components/ApplicationInstance/__fixtures__/applicationInstanceReducer.fixtures.js +80 -0
- data/webpack/components/ApplicationInstance/__tests__/ApplicationInstance.test.js +24 -0
- data/webpack/components/ApplicationInstance/__tests__/ApplicationInstanceReducer.test.js +131 -0
- data/webpack/components/ApplicationInstance/__tests__/ApplicationInstanceSelectors.test.js +44 -0
- data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstance.test.js.snap +299 -0
- data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstanceReducer.test.js.snap +2990 -0
- data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstanceSelectors.test.js.snap +276 -0
- data/webpack/components/ApplicationInstance/components/AppDefinitionSelector.js +1 -0
- data/webpack/components/ApplicationInstance/components/Service.js +1 -1
- data/webpack/components/ApplicationInstance/components/ServiceCounter.js +1 -1
- data/webpack/components/ApplicationInstance/helper.js +0 -0
- data/webpack/components/ApplicationInstance/index.js +8 -0
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.js +128 -60
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.scss +17 -0
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportActions.js +40 -50
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportConstants.js +5 -4
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportReducer.js +19 -14
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportSelectors.js +4 -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 +7 -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 +8 -3
- data/webpack/components/ExistingHostSelection/ExistingHostSelection.js +104 -0
- data/webpack/components/ExistingHostSelection/ExistingHostSelection.scss +15 -0
- data/webpack/components/ExistingHostSelection/ExistingHostSelectionActions.js +71 -0
- data/webpack/components/ExistingHostSelection/ExistingHostSelectionConstants.js +4 -0
- data/webpack/components/ExistingHostSelection/ExistingHostSelectionHelper.js +0 -0
- data/webpack/components/ExistingHostSelection/ExistingHostSelectionReducer.js +90 -0
- data/webpack/components/ExistingHostSelection/ExistingHostSelectionSelectors.js +8 -0
- data/webpack/components/ExistingHostSelection/__fixtures__/existingHostSelectionConfData_1.fixtures.js +191 -0
- data/webpack/components/ExistingHostSelection/__fixtures__/existingHostSelectionReducer.fixtures.js +203 -0
- data/webpack/components/ExistingHostSelection/__tests__/ExistingHostSelection.test.js +19 -0
- data/webpack/components/ExistingHostSelection/__tests__/ExistingHostSelectionReducer.test.js +59 -0
- data/webpack/components/ExistingHostSelection/__tests__/ExistingHostSelectionSelectors.test.js +36 -0
- data/webpack/components/ExistingHostSelection/__tests__/__snapshots__/ExistingHostSelection.test.js.snap +35 -0
- data/webpack/components/ExistingHostSelection/__tests__/__snapshots__/ExistingHostSelectionReducer.test.js.snap +614 -0
- data/webpack/components/ExistingHostSelection/__tests__/__snapshots__/ExistingHostSelectionSelectors.test.js.snap +27 -0
- data/webpack/components/ExistingHostSelection/components/ServiceSelector.js +48 -0
- data/webpack/components/ExistingHostSelection/components/__tests__/ServiceSelector.test.js +35 -0
- data/webpack/components/ExistingHostSelection/components/__tests__/__snapshots__/ServiceSelector.test.js.snap +77 -0
- data/webpack/components/ExistingHostSelection/index.js +26 -0
- data/webpack/components/ParameterSelection/ParameterSelection.js +138 -15
- data/webpack/components/ParameterSelection/ParameterSelection.scss +7 -0
- data/webpack/components/ParameterSelection/ParameterSelectionActions.js +52 -9
- data/webpack/components/ParameterSelection/ParameterSelectionConstants.js +3 -0
- data/webpack/components/ParameterSelection/ParameterSelectionReducer.js +62 -25
- data/webpack/components/ParameterSelection/ParameterSelectionSelectors.js +1 -0
- 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 +33 -25
- data/webpack/components/ParameterSelection/__tests__/ParameterSelectionSelectors.test.js +6 -6
- data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelection.test.js.snap +84 -112
- data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionReducer.test.js.snap +1488 -872
- data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionSelectors.test.js.snap +117 -79
- data/webpack/components/ParameterSelection/index.js +2 -1
- data/webpack/components/SyncGitRepo/SyncGitRepo.js +202 -0
- data/webpack/components/SyncGitRepo/SyncGitRepo.scss +1 -0
- data/webpack/components/SyncGitRepo/SyncGitRepoActions.js +123 -0
- data/webpack/components/SyncGitRepo/SyncGitRepoConstants.js +8 -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 +31 -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 +47 -0
- data/webpack/components/SyncGitRepo/index.js +28 -0
- data/webpack/components/common/DeleteTableEntry.js +18 -4
- 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 +40 -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 +20 -1
- data/webpack/helper.test.js +37 -0
- data/webpack/index.js +7 -0
- data/webpack/js-yaml.js +3874 -0
- data/webpack/reducer.js +16 -1
- metadata +182 -11
- data/app/views/foreman_acd/app_instances/deploy.html.erb +0 -19
- data/webpack/components/common/EasyHeaderFormatter.js +0 -18
- data/webpack/components/common/__tests__/__snapshots__/AddParameter.test.js.snap +0 -35
- data/webpack/components/common/__tests__/__snapshots__/DeleteParameter.test.js.snap +0 -41
@@ -0,0 +1,214 @@
|
|
1
|
+
import React, { useState } from 'react';
|
2
|
+
import {
|
3
|
+
cloneDeep,
|
4
|
+
} from 'lodash';
|
5
|
+
import PropTypes from 'prop-types';
|
6
|
+
import {
|
7
|
+
Icon,
|
8
|
+
Button,
|
9
|
+
MessageDialog,
|
10
|
+
} from 'patternfly-react';
|
11
|
+
import * as resolve from 'table-resolver';
|
12
|
+
import Select from 'foremanReact/components/common/forms/Select';
|
13
|
+
import CommonForm from 'foremanReact/components/common/forms/CommonForm';
|
14
|
+
import AddTableEntry from '../common/AddTableEntry';
|
15
|
+
import DeleteTableEntry from '../common/DeleteTableEntry';
|
16
|
+
import RailsData from '../common/RailsData';
|
17
|
+
import { EasyHeaderFormatter } from '../../helper';
|
18
|
+
import { translate as __ } from 'foremanReact/common/I18n';
|
19
|
+
|
20
|
+
import {
|
21
|
+
Table,
|
22
|
+
FormControl,
|
23
|
+
inlineEditFormatterFactory,
|
24
|
+
} from 'patternfly-react';
|
25
|
+
|
26
|
+
class ApplicationDefinitionImport extends React.Component {
|
27
|
+
|
28
|
+
constructor(props) {
|
29
|
+
super(props);
|
30
|
+
}
|
31
|
+
|
32
|
+
onFileChange = event => {
|
33
|
+
// Update the state
|
34
|
+
this.setState({ selectedFile: event.target.files[0] });
|
35
|
+
|
36
|
+
};
|
37
|
+
|
38
|
+
isEditing({rowData}) {
|
39
|
+
return (rowData.backup !== undefined);
|
40
|
+
}
|
41
|
+
|
42
|
+
setAnsiblePlaybookServices() {
|
43
|
+
this.setState({ansiblePlaybookServices: this.props.ansiblePlaybookServices});
|
44
|
+
}
|
45
|
+
|
46
|
+
componentDidMount() {
|
47
|
+
const {
|
48
|
+
mode,
|
49
|
+
ansiblePlaybookServices,
|
50
|
+
hostgroups, } = this.props;
|
51
|
+
|
52
|
+
const {
|
53
|
+
initApplicationDefinitionImport,
|
54
|
+
changeEditApplicationDefinitionImportService,
|
55
|
+
handleImportAnsiblePlaybook,
|
56
|
+
} = this.props;
|
57
|
+
|
58
|
+
this.headerFormatter = EasyHeaderFormatter;
|
59
|
+
|
60
|
+
const inlineEditFormatterImpl = {
|
61
|
+
renderValue: (value, additionalData) => (
|
62
|
+
<td>
|
63
|
+
<span className="static">{value}</span>
|
64
|
+
</td>
|
65
|
+
),
|
66
|
+
renderEditSelect: (value, additionalData, options) => (
|
67
|
+
<td className="editing">
|
68
|
+
<Select
|
69
|
+
value={value.toString()}
|
70
|
+
onChange={e => changeEditApplicationDefinitionImportService(e.target.value, additionalData) }
|
71
|
+
options={options}
|
72
|
+
allowClear
|
73
|
+
key="key"
|
74
|
+
/>
|
75
|
+
</td>
|
76
|
+
)
|
77
|
+
};
|
78
|
+
|
79
|
+
const inlineEditFormatter = inlineEditFormatterFactory({
|
80
|
+
isEditing: additionalData => this.isEditing(additionalData),
|
81
|
+
renderValue: (value, additionalData) => {
|
82
|
+
let prettyValue = value;
|
83
|
+
if (additionalData.property == 'hostgroup') {
|
84
|
+
prettyValue = hostgroups[value];
|
85
|
+
}
|
86
|
+
return inlineEditFormatterImpl.renderValue(prettyValue, additionalData)
|
87
|
+
},
|
88
|
+
renderEdit: (value, additionalData) => {
|
89
|
+
if (additionalData.property == 'hostgroup') {
|
90
|
+
if (additionalData.rowData) {
|
91
|
+
return inlineEditFormatterImpl.renderEditSelect(value, additionalData, hostgroups);
|
92
|
+
}
|
93
|
+
return inlineEditFormatterImpl.renderValue(hostgroups[value], additionalData)
|
94
|
+
}
|
95
|
+
return inlineEditFormatterImpl.renderValue(value, additionalData);
|
96
|
+
}
|
97
|
+
});
|
98
|
+
this.inlineEditFormatter = inlineEditFormatter;
|
99
|
+
|
100
|
+
initApplicationDefinitionImport(
|
101
|
+
ansiblePlaybookServices,
|
102
|
+
this.headerFormatter,
|
103
|
+
this.inlineEditFormatter,
|
104
|
+
);
|
105
|
+
};
|
106
|
+
|
107
|
+
render() {
|
108
|
+
const {
|
109
|
+
organization,
|
110
|
+
location,
|
111
|
+
foremanDataUrl,
|
112
|
+
mode,} = this.props;
|
113
|
+
|
114
|
+
const {
|
115
|
+
showAlertModal,
|
116
|
+
alertModalText,
|
117
|
+
alertModalTitle,
|
118
|
+
closeAlertModal,
|
119
|
+
ansiblePlaybookServices,
|
120
|
+
columns,
|
121
|
+
handleImportAnsiblePlaybook,
|
122
|
+
} = this.props;
|
123
|
+
let ansibleServices;
|
124
|
+
|
125
|
+
return (
|
126
|
+
<span>
|
127
|
+
{ansibleServices = this.setAnsiblePlaybookServices}
|
128
|
+
{ansibleServices}
|
129
|
+
<MessageDialog
|
130
|
+
show={showAlertModal}
|
131
|
+
onHide={closeAlertModal}
|
132
|
+
primaryAction={closeAlertModal}
|
133
|
+
primaryActionButtonContent={__('OK')}
|
134
|
+
primaryActionButtonBsStyle={"danger"}
|
135
|
+
icon={<Icon type="pf" name="error-circle-o" />}
|
136
|
+
title={alertModalTitle}
|
137
|
+
primaryContent={alertModalText}
|
138
|
+
/>
|
139
|
+
<div>
|
140
|
+
<CommonForm label="Application Definition file" className="custom-file-upload">
|
141
|
+
<input
|
142
|
+
type="file"
|
143
|
+
onChange={this.onFileChange}
|
144
|
+
/>
|
145
|
+
</CommonForm>
|
146
|
+
<CommonForm>
|
147
|
+
<Button
|
148
|
+
bsStyle="default"
|
149
|
+
onClick={e => handleImportAnsiblePlaybook(this.state.selectedFile, e)}
|
150
|
+
>
|
151
|
+
{__('Import')} </Button>
|
152
|
+
</CommonForm>
|
153
|
+
</div>
|
154
|
+
|
155
|
+
{(Object.keys(this.props.ansiblePlaybookServices).length > 0) ? (
|
156
|
+
<div className="form-group">
|
157
|
+
<Table.PfProvider
|
158
|
+
striped
|
159
|
+
bordered
|
160
|
+
hover
|
161
|
+
dataTable
|
162
|
+
columns={columns}
|
163
|
+
components={{
|
164
|
+
body: {
|
165
|
+
cell: cellProps => cellProps.children
|
166
|
+
}
|
167
|
+
}}
|
168
|
+
>
|
169
|
+
<Table.Header headerRows={resolve.headerRows({ columns })} />
|
170
|
+
<Table.Body
|
171
|
+
rows={this.props.ansiblePlaybookServices}
|
172
|
+
rowKey="id"
|
173
|
+
onRow={(rowData, { rowIndex }) => ({
|
174
|
+
role: 'row',
|
175
|
+
isEditing: () => this.isEditing({ rowData }),
|
176
|
+
last: rowIndex === this.props.ansiblePlaybookServices.length - 1
|
177
|
+
})}
|
178
|
+
/>
|
179
|
+
</Table.PfProvider>
|
180
|
+
</div>) : null }
|
181
|
+
<RailsData
|
182
|
+
key='applications_definition_import'
|
183
|
+
view='app_definition_import'
|
184
|
+
parameter='services'
|
185
|
+
value={JSON.stringify(this.props.ansiblePlaybookServices)}
|
186
|
+
/>
|
187
|
+
</span>
|
188
|
+
)};
|
189
|
+
}
|
190
|
+
|
191
|
+
ApplicationDefinitionImport.defaultProps = {
|
192
|
+
error: {},
|
193
|
+
showAlertModal: false,
|
194
|
+
alertModalText: '',
|
195
|
+
alertModalTitle: '',
|
196
|
+
editMode: false,
|
197
|
+
columns: [],
|
198
|
+
ansiblePlaybookServices: {},
|
199
|
+
editParamsOfRowId: null,
|
200
|
+
}
|
201
|
+
|
202
|
+
ApplicationDefinitionImport.propTypes = {
|
203
|
+
initApplicationDefinitionImport: PropTypes.func,
|
204
|
+
editMode: PropTypes.bool.isRequired,
|
205
|
+
columns: PropTypes.array,
|
206
|
+
showAlertModal: PropTypes.bool,
|
207
|
+
alertModalText: PropTypes.string,
|
208
|
+
alertModalTitle: PropTypes.string,
|
209
|
+
closeAlertModal: PropTypes.func,
|
210
|
+
handleImportAnsiblePlaybook: PropTypes.func,
|
211
|
+
changeEditApplicationDefinitionImportService: PropTypes.func,
|
212
|
+
};
|
213
|
+
|
214
|
+
export default ApplicationDefinitionImport;
|
@@ -0,0 +1 @@
|
|
1
|
+
@import '~@theforeman/vendor/scss/variables';
|
@@ -0,0 +1,161 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { API, actionTypeGenerator } from 'foremanReact/redux/API';
|
3
|
+
import { addToast } from 'foremanReact/redux/actions/toasts';
|
4
|
+
import { sprintf, translate as __ } from 'foremanReact/common/I18n';
|
5
|
+
|
6
|
+
|
7
|
+
import {
|
8
|
+
setModalOpen,
|
9
|
+
setModalClosed,
|
10
|
+
} from 'foremanReact/components/ForemanModal/ForemanModalActions';
|
11
|
+
|
12
|
+
import {
|
13
|
+
actionHeaderCellFormatter,
|
14
|
+
} from 'patternfly-react';
|
15
|
+
|
16
|
+
import {
|
17
|
+
propsToSnakeCase,
|
18
|
+
propsToCamelCase,
|
19
|
+
} from 'foremanReact/common/helpers';
|
20
|
+
|
21
|
+
import {
|
22
|
+
APPLICATION_DEFINITION_IMPORT_INIT,
|
23
|
+
APPLICATION_DEFINITION_IMPORT_CLOSE_ALERT_MODAL,
|
24
|
+
APPLICATION_DEFINITION_IMPORT_SERVICE_EDIT_CHANGE,
|
25
|
+
APPLICATION_DEFINITION_IMPORT_FILE_REQUEST,
|
26
|
+
APPLICATION_DEFINITION_IMPORT_FILE_SUCCESS,
|
27
|
+
APPLICATION_DEFINITION_IMPORT_FILE_FAILURE,
|
28
|
+
} from './ApplicationDefinitionImportConstants';
|
29
|
+
|
30
|
+
|
31
|
+
export const initApplicationDefinitionImport = (
|
32
|
+
ansiblePlaybookServices,
|
33
|
+
headerFormatter,
|
34
|
+
inlineEditFormatter,
|
35
|
+
) => dispatch => {
|
36
|
+
const initialState = {};
|
37
|
+
|
38
|
+
initialState.columns = [
|
39
|
+
{
|
40
|
+
property: 'name',
|
41
|
+
header: {
|
42
|
+
label: 'Service name',
|
43
|
+
formatters: [headerFormatter],
|
44
|
+
props: {
|
45
|
+
index: 0,
|
46
|
+
style: {
|
47
|
+
width: '20%'
|
48
|
+
}
|
49
|
+
},
|
50
|
+
},
|
51
|
+
cell: {
|
52
|
+
props: {
|
53
|
+
index: 0,
|
54
|
+
},
|
55
|
+
formatters: [inlineEditFormatter]
|
56
|
+
}
|
57
|
+
},
|
58
|
+
{
|
59
|
+
property: 'hostgroup',
|
60
|
+
header: {
|
61
|
+
label: 'Hostgroup',
|
62
|
+
formatters: [headerFormatter],
|
63
|
+
props: {
|
64
|
+
index: 1,
|
65
|
+
style: {
|
66
|
+
width: '20%'
|
67
|
+
}
|
68
|
+
},
|
69
|
+
},
|
70
|
+
cell: {
|
71
|
+
props: {
|
72
|
+
index: 1,
|
73
|
+
},
|
74
|
+
formatters: [inlineEditFormatter]
|
75
|
+
}
|
76
|
+
}
|
77
|
+
];
|
78
|
+
|
79
|
+
initialState.ansiblePlaybookServices = ansiblePlaybookServices;
|
80
|
+
|
81
|
+
dispatch({
|
82
|
+
type: APPLICATION_DEFINITION_IMPORT_INIT,
|
83
|
+
payload: initialState,
|
84
|
+
});
|
85
|
+
};
|
86
|
+
|
87
|
+
|
88
|
+
const errorHandler = (msg, err) => {
|
89
|
+
const error = {
|
90
|
+
errorMsg: __('Failed to fetch data from server.'),
|
91
|
+
statusText: err,
|
92
|
+
};
|
93
|
+
return { type: msg, payload: { error } };
|
94
|
+
};
|
95
|
+
|
96
|
+
export const closeAlertModal = () => ({
|
97
|
+
type: APPLICATION_DEFINITION_IMPORT_CLOSE_ALERT_MODAL,
|
98
|
+
payload: {}
|
99
|
+
});
|
100
|
+
|
101
|
+
export const changeEditApplicationDefinitionImportService = (value, additionalData) => ({
|
102
|
+
type: APPLICATION_DEFINITION_IMPORT_SERVICE_EDIT_CHANGE,
|
103
|
+
payload: {
|
104
|
+
value,
|
105
|
+
...additionalData,
|
106
|
+
},
|
107
|
+
});
|
108
|
+
|
109
|
+
|
110
|
+
export const handleImportAnsiblePlaybook = (
|
111
|
+
file, e,) => async dispatch => {
|
112
|
+
e.preventDefault();
|
113
|
+
dispatch({
|
114
|
+
type: APPLICATION_DEFINITION_IMPORT_FILE_REQUEST,
|
115
|
+
payload: {
|
116
|
+
app_definition_file: file,
|
117
|
+
}});
|
118
|
+
try {
|
119
|
+
const formData = new FormData();
|
120
|
+
|
121
|
+
// Update the formData object
|
122
|
+
formData.append(
|
123
|
+
"app_definition_file",
|
124
|
+
file,
|
125
|
+
file.name
|
126
|
+
);
|
127
|
+
const { data } = await API.post(
|
128
|
+
'/acd/app_definitions/handle_file_upload', formData);
|
129
|
+
dispatch(
|
130
|
+
addToast({
|
131
|
+
type: 'success',
|
132
|
+
message: sprintf(
|
133
|
+
__('Sucessfully synced imported app template')
|
134
|
+
),
|
135
|
+
key: APPLICATION_DEFINITION_IMPORT_FILE_SUCCESS,
|
136
|
+
})
|
137
|
+
);
|
138
|
+
return dispatch({
|
139
|
+
type: APPLICATION_DEFINITION_IMPORT_FILE_SUCCESS,
|
140
|
+
payload: {
|
141
|
+
ansiblePlaybookServices: data,
|
142
|
+
},
|
143
|
+
response: data,
|
144
|
+
});
|
145
|
+
} catch (error) {
|
146
|
+
dispatch(
|
147
|
+
addToast({
|
148
|
+
type: 'error',
|
149
|
+
message: sprintf(__('Error occurred while importing app template: %s'), error.response.data.message),
|
150
|
+
key: APPLICATION_DEFINITION_IMPORT_FILE_FAILURE,
|
151
|
+
})
|
152
|
+
);
|
153
|
+
return dispatch({
|
154
|
+
type: APPLICATION_DEFINITION_IMPORT_FILE_FAILURE,
|
155
|
+
payload: {
|
156
|
+
error: error,
|
157
|
+
},
|
158
|
+
response: error,
|
159
|
+
});
|
160
|
+
}
|
161
|
+
};
|
@@ -0,0 +1,6 @@
|
|
1
|
+
export const APPLICATION_DEFINITION_IMPORT_INIT = 'INIT_APPLICATION_DEFINITION_IMPORT_INIT';
|
2
|
+
export const APPLICATION_DEFINITION_IMPORT_SERVICE_EDIT_CHANGE = 'APPLICATION_DEFINITION_IMPORT_SERVICE_EDIT_CHANGE';
|
3
|
+
export const APPLICATION_DEFINITION_IMPORT_FILE_FAILURE = 'APPLICATION_DEFINITION_IMPORT_FILE_FAILURE';
|
4
|
+
export const APPLICATION_DEFINITION_IMPORT_FILE_REQUEST = 'APPLICATION_DEFINITION_IMPORT_FILE_REQUEST';
|
5
|
+
export const APPLICATION_DEFINITION_IMPORT_FILE_SUCCESS = 'APPLICATION_DEFINITION_IMPORT_FILE_SUCCESS';
|
6
|
+
export const APPLICATION_DEFINITION_IMPORT_CLOSE_ALERT_MODAL = 'APPLICATION_DEFINITION_IMPORT_CLOSE_ALERT_MODAL';
|
@@ -0,0 +1,79 @@
|
|
1
|
+
import Immutable from 'seamless-immutable';
|
2
|
+
|
3
|
+
import {
|
4
|
+
cloneDeep,
|
5
|
+
findIndex,
|
6
|
+
findLastIndex,
|
7
|
+
} from 'lodash';
|
8
|
+
|
9
|
+
import { translate as __ } from 'foremanReact/common/I18n';
|
10
|
+
|
11
|
+
import {
|
12
|
+
APPLICATION_DEFINITION_IMPORT_INIT,
|
13
|
+
APPLICATION_DEFINITION_IMPORT_SERVICE_EDIT_CHANGE,
|
14
|
+
APPLICATION_DEFINITION_IMPORT_FILE_FAILURE,
|
15
|
+
APPLICATION_DEFINITION_IMPORT_FILE_REQUEST,
|
16
|
+
APPLICATION_DEFINITION_IMPORT_FILE_SUCCESS,
|
17
|
+
APPLICATION_DEFINITION_IMPORT_CLOSE_ALERT_MODAL,
|
18
|
+
} from './ApplicationDefinitionImportConstants';
|
19
|
+
|
20
|
+
export const initialState = Immutable({
|
21
|
+
name: false,
|
22
|
+
error: { errorMsg: '', status: '', statusText: '' },
|
23
|
+
});
|
24
|
+
|
25
|
+
const applicationDefinitionImportConf = (state = initialState, action) => {
|
26
|
+
const { payload } = action;
|
27
|
+
|
28
|
+
switch (action.type) {
|
29
|
+
case APPLICATION_DEFINITION_IMPORT_INIT: {
|
30
|
+
return state.merge(payload);
|
31
|
+
}
|
32
|
+
|
33
|
+
case APPLICATION_DEFINITION_IMPORT_CLOSE_ALERT_MODAL: {
|
34
|
+
return state.merge({
|
35
|
+
showAlertModal: false,
|
36
|
+
alertModalTitle: '',
|
37
|
+
alertModalText: '',
|
38
|
+
});
|
39
|
+
}
|
40
|
+
|
41
|
+
case APPLICATION_DEFINITION_IMPORT_SERVICE_EDIT_CHANGE: {
|
42
|
+
const services = cloneDeep(state.ansiblePlaybookServices);
|
43
|
+
const index = findIndex(services, { id: payload.rowData.id });
|
44
|
+
|
45
|
+
services[index][payload.property] = payload.value;
|
46
|
+
|
47
|
+
return state.set('ansiblePlaybookServices', services);
|
48
|
+
}
|
49
|
+
|
50
|
+
case APPLICATION_DEFINITION_IMPORT_FILE_FAILURE: {
|
51
|
+
return state.merge({ error: payload.error, loading: false });
|
52
|
+
}
|
53
|
+
case APPLICATION_DEFINITION_IMPORT_FILE_REQUEST: {
|
54
|
+
return state.set('loading', true);
|
55
|
+
}
|
56
|
+
case APPLICATION_DEFINITION_IMPORT_FILE_SUCCESS: {
|
57
|
+
let newState = {};
|
58
|
+
let ansibleServices = [];
|
59
|
+
const ansiblePlaybookServices = payload.ansiblePlaybookServices['ansible_services'];
|
60
|
+
|
61
|
+
for (var ind in ansiblePlaybookServices) {
|
62
|
+
const value = ansiblePlaybookServices[ind];
|
63
|
+
const newRow = { id: value['id'], name: value['value'], hostgroup: '' };
|
64
|
+
newRow.backup = cloneDeep(newRow);
|
65
|
+
ansibleServices.push(newRow);
|
66
|
+
}
|
67
|
+
|
68
|
+
newState = {
|
69
|
+
ansiblePlaybookServices: ansibleServices,
|
70
|
+
};
|
71
|
+
|
72
|
+
return state.merge(newState);
|
73
|
+
}
|
74
|
+
default:
|
75
|
+
return state;
|
76
|
+
}
|
77
|
+
};
|
78
|
+
|
79
|
+
export default applicationDefinitionImportConf;
|
@@ -0,0 +1,8 @@
|
|
1
|
+
const applicationDefinitionImportConf = state => state.foremanAcd.applicationDefinitionImportConf;
|
2
|
+
|
3
|
+
export const selectEditMode = state => applicationDefinitionImportConf(state).editMode;
|
4
|
+
export const selectColumns = state => applicationDefinitionImportConf(state).columns;
|
5
|
+
export const selectAnsiblePlaybookServices = state => applicationDefinitionImportConf(state).ansiblePlaybookServices;
|
6
|
+
export const selectShowAlertModal = state => applicationDefinitionImportConf(state).showAlertModal;
|
7
|
+
export const selectAlertModalText = state => applicationDefinitionImportConf(state).alertModalText;
|
8
|
+
export const selectAlertModalTitle = state => applicationDefinitionImportConf(state).alertModalTitle;
|
@@ -0,0 +1,129 @@
|
|
1
|
+
export const applicationDefinitionImportConfData_1 = {
|
2
|
+
name: false,
|
3
|
+
error: {
|
4
|
+
errorMsg: '',
|
5
|
+
status: '',
|
6
|
+
statusText: ''
|
7
|
+
},
|
8
|
+
columns: [
|
9
|
+
{
|
10
|
+
property: 'name',
|
11
|
+
header: {
|
12
|
+
label: 'Service name',
|
13
|
+
formatters: [
|
14
|
+
null
|
15
|
+
],
|
16
|
+
props: {
|
17
|
+
index: 3,
|
18
|
+
style: {
|
19
|
+
width: '20%'
|
20
|
+
}
|
21
|
+
}
|
22
|
+
},
|
23
|
+
cell: {
|
24
|
+
formatters: [
|
25
|
+
null
|
26
|
+
]
|
27
|
+
}
|
28
|
+
},
|
29
|
+
{
|
30
|
+
property: 'hostgroup',
|
31
|
+
header: {
|
32
|
+
label: 'Hostgroup',
|
33
|
+
formatters: [
|
34
|
+
null
|
35
|
+
],
|
36
|
+
props: {
|
37
|
+
index: 2,
|
38
|
+
style: {
|
39
|
+
width: '20%'
|
40
|
+
}
|
41
|
+
}
|
42
|
+
},
|
43
|
+
cell: {
|
44
|
+
formatters: [
|
45
|
+
null
|
46
|
+
]
|
47
|
+
}
|
48
|
+
}
|
49
|
+
],
|
50
|
+
ansiblePlaybookServices: [
|
51
|
+
{
|
52
|
+
id: 1,
|
53
|
+
name: 'web',
|
54
|
+
description: '',
|
55
|
+
hostgroup: '1',
|
56
|
+
ansibleGroup: 'webservers',
|
57
|
+
minCount: '2',
|
58
|
+
maxCount: '',
|
59
|
+
foremanParameters: [
|
60
|
+
{
|
61
|
+
id: 1,
|
62
|
+
locked: false,
|
63
|
+
name: 'CP',
|
64
|
+
description: '',
|
65
|
+
type: 'computeprofile',
|
66
|
+
value: '1'
|
67
|
+
},
|
68
|
+
{
|
69
|
+
id: 2,
|
70
|
+
locked: true,
|
71
|
+
name: 'LE',
|
72
|
+
description: '',
|
73
|
+
type: 'lifecycleenv',
|
74
|
+
value: '1'
|
75
|
+
}
|
76
|
+
],
|
77
|
+
ansibleParameters: [
|
78
|
+
{
|
79
|
+
id: 0,
|
80
|
+
name: 'dummy_var',
|
81
|
+
value: '0'
|
82
|
+
}
|
83
|
+
]
|
84
|
+
},
|
85
|
+
{
|
86
|
+
id: 2,
|
87
|
+
name: 'db',
|
88
|
+
description: '',
|
89
|
+
hostgroup: '1',
|
90
|
+
ansibleGroup: 'dbservers',
|
91
|
+
minCount: '1',
|
92
|
+
maxCount: '',
|
93
|
+
foremanParameters: [],
|
94
|
+
ansibleParameters: [
|
95
|
+
{
|
96
|
+
id: 0,
|
97
|
+
name: 'mysqlservice',
|
98
|
+
value: 'mysqld'
|
99
|
+
},
|
100
|
+
{
|
101
|
+
id: 1,
|
102
|
+
name: 'mysql_port',
|
103
|
+
value: '3306',
|
104
|
+
locked: true
|
105
|
+
},
|
106
|
+
{
|
107
|
+
id: 2,
|
108
|
+
name: 'dbuser',
|
109
|
+
value: 'webapp'
|
110
|
+
},
|
111
|
+
{
|
112
|
+
id: 3,
|
113
|
+
name: 'dbname',
|
114
|
+
value: 'ANSAP01'
|
115
|
+
},
|
116
|
+
{
|
117
|
+
id: 4,
|
118
|
+
name: 'upassword',
|
119
|
+
value: 'Bond@007'
|
120
|
+
},
|
121
|
+
{
|
122
|
+
id: 5,
|
123
|
+
name: 'masterpassword',
|
124
|
+
value: 'MySQL@007'
|
125
|
+
}
|
126
|
+
]
|
127
|
+
}
|
128
|
+
]
|
129
|
+
}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
import Immutable from 'seamless-immutable';
|
2
|
+
import {
|
3
|
+
cloneDeep,
|
4
|
+
findIndex,
|
5
|
+
findLastIndex,
|
6
|
+
} from 'lodash';
|
7
|
+
|
8
|
+
import {
|
9
|
+
applicationDefinitionImportConfData_1,
|
10
|
+
} from '../__fixtures__/applicationDefinitionImportConfData_1.fixtures';
|
11
|
+
|
12
|
+
export const successState = Immutable(applicationDefinitionImportConfData_1);
|
13
|
+
|
14
|
+
const EDIT_ROW_ID = 2;
|
15
|
+
|
16
|
+
const editClone = applicationDefinitionImportConfData_1;
|
17
|
+
const editIndex = findIndex(editClone.ansiblePlaybookServices, { id: EDIT_ROW_ID })
|
18
|
+
editClone["ansiblePlaybookServices"][editIndex].backup = cloneDeep(editClone["ansiblePlaybookServices"][editIndex]);
|
19
|
+
export const editState = Immutable(editClone);
|
20
|
+
|
21
|
+
// Payload Data
|
22
|
+
export const initApplicationDefinitionImportPayload = applicationDefinitionImportConfData_1;
|
23
|
+
export const changeEditServicePayload = {
|
24
|
+
value: "helloworld",
|
25
|
+
property: "name",
|
26
|
+
rowData: {
|
27
|
+
id: EDIT_ROW_ID,
|
28
|
+
}
|
29
|
+
};
|
data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImport.test.js
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
import { testComponentSnapshotsWithFixtures } from 'react-redux-test-utils';
|
2
|
+
|
3
|
+
import ApplicationDefinitionImport from '../ApplicationDefinitionImport';
|
4
|
+
|
5
|
+
const noop = () => {};
|
6
|
+
|
7
|
+
const fixtures = {
|
8
|
+
'should render application definition import': {
|
9
|
+
location: "Default Location",
|
10
|
+
organization: "Default Organization",
|
11
|
+
hostgroups: [],
|
12
|
+
ansiblePlaybookServices: [],
|
13
|
+
initApplicationDefinitionImport: noop,
|
14
|
+
addApplicationDefinitionImportService: noop,
|
15
|
+
closeAlertModal: noop,
|
16
|
+
},
|
17
|
+
};
|
18
|
+
|
19
|
+
describe('ApplicationDefinitionImport', () =>
|
20
|
+
testComponentSnapshotsWithFixtures(ApplicationDefinitionImport, fixtures));
|
@@ -0,0 +1,43 @@
|
|
1
|
+
import { testReducerSnapshotWithFixtures } from 'react-redux-test-utils';
|
2
|
+
import reducer, { initialState } from '../ApplicationDefinitionImportReducer';
|
3
|
+
|
4
|
+
import {
|
5
|
+
successState,
|
6
|
+
editState,
|
7
|
+
initApplicationDefinitionImportPayload,
|
8
|
+
changeEditServicePayload,
|
9
|
+
} from '../__fixtures__/applicationDefinitionImportReducer.fixtures';
|
10
|
+
|
11
|
+
import {
|
12
|
+
APPLICATION_DEFINITION_IMPORT_INIT,
|
13
|
+
APPLICATION_DEFINITION_IMPORT_SERVICE_EDIT_CHANGE,
|
14
|
+
APPLICATION_DEFINITION_IMPORT_SERVICE_EDIT_CANCEL,
|
15
|
+
} from '../ApplicationDefinitionImportConstants';
|
16
|
+
|
17
|
+
const fixtures = {
|
18
|
+
'should return initial state': {
|
19
|
+
state: initialState,
|
20
|
+
action: {
|
21
|
+
type: undefined,
|
22
|
+
payload: {},
|
23
|
+
},
|
24
|
+
},
|
25
|
+
|
26
|
+
'should initialize component': {
|
27
|
+
state: initialState,
|
28
|
+
action: {
|
29
|
+
type: APPLICATION_DEFINITION_IMPORT_INIT,
|
30
|
+
payload: initApplicationDefinitionImportPayload,
|
31
|
+
},
|
32
|
+
},
|
33
|
+
'should change edit service': {
|
34
|
+
state: editState,
|
35
|
+
action: {
|
36
|
+
type: APPLICATION_DEFINITION_IMPORT_SERVICE_EDIT_CHANGE,
|
37
|
+
payload: changeEditServicePayload,
|
38
|
+
},
|
39
|
+
},
|
40
|
+
};
|
41
|
+
|
42
|
+
describe('ApplicationDefinitionImportReducer', () =>
|
43
|
+
testReducerSnapshotWithFixtures(reducer, fixtures));
|