foreman_acd 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/foreman_acd/ansible_playbooks_controller.rb +75 -0
  3. data/app/controllers/foreman_acd/app_instances_controller.rb +19 -2
  4. data/app/controllers/foreman_acd/concerns/ansible_playbook_parameters.rb +1 -1
  5. data/app/controllers/foreman_acd/remote_execution_controller.rb +37 -21
  6. data/app/lib/actions/foreman_acd/deploy_all_hosts.rb +12 -7
  7. data/app/lib/actions/foreman_acd/run_configurator.rb +10 -7
  8. data/app/models/concerns/foreman_acd/host_managed_extensions.rb +2 -2
  9. data/app/models/foreman_acd/acd_provider.rb +7 -1
  10. data/app/models/foreman_acd/ansible_playbook.rb +2 -1
  11. data/app/models/foreman_acd/app_instance.rb +1 -1
  12. data/app/services/foreman_acd/acd_proxy_proxy_selector.rb +17 -0
  13. data/app/services/foreman_acd/app_configurator.rb +59 -15
  14. data/app/services/foreman_acd/app_deployer.rb +8 -2
  15. data/app/services/foreman_acd/inventory_creator.rb +14 -0
  16. data/app/views/foreman_acd/ansible_playbooks/_form.html.erb +41 -7
  17. data/app/views/foreman_acd/app_definitions/_form.html.erb +1 -1
  18. data/app/views/foreman_acd/app_instances/_form.html.erb +1 -1
  19. data/app/views/foreman_acd/app_instances/index.html.erb +5 -3
  20. data/app/views/foreman_acd/app_instances/report.html.erb +1 -1
  21. data/app/views/templates/job/run_acd_ansible_playbook.erb +1 -1
  22. data/config/routes.rb +3 -0
  23. data/db/migrate/20210316151145_add_git_commit_to_ansible_playbooks.rb +8 -0
  24. data/db/migrate/20210503122809_add_git_url_to_ansible_playbooks.rb +8 -0
  25. data/db/seeds.d/75-job_templates.rb +1 -1
  26. data/lib/foreman_acd.rb +12 -0
  27. data/lib/foreman_acd/engine.rb +26 -4
  28. data/lib/foreman_acd/plugin.rb +0 -9
  29. data/lib/foreman_acd/version.rb +1 -1
  30. data/lib/tasks/foreman_acd_tasks.rake +0 -12
  31. data/package.json +8 -8
  32. data/test/controllers/ansible_playbooks_controller_test.rb +1 -1
  33. data/test/controllers/app_instances_controller_test.rb +8 -3
  34. data/test/controllers/ui_acd_controller_test.rb +22 -6
  35. data/test/factories/foreman_acd_factories.rb +18 -4
  36. data/test/models/acd_provider_test.rb +37 -0
  37. data/test/models/ansible_playbook_test.rb +11 -0
  38. data/test/models/app_definition_test.rb +1 -1
  39. data/test/models/app_instance_test.rb +2 -0
  40. data/test/models/concerns/host_extensions_test.rb +26 -0
  41. data/test/models/foreman_host_test.rb +12 -0
  42. data/webpack/__mocks__/foremanReact/API.js +2 -0
  43. data/webpack/__mocks__/foremanReact/common/I18n.js +3 -0
  44. data/webpack/__mocks__/foremanReact/common/helpers.js +2 -0
  45. data/webpack/__mocks__/foremanReact/components/ForemanModal.js +7 -0
  46. data/webpack/__mocks__/foremanReact/components/common/forms/CommonForm.js +2 -0
  47. data/webpack/__mocks__/foremanReact/components/common/forms/TextInput.js +2 -0
  48. data/webpack/__mocks__/foremanReact/components/hosts/powerStatus.js +1 -0
  49. data/webpack/__snapshots__/helper.test.js.snap +14 -0
  50. data/webpack/components/ApplicationDefinition/ApplicationDefinition.js +1 -1
  51. data/webpack/components/ApplicationDefinition/__fixtures__/applicationDefinitionConfData_1.fixtures.js +288 -0
  52. data/webpack/components/ApplicationDefinition/__fixtures__/applicationDefinitionReducer.fixtures.js +79 -0
  53. data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinition.test.js +25 -0
  54. data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinitionReducer.test.js +119 -0
  55. data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinitionSelectors.test.js +41 -0
  56. data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinition.test.js.snap +200 -0
  57. data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinitionReducer.test.js.snap +3033 -0
  58. data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinitionSelectors.test.js.snap +299 -0
  59. data/webpack/components/ApplicationDefinition/components/AnsiblePlaybookSelector.js +1 -0
  60. data/webpack/components/ApplicationDefinition/components/__tests__/AnsiblePlaybookSelector.test.js +41 -0
  61. data/webpack/components/ApplicationDefinition/components/__tests__/__snapshots__/AnsiblePlaybookSelector.test.js.snap +121 -0
  62. data/webpack/components/ApplicationInstance/ApplicationInstance.js +3 -5
  63. data/webpack/components/ApplicationInstance/__fixtures__/applicationInstanceConfData_1.fixtures.js +263 -0
  64. data/webpack/components/ApplicationInstance/__fixtures__/applicationInstanceReducer.fixtures.js +78 -0
  65. data/webpack/components/ApplicationInstance/__tests__/ApplicationInstance.test.js +23 -0
  66. data/webpack/components/ApplicationInstance/__tests__/ApplicationInstanceReducer.test.js +119 -0
  67. data/webpack/components/ApplicationInstance/__tests__/ApplicationInstanceSelectors.test.js +44 -0
  68. data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstance.test.js.snap +209 -0
  69. data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstanceReducer.test.js.snap +2719 -0
  70. data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstanceSelectors.test.js.snap +276 -0
  71. data/webpack/components/ApplicationInstanceReport/__fixtures__/applicationInstanceReportData_1.fixtures.js +349 -0
  72. data/webpack/components/ApplicationInstanceReport/__fixtures__/applicationInstanceReportReducer.fixtures.js +20 -0
  73. data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReport.test.js +47 -0
  74. data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReportReducer.test.js +41 -0
  75. data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReportSelectors.test.js +26 -0
  76. data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReport.test.js.snap +130 -0
  77. data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReportReducer.test.js.snap +718 -0
  78. data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReportSelectors.test.js.snap +347 -0
  79. data/webpack/components/ApplicationInstanceReport/components/__tests__/ReportViewer.test.js +24 -0
  80. data/webpack/components/ApplicationInstanceReport/components/__tests__/__snapshots__/ReportViewer.test.js.snap +24 -0
  81. data/webpack/components/ParameterSelection/ParameterSelectionReducer.js +2 -21
  82. data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionData_1.fixtures.js +116 -84
  83. data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionReducer.fixtures.js +10 -4
  84. data/webpack/components/ParameterSelection/__tests__/ParameterSelection.test.js +36 -46
  85. data/webpack/components/ParameterSelection/__tests__/ParameterSelectionReducer.test.js +31 -25
  86. data/webpack/components/ParameterSelection/__tests__/ParameterSelectionSelectors.test.js +6 -6
  87. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelection.test.js.snap +2 -126
  88. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionReducer.test.js.snap +1483 -872
  89. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionSelectors.test.js.snap +117 -79
  90. data/webpack/components/SyncGitRepo/SyncGitRepo.js +210 -0
  91. data/webpack/components/SyncGitRepo/SyncGitRepo.scss +1 -0
  92. data/webpack/components/SyncGitRepo/SyncGitRepoActions.js +124 -0
  93. data/webpack/components/SyncGitRepo/SyncGitRepoConstants.js +9 -0
  94. data/webpack/components/SyncGitRepo/SyncGitRepoReducer.js +80 -0
  95. data/webpack/components/SyncGitRepo/SyncGitRepoSelectors.js +6 -0
  96. data/webpack/components/SyncGitRepo/__fixtures__/syncGitRepoConfData_1.fixtures.js +7 -0
  97. data/webpack/components/SyncGitRepo/__fixtures__/syncGitRepoReducer.fixtures.js +44 -0
  98. data/webpack/components/SyncGitRepo/__tests__/SyncGitRepo.test.js +27 -0
  99. data/webpack/components/SyncGitRepo/__tests__/SyncGitRepoReducer.test.js +95 -0
  100. data/webpack/components/SyncGitRepo/__tests__/SyncGitRepoSelectors.test.js +32 -0
  101. data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepo.test.js.snap +30 -0
  102. data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepoReducer.test.js.snap +137 -0
  103. data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepoSelectors.test.js.snap +13 -0
  104. data/webpack/components/SyncGitRepo/components/FormTextInput.js +42 -0
  105. data/webpack/components/SyncGitRepo/components/ScmTypeSelector.js +46 -0
  106. data/webpack/components/SyncGitRepo/index.js +28 -0
  107. data/webpack/components/common/ExtTextInput.js +43 -0
  108. data/webpack/components/common/__tests__/EditTableEntry.test.js +53 -0
  109. data/webpack/components/common/__tests__/LockTableEntry.test.js +35 -0
  110. data/webpack/components/common/__tests__/__snapshots__/DeleteTableEntry.test.js.snap +2 -2
  111. data/webpack/components/common/__tests__/__snapshots__/EditTableEntry.test.js.snap +81 -0
  112. data/webpack/components/common/__tests__/__snapshots__/LockTableEntry.test.js.snap +60 -0
  113. data/webpack/helper.js +15 -1
  114. data/webpack/helper.test.js +37 -0
  115. data/webpack/index.js +2 -0
  116. data/webpack/reducer.js +4 -0
  117. metadata +92 -11
  118. data/webpack/components/common/EasyHeaderFormatter.js +0 -18
  119. data/webpack/components/common/__tests__/__snapshots__/AddParameter.test.js.snap +0 -35
  120. data/webpack/components/common/__tests__/__snapshots__/DeleteParameter.test.js.snap +0 -41
