foreman_webhooks 3.0.4 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5382cbf96f38f9ab42cef651aaf8eb1e602d2c651352c370138b911e7cd10901
4
- data.tar.gz: 5e32f69db8731876e51af931c9d3b174c9dcae62ae3ebdb11b186d70b5fff384
3
+ metadata.gz: 546a669c4f3c26a491fb5ab87ce068aa5391085cd5e0994e793d4f2d56c19a63
4
+ data.tar.gz: 5e19ad3a87e48dd0759cd7c418fadec7cd1574dd157b4e15563e43f1a3bce3e9
5
5
  SHA512:
6
- metadata.gz: fc5314756061144ef29988e98b7344c25b2df0e13b3cb122a965d071c18c5fdb9e46badc061b50f2e79b76e33ebf95e8d9c54671bac1dd0e46b334e070a9048a
7
- data.tar.gz: f9e3824a1b66dfdd988eeb9b3bbbd922d9e9b460bb7922a0139130a47cf7074ed958449c82e97941b7492328b361f2296026168b41ee85d492689ae691620012
6
+ metadata.gz: cba01a2168b1916b5874a8b39d50cd4cc463955e63352a84d8794183078e898f301eec2b79a893745caa1c7ad3f9d493a8b1363a8d0eeac53a2fa5d740bc3722
7
+ data.tar.gz: fd537f4c7dd5e995ad5f5f2116a2c0670d2df8bbe1398cc982684eee8fbb558dae9ef36b939cd557a7ea6d57d455ed12a3579ff7ec05cede892d73b92c145193
@@ -15,6 +15,10 @@ attributes :target_url,
15
15
  :ssl_ca_certs,
16
16
  :user
17
17
 
18
+ node :password_set do |webhook|
19
+ webhook.password.present?
20
+ end
21
+
18
22
  child :webhook_template do
19
23
  extends 'api/v2/webhook_templates/base'
20
24
  end
@@ -20,4 +20,4 @@ model: WebhookTemplate
20
20
  # Task ended at <%= @object.task.ended_at %>
21
21
  # Task resulted with <%= @object.task.result %>
22
22
  # Task state <%= @object.task.state %>
23
- # Task action output <%= @object.task.action_output %>
23
+ # Task action output <%= @object.task.action_continuous_output %>
@@ -21,4 +21,4 @@ model: WebhookTemplate
21
21
  # Task ended at <%= @object.task.ended_at %>
22
22
  # Task resulted with <%= @object.task.result %>
23
23
  # Task state <%= @object.task.state %>
24
- # Task action output <%= @object.task.action_output %>
24
+ # Task action output <%= @object.task.action_continuous_output %>
@@ -24,4 +24,4 @@ model: WebhookTemplate
24
24
  # Task ended at <%= @object.task.ended_at %>
25
25
  # Task resulted with <%= @object.task.result %>
26
26
  # Task state <%= @object.task.state %>
27
- # Task action output <%= @object.task.action_output %>
27
+ # Task action output <%= @object.task.action_continuous_output %>
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ForemanWebhooks
4
- VERSION = '3.0.4'
4
+ VERSION = "3.1.0"
5
5
  end
