foreman_acd 0.0.6 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (141) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +107 -56
  3. data/app/controllers/foreman_acd/ansible_playbooks_controller.rb +124 -0
  4. data/app/controllers/foreman_acd/api/v2/ansible_playbooks_controller.rb +72 -0
  5. data/app/controllers/foreman_acd/api/v2/app_definitions_controller.rb +2 -2
  6. data/app/controllers/foreman_acd/api/v2/app_instances_controller.rb +62 -0
  7. data/app/controllers/foreman_acd/app_definitions_controller.rb +46 -9
  8. data/app/controllers/foreman_acd/app_instances_controller.rb +96 -90
  9. data/app/controllers/foreman_acd/concerns/ansible_playbook_parameters.rb +23 -0
  10. data/app/controllers/foreman_acd/concerns/app_definition_parameters.rb +1 -1
  11. data/app/controllers/foreman_acd/concerns/app_instance_parameters.rb +1 -1
  12. data/app/controllers/foreman_acd/remote_execution_controller.rb +46 -0
  13. data/app/controllers/ui_acd_controller.rb +20 -4
  14. data/app/lib/actions/foreman_acd/deploy_all_hosts.rb +42 -0
  15. data/app/lib/actions/foreman_acd/run_configurator.rb +41 -0
  16. data/app/models/concerns/foreman_acd/host_managed_extensions.rb +51 -0
  17. data/app/models/foreman_acd/acd_provider.rb +30 -0
  18. data/app/models/foreman_acd/ansible_playbook.rb +67 -0
  19. data/app/models/foreman_acd/app_definition.rb +25 -1
  20. data/app/models/foreman_acd/app_instance.rb +42 -0
  21. data/app/models/foreman_acd/foreman_host.rb +23 -0
  22. data/app/models/foreman_acd/taxonomy_extensions.rb +17 -0
  23. data/app/services/foreman_acd/app_configurator.rb +54 -0
  24. data/app/services/foreman_acd/app_deployer.rb +151 -0
  25. data/app/services/foreman_acd/inventory_creator.rb +54 -0
  26. data/app/views/foreman_acd/ansible_playbooks/_form.html.erb +30 -0
  27. data/app/views/foreman_acd/ansible_playbooks/edit.html.erb +11 -0
  28. data/app/views/foreman_acd/ansible_playbooks/index.html.erb +30 -0
  29. data/app/views/foreman_acd/ansible_playbooks/new.html.erb +3 -0
  30. data/app/views/foreman_acd/api/v2/ansible_playbooks/base.json.rabl +5 -0
  31. data/app/views/foreman_acd/api/v2/ansible_playbooks/index.json.rabl +5 -0
  32. data/app/views/foreman_acd/api/v2/ansible_playbooks/show.json.rabl +9 -0
  33. data/app/views/foreman_acd/api/v2/app_definitions/base.json.rabl +5 -0
  34. data/app/views/foreman_acd/api/v2/app_definitions/index.json.rabl +5 -0
  35. data/app/views/foreman_acd/api/v2/app_definitions/show.json.rabl +9 -0
  36. data/app/views/foreman_acd/api/v2/app_instances/base.json.rabl +5 -0
  37. data/app/views/foreman_acd/api/v2/app_instances/index.json.rabl +5 -0
  38. data/app/views/foreman_acd/api/v2/app_instances/show.json.rabl +5 -0
  39. data/app/views/foreman_acd/app_definitions/_form.html.erb +34 -20
  40. data/app/views/foreman_acd/app_definitions/edit.html.erb +10 -0
  41. data/app/views/foreman_acd/app_definitions/import.html.erb +18 -0
  42. data/app/views/foreman_acd/app_definitions/index.html.erb +10 -6
  43. data/app/views/foreman_acd/app_instances/_form.html.erb +12 -10
  44. data/app/views/foreman_acd/app_instances/edit.html.erb +10 -0
  45. data/app/views/foreman_acd/app_instances/index.html.erb +87 -9
  46. data/app/views/foreman_acd/app_instances/report.html.erb +22 -0
  47. data/app/views/templates/job/run_acd_ansible_playbook.erb +62 -0
  48. data/app/views/ui_acd/ansible_data.json.rabl +6 -0
  49. data/app/views/ui_acd/app.json.rabl +6 -2
  50. data/app/views/ui_acd/app_definition.json.rabl +1 -1
  51. data/app/views/ui_acd/{fdata.json.rabl → foreman_data.json.rabl} +1 -1
  52. data/config/routes.rb +35 -1
  53. data/db/migrate/20190610202252_create_app_definitions.rb +1 -3
  54. data/db/migrate/20190625140305_create_app_instances.rb +1 -1
  55. data/db/migrate/20200916091018_create_ansible_playbooks.rb +20 -0
  56. data/db/migrate/20200917120220_add_ansible_playbook_id.rb +14 -0
  57. data/db/migrate/20201016002819_add_ansible_vars_all_to_app_definitions.rb +8 -0
  58. data/db/migrate/20201016104338_add_ansible_vars_all_to_app_instances.rb +8 -0
  59. data/db/migrate/20210112111548_add_organization_to_app_instance.rb +22 -0
  60. data/db/migrate/20210112113853_add_location_to_app_instance.rb +8 -0
  61. data/db/migrate/20210202141658_create_foreman_hosts.rb +24 -0
  62. data/db/migrate/20210204111306_remove_hosts_from_app_instances.rb +8 -0
  63. data/db/migrate/20210209091014_rename_acd_tables.rb +16 -0
  64. data/db/migrate/20210216083522_add_last_progress_report.rb +8 -0
  65. data/db/migrate/20210216091529_add_last_deploy_task.rb +8 -0
  66. data/db/seeds.d/62_acd_proxy_feature.rb +4 -0
  67. data/db/seeds.d/75-job_templates.rb +13 -0
  68. data/lib/foreman_acd/engine.rb +21 -3
  69. data/lib/foreman_acd/plugin.rb +112 -20
  70. data/lib/foreman_acd/version.rb +1 -1
  71. data/locale/en/foreman_acd.edit.po +326 -0
  72. data/locale/en/foreman_acd.po +232 -2
  73. data/locale/en/foreman_acd.po.time_stamp +0 -0
  74. data/locale/foreman_acd.pot +343 -8
  75. data/package.json +1 -1
  76. data/test/controllers/ansible_playbooks_controller_test.rb +27 -0
  77. data/webpack/components/ApplicationDefinition/ApplicationDefinition.js +391 -0
  78. data/webpack/components/ApplicationDefinition/ApplicationDefinition.scss +1 -0
  79. data/webpack/components/ApplicationDefinition/ApplicationDefinitionActions.js +303 -0
  80. data/webpack/components/ApplicationDefinition/ApplicationDefinitionConstants.js +15 -0
  81. data/webpack/components/ApplicationDefinition/ApplicationDefinitionHelper.js +26 -0
  82. data/webpack/components/ApplicationDefinition/ApplicationDefinitionReducer.js +269 -0
  83. data/webpack/components/ApplicationDefinition/ApplicationDefinitionSelectors.js +9 -0
  84. data/webpack/components/ApplicationDefinition/components/AnsiblePlaybookSelector.js +49 -0
  85. data/webpack/components/ApplicationDefinition/index.js +35 -0
  86. data/webpack/components/ApplicationInstance/ApplicationInstance.js +451 -0
  87. data/webpack/components/ApplicationInstance/ApplicationInstance.scss +11 -0
  88. data/webpack/components/ApplicationInstance/ApplicationInstanceActions.js +247 -0
  89. data/webpack/components/ApplicationInstance/ApplicationInstanceConstants.js +15 -0
  90. data/webpack/components/ApplicationInstance/ApplicationInstanceReducer.js +309 -0
  91. data/webpack/components/ApplicationInstance/ApplicationInstanceSelectors.js +10 -0
  92. data/webpack/components/ApplicationInstance/components/AppDefinitionSelector.js +49 -0
  93. data/webpack/components/ApplicationInstance/components/Service.js +30 -0
  94. data/webpack/components/ApplicationInstance/components/ServiceCounter.js +37 -0
  95. data/webpack/components/ApplicationInstance/index.js +37 -0
  96. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.js +148 -0
  97. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.scss +44 -0
  98. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportActions.js +42 -0
  99. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportConstants.js +2 -0
  100. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportReducer.js +38 -0
  101. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportSelectors.js +4 -0
  102. data/webpack/components/ApplicationInstanceReport/components/ReportViewer.js +26 -0
  103. data/webpack/components/ApplicationInstanceReport/index.js +25 -0
  104. data/webpack/components/ParameterSelection/ParameterSelection.js +131 -192
  105. data/webpack/components/ParameterSelection/ParameterSelection.scss +9 -0
  106. data/webpack/components/ParameterSelection/ParameterSelectionActions.js +87 -110
  107. data/webpack/components/ParameterSelection/ParameterSelectionConstants.js +15 -19
  108. data/webpack/components/ParameterSelection/ParameterSelectionHelper.js +3 -35
  109. data/webpack/components/ParameterSelection/ParameterSelectionReducer.js +116 -84
  110. data/webpack/components/ParameterSelection/ParameterSelectionSelectors.js +3 -7
  111. data/webpack/components/ParameterSelection/__fixtures__/parameterSelection.fixtures.js +12 -21
  112. data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionData_1.fixtures.js +1 -1
  113. data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionReducer.fixtures.js +3 -45
  114. data/webpack/components/ParameterSelection/__tests__/ParameterSelection.test.js +20 -0
  115. data/webpack/components/ParameterSelection/__tests__/ParameterSelectionReducer.test.js +22 -46
  116. data/webpack/components/ParameterSelection/__tests__/ParameterSelectionSelectors.test.js +6 -6
  117. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelection.test.js.snap +40 -265
  118. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionReducer.test.js.snap +11 -96
  119. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionSelectors.test.js.snap +3 -9
  120. data/webpack/components/ParameterSelection/index.js +6 -8
  121. data/webpack/components/common/AddTableEntry.js +30 -0
  122. data/webpack/components/common/DeleteTableEntry.js +39 -0
  123. data/webpack/components/common/EasyHeaderFormatter.js +18 -0
  124. data/webpack/components/common/EditTableEntry.js +50 -0
  125. data/webpack/components/common/ExtSelect.js +43 -0
  126. data/webpack/components/common/LockTableEntry.js +60 -0
  127. data/webpack/components/common/RailsData.js +27 -0
  128. data/webpack/components/common/__tests__/AddTableEntry.test.js +26 -0
  129. data/webpack/components/common/__tests__/DeleteTableEntry.test.js +29 -0
  130. data/webpack/components/common/__tests__/ExtSelect.test.js +38 -0
  131. data/webpack/components/common/__tests__/RailsData.test.js +16 -0
  132. data/webpack/components/common/__tests__/__snapshots__/AddParameter.test.js.snap +35 -0
  133. data/webpack/components/common/__tests__/__snapshots__/AddTableEntry.test.js.snap +35 -0
  134. data/webpack/components/common/__tests__/__snapshots__/DeleteParameter.test.js.snap +41 -0
  135. data/webpack/components/common/__tests__/__snapshots__/DeleteTableEntry.test.js.snap +41 -0
  136. data/webpack/components/common/__tests__/__snapshots__/ExtSelect.test.js.snap +18 -0
  137. data/webpack/components/common/__tests__/__snapshots__/RailsData.test.js.snap +10 -0
  138. data/webpack/helper.js +20 -0
  139. data/webpack/index.js +6 -0
  140. data/webpack/reducer.js +43 -3
  141. metadata +114 -20