@@ -1,27 +1,58 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
+ exports[`ParameterSelectionSelectors should return ParamDefinition from parameterSelectionData_1 fixtures 1`] = `
4
+ Object {
5
+ "dataId": "1",
6
+ "id": 1,
7
+ "name": "web",
8
+ }
9
+ `;
10
+
3
11
  exports[`ParameterSelectionSelectors should return columns from parameterSelectionData_1 fixtures 1`] = `
4
12
  Array [
5
13
  Object {
14
+ "cell": Object {
15
+ "formatters": Array [
16
+ null,
17
+ ],
18
+ },
6
19
  "header": Object {
20
+ "customFormatters": Array [
21
+ null,
22
+ ],
23
+ "formatters": Array [
24
+ null,
25
+ ],
7
26
  "label": "Name",
8
27
  "props": Object {
9
28
  "index": 0,
10
29
  "sort": true,
11
30
  "style": Object {
12
- "width": "20%",
31
+ "width": "25%",
13
32
  },
14
33
  },
34
+ "transforms": Array [
35
+ null,
36
+ ],
15
37
  },
16
38
  "property": "name",
17
39
  },
18
40
  Object {
19
41
  "cell": Object {
42
+ "formatters": Array [
43
+ null,
44
+ ],
20
45
  "props": Object {
21
46
  "index": 1,
22
47
  },
23
48
  },
24
49
  "header": Object {
50
+ "customFormatters": Array [
51
+ null,
52
+ ],
53
+ "formatters": Array [
54
+ null,
55
+ ],
25
56
  "label": "Description",
26
57
  "props": Object {
27
58
  "index": 1,
@@ -30,16 +61,25 @@ Array [
30
61
  "width": "25%",
31
62
  },
32
63
  },
64
+ "transforms": Array [
65
+ null,
66
+ ],
33
67
  },
34
68
  "property": "description",
35
69
  },
36
70
  Object {
37
71
  "cell": Object {
38
- "props": Object {
39
- "index": 2,
40
- },
72
+ "formatters": Array [
73
+ null,
74
+ ],
41
75
  },
42
76
  "header": Object {
77
+ "customFormatters": Array [
78
+ null,
79
+ ],
80
+ "formatters": Array [
81
+ null,
82
+ ],
43
83
  "label": "Type",
44
84
  "props": Object {
45
85
  "index": 2,
@@ -48,37 +88,55 @@ Array [
48
88
  "width": "20%",
49
89
  },
50
90
  },
91
+ "transforms": Array [
92
+ null,
93
+ ],
51
94
  },
52
95
  "property": "type",
53
96
  },
54
97
  Object {
55
98
  "cell": Object {
56
- "props": Object {
57
- "index": 3,
58
- },
99
+ "formatters": Array [
100
+ null,
101
+ ],
59
102
  },
60
103
  "header": Object {
104
+ "customFormatters": Array [
105
+ null,
106
+ ],
107
+ "formatters": Array [
108
+ null,
109
+ ],
61
110
  "label": "Default value",
62
111
  "props": Object {
63
112
  "index": 3,
64
113
  "sort": true,
65
114
  "style": Object {
66
- "width": "25%",
115
+ "width": "20%",
67
116
  },
68
117
  },
118
+ "transforms": Array [
119
+ null,
120
+ ],
69
121
  },
70
122
  "property": "value",
71
123
  },
72
124
  Object {
73
125
  "cell": Object {
74
- "props": Object {
75
- "index": 4,
76
- },
126
+ "formatters": Array [
127
+ null,
128
+ ],
77
129
  },
78
130
  "header": Object {
131
+ "formatters": Array [
132
+ null,
133
+ ],
79
134
  "label": "Actions",
80
135
  "props": Object {
81
136
  "index": 4,
137
+ "style": Object {
138
+ "width": "10%",
139
+ },
82
140
  },
83
141
  },
84
142
  "property": "actions",
@@ -88,45 +146,67 @@ Array [
88
146
 
89
147
  exports[`ParameterSelectionSelectors should return editMode from parameterSelectionData_1 fixtures 1`] = `false`;
90
148
 
91
- exports[`ParameterSelectionSelectors should return foremanData from parameterSelectionData_1 fixtures 1`] = `
149
+ exports[`ParameterSelectionSelectors should return hostgroupId from parameterSelectionData_1 fixtures 1`] = `1`;
150
+
151
+ exports[`ParameterSelectionSelectors should return loading from parameterSelectionData_1 fixtures 1`] = `false`;
152
+
153
+ exports[`ParameterSelectionSelectors should return paramData from parameterSelectionData_1 fixtures 1`] = `
92
154
  Object {
93
- "computeprofiles": Array [],
94
- "domains": Array [],
95
- "environments": Array [
155
+ "computeprofiles": Array [
96
156
  Object {
97
157
  "id": 1,
98
- "name": "production",
158
+ "name": "1-Small",
99
159
  },
100
160
  Object {
101
161
  "id": 2,
102
- "name": "test",
162
+ "name": "2-Medium",
163
+ },
164
+ Object {
165
+ "id": 3,
166
+ "name": "3-Large",
167
+ },
168
+ Object {
169
+ "id": 4,
170
+ "name": "Orchahosts-VM",
171
+ },
172
+ ],
173
+ "dataType": "PARAMETER_SELECTION_PARAM_TYPE_FOREMAN",
174
+ "domains": Array [
175
+ Object {
176
+ "id": 1,
177
+ "name": "deploy3.dev.atix",
178
+ },
179
+ ],
180
+ "environments": Array [
181
+ Object {
182
+ "id": 1,
183
+ "name": "production",
103
184
  },
104
185
  ],
105
186
  "hostgroup_id": 1,
106
- "lifecycle_environments": Array [],
107
- "ptables": Array [
187
+ "lifecycle_environments": Array [
108
188
  Object {
109
- "id": 105,
110
- "name": "Kickstart default",
189
+ "id": 1,
190
+ "name": "Library",
111
191
  },
192
+ ],
193
+ "ptables": Array [
112
194
  Object {
113
- "id": 104,
114
- "name": "Kickstart default thin",
195
+ "id": 125,
196
+ "name": "Kickstart default",
115
197
  },
116
198
  ],
117
199
  }
118
200
  `;