@@ -21,6 +21,8 @@ const ForemanFormikField = ({
21
21
  placeholder,
22
22
  options,
23
23
  isLoading,
24
+ disabled,
25
+ setDisabled,
24
26
  }) => (
25
27
  <FormikField name={name}>
26
28
  {({
@@ -32,6 +34,15 @@ const ForemanFormikField = ({
32
34
 
33
35
  return filter(initialOptions, o => o.value === fieldValue);
34
36
  };
37
+ const passwordInput = (
38
+ <input
39
+ {...field}
40
+ placeholder={disabled ? '********' : ''}
41
+ type={type}
42
+ disabled={disabled}
43
+ className="form-control"
44
+ />
45
+ );
35
46
  let content = null;
36
47
  switch (type) {
37
48
  case 'textarea':
@@ -56,10 +67,30 @@ const ForemanFormikField = ({
56
67
  onChange={selected =>
57
68
  setFieldValue(field.name, selected[0]?.value)
58
69
  }
59
- // onBlur={e => setFieldTouched(field.name, true)}
60
70
  />
61
71
  );
62
72
  break;
73
+ case 'password':
74
+ content = setDisabled ? (
75
+ <div className="input-group">
76
+ {passwordInput}
77
+ <span className="input-group-btn">
78
+ <button
79
+ className="btn btn-default"
80
+ onClick={e => {
81
+ e.preventDefault();
82
+ setDisabled(!disabled);
83
+ }}
84
+ title={__('Change the password')}
85
+ >
86
+ <span className="pficon pficon-edit" />
87
+ </button>
88
+ </span>
89
+ </div>
90
+ ) : (
91
+ passwordInput
92
+ );
93
+ break;
63
94
  default:
64
95
  content = (
65
96
  <input
@@ -101,6 +132,8 @@ ForemanFormikField.propTypes = {
101
132
  placeholder: PropTypes.string,
102
133
  options: PropTypes.array,
103
134
  isLoading: PropTypes.bool,
135
+ disabled: PropTypes.bool,
136
+ setDisabled: PropTypes.func,
104
137
  };
105
138
 
106
139
  ForemanFormikField.defaultProps = {
@@ -112,6 +145,8 @@ ForemanFormikField.defaultProps = {
112
145
  placeholder: '',
113
146
  options: null,
114
147
  isLoading: false,
148
+ disabled: false,
149
+ setDisabled: undefined,
115
150
  };
116
151
 
117
152
  export default ForemanFormikField;
@@ -18,6 +18,8 @@ const WebhookFormTabs = ({
18
18
  availableEvents,
19
19
  isTemplatesLoading,
20
20
  isEventsLoading,
21
+ isPasswordDisabled,
22
+ setIsPasswordDisabled,
21
23
  }) => (
22
24
  <Tabs activeKey={activeTab} onSelect={handleTabClick} isFilled>
23
25
  <Tab
@@ -90,6 +92,8 @@ const WebhookFormTabs = ({
90
92
  type="password"
91
93
  label={__('Password')}
92
94
  labelHelp={__('Authentication credentials')}
95
+ disabled={isPasswordDisabled}
96
+ setDisabled={setIsPasswordDisabled}
93
97
  />
94
98
  <ForemanFormikField
95
99
  name="verify_ssl"
@@ -153,11 +157,15 @@ WebhookFormTabs.propTypes = {
153
157
  availableEvents: PropTypes.array.isRequired,
154
158
  isTemplatesLoading: PropTypes.bool.isRequired,
155
159
  isEventsLoading: PropTypes.bool.isRequired,
160
+ isPasswordDisabled: PropTypes.bool,
161
+ setIsPasswordDisabled: PropTypes.func,
156
162
  };
157
163
 
158
164
  WebhookFormTabs.defaultProps = {
159
165
  disabled: false,
160
166
  formProps: {},
167
+ isPasswordDisabled: false,
168
+ setIsPasswordDisabled: undefined,
161
169
  };
162
170
 
163
171
  export default WebhookFormTabs;
@@ -25,6 +25,8 @@ const WebhookForm = ({
25
25
  availableEvents,
26
26
  isTemplatesLoading,
27
27
  isEventsLoading,
28
+ isPasswordDisabled,
29
+ setIsPasswordDisabled,
28
30
  }) => {
29
31
  const webhookTemplates = templates.map(t => ({ value: t.id, label: t.name }));
30
32
 
@@ -51,6 +53,8 @@ const WebhookForm = ({
51
53
  availableEvents={availableEvents}
52
54
  isEventsLoading={isEventsLoading}
53
55
  isTemplatesLoading={isTemplatesLoading}
56
+ isPasswordDisabled={isPasswordDisabled}
57
+ setIsPasswordDisabled={setIsPasswordDisabled}
54
58
  />
55
59
  </ForemanForm>
56
60
  );
@@ -64,6 +68,13 @@ WebhookForm.propTypes = {
64
68
  availableEvents: PropTypes.array.isRequired,
65
69
  isEventsLoading: PropTypes.bool.isRequired,
66
70
  isTemplatesLoading: PropTypes.bool.isRequired,
71
+ isPasswordDisabled: PropTypes.bool,
72
+ setIsPasswordDisabled: PropTypes.func,
73
+ };
74
+
75
+ WebhookForm.defaultProps = {
76
+ isPasswordDisabled: false,
77
+ setIsPasswordDisabled: undefined,
67
78
  };
68
79
 
69
80
  export default WebhookForm;
@@ -241,6 +241,7 @@ exports[`WebhookForm rendering should render for edit page 1`] = `
241
241
  ]
242
242
  }
243
243
  isEventsLoading={false}
244
+ isPasswordDisabled={false}
244
245
  isTemplatesLoading={false}
245
246
  webhookTemplates={
246
247
  Array [
@@ -492,6 +493,7 @@ exports[`WebhookForm rendering should render for new page 1`] = `
492
493
  ]
493
494
  }
494
495
  isEventsLoading={false}
496
+ isPasswordDisabled={false}
495
497
  isTemplatesLoading={false}
496
498
  webhookTemplates={
497
499
  Array [
@@ -24,7 +24,13 @@ import {
24
24
 
25
25
  const params = { page: 1, search: 'snippet = false', per_page: 'all' };
26
26
 
27
- const ConnectedWebhookForm = ({ onCancel, handleSubmit, initialValues }) => {
27
+ const ConnectedWebhookForm = ({
28
+ onCancel,
29
+ handleSubmit,
30
+ initialValues,
31
+ isPasswordDisabled,
32
+ setIsPasswordDisabled,
33
+ }) => {
28
34
  const dispatch = useDispatch();
29
35
 
30
36
  const templates = useSelector(selectWebhookTemplates);
@@ -60,6 +66,8 @@ const ConnectedWebhookForm = ({ onCancel, handleSubmit, initialValues }) => {
60
66
  initialValues={initialValues}
61
67
  isTemplatesLoading={isTemplatesLoading}
62
68
  isEventsLoading={isEventsLoading}
69
+ isPasswordDisabled={isPasswordDisabled}
70
+ setIsPasswordDisabled={setIsPasswordDisabled}
63
71
  />
64
72
  );
65
73
  };
@@ -68,6 +76,13 @@ ConnectedWebhookForm.propTypes = {
68
76
  onCancel: PropTypes.func.isRequired,
69
77
  handleSubmit: PropTypes.func.isRequired,
70
78
  initialValues: PropTypes.object.isRequired,
79
+ isPasswordDisabled: PropTypes.bool,
80
+ setIsPasswordDisabled: PropTypes.func,
81
+ };
82
+
83
+ ConnectedWebhookForm.defaultProps = {
84
+ isPasswordDisabled: false,
85
+ setIsPasswordDisabled: undefined,
71
86
  };
72
87
 
73
88
  export default ConnectedWebhookForm;
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
+ import { Modal } from 'patternfly-react';
3
4
  import { useDispatch } from 'react-redux';
4
5
 
5
6
  import { translate as __ } from 'foremanReact/common/I18n';
@@ -47,11 +48,12 @@ const WebhookCreateModal = ({ onSuccess, onCancel }) => {
47
48
  return (
48
49
  <ForemanModal
49
50
  id={WEBHOOK_CREATE_MODAL_ID}
50
- title={__('Create Webhook')}
51
51
  backdrop="static"
52
52
  className="webhooks-modal"
53
53
  >
54
- <ForemanModal.Header />
54
+ <Modal.Header>
55
+ <Modal.Title>{__('Create Webhook')}</Modal.Title>
56
+ </Modal.Header>
55
57
  <ConnectedWebhookForm
56
58
  handleSubmit={handleSubmit}
57
59
  initialValues={initialWebhookValues}
@@ -1,4 +1,5 @@
1
- import React, { useEffect } from 'react';
1
+ import React, { useEffect, useState } from 'react';
2
+ import { Modal } from 'patternfly-react';
2
3
  import { useSelector, useDispatch } from 'react-redux';
3
4
  import PropTypes from 'prop-types';
4
5
 
@@ -29,22 +30,11 @@ import './WebhookModal.scss';
29
30
  const WebhookEditModal = ({ toEdit, onSuccess, onCancel }) => {
30
31
  const dispatch = useDispatch();
31
32
 
33
+ const [isPasswordDisabled, setIsPasswordDisabled] = useState(false);
32
34
  const id = toEdit;
33
35
 
34
- const handleSubmit = (values, actions) =>
35
- dispatch(
36
- submitForm({
37
- url: foremanUrl(`/api${WEBHOOKS_PATH}/${id}`),
38
- values: { ...values, controller: 'webhooks' },
39
- item: 'Webhook',
40
- message: __('Webhook was successfully updated.'),
41
- method: 'put',
42
- successCallback: onSuccess,
43
- actions,
44
- })
45
- );
46
-
47
36
  const isLoading = useSelector(selectIsLoading);
37
+ const isPasswordSet = useSelector(selectWebhookValues).passwordSet;
48
38
  const initialWebhookValues = {
49
39
  id: useSelector(selectWebhookValues).id,
50
40
  name: useSelector(selectWebhookValues).name,
@@ -62,6 +52,27 @@ const WebhookEditModal = ({ toEdit, onSuccess, onCancel }) => {
62
52
  proxy_authorization: useSelector(selectWebhookValues).proxyAuthorization,
63
53
  };
64
54
 
55
+ useEffect(() => {
56
+ setIsPasswordDisabled(isPasswordSet);
57
+ }, [isPasswordSet]);
58
+
59
+ const handleSubmit = (values, actions) => {
60
+ if (isPasswordDisabled) {
61
+ delete values.password;
62
+ }
63
+ dispatch(
64
+ submitForm({
65
+ url: foremanUrl(`/api${WEBHOOKS_PATH}/${id}`),
66
+ values: { ...values, controller: 'webhooks' },
67
+ item: 'Webhook',
68
+ message: __('Webhook was successfully updated.'),
69
+ method: 'put',
70
+ successCallback: onSuccess,
71
+ actions,
72
+ })
73
+ );
74
+ };
75
+
65
76
  useEffect(() => {
66
77
  if (id) {
67
78
  dispatch(
@@ -73,21 +84,31 @@ const WebhookEditModal = ({ toEdit, onSuccess, onCancel }) => {
73
84
  }
74
85
  }, [id, dispatch]);
75
86
 
87
+ const onEditCancel = () => {
88
+ if (isPasswordSet) setIsPasswordDisabled(true);
89
+ onCancel();
90
+ };
91
+
76
92
  return (
77
93
  <ForemanModal
78
94
  id={WEBHOOK_EDIT_MODAL_ID}
79
- title={`${__('Edit')} ${initialWebhookValues.name}`}
80
95
  backdrop="static"
81
96
  className="webhooks-modal"
82
97
  >
83
- <ForemanModal.Header />
98
+ <Modal.Header>
99
+ <Modal.Title>
100
+ {`${__('Edit')} ${initialWebhookValues.name}`}
101
+ </Modal.Title>
102
+ </Modal.Header>
84
103
  {isLoading ? (
85
104
  <Loading />
86
105
  ) : (
87
106
  <ConnectedWebhookForm
88
107
  handleSubmit={handleSubmit}
89
108
  initialValues={initialWebhookValues}
90
- onCancel={onCancel}
109
+ onCancel={onEditCancel}
110
+ isPasswordDisabled={isPasswordDisabled}
111
+ setIsPasswordDisabled={setIsPasswordDisabled}
91
112
  />
92
113
  )}
93
114
  </ForemanModal>
metadata CHANGED
@@ -1,15 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_webhooks
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.4
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Timo Goebel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-16 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2023-03-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rdoc
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
13
41
  description: Plugin for Foreman that allows to configure Webhooks.
14
42
  email:
15
43
  - mail@timogoebel.name
@@ -175,7 +203,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
175
203
  - !ruby/object:Gem::Version
176
204
  version: '0'
177
205
  requirements: []
178
- rubygems_version: 3.1.2
206
+ rubygems_version: 3.1.6
179
207
  signing_key:
180
208
  specification_version: 4
181
209
  summary: Configure webhooks for Foreman.