foreman_acd 0.0.3 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/foreman_acd/ansible_playbooks_controller.rb +122 -0
- data/app/controllers/foreman_acd/api/v2/ansible_playbooks_controller.rb +54 -0
- data/app/controllers/foreman_acd/api/v2/app_definitions_controller.rb +1 -2
- data/app/controllers/foreman_acd/api/v2/app_instances_controller.rb +54 -0
- data/app/controllers/foreman_acd/api/v2/app_playbooks_controller.rb +0 -0
- data/app/controllers/foreman_acd/app_definitions_controller.rb +35 -4
- data/app/controllers/foreman_acd/app_instances_controller.rb +43 -87
- data/app/controllers/foreman_acd/concerns/ansible_playbook_parameters.rb +23 -0
- data/app/controllers/foreman_acd/concerns/app_definition_parameters.rb +1 -1
- data/app/controllers/foreman_acd/concerns/app_instance_parameters.rb +1 -1
- data/app/controllers/ui_acd_controller.rb +11 -4
- data/app/models/foreman_acd/ansible_playbook.rb +50 -0
- data/app/models/foreman_acd/app_definition.rb +2 -1
- data/app/models/foreman_acd/app_instance.rb +7 -0
- data/app/services/foreman_acd/app_configurator.rb +70 -0
- data/app/services/foreman_acd/app_deployer.rb +143 -0
- data/app/services/foreman_acd/inventory_creator.rb +67 -0
- data/app/views/foreman_acd/ansible_playbooks/_form.html.erb +21 -0
- data/app/views/foreman_acd/ansible_playbooks/edit.html.erb +3 -0
- data/app/views/foreman_acd/ansible_playbooks/index.html.erb +30 -0
- data/app/views/foreman_acd/ansible_playbooks/new.html.erb +3 -0
- data/app/views/foreman_acd/api/v2/ansible_playbooks/base.json.rabl +3 -0
- data/app/views/foreman_acd/api/v2/ansible_playbooks/index.json.rabl +3 -0
- data/app/views/foreman_acd/api/v2/ansible_playbooks/show.json.rabl +3 -0
- data/app/views/foreman_acd/api/v2/app_definitions/base.json.rabl +3 -0
- data/app/views/foreman_acd/api/v2/app_definitions/index.json.rabl +3 -0
- data/app/views/foreman_acd/api/v2/app_definitions/show.json.rabl +3 -0
- data/app/views/foreman_acd/api/v2/app_instances/base.json.rabl +3 -0
- data/app/views/foreman_acd/api/v2/app_instances/index.json.rabl +3 -0
- data/app/views/foreman_acd/api/v2/app_instances/show.json.rabl +3 -0
- data/app/views/foreman_acd/app_definitions/_form.html.erb +25 -19
- data/app/views/foreman_acd/app_definitions/edit.html.erb +5 -0
- data/app/views/foreman_acd/app_definitions/import.html.erb +18 -0
- data/app/views/foreman_acd/app_definitions/index.html.erb +9 -5
- data/app/views/foreman_acd/app_instances/_form.html.erb +10 -8
- data/app/views/foreman_acd/app_instances/deploy.html.erb +19 -0
- data/app/views/foreman_acd/app_instances/index.html.erb +10 -5
- data/app/views/foreman_acd/app_instances/report.html.erb +19 -0
- data/app/views/templates/job/run_acd_ansible_playbook.erb +49 -0
- data/app/views/ui_acd/ansible_data.json.rabl +6 -0
- data/app/views/ui_acd/app.json.rabl +6 -2
- data/app/views/ui_acd/app_definition.json.rabl +1 -1
- data/app/views/ui_acd/{fdata.json.rabl → foreman_data.json.rabl} +1 -1
- data/config/routes.rb +31 -1
- data/db/migrate/20190610202252_create_app_definitions.rb +1 -3
- data/db/migrate/20190625140305_create_app_instances.rb +1 -1
- data/db/migrate/20200916091018_create_ansible_playbooks.rb +20 -0
- data/db/migrate/20200917120220_add_ansible_playbook_id.rb +14 -0
- data/db/migrate/20201016002819_add_ansible_vars_all_to_app_definitions.rb +5 -0
- data/db/migrate/20201016104338_add_ansible_vars_all_to_app_instances.rb +5 -0
- data/db/seeds.d/75-job_templates.rb +8 -0
- data/lib/foreman_acd/engine.rb +3 -0
- data/lib/foreman_acd/plugin.rb +72 -4
- data/lib/foreman_acd/version.rb +1 -1
- data/package.json +2 -1
- data/webpack/components/ApplicationDefinition/ApplicationDefinition.js +376 -0
- data/webpack/components/ApplicationDefinition/ApplicationDefinition.scss +1 -0
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionActions.js +295 -0
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionConstants.js +14 -0
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionHelper.js +26 -0
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionReducer.js +243 -0
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionSelectors.js +8 -0
- data/webpack/components/ApplicationDefinition/components/AnsiblePlaybookSelector.js +49 -0
- data/webpack/components/ApplicationDefinition/index.js +33 -0
- data/webpack/components/ApplicationInstance/ApplicationInstance.js +412 -0
- data/webpack/components/ApplicationInstance/ApplicationInstance.scss +11 -0
- data/webpack/components/ApplicationInstance/ApplicationInstanceActions.js +239 -0
- data/webpack/components/ApplicationInstance/ApplicationInstanceConstants.js +14 -0
- data/webpack/components/ApplicationInstance/ApplicationInstanceReducer.js +295 -0
- data/webpack/components/ApplicationInstance/ApplicationInstanceSelectors.js +9 -0
- data/webpack/components/ApplicationInstance/components/AppDefinitionSelector.js +49 -0
- data/webpack/components/ApplicationInstance/components/Service.js +30 -0
- data/webpack/components/ApplicationInstance/components/ServiceCounter.js +37 -0
- data/webpack/components/ApplicationInstance/index.js +35 -0
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.js +155 -0
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.scss +27 -0
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportActions.js +86 -0
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportConstants.js +4 -0
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportReducer.js +52 -0
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportSelectors.js +5 -0
- data/webpack/components/ApplicationInstanceReport/components/ReportViewer.js +26 -0
- data/webpack/components/ApplicationInstanceReport/index.js +27 -0
- data/webpack/components/ParameterSelection/ParameterSelection.js +96 -183
- data/webpack/components/ParameterSelection/ParameterSelection.scss +10 -3
- data/webpack/components/ParameterSelection/ParameterSelectionActions.js +72 -104
- data/webpack/components/ParameterSelection/ParameterSelectionConstants.js +14 -19
- data/webpack/components/ParameterSelection/ParameterSelectionHelper.js +3 -35
- data/webpack/components/ParameterSelection/ParameterSelectionReducer.js +100 -83
- data/webpack/components/ParameterSelection/ParameterSelectionSelectors.js +3 -7
- data/webpack/components/ParameterSelection/__fixtures__/parameterSelection.fixtures.js +12 -21
- data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionData_1.fixtures.js +1 -1
- data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionReducer.fixtures.js +3 -45
- data/webpack/components/ParameterSelection/__tests__/ParameterSelection.test.js +20 -0
- data/webpack/components/ParameterSelection/__tests__/ParameterSelectionReducer.test.js +22 -46
- data/webpack/components/ParameterSelection/__tests__/ParameterSelectionSelectors.test.js +6 -6
- data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelection.test.js.snap +40 -265
- data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionReducer.test.js.snap +11 -96
- data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionSelectors.test.js.snap +3 -9
- data/webpack/components/ParameterSelection/index.js +6 -8
- data/webpack/components/common/AddTableEntry.js +30 -0
- data/webpack/components/common/DeleteTableEntry.js +39 -0
- data/webpack/components/common/ExtSelect.js +43 -0
- data/webpack/components/common/RailsData.js +27 -0
- data/webpack/components/common/__tests__/AddTableEntry.test.js +26 -0
- data/webpack/components/common/__tests__/DeleteTableEntry.test.js +29 -0
- data/webpack/components/common/__tests__/ExtSelect.test.js +38 -0
- data/webpack/components/common/__tests__/RailsData.test.js +16 -0
- data/webpack/components/common/__tests__/__snapshots__/AddParameter.test.js.snap +35 -0
- data/webpack/components/common/__tests__/__snapshots__/AddTableEntry.test.js.snap +35 -0
- data/webpack/components/common/__tests__/__snapshots__/DeleteParameter.test.js.snap +41 -0
- data/webpack/components/common/__tests__/__snapshots__/DeleteTableEntry.test.js.snap +41 -0
- data/webpack/components/common/__tests__/__snapshots__/ExtSelect.test.js.snap +18 -0
- data/webpack/components/common/__tests__/__snapshots__/RailsData.test.js.snap +10 -0
- data/webpack/helper.js +20 -0
- data/webpack/index.js +6 -0
- data/webpack/reducer.js +43 -3
- metadata +85 -39
@@ -130,7 +130,7 @@ Object {
|
|
130
130
|
"hostparam": "Host parameter",
|
131
131
|
"lifecycleenv": "Lifecycle environment",
|
132
132
|
},
|
133
|
-
"
|
133
|
+
"parameters": Array [
|
134
134
|
Object {
|
135
135
|
"description": "",
|
136
136
|
"id": 1,
|
@@ -334,7 +334,7 @@ Object {
|
|
334
334
|
"hostparam": "Host parameter",
|
335
335
|
"lifecycleenv": "Lifecycle environment",
|
336
336
|
},
|
337
|
-
"
|
337
|
+
"parameters": Array [
|
338
338
|
Object {
|
339
339
|
"description": "",
|
340
340
|
"id": 1,
|
@@ -547,7 +547,7 @@ Object {
|
|
547
547
|
"hostparam": "Host parameter",
|
548
548
|
"lifecycleenv": "Lifecycle environment",
|
549
549
|
},
|
550
|
-
"
|
550
|
+
"parameters": Array [
|
551
551
|
Object {
|
552
552
|
"description": "",
|
553
553
|
"id": 1,
|
@@ -744,7 +744,7 @@ Object {
|
|
744
744
|
"hostparam": "Host parameter",
|
745
745
|
"lifecycleenv": "Lifecycle environment",
|
746
746
|
},
|
747
|
-
"
|
747
|
+
"parameters": Array [
|
748
748
|
Object {
|
749
749
|
"description": "",
|
750
750
|
"id": 1,
|
@@ -948,7 +948,7 @@ Object {
|
|
948
948
|
"hostparam": "Host parameter",
|
949
949
|
"lifecycleenv": "Lifecycle environment",
|
950
950
|
},
|
951
|
-
"
|
951
|
+
"parameters": Array [
|
952
952
|
Object {
|
953
953
|
"description": "",
|
954
954
|
"id": 1,
|
@@ -1142,11 +1142,10 @@ Object {
|
|
1142
1142
|
"parameterTypes": Object {
|
1143
1143
|
"computeprofile": "Compute profile",
|
1144
1144
|
"domain": "Domain",
|
1145
|
-
"hostname": "Hostname",
|
1146
1145
|
"hostparam": "Host parameter",
|
1147
1146
|
"lifecycleenv": "Lifecycle environment",
|
1148
1147
|
},
|
1149
|
-
"
|
1148
|
+
"parameters": Array [
|
1150
1149
|
Object {
|
1151
1150
|
"description": "",
|
1152
1151
|
"id": 1,
|
@@ -1336,7 +1335,7 @@ Object {
|
|
1336
1335
|
"hostparam": "Host parameter",
|
1337
1336
|
"lifecycleenv": "Lifecycle environment",
|
1338
1337
|
},
|
1339
|
-
"
|
1338
|
+
"parameters": Array [
|
1340
1339
|
Object {
|
1341
1340
|
"description": "",
|
1342
1341
|
"id": 1,
|
@@ -1536,7 +1535,7 @@ Object {
|
|
1536
1535
|
"hostparam": "Host parameter",
|
1537
1536
|
"lifecycleenv": "Lifecycle environment",
|
1538
1537
|
},
|
1539
|
-
"
|
1538
|
+
"parameters": Array [
|
1540
1539
|
Object {
|
1541
1540
|
"description": "",
|
1542
1541
|
"id": 1,
|
@@ -1733,7 +1732,7 @@ Object {
|
|
1733
1732
|
"hostparam": "Host parameter",
|
1734
1733
|
"lifecycleenv": "Lifecycle environment",
|
1735
1734
|
},
|
1736
|
-
"
|
1735
|
+
"parameters": Array [
|
1737
1736
|
Object {
|
1738
1737
|
"description": "",
|
1739
1738
|
"id": 1,
|
@@ -1800,78 +1799,6 @@ Object {
|
|
1800
1799
|
}
|
1801
1800
|
`;
|
1802
1801
|
|
1803
|
-
exports[`ParameterSelectionReducer should load parameter selection be erroneous 1`] = `
|
1804
|
-
Object {
|
1805
|
-
"editMode": false,
|
1806
|
-
"error": "Something really bad happend",
|
1807
|
-
"loading": false,
|
1808
|
-
}
|
1809
|
-
`;
|
1810
|
-
|
1811
|
-
exports[`ParameterSelectionReducer should load parameter selection be successful 1`] = `
|
1812
|
-
Object {
|
1813
|
-
"appDefinition": Object {
|
1814
|
-
"created_at": "2019-11-13 17:47:27 +0100",
|
1815
|
-
"description": "",
|
1816
|
-
"hostgroup_id": 1,
|
1817
|
-
"id": 2,
|
1818
|
-
"name": "sowasvonneu",
|
1819
|
-
"parameters": "[{\\"id\\":0,\\"name\\":\\"richtigneu\\",\\"description\\":\\"\\",\\"type\\":\\"puppetenv\\",\\"value\\":\\"1\\"},{\\"id\\":1,\\"name\\":\\"ganzgut\\",\\"description\\":\\"\\",\\"type\\":\\"ip\\",\\"value\\":\\"1.1.1.2\\"}]",
|
1820
|
-
"updated_at": "2019-11-13 17:47:27 +0100",
|
1821
|
-
},
|
1822
|
-
"editMode": false,
|
1823
|
-
"error": Object {
|
1824
|
-
"errorMsg": "",
|
1825
|
-
"status": "",
|
1826
|
-
"statusText": "",
|
1827
|
-
},
|
1828
|
-
"foremanData": Object {
|
1829
|
-
"computeprofiles": Array [],
|
1830
|
-
"domains": Array [],
|
1831
|
-
"environments": Array [
|
1832
|
-
Object {
|
1833
|
-
"id": 1,
|
1834
|
-
"name": "production",
|
1835
|
-
},
|
1836
|
-
Object {
|
1837
|
-
"id": 2,
|
1838
|
-
"name": "test",
|
1839
|
-
},
|
1840
|
-
],
|
1841
|
-
"hostgroup_id": 1,
|
1842
|
-
"lifecycle_environments": Array [],
|
1843
|
-
"ptables": Array [
|
1844
|
-
Object {
|
1845
|
-
"id": 105,
|
1846
|
-
"name": "Kickstart default",
|
1847
|
-
},
|
1848
|
-
Object {
|
1849
|
-
"id": 104,
|
1850
|
-
"name": "Kickstart default thin",
|
1851
|
-
},
|
1852
|
-
],
|
1853
|
-
},
|
1854
|
-
"hostgroupId": 1,
|
1855
|
-
"loading": false,
|
1856
|
-
"rows": Array [
|
1857
|
-
Object {
|
1858
|
-
"description": "",
|
1859
|
-
"id": 0,
|
1860
|
-
"name": "richtigneu",
|
1861
|
-
"type": "puppetenv",
|
1862
|
-
"value": "1",
|
1863
|
-
},
|
1864
|
-
Object {
|
1865
|
-
"description": "",
|
1866
|
-
"id": 1,
|
1867
|
-
"name": "ganzgut",
|
1868
|
-
"type": "ip",
|
1869
|
-
"value": "1.1.1.2",
|
1870
|
-
},
|
1871
|
-
],
|
1872
|
-
}
|
1873
|
-
`;
|
1874
|
-
|
1875
1802
|
exports[`ParameterSelectionReducer should request load foreman data 1`] = `
|
1876
1803
|
Object {
|
1877
1804
|
"appDefinition": Object {
|
@@ -1977,7 +1904,7 @@ Object {
|
|
1977
1904
|
"hostparam": "Host parameter",
|
1978
1905
|
"lifecycleenv": "Lifecycle environment",
|
1979
1906
|
},
|
1980
|
-
"
|
1907
|
+
"parameters": Array [
|
1981
1908
|
Object {
|
1982
1909
|
"description": "",
|
1983
1910
|
"id": 1,
|
@@ -2044,18 +1971,6 @@ Object {
|
|
2044
1971
|
}
|
2045
1972
|
`;
|
2046
1973
|
|
2047
|
-
exports[`ParameterSelectionReducer should request parameter selection 1`] = `
|
2048
|
-
Object {
|
2049
|
-
"editMode": false,
|
2050
|
-
"error": Object {
|
2051
|
-
"errorMsg": "",
|
2052
|
-
"status": "",
|
2053
|
-
"statusText": "",
|
2054
|
-
},
|
2055
|
-
"loading": true,
|
2056
|
-
}
|
2057
|
-
`;
|
2058
|
-
|
2059
1974
|
exports[`ParameterSelectionReducer should return initial state 1`] = `
|
2060
1975
|
Object {
|
2061
1976
|
"editMode": false,
|
@@ -2197,7 +2112,7 @@ Object {
|
|
2197
2112
|
"hostparam": "Host parameter",
|
2198
2113
|
"lifecycleenv": "Lifecycle environment",
|
2199
2114
|
},
|
2200
|
-
"
|
2115
|
+
"parameters": Array [
|
2201
2116
|
Object {
|
2202
2117
|
"description": "",
|
2203
2118
|
"id": 1,
|
@@ -1,13 +1,5 @@
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
2
|
|
3
|
-
exports[`ParameterSelectionSelectors should return appDefinition from parameterSelectionData_1 fixtures 1`] = `
|
4
|
-
Object {
|
5
|
-
"hostgroup_id": 1,
|
6
|
-
"id": 1,
|
7
|
-
"name": "Test123",
|
8
|
-
}
|
9
|
-
`;
|
10
|
-
|
11
3
|
exports[`ParameterSelectionSelectors should return columns from parameterSelectionData_1 fixtures 1`] = `
|
12
4
|
Array [
|
13
5
|
Object {
|
@@ -138,7 +130,7 @@ Object {
|
|
138
130
|
}
|
139
131
|
`;
|
140
132
|
|
141
|
-
exports[`ParameterSelectionSelectors should return
|
133
|
+
exports[`ParameterSelectionSelectors should return parameters from parameterSelectionData_1 fixtures 1`] = `
|
142
134
|
Array [
|
143
135
|
Object {
|
144
136
|
"description": "",
|
@@ -199,6 +191,8 @@ Array [
|
|
199
191
|
]
|
200
192
|
`;
|
201
193
|
|
194
|
+
exports[`ParameterSelectionSelectors should return serviceDefinition from parameterSelectionData_1 fixtures 1`] = `undefined`;
|
195
|
+
|
202
196
|
exports[`ParameterSelectionSelectors should return sortingColumns from parameterSelectionData_1 fixtures 1`] = `
|
203
197
|
Object {
|
204
198
|
"name": Object {
|
@@ -8,25 +8,23 @@ import * as ParameterSelectionActions from './ParameterSelectionActions';
|
|
8
8
|
import {
|
9
9
|
selectLoading,
|
10
10
|
selectEditMode,
|
11
|
-
|
11
|
+
selectParamData,
|
12
12
|
selectParameterTypes,
|
13
|
-
|
13
|
+
selectParameters,
|
14
14
|
selectSortingColumns,
|
15
15
|
selectColumns,
|
16
|
-
|
17
|
-
selectHostgroupId,
|
16
|
+
selectParamDefinition,
|
18
17
|
} from './ParameterSelectionSelectors';
|
19
18
|
|
20
19
|
const mapStateToProps = state => ({
|
21
20
|
loading: selectLoading(state),
|
22
21
|
editMode: selectEditMode(state),
|
23
|
-
|
22
|
+
paramData: selectParamData(state),
|
24
23
|
parameterTypes: selectParameterTypes(state),
|
25
|
-
|
24
|
+
parameters: selectParameters(state),
|
26
25
|
sortingColumns: selectSortingColumns(state),
|
27
26
|
columns: selectColumns(state),
|
28
|
-
|
29
|
-
hostgroupId: selectHostgroupId(state),
|
27
|
+
paramDefinition: selectParamDefinition(state),
|
30
28
|
});
|
31
29
|
|
32
30
|
const mapDispatchToProps = dispatch =>
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import PropTypes from 'prop-types';
|
3
|
+
import {
|
4
|
+
Icon,
|
5
|
+
Button,
|
6
|
+
} from 'patternfly-react';
|
7
|
+
|
8
|
+
const AddTableEntry = ({
|
9
|
+
hidden,
|
10
|
+
disabled,
|
11
|
+
onAddTableEntry,
|
12
|
+
}) =>{
|
13
|
+
if (hidden) {
|
14
|
+
return null;
|
15
|
+
}
|
16
|
+
|
17
|
+
return (
|
18
|
+
<Button bsStyle="default" disabled={disabled} onClick={onAddTableEntry}>
|
19
|
+
<Icon type="fa" name="plus" />
|
20
|
+
</Button>
|
21
|
+
);
|
22
|
+
};
|
23
|
+
|
24
|
+
AddTableEntry.propTypes = {
|
25
|
+
hidden: PropTypes.bool.isRequired,
|
26
|
+
disabled: PropTypes.bool.isRequired,
|
27
|
+
onAddTableEntry: PropTypes.func.isRequired
|
28
|
+
};
|
29
|
+
|
30
|
+
export default AddTableEntry;
|
@@ -0,0 +1,39 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import PropTypes from 'prop-types';
|
3
|
+
import {
|
4
|
+
Icon,
|
5
|
+
Button,
|
6
|
+
} from 'patternfly-react';
|
7
|
+
|
8
|
+
const DeleteTableEntry = ({
|
9
|
+
hidden,
|
10
|
+
disabled,
|
11
|
+
onDeleteTableEntry,
|
12
|
+
additionalData,
|
13
|
+
}) =>{
|
14
|
+
if (hidden) {
|
15
|
+
return null;
|
16
|
+
}
|
17
|
+
|
18
|
+
return (
|
19
|
+
<span>
|
20
|
+
|
21
|
+
<Button
|
22
|
+
bsStyle="default"
|
23
|
+
disabled={disabled}
|
24
|
+
onClick={() => window.confirm("Are you sure you wish to delete this item?") && onDeleteTableEntry(additionalData) }
|
25
|
+
>
|
26
|
+
<Icon type="pf" name="delete" title="delete entry" />
|
27
|
+
</Button>
|
28
|
+
</span>
|
29
|
+
);
|
30
|
+
};
|
31
|
+
|
32
|
+
DeleteTableEntry.propTypes = {
|
33
|
+
hidden: PropTypes.bool.isRequired,
|
34
|
+
disabled: PropTypes.bool.isRequired,
|
35
|
+
onDeleteTableEntry: PropTypes.func.isRequired,
|
36
|
+
additionalData: PropTypes.object.isRequired,
|
37
|
+
};
|
38
|
+
|
39
|
+
export default DeleteTableEntry;
|
@@ -0,0 +1,43 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import PropTypes from 'prop-types';
|
3
|
+
import Select from 'foremanReact/components/common/forms/Select';
|
4
|
+
|
5
|
+
const ExtSelect= ({
|
6
|
+
hidden,
|
7
|
+
editable,
|
8
|
+
viewText,
|
9
|
+
selectValue,
|
10
|
+
onChange,
|
11
|
+
options,
|
12
|
+
additionalData,
|
13
|
+
}) =>{
|
14
|
+
if (hidden) {
|
15
|
+
return null;
|
16
|
+
}
|
17
|
+
|
18
|
+
if (!editable) {
|
19
|
+
return (
|
20
|
+
<div>{viewText}</div>
|
21
|
+
);
|
22
|
+
}
|
23
|
+
|
24
|
+
return (
|
25
|
+
<Select
|
26
|
+
value={selectValue}
|
27
|
+
onChange={e => onChange(e.target.value, additionalData) }
|
28
|
+
options={options}
|
29
|
+
/>
|
30
|
+
);
|
31
|
+
};
|
32
|
+
|
33
|
+
ExtSelect.propTypes = {
|
34
|
+
hidden: PropTypes.bool.isRequired,
|
35
|
+
editable: PropTypes.bool.isRequired,
|
36
|
+
viewText: PropTypes.string,
|
37
|
+
selectValue: PropTypes.string,
|
38
|
+
onChange: PropTypes.func.isRequired,
|
39
|
+
options: PropTypes.object,
|
40
|
+
additionalData: PropTypes.object,
|
41
|
+
};
|
42
|
+
|
43
|
+
export default ExtSelect;
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import PropTypes from 'prop-types';
|
3
|
+
|
4
|
+
const RailsData = ({
|
5
|
+
view,
|
6
|
+
parameter,
|
7
|
+
value,
|
8
|
+
}) => {
|
9
|
+
const id = "foreman_acd_"+ view +"_"+ parameter;
|
10
|
+
const name = "foreman_acd_"+ view +"["+ parameter +"]";
|
11
|
+
|
12
|
+
return (
|
13
|
+
<input
|
14
|
+
id={id}
|
15
|
+
name={name}
|
16
|
+
value={value}
|
17
|
+
type="hidden"
|
18
|
+
/>
|
19
|
+
);
|
20
|
+
}
|
21
|
+
|
22
|
+
RailsData.propTypes = {
|
23
|
+
view: PropTypes.string.isRequired,
|
24
|
+
parameter: PropTypes.string.isRequired,
|
25
|
+
};
|
26
|
+
|
27
|
+
export default RailsData;
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import { testComponentSnapshotsWithFixtures } from 'react-redux-test-utils';
|
2
|
+
|
3
|
+
import AddTableEntry from '../AddTableEntry';
|
4
|
+
|
5
|
+
const noop = () => {};
|
6
|
+
|
7
|
+
const fixtures = {
|
8
|
+
'should render add parameter': {
|
9
|
+
hidden: false,
|
10
|
+
disabled: false,
|
11
|
+
onAddTableEntry: noop,
|
12
|
+
},
|
13
|
+
'should render hidden button': {
|
14
|
+
hidden: true,
|
15
|
+
disabled: false,
|
16
|
+
onAddTableEntry: noop,
|
17
|
+
},
|
18
|
+
'should render disabled button': {
|
19
|
+
hidden: false,
|
20
|
+
disabled: true,
|
21
|
+
onAddTableEntry: noop,
|
22
|
+
},
|
23
|
+
};
|
24
|
+
|
25
|
+
describe('AddTableEntry', () =>
|
26
|
+
testComponentSnapshotsWithFixtures(AddTableEntry, fixtures));
|
@@ -0,0 +1,29 @@
|
|
1
|
+
import { testComponentSnapshotsWithFixtures } from 'react-redux-test-utils';
|
2
|
+
|
3
|
+
import DeleteTableEntry from '../DeleteTableEntry';
|
4
|
+
|
5
|
+
const noop = () => {};
|
6
|
+
|
7
|
+
const fixtures = {
|
8
|
+
'should render delete parameter': {
|
9
|
+
hidden: false,
|
10
|
+
disabled: false,
|
11
|
+
onDeleteTableEntry: noop,
|
12
|
+
additionalData: {},
|
13
|
+
},
|
14
|
+
'should render hidden button': {
|
15
|
+
hidden: true,
|
16
|
+
disabled: false,
|
17
|
+
onDeleteTableEntry: noop,
|
18
|
+
additionalData: {},
|
19
|
+
},
|
20
|
+
'should render disabled button': {
|
21
|
+
hidden: false,
|
22
|
+
disabled: true,
|
23
|
+
onDeleteTableEntry: noop,
|
24
|
+
additionalData: {},
|
25
|
+
},
|
26
|
+
};
|
27
|
+
|
28
|
+
describe('DeleteTableEntry', () =>
|
29
|
+
testComponentSnapshotsWithFixtures(DeleteTableEntry, fixtures));
|