119
201
 
120
- exports[`ParameterSelectionSelectors should return hostgroupId from parameterSelectionData_1 fixtures 1`] = `1`;
121
-
122
- exports[`ParameterSelectionSelectors should return loading from parameterSelectionData_1 fixtures 1`] = `false`;
123
-
124
202
  exports[`ParameterSelectionSelectors should return parameterTypes from parameterSelectionData_1 fixtures 1`] = `
125
203
  Object {
126
- "computeprofile": "Compute profile",
127
204
  "domain": "Domain",
128
205
  "hostparam": "Host parameter",
129
- "lifecycleenv": "Lifecycle environment",
206
+ "ip": "IP",
207
+ "password": "Root password",
208
+ "ptable": "Partition table",
209
+ "puppetenv": "Puppet environment",
130
210
  }
131
211
  `;
132
212
 
@@ -135,64 +215,22 @@ Array [
135
215
  Object {
136
216
  "description": "",
137
217
  "id": 1,
138
- "name": "PuppetEnv",
139
- "type": "puppetenv",
140
- "value": "2",
218
+ "locked": false,
219
+ "name": "CP",
220
+ "type": "computeprofile",
221
+ "value": "1",
141
222
  },
142
223
  Object {
143
224
  "description": "",
144
225
  "id": 2,
145
- "name": "PW",
146
- "type": "password",
147
- "value": "rooot",
148
- },
149
- Object {
150
- "description": "",
151
- "id": 3,
152
- "name": "Blub",
153
- "type": "hostparam",
154
- "value": "awesome",
155
- },
156
- Object {
157
- "description": "",
158
- "id": 4,
159
- "name": "111allo",
160
- "type": "ip",
161
- "value": "1.1.1.1",
162
- },
163
- Object {
164
- "description": "",
165
- "id": 5,
166
- "name": "1111aasdfasf",
167
- "type": "hostname",
168
- "value": "dername",
169
- },
170
- Object {
171
- "description": "",
172
- "id": 6,
173
- "name": "222nocheiner",
174
- "type": "hostparam",
175
- "value": "",
176
- },
177
- Object {
178
- "description": "aa",
179
- "id": 7,
180
- "name": "aaaaa",
181
- "type": "ptable",
182
- "value": "",
183
- },
184
- Object {
185
- "description": "",
186
- "id": 8,
187
- "name": "aaa",
188
- "type": "hostparam",
189
- "value": "2134234",
226
+ "locked": true,
227
+ "name": "LE",
228
+ "type": "lifecycleenv",
229
+ "value": "1",
190
230
  },
191
231
  ]