@@ -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 {
@@ -8,25 +8,23 @@ import * as ParameterSelectionActions from './ParameterSelectionActions';
8
8
  import {
9
9
  selectLoading,
10
10
  selectEditMode,
11
- selectForemanData,
11
+ selectParamData,
12
12
  selectParameterTypes,
13
- selectRows,
13
+ selectParameters,
14
14
  selectSortingColumns,
15
15
  selectColumns,
16
- selectAppDefinition,
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
- foremanData: selectForemanData(state),
22
+ paramData: selectParamData(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
+ 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
+ import { translate as __ } from 'foremanReact/common/I18n';
8
+
9
+ const DeleteTableEntry = ({
10
+ hidden,
11
+ disabled,
12
+ onDeleteTableEntry,
13
+ additionalData,
14
+ }) =>{
15
+ if (hidden) {
16
+ return null;
17
+ }
18
+
19
+ return (
20
+ <span>
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,18 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import {
4
+ Table,
5
+ } from 'patternfly-react';
6
+
7
+ const EasyHeaderFormatter = (value, { column }) => (
8
+ <Table.Heading aria-label={column.header.label} {...column.header.props}>
9
+ {value}
10
+ </Table.Heading>
11
+ );
12
+
13
+ EasyHeaderFormatter.propTypes = {
14
+ value: PropTypes.string.isRequired,
15
+ column: PropTypes.object.isRequired,
16
+ };
17
+
18
+ export default EasyHeaderFormatter;
@@ -0,0 +1,50 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import {
4
+ Icon,
5
+ Button,
6
+ } from 'patternfly-react';
7
+ import { translate as __ } from 'foremanReact/common/I18n';
8
+
9
+ const EditTableEntry = ({
10
+ hidden,
11
+ disabled,
12
+ handleLocking,
13
+ onEditTableEntry,
14
+ additionalData,
15
+ }) =>{
16
+ if (hidden) {
17
+ return null;
18
+ }
19
+
20
+ let title = 'edit this entry'
21
+
22
+ if (handleLocking === true) {
23
+ if (additionalData.rowData.locked === true) {
24
+ disabled = true;
25
+ title = 'This entry is locked and can not be changed.';
26
+ }
27
+ }
28
+
29
+ return (
30
+ <span>
31
+ <Button
32
+ bsStyle="default"
33
+ disabled={disabled}
34
+ onClick={() => onEditTableEntry(additionalData) }
35
+ >
36
+ <Icon type="pf" name="edit" title={__(title)} />
37
+ </Button>
38
+ </span>
39
+ );
40
+ };
41
+
42
+ EditTableEntry.propTypes = {
43
+ hidden: PropTypes.bool,
44
+ disabled: PropTypes.bool.isRequired,
45
+ handleLocking: PropTypes.bool.isRequired,
46
+ onEditTableEntry: PropTypes.func.isRequired,
47
+ additionalData: PropTypes.object.isRequired,
48
+ };
49
+
50
+ export default EditTableEntry;
@@ -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;