foreman_acd 0.0.6 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/foreman_acd/api/v2/app_definitions_controller.rb +1 -2
  3. data/app/controllers/foreman_acd/app_definitions_controller.rb +29 -1
  4. data/app/controllers/foreman_acd/app_instances_controller.rb +70 -21
  5. data/app/controllers/foreman_acd/concerns/app_definition_parameters.rb +1 -1
  6. data/app/controllers/foreman_acd/concerns/app_instance_parameters.rb +1 -1
  7. data/app/controllers/ui_acd_controller.rb +0 -1
  8. data/app/models/foreman_acd/app_definition.rb +0 -1
  9. data/app/views/foreman_acd/app_definitions/_form.html.erb +6 -14
  10. data/app/views/foreman_acd/app_definitions/import.html.erb +18 -0
  11. data/app/views/foreman_acd/app_definitions/index.html.erb +9 -5
  12. data/app/views/foreman_acd/app_instances/_form.html.erb +5 -5
  13. data/app/views/foreman_acd/app_instances/deploy.html.erb +19 -0
  14. data/app/views/foreman_acd/app_instances/index.html.erb +6 -5
  15. data/app/views/foreman_acd/app_instances/report.html.erb +19 -0
  16. data/app/views/ui_acd/app_definition.json.rabl +1 -1
  17. data/config/routes.rb +7 -0
  18. data/db/migrate/20190610202252_create_app_definitions.rb +1 -3
  19. data/db/migrate/20190625140305_create_app_instances.rb +1 -1
  20. data/lib/foreman_acd/plugin.rb +19 -2
  21. data/lib/foreman_acd/version.rb +1 -1
  22. data/webpack/components/ApplicationDefinition/ApplicationDefinition.js +261 -0
  23. data/webpack/components/ApplicationDefinition/ApplicationDefinition.scss +1 -0
  24. data/webpack/components/ApplicationDefinition/ApplicationDefinitionActions.js +211 -0
  25. data/webpack/components/ApplicationDefinition/ApplicationDefinitionConstants.js +9 -0
  26. data/webpack/components/ApplicationDefinition/ApplicationDefinitionReducer.js +147 -0
  27. data/webpack/components/ApplicationDefinition/ApplicationDefinitionSelectors.js +6 -0
  28. data/webpack/components/ApplicationDefinition/index.js +29 -0
  29. data/webpack/components/ApplicationInstance/ApplicationInstance.js +342 -0
  30. data/webpack/components/ApplicationInstance/ApplicationInstance.scss +11 -0
  31. data/webpack/components/ApplicationInstance/ApplicationInstanceActions.js +210 -0
  32. data/webpack/components/ApplicationInstance/ApplicationInstanceConstants.js +12 -0
  33. data/webpack/components/ApplicationInstance/ApplicationInstanceReducer.js +223 -0
  34. data/webpack/components/ApplicationInstance/ApplicationInstanceSelectors.js +8 -0
  35. data/webpack/components/ApplicationInstance/components/AppDefinitionSelector.js +49 -0
  36. data/webpack/components/ApplicationInstance/components/Service.js +30 -0
  37. data/webpack/components/ApplicationInstance/components/ServiceCounter.js +37 -0
  38. data/webpack/components/ApplicationInstance/index.js +33 -0
  39. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.js +155 -0
  40. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.scss +27 -0
  41. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportActions.js +86 -0
  42. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportConstants.js +4 -0
  43. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportReducer.js +52 -0
  44. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportSelectors.js +5 -0
  45. data/webpack/components/ApplicationInstanceReport/components/ReportViewer.js +26 -0
  46. data/webpack/components/ApplicationInstanceReport/index.js +27 -0
  47. data/webpack/components/ParameterSelection/ParameterSelection.js +65 -161
  48. data/webpack/components/ParameterSelection/ParameterSelection.scss +9 -0
  49. data/webpack/components/ParameterSelection/ParameterSelectionActions.js +42 -71
  50. data/webpack/components/ParameterSelection/ParameterSelectionConstants.js +12 -19
  51. data/webpack/components/ParameterSelection/ParameterSelectionHelper.js +3 -3
  52. data/webpack/components/ParameterSelection/ParameterSelectionReducer.js +76 -75
  53. data/webpack/components/ParameterSelection/ParameterSelectionSelectors.js +2 -6
  54. data/webpack/components/ParameterSelection/__fixtures__/parameterSelection.fixtures.js +12 -21
  55. data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionData_1.fixtures.js +1 -1
  56. data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionReducer.fixtures.js +3 -45
  57. data/webpack/components/ParameterSelection/__tests__/ParameterSelection.test.js +20 -0
  58. data/webpack/components/ParameterSelection/__tests__/ParameterSelectionReducer.test.js +22 -46
  59. data/webpack/components/ParameterSelection/__tests__/ParameterSelectionSelectors.test.js +6 -6
  60. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelection.test.js.snap +40 -265
  61. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionReducer.test.js.snap +11 -96
  62. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionSelectors.test.js.snap +3 -9
  63. data/webpack/components/ParameterSelection/index.js +4 -6
  64. data/webpack/components/common/AddTableEntry.js +30 -0
  65. data/webpack/components/common/DeleteTableEntry.js +39 -0
  66. data/webpack/components/common/ExtSelect.js +43 -0
  67. data/webpack/components/common/RailsData.js +27 -0
  68. data/webpack/components/common/__tests__/AddTableEntry.test.js +26 -0
  69. data/webpack/components/common/__tests__/DeleteTableEntry.test.js +29 -0
  70. data/webpack/components/common/__tests__/ExtSelect.test.js +38 -0
  71. data/webpack/components/common/__tests__/RailsData.test.js +16 -0
  72. data/webpack/components/common/__tests__/__snapshots__/AddParameter.test.js.snap +35 -0
  73. data/webpack/components/common/__tests__/__snapshots__/AddTableEntry.test.js.snap +35 -0
  74. data/webpack/components/common/__tests__/__snapshots__/DeleteParameter.test.js.snap +41 -0
  75. data/webpack/components/common/__tests__/__snapshots__/DeleteTableEntry.test.js.snap +41 -0
  76. data/webpack/components/common/__tests__/__snapshots__/ExtSelect.test.js.snap +18 -0
  77. data/webpack/components/common/__tests__/__snapshots__/RailsData.test.js.snap +10 -0
  78. data/webpack/helper.js +20 -0
  79. data/webpack/index.js +6 -0
  80. data/webpack/reducer.js +40 -3
  81. metadata +47 -46