192
232
  `;
193
233
 
194
- exports[`ParameterSelectionSelectors should return serviceDefinition from parameterSelectionData_1 fixtures 1`] = `undefined`;
195
-
196
234
  exports[`ParameterSelectionSelectors should return sortingColumns from parameterSelectionData_1 fixtures 1`] = `
197
235
  Object {
198
236
  "name": Object {
@@ -0,0 +1,210 @@
1
+ import React, { useState } from 'react'
2
+ import PropTypes from 'prop-types';
3
+ import {
4
+ Icon,
5
+ Button,
6
+ } from 'patternfly-react';
7
+ import {
8
+ sprintf,
9
+ translate as __
10
+ } from 'foremanReact/common/I18n';
11
+ import {Select, TextInput} from 'foremanReact/components/common/forms/Select';
12
+ import RailsData from '../common/RailsData';
13
+ import ScmTypeSelector from './components/ScmTypeSelector';
14
+ import FormTextInput from './components/FormTextInput'
15
+ import { arrayToObject } from '../../helper';
16
+ import CommonForm from 'foremanReact/components/common/forms/CommonForm';
17
+ import $ from 'jquery';
18
+
19
+ import {
20
+ FormControl,
21
+ inlineEditFormatterFactory,
22
+ } from 'patternfly-react';
23
+
24
+ class SyncGitRepo extends React.Component {
25
+ constructor(props) {
26
+ super(props);
27
+ }
28
+
29
+ validateParameters() {
30
+ let result = true;
31
+ let msg = "";
32
+
33
+ if (this.props.path === "" && this.props.scmType === 'directory') {
34
+ result = false;
35
+
36
+ if (msg == "") {
37
+ msg += __("Directory path cannot be blank");
38
+ }
39
+ }
40
+
41
+ if (this.props.scmType === 'git') {
42
+ if (this.props.gitUrl === "") {
43
+ result = false;
44
+
45
+ if (msg == "") {
46
+ msg += __("Git URL cannot be blank");
47
+ }
48
+ }
49
+
50
+ if (this.props.gitCommit === "") {
51
+ result = false;
52
+
53
+ if (msg == "") {
54
+ msg += __("Git Branch/Commit/Tag cannot be blank");
55
+ }
56
+ }
57
+ }
58
+
59
+ if (this.props.scmType !== "git" && this.props.scmType !== "directory" ) {
60
+ result = false;
61
+
62
+ if (msg == "") {
63
+ msg += __("SCM Type cannot be blank");
64
+ }
65
+ }
66
+
67
+ return {
68
+ validateResult: result,
69
+ validateMsg: msg
70
+ }
71
+ }
72
+
73
+ componentDidMount() {
74
+ const {
75
+ data: {mode, scmType, path, gitCommit, gitUrl, appDefinitions},
76
+ initSyncGitRepo,
77
+ loadScmType,
78
+ loadPath,
79
+ loadGitCommit,
80
+ loadGitUrl,
81
+ handleGitRepoSync,
82
+ } = this.props;
83
+
84
+ if (mode === 'editInstance') {
85
+ loadScmType(scmType);
86
+ loadPath(path);
87
+ loadGitCommit(gitCommit);
88
+ loadGitUrl(gitUrl);
89
+ handleGitRepoSync(this.props.scmType, this.props.path, this.props.gitCommit)
90
+ }
91
+
92
+ initSyncGitRepo(
93
+ scmType,
94
+ path,
95
+ gitCommit,
96
+ gitUrl,
97
+ );
98
+ };
99
+
100
+ render() {
101
+ const {
102
+ data: {mode, scmTypes, organization, location, appDefinitions},
103
+ scmType,
104
+ path,
105
+ gitCommit,
106
+ gitUrl,
107
+ loadScmType,
108
+ loadPath,
109
+ loadGitCommit,
110
+ loadGitUrl,
111
+ handleGitRepoSync,
112
+ } = this.props;
113
+
114
+ var url_validator = /^(ftp|http|https):\/\/[^ "]+$/;
115
+
116
+ let { validateResult, validateMsg } = this.validateParameters();
117
+
118
+ if (validateResult === false) {
119
+ $('input[type="submit"][name="commit"]').attr("disabled", true);
120
+ } else {
121
+ $('input[type="submit"][name="commit"]').attr("disabled", false);
122
+ }
123
+
124
+ return (
125
+ <span>
126
+ <div>
127
+ <ScmTypeSelector
128
+ label="SCM Type *"
129
+ editable={ appDefinitions.length == 0 }
130
+ viewText={ scmTypes[scmType] }
131
+ options={ scmTypes }
132
+ onChange={ loadScmType }
133
+ selectValue={ scmType }
134
+ />
135
+ {(scmType === 'directory') ? (
136
+ <FormTextInput
137
+ label= 'Directory Path *'
138
+ editable= { appDefinitions.length == 0 }
139
+ viewText={ path }
140
+ onChange={ loadPath }
141
+ parameter="path"
142
+ /> ) : null }
143
+ {(scmType === 'git') ? (
144
+ <FormTextInput
145
+ label= 'Git Url *'
146
+ editable= { appDefinitions.length == 0 }
147
+ viewText={ gitUrl }
148
+ onChange={ loadGitUrl }
149
+ parameter="git_url"
150
+ /> ) : null }
151
+ {(!url_validator.test(gitUrl) && gitUrl)? (
152
+ <div className="form-group">
153
+ <div className="col-md-2"></div>
154
+ <div className="col-md-4"><pre>{ __("Git URL is wrong") }</pre></div>
155
+ </div>
156
+ ) : (<div></div>)}
157
+ {validateResult == false ? (
158
+ <div className="form-group">
159
+ <div className="col-md-2"></div>
160
+ <div className="col-md-4"><pre>{validateMsg}</pre></div>
161
+ </div>
162
+ ) : (<div></div>)}
163
+ {(scmType === "git") ? (
164
+ <FormTextInput
165
+ label="Git Branch/Commit/Tag *"
166
+ editable= { appDefinitions.length == 0 }
167
+ viewText={ gitCommit }
168
+ onChange={ loadGitCommit }
169
+ parameter="git_commit"
170
+ /> ) : null }
171
+ {(scmType === "git") ? (
172
+ <CommonForm>
173
+ <span className="help-block help-inline">
174
+ <Button
175
+ bsStyle="default"
176
+ onClick={ (e) => handleGitRepoSync(gitUrl, gitCommit, scmType, e) }
177
+ >
178
+ {__('Sync Repository')} </Button>
179
+ </span>
180
+ </CommonForm>
181
+ ) : null }
182
+
183
+ </div>
184
+ </span>
185
+ )};
186
+ }
187
+
188
+ SyncGitRepo.defaultProps = {
189
+ error: {},
190
+ scmType: "",
191
+ path: "",
192
+ gitCommit: "",
193
+ gitUrl: "",
194
+
195
+ }
196
+
197
+ SyncGitRepo.propTypes = {
198
+ initSyncGitRepo: PropTypes.func,
199
+ loadScmType: PropTypes.func,
200
+ loadGitCommit: PropTypes.func,
201
+ loadPath: PropTypes.func,
202
+ loadGitUrl: PropTypes.func,
203
+ handleGitRepoSync: PropTypes.func,
204
+ scmType: PropTypes.string.isRequired,
205
+ path: PropTypes.string.isRequired,
206
+ gitCommit: PropTypes.string,
207
+ gitUrl: PropTypes.string,
208
+ };
209
+
210
+ export default SyncGitRepo;