foreman_scc_manager 5.3.1 → 5.4.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/lib/foreman_scc_manager/version.rb +1 -1
- data/webpack/components/SCCAccountForm/components/DateTimeField.js +4 -1
- data/webpack/components/SCCAccountIndex/SCCAccountIndexActions.js +3 -1
- data/webpack/components/SCCProductPage/SCCProductPage.js +5 -18
- data/webpack/components/SCCProductPage/SCCProductPageConstants.js +0 -1
- data/webpack/components/SCCProductPage/components/SCCProductPicker/components/SCCGenericPicker/index.js +3 -2
- data/webpack/components/SCCProductPage/components/SCCProductPicker/components/SCCTreePicker/components/SCCRepoPicker/index.js +1 -0
- data/webpack/components/SCCProductPage/components/SCCProductPickerModal/SCCProductPickerModal.test.js +69 -0
- data/webpack/components/SCCProductPage/components/SCCProductPickerModal/index.js +46 -39
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b52bcdb6e07b2cdef965068534e58d4c8774aaa6324c07313e9f1b6826601cda
|
|
4
|
+
data.tar.gz: 1af1c59be010d873fa65aa70ba4d9d893abee2fcc8cc22ceb5c994cc310ec903
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e2c0ea23ca1bc8fb2f63a9965c7d0f29e80e27c9a9b033354e5f2132e4e3ef07ed13b2034cedfcc86c8a7c4e994731f4a0d679829d972f9b9bb011179a2ae0c0
|
|
7
|
+
data.tar.gz: 51a87268a1fea3e5e6ac7b99330c835feb57ad551185bce8e7f79777fb7caf133011337f4c510dc5faff11bd9ab09bd30862670e28fc2c41cece01112f04120c
|
|
@@ -8,6 +8,8 @@ import {
|
|
|
8
8
|
} from '@patternfly/react-core';
|
|
9
9
|
import { translate as __ } from 'foremanReact/common/I18n';
|
|
10
10
|
|
|
11
|
+
const HOURS_DAY_MAX = 12;
|
|
12
|
+
|
|
11
13
|
export const formatDateTime = (dateStr, timeStr) => {
|
|
12
14
|
if (!dateStr || !timeStr) return undefined;
|
|
13
15
|
|
|
@@ -16,7 +18,8 @@ export const formatDateTime = (dateStr, timeStr) => {
|
|
|
16
18
|
|
|
17
19
|
const [, hourStr, minuteStr, ampm] = match;
|
|
18
20
|
const hour24 =
|
|
19
|
-
(parseInt(hourStr, 10) %
|
|
21
|
+
(parseInt(hourStr, 10) % HOURS_DAY_MAX) +
|
|
22
|
+
(ampm.toUpperCase() === 'PM' ? HOURS_DAY_MAX : 0);
|
|
20
23
|
|
|
21
24
|
const [year, month, day] = dateStr.split('-').map(Number);
|
|
22
25
|
if (!year || !month || !day) return undefined;
|
|
@@ -3,6 +3,8 @@ import { translate as __ } from 'foremanReact/common/I18n';
|
|
|
3
3
|
|
|
4
4
|
import { INITIAL_DELAY, MAX_DELAY, BACKOFF } from './SCCAccountIndexConstants';
|
|
5
5
|
|
|
6
|
+
const TIMEOUT_API_MSEC = 15000;
|
|
7
|
+
|
|
6
8
|
const isDone = (state, result) =>
|
|
7
9
|
state === 'stopped' || result === 'success' || result === 'error';
|
|
8
10
|
|
|
@@ -157,7 +159,7 @@ export const syncSccAccountAction = (
|
|
|
157
159
|
taskTimeoutRef,
|
|
158
160
|
lastStateRef
|
|
159
161
|
);
|
|
160
|
-
},
|
|
162
|
+
}, TIMEOUT_API_MSEC);
|
|
161
163
|
},
|
|
162
164
|
handleError: () => {
|
|
163
165
|
setAccounts((prev) =>
|
|
@@ -1,35 +1,22 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
2
|
import React, { useState } from 'react';
|
|
3
3
|
import { Stack, StackItem } from '@patternfly/react-core';
|
|
4
|
-
import { useDispatch } from 'react-redux';
|
|
5
|
-
import { translate as __ } from 'foremanReact/common/I18n';
|
|
6
|
-
import { useForemanModal } from 'foremanReact/components/ForemanModal/ForemanModalHooks';
|
|
7
4
|
import SCCProductView from './components/SCCProductView';
|
|
8
5
|
import { EmptySccProducts } from './EmptySccProducts';
|
|
9
6
|
import SCCProductPicker from './components/SCCProductPicker';
|
|
10
7
|
import SCCProductPickerModal from './components/SCCProductPickerModal';
|
|
11
|
-
import { SCCPRODUCTPAGE_SUMMARY_MODAL_ID } from './SCCProductPageConstants';
|
|
12
8
|
import './sccProductPage.scss';
|
|
13
9
|
|
|
14
|
-
const SCCProductPage = ({
|
|
15
|
-
canCreate,
|
|
16
|
-
sccAccountId,
|
|
17
|
-
sccProductsInit,
|
|
18
|
-
...props
|
|
19
|
-
}) => {
|
|
20
|
-
const dispatch = useDispatch();
|
|
10
|
+
const SCCProductPage = ({ canCreate, sccAccountId, sccProductsInit }) => {
|
|
21
11
|
const [productToEdit, setProductToEdit] = useState(0);
|
|
22
12
|
const [reposToSubscribe, setReposToSubscribe] = useState([]);
|
|
23
13
|
const [subscriptionTaskId, setSubscriptionTaskId] = useState();
|
|
14
|
+
const [isSummaryModalOpen, setIsSummaryModalOpen] = useState(false);
|
|
24
15
|
|
|
25
16
|
const editProductTree = (productId) => {
|
|
26
17
|
setProductToEdit(productId);
|
|
27
18
|
};
|
|
28
19
|
|
|
29
|
-
const { setModalOpen } = useForemanModal({
|
|
30
|
-
id: SCCPRODUCTPAGE_SUMMARY_MODAL_ID,
|
|
31
|
-
});
|
|
32
|
-
|
|
33
20
|
const handleSubscribeCallback = (
|
|
34
21
|
subscriptionTaskIdFromAction,
|
|
35
22
|
reposToSubscribeFromAction
|
|
@@ -44,15 +31,15 @@ const SCCProductPage = ({
|
|
|
44
31
|
newReposToSubscribe.push(repo);
|
|
45
32
|
});
|
|
46
33
|
setReposToSubscribe(newReposToSubscribe);
|
|
47
|
-
|
|
34
|
+
setIsSummaryModalOpen(true);
|
|
48
35
|
};
|
|
49
36
|
|
|
50
37
|
return sccProductsInit.length > 0 ? (
|
|
51
38
|
<Stack>
|
|
52
39
|
<StackItem>
|
|
53
40
|
<SCCProductPickerModal
|
|
54
|
-
|
|
55
|
-
|
|
41
|
+
isOpen={isSummaryModalOpen}
|
|
42
|
+
onClose={() => setIsSummaryModalOpen(false)}
|
|
56
43
|
taskId={subscriptionTaskId}
|
|
57
44
|
reposToSubscribe={reposToSubscribe}
|
|
58
45
|
/>
|
|
@@ -16,6 +16,8 @@ import { TimesIcon } from '@patternfly/react-icons';
|
|
|
16
16
|
import { translate as __ } from 'foremanReact/common/I18n';
|
|
17
17
|
import '../../../SCCProductPicker/styles.scss';
|
|
18
18
|
|
|
19
|
+
const NO_RESULTS = __('no results');
|
|
20
|
+
|
|
19
21
|
const GenericSelector = ({
|
|
20
22
|
initialSelectOptions,
|
|
21
23
|
setSelected,
|
|
@@ -34,7 +36,6 @@ const GenericSelector = ({
|
|
|
34
36
|
);
|
|
35
37
|
const [focusedItemIndex, setFocusedItemIndex] = useState(null);
|
|
36
38
|
const [activeItemId, setActiveItemId] = useState(null);
|
|
37
|
-
const NO_RESULTS = __('no results');
|
|
38
39
|
|
|
39
40
|
useEffect(() => {
|
|
40
41
|
let newSelectOptions = initialSelectOptions.map((option) => ({
|
|
@@ -61,7 +62,7 @@ const GenericSelector = ({
|
|
|
61
62
|
}
|
|
62
63
|
}
|
|
63
64
|
setSelectOptions(newSelectOptions);
|
|
64
|
-
}, [filterValue, initialSelectOptions]);
|
|
65
|
+
}, [filterValue, initialSelectOptions, isOpen]);
|
|
65
66
|
const createItemId = (value) =>
|
|
66
67
|
`select-typeahead-${value?.replace(' ', '-')}`;
|
|
67
68
|
const setActiveAndFocusedItem = (itemIndex) => {
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/* eslint-disable react/prop-types, import/no-unresolved */
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import '@testing-library/jest-dom';
|
|
4
|
+
import { fireEvent, render, screen, within } from '@testing-library/react';
|
|
5
|
+
|
|
6
|
+
import SCCProductPickerModal from './index';
|
|
7
|
+
|
|
8
|
+
describe('SCCProductPickerModal', () => {
|
|
9
|
+
const defaultProps = {
|
|
10
|
+
isOpen: true,
|
|
11
|
+
onClose: jest.fn(),
|
|
12
|
+
taskId: 'task-123',
|
|
13
|
+
reposToSubscribe: [
|
|
14
|
+
{
|
|
15
|
+
productName: 'SLES',
|
|
16
|
+
repoNames: ['Repo A', 'Repo B'],
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
productName: 'Tools',
|
|
20
|
+
repoNames: ['Repo C'],
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
beforeEach(() => {
|
|
26
|
+
jest.clearAllMocks();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('does not render when closed', () => {
|
|
30
|
+
render(<SCCProductPickerModal {...defaultProps} isOpen={false} />);
|
|
31
|
+
|
|
32
|
+
expect(
|
|
33
|
+
screen.queryByRole('dialog', {
|
|
34
|
+
name: 'Summary of SCC product subscription',
|
|
35
|
+
})
|
|
36
|
+
).not.toBeInTheDocument();
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('renders the subscription summary, task link, and imported products', () => {
|
|
40
|
+
render(<SCCProductPickerModal {...defaultProps} />);
|
|
41
|
+
|
|
42
|
+
const dialog = screen.getByRole('dialog', {
|
|
43
|
+
name: 'Summary of SCC product subscription',
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
expect(
|
|
47
|
+
within(dialog).getByText(/The subscription task with id/i)
|
|
48
|
+
).toBeInTheDocument();
|
|
49
|
+
expect(
|
|
50
|
+
within(dialog).getByRole('link', { name: 'task-123' })
|
|
51
|
+
).toHaveAttribute('href', '/foreman_tasks/tasks/task-123');
|
|
52
|
+
expect(
|
|
53
|
+
within(dialog).getByText('The following products will be imported:')
|
|
54
|
+
).toBeInTheDocument();
|
|
55
|
+
expect(within(dialog).getByText('SLES')).toBeInTheDocument();
|
|
56
|
+
expect(within(dialog).getByText('Repo A')).toBeInTheDocument();
|
|
57
|
+
expect(within(dialog).getByText('Repo B')).toBeInTheDocument();
|
|
58
|
+
expect(within(dialog).getByText('Tools')).toBeInTheDocument();
|
|
59
|
+
expect(within(dialog).getByText('Repo C')).toBeInTheDocument();
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('calls onClose when the modal is closed', () => {
|
|
63
|
+
render(<SCCProductPickerModal {...defaultProps} />);
|
|
64
|
+
|
|
65
|
+
fireEvent.click(screen.getByRole('button', { name: 'Close' }));
|
|
66
|
+
|
|
67
|
+
expect(defaultProps.onClose).toHaveBeenCalledTimes(1);
|
|
68
|
+
});
|
|
69
|
+
});
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import React, { Fragment } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import ForemanModal from 'foremanReact/components/ForemanModal';
|
|
4
3
|
|
|
5
4
|
import { sprintf, translate as __ } from 'foremanReact/common/I18n';
|
|
6
5
|
import {
|
|
7
6
|
Card,
|
|
8
7
|
CardBody,
|
|
8
|
+
Modal,
|
|
9
9
|
TextContent,
|
|
10
10
|
Text,
|
|
11
11
|
TextList,
|
|
@@ -34,55 +34,62 @@ const generateProductList = (reposToSubscribe) => (
|
|
|
34
34
|
</TextList>
|
|
35
35
|
);
|
|
36
36
|
|
|
37
|
-
const SCCProductPickerModal = ({
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
>
|
|
59
|
-
{sprintf('%s', taskId)}
|
|
60
|
-
</Text>
|
|
61
|
-
{__(' has started successfully.')}
|
|
62
|
-
</Text>
|
|
37
|
+
const SCCProductPickerModal = ({
|
|
38
|
+
isOpen,
|
|
39
|
+
onClose,
|
|
40
|
+
taskId,
|
|
41
|
+
reposToSubscribe,
|
|
42
|
+
}) => (
|
|
43
|
+
<Modal
|
|
44
|
+
ouiaId="scc-product-picker-modal"
|
|
45
|
+
title={__('Summary of SCC product subscription')}
|
|
46
|
+
isOpen={isOpen}
|
|
47
|
+
onClose={onClose}
|
|
48
|
+
variant="medium"
|
|
49
|
+
>
|
|
50
|
+
<Card ouiaId="scc-product-picker-modal-card">
|
|
51
|
+
<CardBody>
|
|
52
|
+
<TextContent key={taskId}>
|
|
53
|
+
<Text
|
|
54
|
+
ouiaId={'scc-subscription-task-message-'.concat(taskId)}
|
|
55
|
+
key={'scc-subscription-task-message-'.concat(taskId)}
|
|
56
|
+
>
|
|
57
|
+
{__('The subscription task with id ')}
|
|
63
58
|
<Text
|
|
64
|
-
ouiaId={'
|
|
65
|
-
key={'
|
|
59
|
+
ouiaId={'scc-subscription-task-link-'.concat(taskId)}
|
|
60
|
+
key={'scc-subscription-task-link-'.concat(taskId)}
|
|
61
|
+
component={TextVariants.a}
|
|
62
|
+
target="_blank"
|
|
63
|
+
href={sprintf('/foreman_tasks/tasks/%s', taskId)}
|
|
66
64
|
>
|
|
67
|
-
{
|
|
65
|
+
{sprintf('%s', taskId)}
|
|
68
66
|
</Text>
|
|
69
|
-
{
|
|
70
|
-
</
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
67
|
+
{__(' has started successfully.')}
|
|
68
|
+
</Text>
|
|
69
|
+
<Text
|
|
70
|
+
ouiaId={'scc-subscription-import-summary-'.concat(taskId)}
|
|
71
|
+
key={'scc-subscription-import-summary-'.concat(taskId)}
|
|
72
|
+
>
|
|
73
|
+
{__('The following products will be imported:')}
|
|
74
|
+
</Text>
|
|
75
|
+
{generateProductList(reposToSubscribe)}
|
|
76
|
+
</TextContent>
|
|
77
|
+
</CardBody>
|
|
78
|
+
</Card>
|
|
79
|
+
</Modal>
|
|
75
80
|
);
|
|
76
81
|
SCCProductPickerModal.propTypes = {
|
|
77
|
-
|
|
82
|
+
isOpen: PropTypes.bool,
|
|
83
|
+
onClose: PropTypes.func,
|
|
78
84
|
taskId: PropTypes.string,
|
|
79
85
|
reposToSubscribe: PropTypes.array,
|
|
80
86
|
};
|
|
81
87
|
|
|
82
88
|
SCCProductPickerModal.defaultProps = {
|
|
83
|
-
|
|
89
|
+
isOpen: false,
|
|
90
|
+
onClose: () => {},
|
|
84
91
|
taskId: '',
|
|
85
|
-
reposToSubscribe:
|
|
92
|
+
reposToSubscribe: [],
|
|
86
93
|
};
|
|
87
94
|
|
|
88
95
|
export default SCCProductPickerModal;
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: foreman_scc_manager
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 5.
|
|
4
|
+
version: 5.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- ATIX AG
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-
|
|
10
|
+
date: 2026-08-05 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: rdoc
|
|
@@ -220,6 +220,7 @@ files:
|
|
|
220
220
|
- webpack/components/SCCProductPage/components/SCCProductPicker/components/SCCTreePicker/index.js
|
|
221
221
|
- webpack/components/SCCProductPage/components/SCCProductPicker/index.js
|
|
222
222
|
- webpack/components/SCCProductPage/components/SCCProductPicker/styles.scss
|
|
223
|
+
- webpack/components/SCCProductPage/components/SCCProductPickerModal/SCCProductPickerModal.test.js
|
|
223
224
|
- webpack/components/SCCProductPage/components/SCCProductPickerModal/index.js
|
|
224
225
|
- webpack/components/SCCProductPage/components/SCCProductView/components/SCCRepoView/index.js
|
|
225
226
|
- webpack/components/SCCProductPage/components/SCCProductView/components/SCCRepoView/styles.scss
|