@@ -130,7 +130,7 @@ Object {
130
130
  "hostparam": "Host parameter",
131
131
  "lifecycleenv": "Lifecycle environment",
132
132
  },
133
- "rows": Array [
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
- "rows": Array [
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
- "rows": Array [
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
- "rows": Array [
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
- "rows": Array [
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
- "rows": Array [
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
- "rows": Array [
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
- "rows": Array [
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
- "rows": Array [
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
- "rows": Array [
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
- "rows": Array [
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 rows from parameterSelectionData_1 fixtures 1`] = `
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 {
@@ -10,11 +10,10 @@ import {
10
10
  selectEditMode,
11
11
  selectForemanData,
12
12
  selectParameterTypes,
13
- selectRows,
13
+ selectParameters,
14
14
  selectSortingColumns,
15
15
  selectColumns,
16
- selectAppDefinition,
17
- selectHostgroupId,
16
+ selectServiceDefinition,
18
17
  } from './ParameterSelectionSelectors';
19
18
 
20
19
  const mapStateToProps = state => ({
@@ -22,11 +21,10 @@ const mapStateToProps = state => ({
22
21
  editMode: selectEditMode(state),
23
22
  foremanData: selectForemanData(state),
24
23
  parameterTypes: selectParameterTypes(state),
25
- rows: selectRows(state),
24
+ parameters: selectParameters(state),
26
25
  sortingColumns: selectSortingColumns(state),
27
26
  columns: selectColumns(state),
28
- appDefinition: selectAppDefinition(state),
29
- hostgroupId: selectHostgroupId(state),
27
+ serviceDefinition: selectServiceDefinition(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
+ &nbsp;
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" />
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));