foreman_puppet 10.0.0 → 10.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 +4 -4
- data/app/controllers/foreman_puppet/api/v2/hosts_bulk_actions_controller.rb +102 -0
- data/app/services/concerns/foreman_puppet/extensions/bulk_hosts_manager.rb +24 -0
- data/config/api_routes.rb +11 -0
- data/lib/foreman_puppet/engine.rb +1 -0
- data/lib/foreman_puppet/register.rb +2 -0
- data/lib/foreman_puppet/version.rb +1 -1
- data/test/controllers/foreman_puppet/api/v2/hosts_bulk_actions_controller_test.rb +171 -0
- data/test/services/foreman_puppet/bulk_hosts_manager_test.rb +33 -0
- data/webpack/global_index.js +42 -0
- data/webpack/src/Extends/Hosts/ActionsBar/ActionsBar.scss +14 -0
- data/webpack/src/Extends/Hosts/ActionsBar/index.js +73 -0
- data/webpack/src/Extends/Hosts/BulkActions/BulkChangeProxyCommon/__tests__/actions.test.js +78 -0
- data/webpack/src/Extends/Hosts/BulkActions/BulkChangeProxyCommon/actions.js +36 -0
- data/webpack/src/Extends/Hosts/BulkActions/BulkChangeProxyCommon/index.js +252 -0
- data/webpack/src/Extends/Hosts/BulkActions/BulkChangePuppetCAProxy/__tests__/index.test.js +66 -0
- data/webpack/src/Extends/Hosts/BulkActions/BulkChangePuppetCAProxy/index.js +40 -0
- data/webpack/src/Extends/Hosts/BulkActions/BulkChangePuppetProxy/__tests__/index.test.js +66 -0
- data/webpack/src/Extends/Hosts/BulkActions/BulkChangePuppetProxy/index.js +40 -0
- data/webpack/src/Extends/Hosts/BulkActions/BulkRemoveProxyCommon/__tests__/actions.test.js +64 -0
- data/webpack/src/Extends/Hosts/BulkActions/BulkRemoveProxyCommon/actions.js +24 -0
- data/webpack/src/Extends/Hosts/BulkActions/BulkRemoveProxyCommon/index.js +164 -0
- data/webpack/src/Extends/Hosts/BulkActions/BulkRemovePuppetCAProxy/__tests__/index.test.js +65 -0
- data/webpack/src/Extends/Hosts/BulkActions/BulkRemovePuppetCAProxy/index.js +39 -0
- data/webpack/src/Extends/Hosts/BulkActions/BulkRemovePuppetProxy/__tests__/index.test.js +61 -0
- data/webpack/src/Extends/Hosts/BulkActions/BulkRemovePuppetProxy/index.js +39 -0
- data/webpack/src/Extends/Hosts/BulkActions/__tests__/toastHelpers.test.js +55 -0
- data/webpack/src/Extends/Hosts/BulkActions/toastHelpers.js +17 -0
- data/webpack/src/foreman_puppet_host_form.test.js +4 -4
- metadata +26 -2
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { FormattedMessage } from 'react-intl';
|
|
4
|
+
import { useDispatch } from 'react-redux';
|
|
5
|
+
import { Modal, Button, TextContent, Text } from '@patternfly/react-core';
|
|
6
|
+
import { addToast } from 'foremanReact/components/ToastsList/slice';
|
|
7
|
+
import { translate as __ } from 'foremanReact/common/I18n';
|
|
8
|
+
import { foremanUrl } from 'foremanReact/common/helpers';
|
|
9
|
+
import { APIActions } from 'foremanReact/redux/API';
|
|
10
|
+
import {
|
|
11
|
+
HOSTS_API_PATH,
|
|
12
|
+
API_REQUEST_KEY,
|
|
13
|
+
} from 'foremanReact/routes/Hosts/constants';
|
|
14
|
+
|
|
15
|
+
import {
|
|
16
|
+
BULK_REMOVE_PUPPET_PROXY_KEY,
|
|
17
|
+
BULK_REMOVE_PUPPET_CA_PROXY_KEY,
|
|
18
|
+
bulkRemovePuppetProxyAction,
|
|
19
|
+
} from './actions';
|
|
20
|
+
import { bulkActionErrorToastParams } from '../toastHelpers';
|
|
21
|
+
|
|
22
|
+
const BulkRemoveProxyCommon = ({
|
|
23
|
+
isCAProxy,
|
|
24
|
+
isOpen,
|
|
25
|
+
closeModal,
|
|
26
|
+
selectAllHostsMode,
|
|
27
|
+
selectedCount,
|
|
28
|
+
fetchBulkParams,
|
|
29
|
+
handleErrorMessage,
|
|
30
|
+
removeMessage,
|
|
31
|
+
allHostsMessage,
|
|
32
|
+
someHostsMessage,
|
|
33
|
+
}) => {
|
|
34
|
+
const actionKey = isCAProxy
|
|
35
|
+
? BULK_REMOVE_PUPPET_CA_PROXY_KEY
|
|
36
|
+
: BULK_REMOVE_PUPPET_PROXY_KEY;
|
|
37
|
+
|
|
38
|
+
const handleModalClose = () => {
|
|
39
|
+
closeModal();
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const dispatch = useDispatch();
|
|
43
|
+
|
|
44
|
+
const handleError = response => {
|
|
45
|
+
handleModalClose();
|
|
46
|
+
dispatch(
|
|
47
|
+
addToast(
|
|
48
|
+
bulkActionErrorToastParams(response, handleErrorMessage, actionKey)
|
|
49
|
+
)
|
|
50
|
+
);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const handleSuccess = response => {
|
|
54
|
+
dispatch(
|
|
55
|
+
addToast({
|
|
56
|
+
type: 'success',
|
|
57
|
+
message: response.data.message,
|
|
58
|
+
})
|
|
59
|
+
);
|
|
60
|
+
dispatch(
|
|
61
|
+
APIActions.get({
|
|
62
|
+
key: API_REQUEST_KEY,
|
|
63
|
+
url: foremanUrl(HOSTS_API_PATH),
|
|
64
|
+
})
|
|
65
|
+
);
|
|
66
|
+
handleModalClose();
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const handleConfirm = () => {
|
|
70
|
+
const requestBody = {
|
|
71
|
+
included: {
|
|
72
|
+
search: fetchBulkParams(),
|
|
73
|
+
},
|
|
74
|
+
ca_proxy: isCAProxy,
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
dispatch(
|
|
78
|
+
bulkRemovePuppetProxyAction(
|
|
79
|
+
actionKey,
|
|
80
|
+
requestBody,
|
|
81
|
+
handleSuccess,
|
|
82
|
+
handleError
|
|
83
|
+
)
|
|
84
|
+
);
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const modalActions = [
|
|
88
|
+
<Button
|
|
89
|
+
key="add"
|
|
90
|
+
ouiaId="bulk-remove-proxy-common-modal-add-button"
|
|
91
|
+
variant="primary"
|
|
92
|
+
onClick={handleConfirm}
|
|
93
|
+
>
|
|
94
|
+
{removeMessage}
|
|
95
|
+
</Button>,
|
|
96
|
+
<Button
|
|
97
|
+
key="cancel"
|
|
98
|
+
ouiaId="bulk-remove-proxy-common-modal-cancel-button"
|
|
99
|
+
variant="link"
|
|
100
|
+
onClick={handleModalClose}
|
|
101
|
+
>
|
|
102
|
+
{__('Cancel')}
|
|
103
|
+
</Button>,
|
|
104
|
+
];
|
|
105
|
+
|
|
106
|
+
return (
|
|
107
|
+
<Modal
|
|
108
|
+
isOpen={isOpen}
|
|
109
|
+
onClose={handleModalClose}
|
|
110
|
+
onEscapePress={handleModalClose}
|
|
111
|
+
title={removeMessage}
|
|
112
|
+
width="50%"
|
|
113
|
+
position="top"
|
|
114
|
+
actions={modalActions}
|
|
115
|
+
id="bulk-remove-proxy-common"
|
|
116
|
+
key="bulk-remove-proxy-common"
|
|
117
|
+
ouiaId="bulk-remove-proxy-common"
|
|
118
|
+
>
|
|
119
|
+
<TextContent>
|
|
120
|
+
<Text ouiaId="bulk-remove-proxy-common-options">
|
|
121
|
+
{selectAllHostsMode ? (
|
|
122
|
+
<FormattedMessage
|
|
123
|
+
id="bulk-remove-proxy-common-warning-message-all"
|
|
124
|
+
defaultMessage={allHostsMessage}
|
|
125
|
+
values={{
|
|
126
|
+
boldCount: <strong>{__('All')}</strong>,
|
|
127
|
+
}}
|
|
128
|
+
/>
|
|
129
|
+
) : (
|
|
130
|
+
<FormattedMessage
|
|
131
|
+
id="bulk-remove-proxy-common-warning-message"
|
|
132
|
+
defaultMessage={someHostsMessage}
|
|
133
|
+
values={{
|
|
134
|
+
count: selectedCount,
|
|
135
|
+
boldCount: <strong>{selectedCount}</strong>,
|
|
136
|
+
}}
|
|
137
|
+
/>
|
|
138
|
+
)}
|
|
139
|
+
</Text>
|
|
140
|
+
</TextContent>
|
|
141
|
+
</Modal>
|
|
142
|
+
);
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
BulkRemoveProxyCommon.propTypes = {
|
|
146
|
+
isCAProxy: PropTypes.bool.isRequired,
|
|
147
|
+
isOpen: PropTypes.bool,
|
|
148
|
+
closeModal: PropTypes.func,
|
|
149
|
+
fetchBulkParams: PropTypes.func.isRequired,
|
|
150
|
+
selectedCount: PropTypes.number.isRequired,
|
|
151
|
+
selectAllHostsMode: PropTypes.bool.isRequired,
|
|
152
|
+
handleErrorMessage: PropTypes.string.isRequired,
|
|
153
|
+
removeMessage: PropTypes.string,
|
|
154
|
+
allHostsMessage: PropTypes.string.isRequired,
|
|
155
|
+
someHostsMessage: PropTypes.string.isRequired,
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
BulkRemoveProxyCommon.defaultProps = {
|
|
159
|
+
isOpen: false,
|
|
160
|
+
closeModal: () => {},
|
|
161
|
+
removeMessage: 'Remove Puppet (CA) Proxy',
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
export default BulkRemoveProxyCommon;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { mount } from '@theforeman/test';
|
|
3
|
+
|
|
4
|
+
import { openBulkModal } from 'foremanReact/common/BulkModalStateHelper';
|
|
5
|
+
import { ForemanActionsBarContext } from 'foremanReact/components/HostDetails/ActionsBar';
|
|
6
|
+
|
|
7
|
+
import BulkRemovePuppetCAProxyScene from '../index';
|
|
8
|
+
import BulkRemoveProxyCommon from '../../BulkRemoveProxyCommon';
|
|
9
|
+
|
|
10
|
+
jest.mock('foremanReact/components/HostDetails/ActionsBar', () => ({
|
|
11
|
+
ForemanActionsBarContext: jest.requireActual('react').createContext(),
|
|
12
|
+
}));
|
|
13
|
+
|
|
14
|
+
jest.mock('../../BulkRemoveProxyCommon', () => ({
|
|
15
|
+
__esModule: true,
|
|
16
|
+
default: jest.fn(() => null),
|
|
17
|
+
}));
|
|
18
|
+
|
|
19
|
+
describe('BulkRemovePuppetCAProxyScene', () => {
|
|
20
|
+
const fetchBulkParams = jest.fn();
|
|
21
|
+
const contextValue = {
|
|
22
|
+
selectAllHostsMode: false,
|
|
23
|
+
selectedCount: 2,
|
|
24
|
+
selectedResults: [1, 2],
|
|
25
|
+
fetchBulkParams,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
beforeEach(() => {
|
|
29
|
+
jest.clearAllMocks();
|
|
30
|
+
openBulkModal('bulk-remove-puppet-ca-proxy', false);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('opens with bulk modal state and passes expected CA proxy props', () => {
|
|
34
|
+
openBulkModal('bulk-remove-puppet-ca-proxy', true);
|
|
35
|
+
const wrapper = mount(
|
|
36
|
+
<ForemanActionsBarContext.Provider value={contextValue}>
|
|
37
|
+
<BulkRemovePuppetCAProxyScene />
|
|
38
|
+
</ForemanActionsBarContext.Provider>
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
const componentType =
|
|
42
|
+
BulkRemoveProxyCommon.default || BulkRemoveProxyCommon;
|
|
43
|
+
const props = wrapper.find(componentType).props();
|
|
44
|
+
|
|
45
|
+
expect(props).toEqual(
|
|
46
|
+
expect.objectContaining({
|
|
47
|
+
isCAProxy: true,
|
|
48
|
+
selectAllHostsMode: false,
|
|
49
|
+
selectedCount: 2,
|
|
50
|
+
selectedResults: [1, 2],
|
|
51
|
+
fetchBulkParams,
|
|
52
|
+
isOpen: true,
|
|
53
|
+
closeModal: expect.any(Function),
|
|
54
|
+
handleErrorMessage: 'Failed to remove Puppet CA Proxy',
|
|
55
|
+
allHostsMessage:
|
|
56
|
+
'Removing the Puppet CA proxy will affect {boldCount} selected hosts. Warning: If a Puppet Proxy is still set, the Puppet CA Proxy will fall back to that value after removal!',
|
|
57
|
+
someHostsMessage:
|
|
58
|
+
'Removing the Puppet CA proxy will affect {boldCount} selected {count, plural, one {host} other {hosts}}. Warning: If a Puppet Proxy is still set, the Puppet CA Proxy will fall back to that value after removal!',
|
|
59
|
+
removeMessage: 'Remove Puppet CA Proxy',
|
|
60
|
+
})
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
wrapper.unmount();
|
|
64
|
+
});
|
|
65
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
import { ForemanActionsBarContext } from 'foremanReact/components/HostDetails/ActionsBar';
|
|
3
|
+
import { useBulkModalOpen } from 'foremanReact/common/BulkModalStateHelper';
|
|
4
|
+
import { translate as __ } from 'foremanReact/common/I18n';
|
|
5
|
+
import BulkRemoveProxyCommon from '../BulkRemoveProxyCommon';
|
|
6
|
+
|
|
7
|
+
const BulkRemovePuppetCAProxyScene = () => {
|
|
8
|
+
const {
|
|
9
|
+
selectAllHostsMode,
|
|
10
|
+
selectedCount,
|
|
11
|
+
selectedResults,
|
|
12
|
+
fetchBulkParams,
|
|
13
|
+
} = useContext(ForemanActionsBarContext);
|
|
14
|
+
const { isOpen, close: closeModal } = useBulkModalOpen(
|
|
15
|
+
'bulk-remove-puppet-ca-proxy'
|
|
16
|
+
);
|
|
17
|
+
return (
|
|
18
|
+
<BulkRemoveProxyCommon
|
|
19
|
+
isCAProxy
|
|
20
|
+
key="bulk-remove-puppet-ca-proxy"
|
|
21
|
+
selectAllHostsMode={selectAllHostsMode}
|
|
22
|
+
selectedCount={selectedCount}
|
|
23
|
+
selectedResults={selectedResults}
|
|
24
|
+
fetchBulkParams={fetchBulkParams}
|
|
25
|
+
isOpen={isOpen}
|
|
26
|
+
closeModal={closeModal}
|
|
27
|
+
handleErrorMessage={__('Failed to remove Puppet CA Proxy')}
|
|
28
|
+
allHostsMessage={__(
|
|
29
|
+
'Removing the Puppet CA proxy will affect {boldCount} selected hosts. Warning: If a Puppet Proxy is still set, the Puppet CA Proxy will fall back to that value after removal!'
|
|
30
|
+
)}
|
|
31
|
+
someHostsMessage={__(
|
|
32
|
+
'Removing the Puppet CA proxy will affect {boldCount} selected {count, plural, one {host} other {hosts}}. Warning: If a Puppet Proxy is still set, the Puppet CA Proxy will fall back to that value after removal!'
|
|
33
|
+
)}
|
|
34
|
+
removeMessage={__('Remove Puppet CA Proxy')}
|
|
35
|
+
/>
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export default BulkRemovePuppetCAProxyScene;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { mount } from '@theforeman/test';
|
|
3
|
+
|
|
4
|
+
import { openBulkModal } from 'foremanReact/common/BulkModalStateHelper';
|
|
5
|
+
import { ForemanActionsBarContext } from 'foremanReact/components/HostDetails/ActionsBar';
|
|
6
|
+
|
|
7
|
+
import BulkRemovePuppetProxyScene from '../index';
|
|
8
|
+
import BulkRemoveProxyCommon from '../../BulkRemoveProxyCommon';
|
|
9
|
+
|
|
10
|
+
jest.mock('foremanReact/components/HostDetails/ActionsBar', () => ({
|
|
11
|
+
ForemanActionsBarContext: jest.requireActual('react').createContext(),
|
|
12
|
+
}));
|
|
13
|
+
|
|
14
|
+
jest.mock('../../BulkRemoveProxyCommon', () => ({
|
|
15
|
+
__esModule: true,
|
|
16
|
+
default: jest.fn(() => null),
|
|
17
|
+
}));
|
|
18
|
+
|
|
19
|
+
describe('BulkRemovePuppetProxyScene', () => {
|
|
20
|
+
const fetchBulkParams = jest.fn();
|
|
21
|
+
const contextValue = {
|
|
22
|
+
selectAllHostsMode: false,
|
|
23
|
+
selectedCount: 2,
|
|
24
|
+
selectedResults: [1, 2],
|
|
25
|
+
fetchBulkParams,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
beforeEach(() => {
|
|
29
|
+
jest.clearAllMocks();
|
|
30
|
+
openBulkModal('bulk-remove-puppet-proxy', false);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('opens with bulk modal state and passes expected props', () => {
|
|
34
|
+
openBulkModal('bulk-remove-puppet-proxy', true);
|
|
35
|
+
const wrapper = mount(
|
|
36
|
+
<ForemanActionsBarContext.Provider value={contextValue}>
|
|
37
|
+
<BulkRemovePuppetProxyScene />
|
|
38
|
+
</ForemanActionsBarContext.Provider>
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
const componentType =
|
|
42
|
+
BulkRemoveProxyCommon.default || BulkRemoveProxyCommon;
|
|
43
|
+
const props = wrapper.find(componentType).props();
|
|
44
|
+
|
|
45
|
+
expect(props).toEqual(
|
|
46
|
+
expect.objectContaining({
|
|
47
|
+
isCAProxy: false,
|
|
48
|
+
selectAllHostsMode: false,
|
|
49
|
+
selectedCount: 2,
|
|
50
|
+
selectedResults: [1, 2],
|
|
51
|
+
fetchBulkParams,
|
|
52
|
+
isOpen: true,
|
|
53
|
+
closeModal: expect.any(Function),
|
|
54
|
+
handleErrorMessage: 'Failed to remove Puppet Proxy',
|
|
55
|
+
removeMessage: 'Remove Puppet Proxy',
|
|
56
|
+
})
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
wrapper.unmount();
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
import { ForemanActionsBarContext } from 'foremanReact/components/HostDetails/ActionsBar';
|
|
3
|
+
import { useBulkModalOpen } from 'foremanReact/common/BulkModalStateHelper';
|
|
4
|
+
import { translate as __ } from 'foremanReact/common/I18n';
|
|
5
|
+
import BulkRemoveProxyCommon from '../BulkRemoveProxyCommon';
|
|
6
|
+
|
|
7
|
+
const BulkRemovePuppetProxyScene = () => {
|
|
8
|
+
const {
|
|
9
|
+
selectAllHostsMode,
|
|
10
|
+
selectedCount,
|
|
11
|
+
selectedResults,
|
|
12
|
+
fetchBulkParams,
|
|
13
|
+
} = useContext(ForemanActionsBarContext);
|
|
14
|
+
const { isOpen, close: closeModal } = useBulkModalOpen(
|
|
15
|
+
'bulk-remove-puppet-proxy'
|
|
16
|
+
);
|
|
17
|
+
return (
|
|
18
|
+
<BulkRemoveProxyCommon
|
|
19
|
+
isCAProxy={false}
|
|
20
|
+
key="bulk-remove-puppet-proxy"
|
|
21
|
+
selectAllHostsMode={selectAllHostsMode}
|
|
22
|
+
selectedCount={selectedCount}
|
|
23
|
+
selectedResults={selectedResults}
|
|
24
|
+
fetchBulkParams={fetchBulkParams}
|
|
25
|
+
isOpen={isOpen}
|
|
26
|
+
closeModal={closeModal}
|
|
27
|
+
handleErrorMessage={__('Failed to remove Puppet Proxy')}
|
|
28
|
+
allHostsMessage={__(
|
|
29
|
+
'Removing the Puppet proxy will affect {boldCount} selected hosts.'
|
|
30
|
+
)}
|
|
31
|
+
someHostsMessage={__(
|
|
32
|
+
'Removing the Puppet proxy will affect {boldCount} selected {count, plural, one {host} other {hosts}}.'
|
|
33
|
+
)}
|
|
34
|
+
removeMessage={__('Remove Puppet Proxy')}
|
|
35
|
+
/>
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export default BulkRemovePuppetProxyScene;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { bulkActionErrorToastParams } from '../toastHelpers';
|
|
2
|
+
|
|
3
|
+
jest.mock('foremanReact/components/HostsIndex/BulkActions/helpers', () => ({
|
|
4
|
+
failedHostsToastParams: jest.fn(params => params),
|
|
5
|
+
}));
|
|
6
|
+
|
|
7
|
+
describe('bulkActionErrorToastParams', () => {
|
|
8
|
+
const actionKey = 'BULK_ACTION_KEY';
|
|
9
|
+
const fallbackMessage = 'Fallback error';
|
|
10
|
+
|
|
11
|
+
it('uses the API error payload message when present', () => {
|
|
12
|
+
const response = {
|
|
13
|
+
data: {
|
|
14
|
+
error: {
|
|
15
|
+
message: 'API error',
|
|
16
|
+
failed_host_ids: [1, 2],
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
expect(
|
|
22
|
+
bulkActionErrorToastParams(response, fallbackMessage, actionKey)
|
|
23
|
+
).toEqual({
|
|
24
|
+
message: 'API error',
|
|
25
|
+
failed_host_ids: [1, 2],
|
|
26
|
+
key: actionKey,
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('supports axios-style wrapped error responses', () => {
|
|
31
|
+
const response = {
|
|
32
|
+
response: {
|
|
33
|
+
data: {
|
|
34
|
+
error: {
|
|
35
|
+
message: 'Wrapped API error',
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
expect(
|
|
42
|
+
bulkActionErrorToastParams(response, fallbackMessage, actionKey)
|
|
43
|
+
).toEqual({
|
|
44
|
+
message: 'Wrapped API error',
|
|
45
|
+
key: actionKey,
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('falls back to the generic message when the API message is missing', () => {
|
|
50
|
+
expect(bulkActionErrorToastParams({}, fallbackMessage, actionKey)).toEqual({
|
|
51
|
+
message: fallbackMessage,
|
|
52
|
+
key: actionKey,
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { failedHostsToastParams } from 'foremanReact/components/HostsIndex/BulkActions/helpers';
|
|
2
|
+
|
|
3
|
+
export const bulkActionErrorToastParams = (
|
|
4
|
+
response,
|
|
5
|
+
fallbackMessage,
|
|
6
|
+
actionKey
|
|
7
|
+
) => {
|
|
8
|
+
const error = response?.data?.error || response?.response?.data?.error || {};
|
|
9
|
+
|
|
10
|
+
return failedHostsToastParams({
|
|
11
|
+
...error,
|
|
12
|
+
message: error.message || fallbackMessage,
|
|
13
|
+
key: actionKey,
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export default bulkActionErrorToastParams;
|
|
@@ -37,7 +37,7 @@ describe('checkForUnavailablePuppetclasses', () => {
|
|
|
37
37
|
);
|
|
38
38
|
|
|
39
39
|
checkForUnavailablePuppetclasses();
|
|
40
|
-
expect($('#puppetclasses_unavailable_warning')
|
|
40
|
+
expect($('#puppetclasses_unavailable_warning')).toHaveLength(1);
|
|
41
41
|
});
|
|
42
42
|
|
|
43
43
|
it('does not add a warning if no unavailable classes are found', () => {
|
|
@@ -48,8 +48,8 @@ describe('checkForUnavailablePuppetclasses', () => {
|
|
|
48
48
|
expect(
|
|
49
49
|
$('#hostgroup .help-block')
|
|
50
50
|
.first()
|
|
51
|
-
.children()
|
|
52
|
-
).
|
|
51
|
+
.children()
|
|
52
|
+
).toHaveLength(0);
|
|
53
53
|
});
|
|
54
54
|
|
|
55
55
|
it('adds a warning sign to the tab if unavailable classes are found', () => {
|
|
@@ -58,7 +58,7 @@ describe('checkForUnavailablePuppetclasses', () => {
|
|
|
58
58
|
);
|
|
59
59
|
checkForUnavailablePuppetclasses();
|
|
60
60
|
setTimeout(() => {
|
|
61
|
-
expect($('a .pficon')
|
|
61
|
+
expect($('a .pficon')).toHaveLength(1);
|
|
62
62
|
}, 100);
|
|
63
63
|
});
|
|
64
64
|
});
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: foreman_puppet
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 10.
|
|
4
|
+
version: 10.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ondřej Ezr
|
|
@@ -61,6 +61,7 @@ files:
|
|
|
61
61
|
- app/controllers/foreman_puppet/api/v2/environments_controller.rb
|
|
62
62
|
- app/controllers/foreman_puppet/api/v2/host_classes_controller.rb
|
|
63
63
|
- app/controllers/foreman_puppet/api/v2/hostgroup_classes_controller.rb
|
|
64
|
+
- app/controllers/foreman_puppet/api/v2/hosts_bulk_actions_controller.rb
|
|
64
65
|
- app/controllers/foreman_puppet/api/v2/override_values_controller.rb
|
|
65
66
|
- app/controllers/foreman_puppet/api/v2/puppet_base_controller.rb
|
|
66
67
|
- app/controllers/foreman_puppet/api/v2/puppet_lookups_common_controller.rb
|
|
@@ -113,6 +114,7 @@ files:
|
|
|
113
114
|
- app/models/foreman_puppet/puppetclass.rb
|
|
114
115
|
- app/models/foreman_puppet/puppetclass_lookup_key.rb
|
|
115
116
|
- app/prepend_views/api/v2/template_combinations/base.json.rabl
|
|
117
|
+
- app/services/concerns/foreman_puppet/extensions/bulk_hosts_manager.rb
|
|
116
118
|
- app/services/concerns/foreman_puppet/extensions/host_counter.rb
|
|
117
119
|
- app/services/foreman_puppet/host_info_providers/config_groups_info.rb
|
|
118
120
|
- app/services/foreman_puppet/host_info_providers/puppet_info.rb
|
|
@@ -282,6 +284,7 @@ files:
|
|
|
282
284
|
- test/controllers/foreman_puppet/api/v2/host_classes_controller_test.rb
|
|
283
285
|
- test/controllers/foreman_puppet/api/v2/hostgroup_classes_controller_test.rb
|
|
284
286
|
- test/controllers/foreman_puppet/api/v2/hostgroups_controller_test.rb
|
|
287
|
+
- test/controllers/foreman_puppet/api/v2/hosts_bulk_actions_controller_test.rb
|
|
285
288
|
- test/controllers/foreman_puppet/api/v2/hosts_controller_test.rb
|
|
286
289
|
- test/controllers/foreman_puppet/api/v2/lookups_common_controller_test.rb
|
|
287
290
|
- test/controllers/foreman_puppet/api/v2/override_values_controller_test.rb
|
|
@@ -335,6 +338,7 @@ files:
|
|
|
335
338
|
- test/models/foreman_puppet/report_test.rb
|
|
336
339
|
- test/models/foreman_puppet/smart_proxy_test.rb
|
|
337
340
|
- test/models/foreman_puppet/user_test.rb
|
|
341
|
+
- test/services/foreman_puppet/bulk_hosts_manager_test.rb
|
|
338
342
|
- test/services/foreman_puppet/host_counter_test.rb
|
|
339
343
|
- test/services/foreman_puppet/host_info_providers/config_groups_info_test.rb
|
|
340
344
|
- test/services/foreman_puppet/host_info_providers/puppet_info_test.rb
|
|
@@ -373,6 +377,24 @@ files:
|
|
|
373
377
|
- webpack/src/Extends/Host/PuppetTab/helpers.js
|
|
374
378
|
- webpack/src/Extends/Host/PuppetTab/index.js
|
|
375
379
|
- webpack/src/Extends/Host/PuppetTab/styles.scss
|
|
380
|
+
- webpack/src/Extends/Hosts/ActionsBar/ActionsBar.scss
|
|
381
|
+
- webpack/src/Extends/Hosts/ActionsBar/index.js
|
|
382
|
+
- webpack/src/Extends/Hosts/BulkActions/BulkChangeProxyCommon/__tests__/actions.test.js
|
|
383
|
+
- webpack/src/Extends/Hosts/BulkActions/BulkChangeProxyCommon/actions.js
|
|
384
|
+
- webpack/src/Extends/Hosts/BulkActions/BulkChangeProxyCommon/index.js
|
|
385
|
+
- webpack/src/Extends/Hosts/BulkActions/BulkChangePuppetCAProxy/__tests__/index.test.js
|
|
386
|
+
- webpack/src/Extends/Hosts/BulkActions/BulkChangePuppetCAProxy/index.js
|
|
387
|
+
- webpack/src/Extends/Hosts/BulkActions/BulkChangePuppetProxy/__tests__/index.test.js
|
|
388
|
+
- webpack/src/Extends/Hosts/BulkActions/BulkChangePuppetProxy/index.js
|
|
389
|
+
- webpack/src/Extends/Hosts/BulkActions/BulkRemoveProxyCommon/__tests__/actions.test.js
|
|
390
|
+
- webpack/src/Extends/Hosts/BulkActions/BulkRemoveProxyCommon/actions.js
|
|
391
|
+
- webpack/src/Extends/Hosts/BulkActions/BulkRemoveProxyCommon/index.js
|
|
392
|
+
- webpack/src/Extends/Hosts/BulkActions/BulkRemovePuppetCAProxy/__tests__/index.test.js
|
|
393
|
+
- webpack/src/Extends/Hosts/BulkActions/BulkRemovePuppetCAProxy/index.js
|
|
394
|
+
- webpack/src/Extends/Hosts/BulkActions/BulkRemovePuppetProxy/__tests__/index.test.js
|
|
395
|
+
- webpack/src/Extends/Hosts/BulkActions/BulkRemovePuppetProxy/index.js
|
|
396
|
+
- webpack/src/Extends/Hosts/BulkActions/__tests__/toastHelpers.test.js
|
|
397
|
+
- webpack/src/Extends/Hosts/BulkActions/toastHelpers.js
|
|
376
398
|
- webpack/src/ForemanPuppet.js
|
|
377
399
|
- webpack/src/Router/__snapshots__/routes.test.js.snap
|
|
378
400
|
- webpack/src/Router/index.js
|
|
@@ -404,7 +426,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
404
426
|
- !ruby/object:Gem::Version
|
|
405
427
|
version: '0'
|
|
406
428
|
requirements: []
|
|
407
|
-
rubygems_version: 4.0.
|
|
429
|
+
rubygems_version: 4.0.10
|
|
408
430
|
specification_version: 4
|
|
409
431
|
summary: Add Puppet features to Foreman
|
|
410
432
|
test_files:
|
|
@@ -413,6 +435,7 @@ test_files:
|
|
|
413
435
|
- test/controllers/foreman_puppet/api/v2/host_classes_controller_test.rb
|
|
414
436
|
- test/controllers/foreman_puppet/api/v2/hostgroup_classes_controller_test.rb
|
|
415
437
|
- test/controllers/foreman_puppet/api/v2/hostgroups_controller_test.rb
|
|
438
|
+
- test/controllers/foreman_puppet/api/v2/hosts_bulk_actions_controller_test.rb
|
|
416
439
|
- test/controllers/foreman_puppet/api/v2/hosts_controller_test.rb
|
|
417
440
|
- test/controllers/foreman_puppet/api/v2/lookups_common_controller_test.rb
|
|
418
441
|
- test/controllers/foreman_puppet/api/v2/override_values_controller_test.rb
|
|
@@ -466,6 +489,7 @@ test_files:
|
|
|
466
489
|
- test/models/foreman_puppet/report_test.rb
|
|
467
490
|
- test/models/foreman_puppet/smart_proxy_test.rb
|
|
468
491
|
- test/models/foreman_puppet/user_test.rb
|
|
492
|
+
- test/services/foreman_puppet/bulk_hosts_manager_test.rb
|
|
469
493
|
- test/services/foreman_puppet/host_counter_test.rb
|
|
470
494
|
- test/services/foreman_puppet/host_info_providers/config_groups_info_test.rb
|
|
471
495
|
- test/services/foreman_puppet/host_info_providers/puppet_info_test.rb
|