@rh-support/manage 1.0.301-beta.2 → 1.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.
Files changed (77) hide show
  1. package/lib/esm/ManageTab.d.ts.map +1 -1
  2. package/lib/esm/ManageTab.js +3 -2
  3. package/lib/esm/ManageTabs.d.ts.map +1 -1
  4. package/lib/esm/ManageTabs.js +4 -21
  5. package/lib/esm/Routes.d.ts +0 -1
  6. package/lib/esm/Routes.d.ts.map +1 -1
  7. package/lib/esm/Routes.js +0 -6
  8. package/lib/esm/components/Configs/ConfigInLineEdit.js +1 -1
  9. package/lib/esm/components/Groups/GroupUserPermissionsSelect/GroupUserPermissionsSelect.js +1 -1
  10. package/lib/esm/components/Groups/ManageGroupUsers/ManageGroupUsers.d.ts.map +1 -1
  11. package/lib/esm/components/Groups/ManageGroupUsers/ManageGroupUsers.js +9 -0
  12. package/lib/esm/components/ManageBookmarkedAccountsTab/AddEditBookmarkModal.d.ts.map +1 -1
  13. package/lib/esm/components/ManageBookmarkedAccountsTab/AddEditBookmarkModal.js +24 -11
  14. package/lib/esm/components/ManageBookmarkedAccountsTab/BookmarkAccountSelector.d.ts.map +1 -1
  15. package/lib/esm/components/ManageBookmarkedAccountsTab/BookmarkAccountSelector.js +4 -4
  16. package/lib/esm/components/ManageBookmarkedAccountsTab/BookmarkGroupSelector.d.ts +3 -0
  17. package/lib/esm/components/ManageBookmarkedAccountsTab/BookmarkGroupSelector.d.ts.map +1 -1
  18. package/lib/esm/components/ManageBookmarkedAccountsTab/BookmarkGroupSelector.js +9 -23
  19. package/lib/esm/components/ManageBookmarkedAccountsTab/ManageGroupedBookmarkedAccountsTab.d.ts.map +1 -1
  20. package/lib/esm/components/ManageBookmarkedAccountsTab/ManageGroupedBookmarkedAccountsTab.js +45 -30
  21. package/lib/esm/components/ManagePreferences/sections/PreferencesCaseCreate.d.ts.map +1 -1
  22. package/lib/esm/components/ManagePreferences/sections/PreferencesCaseCreate.js +63 -54
  23. package/lib/esm/components/ManageTable/ManageTable.d.ts +0 -1
  24. package/lib/esm/components/ManageTable/ManageTable.d.ts.map +1 -1
  25. package/lib/esm/components/ManageTable/ManageTable.js +3 -4
  26. package/lib/esm/components/NotificationEmails/NotificationEmailsModal.d.ts.map +1 -1
  27. package/lib/esm/components/NotificationEmails/NotificationEmailsModal.js +1 -0
  28. package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentCategoryContent/AddNewCategoryDropDown.d.ts.map +1 -1
  29. package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentCategoryContent/AddNewCategoryDropDown.js +29 -10
  30. package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentEditor.d.ts.map +1 -1
  31. package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentEditor.js +3 -1
  32. package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentSuggestion/TopContentSuggestion.d.ts +6 -0
  33. package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentSuggestion/TopContentSuggestion.d.ts.map +1 -0
  34. package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentSuggestion/TopContentSuggestion.js +30 -0
  35. package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentSuggestion/TopContentSuggestionHint.d.ts +8 -0
  36. package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentSuggestion/TopContentSuggestionHint.d.ts.map +1 -0
  37. package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentSuggestion/TopContentSuggestionHint.js +64 -0
  38. package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentSuggestion/TopContentSuggestionHintAccept.d.ts +9 -0
  39. package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentSuggestion/TopContentSuggestionHintAccept.d.ts.map +1 -0
  40. package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentSuggestion/TopContentSuggestionHintAccept.js +142 -0
  41. package/lib/esm/components/TopContentManagement/TopContentProductVersionSelector.d.ts.map +1 -1
  42. package/lib/esm/components/TopContentManagement/TopContentProductVersionSelector.js +31 -30
  43. package/lib/esm/context/TopContentProvider.d.ts.map +1 -1
  44. package/lib/esm/context/TopContentProvider.js +1 -0
  45. package/lib/esm/reducers/TopContentReducer.d.ts +32 -2
  46. package/lib/esm/reducers/TopContentReducer.d.ts.map +1 -1
  47. package/lib/esm/reducers/TopContentReducer.js +82 -13
  48. package/lib/esm/scss/_main.scss +8 -0
  49. package/lib/esm/scss/_pf4-overrides.scss +22 -0
  50. package/package.json +10 -10
  51. package/lib/esm/components/ManagePartnerships/NonOrgCustomerInfoModal.d.ts +0 -2
  52. package/lib/esm/components/ManagePartnerships/NonOrgCustomerInfoModal.d.ts.map +0 -1
  53. package/lib/esm/components/ManagePartnerships/NonOrgCustomerInfoModal.js +0 -15
  54. package/lib/esm/components/ManagePartnerships/PartnerLinkNameForm.d.ts +0 -12
  55. package/lib/esm/components/ManagePartnerships/PartnerLinkNameForm.d.ts.map +0 -1
  56. package/lib/esm/components/ManagePartnerships/PartnerLinkNameForm.js +0 -21
  57. package/lib/esm/components/ManagePartnerships/PartnershipsList.d.ts +0 -2
  58. package/lib/esm/components/ManagePartnerships/PartnershipsList.d.ts.map +0 -1
  59. package/lib/esm/components/ManagePartnerships/PartnershipsList.js +0 -164
  60. package/lib/esm/components/ManagePartnerships/PartnershipsTermsModal.d.ts +0 -2
  61. package/lib/esm/components/ManagePartnerships/PartnershipsTermsModal.d.ts.map +0 -1
  62. package/lib/esm/components/ManagePartnerships/PartnershipsTermsModal.js +0 -97
  63. package/lib/esm/components/ManagePartnerships/PendingRequests.d.ts +0 -3
  64. package/lib/esm/components/ManagePartnerships/PendingRequests.d.ts.map +0 -1
  65. package/lib/esm/components/ManagePartnerships/PendingRequests.js +0 -190
  66. package/lib/esm/components/ManagePartnerships/RequestCollaborationModal.d.ts +0 -8
  67. package/lib/esm/components/ManagePartnerships/RequestCollaborationModal.d.ts.map +0 -1
  68. package/lib/esm/components/ManagePartnerships/RequestCollaborationModal.js +0 -130
  69. package/lib/esm/components/ManagePartnerships/index.d.ts +0 -2
  70. package/lib/esm/components/ManagePartnerships/index.d.ts.map +0 -1
  71. package/lib/esm/components/ManagePartnerships/index.js +0 -27
  72. package/lib/esm/context/ManagePartnershipsProvider.d.ts +0 -11
  73. package/lib/esm/context/ManagePartnershipsProvider.d.ts.map +0 -1
  74. package/lib/esm/context/ManagePartnershipsProvider.js +0 -26
  75. package/lib/esm/reducers/ManagePartnershipsReducer.d.ts +0 -16
  76. package/lib/esm/reducers/ManagePartnershipsReducer.d.ts.map +0 -1
  77. package/lib/esm/reducers/ManagePartnershipsReducer.js +0 -30
@@ -1,164 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { pcm } from '@cee-eng/hydrajs';
11
- import { AlertVariant, Button, ButtonVariant, SearchInput } from '@patternfly/react-core';
12
- import TrashIcon from '@patternfly/react-icons/dist/js/icons/trash-icon';
13
- import { defaultTableSortMethod, LoadingIndicator, ToastNotification, useConfirmation, } from '@rh-support/components';
14
- import { fetchAccountManagers, fetchManagedAccounts, GlobalMetadataDispatchContext, useGlobalStateContext, } from '@rh-support/react-context';
15
- import { haventLoadedMetadata } from '@rh-support/utils';
16
- import React, { useContext, useEffect, useState } from 'react';
17
- import { Trans, useTranslation } from 'react-i18next';
18
- import { useManagePartnershipsContext, useManagePartnershipsDispatchContext, } from '../../context/ManagePartnershipsProvider';
19
- import { setIsUpdatingAccounts } from '../../reducers/ManagePartnershipsReducer';
20
- import { ManageTable } from '../ManageTable';
21
- import { RequestCollaborationModal } from './RequestCollaborationModal';
22
- export function PartnershipsList() {
23
- const { t } = useTranslation();
24
- const confirmRemove = useConfirmation();
25
- const [searchString, setSearchString] = useState('');
26
- const [isRequestCollabModalOpen, setIsRequestCollabModalOpen] = useState(false);
27
- const [accountList, setAccountList] = useState([]);
28
- const [isFetching, setIsFetching] = useState(false);
29
- const [hasError, setHasError] = useState(false);
30
- const [isDeleting, setIsdeleting] = useState(false);
31
- const [isDeletingAccountNum, setIsdeletingAccountNum] = useState('');
32
- const { isUpdatingPartnerAccountList } = useManagePartnershipsContext();
33
- const dispatch = useManagePartnershipsDispatchContext();
34
- const { globalMetadataState: { loggedInUserRights, managedAccounts, accountManagers, loggedInUserJwtToken }, } = useGlobalStateContext();
35
- const dispatchToGlobalMetadataReducer = useContext(GlobalMetadataDispatchContext);
36
- const isPartner = () => loggedInUserRights.data.isPartner();
37
- const isCustomerOrgAdmin = () => loggedInUserRights.data.isCustomerOrgAdmin();
38
- console.log('isPartner= ' + isPartner());
39
- const removePartnership = (data) => __awaiter(this, void 0, void 0, function* () {
40
- try {
41
- yield confirmRemove({
42
- catchOnCancel: true,
43
- title: t('Are you sure?'),
44
- description: React.createElement(Trans, null, "You will not be able to undo this action after verifying."),
45
- confirmText: t('Delete'),
46
- confirmButtonVariant: ButtonVariant.danger,
47
- });
48
- try {
49
- setIsdeleting(true);
50
- setIsdeletingAccountNum(data.accountNum);
51
- if (isPartner()) {
52
- yield pcm.partnerships.deleteCustomerAccountByPartner(data.accountNum);
53
- }
54
- else {
55
- yield pcm.partnerships.deletePartnerAccountByCustomer(data.accountNum);
56
- }
57
- setAccountList(accountList.filter((a) => a.accountNum !== data.accountNum));
58
- ToastNotification.addSuccessMessage(t('Partnership removed successfully'));
59
- setIsdeleting(false);
60
- setIsdeletingAccountNum('');
61
- }
62
- catch (e) {
63
- ToastNotification.addDangerMessage(t('Partnership failed to be removed'));
64
- setIsdeleting(false);
65
- setIsdeletingAccountNum('');
66
- }
67
- }
68
- catch (e) {
69
- // on confirm modal, cancel button is clicked
70
- }
71
- });
72
- const columns = [
73
- {
74
- accessor: (data) => data.name,
75
- sortable: false,
76
- id: 'customer-account-name',
77
- title: t('Account name'),
78
- cellWidth: 40,
79
- sortMethod: (a, b) => defaultTableSortMethod(a.toLowerCase(), b.toLowerCase()),
80
- },
81
- {
82
- id: 'customer-account-number',
83
- title: t('Account number'),
84
- sortable: false,
85
- cellWidth: 20,
86
- cell: (data) => data.accountNum,
87
- },
88
- {
89
- id: 'customer-partnership-access-level',
90
- title: t('Access level'),
91
- sortable: false,
92
- cellWidth: 30,
93
- cell: (data) => data.partnerCaseAccess,
94
- },
95
- {
96
- id: 'partnership-delete',
97
- title: ' ',
98
- sortable: false,
99
- cellWidth: 10,
100
- cell: (data) => (React.createElement(Button, { variant: ButtonVariant.plain, "aria-label": t('Remove partnership'), onClick: () => removePartnership(data) },
101
- React.createElement(LoadingIndicator, { isInline: true, show: isDeleting && data.accountNum === isDeletingAccountNum, size: "xs" }),
102
- React.createElement(TrashIcon, null))),
103
- },
104
- ];
105
- const requestCollaborationButton = () => (React.createElement("div", { className: "toolbar-right pf-u-mt-xs" },
106
- React.createElement(Button, { variant: ButtonVariant.primary, isInline: true, onClick: () => setIsRequestCollabModalOpen(true), "data-tracking-id": "request-collaboration-button", isDisabled: false },
107
- React.createElement(Trans, null, "Request Collaboration"))));
108
- // Get Customer Accounts For A Partner
109
- useEffect(() => {
110
- const getManagedAccounts = () => __awaiter(this, void 0, void 0, function* () {
111
- try {
112
- setIsFetching(true);
113
- setHasError(false);
114
- yield fetchManagedAccounts(dispatchToGlobalMetadataReducer, loggedInUserJwtToken);
115
- }
116
- catch (e) {
117
- setHasError(true);
118
- }
119
- setIsFetching(false);
120
- });
121
- if (isPartner() && haventLoadedMetadata(managedAccounts, (data) => data === undefined))
122
- getManagedAccounts();
123
- // eslint-disable-next-line react-hooks/exhaustive-deps
124
- }, [managedAccounts]);
125
- //Get Partner Accounts For A Customer
126
- useEffect(() => {
127
- const getAccountManagers = () => __awaiter(this, void 0, void 0, function* () {
128
- try {
129
- setIsFetching(true);
130
- setHasError(false);
131
- yield fetchAccountManagers(dispatchToGlobalMetadataReducer, loggedInUserJwtToken);
132
- setIsUpdatingAccounts(dispatch, false);
133
- }
134
- catch (e) {
135
- setHasError(true);
136
- }
137
- setIsFetching(false);
138
- });
139
- // when customer accepts a link, need to fetch account data
140
- if (isCustomerOrgAdmin() &&
141
- (haventLoadedMetadata(accountManagers, (data) => data === undefined) || isUpdatingPartnerAccountList))
142
- getAccountManagers();
143
- // eslint-disable-next-line react-hooks/exhaustive-deps
144
- }, [isUpdatingPartnerAccountList]);
145
- useEffect(() => {
146
- if (isPartner()) {
147
- setAccountList(managedAccounts.data);
148
- }
149
- else if (isCustomerOrgAdmin()) {
150
- setAccountList(accountManagers.data);
151
- }
152
- // eslint-disable-next-line react-hooks/exhaustive-deps
153
- }, [managedAccounts, accountManagers]);
154
- return (React.createElement("section", { id: "manage-partnerships-list" },
155
- React.createElement("div", { className: "toolbar" },
156
- React.createElement("div", { className: "toolbar-left" },
157
- React.createElement("label", { htmlFor: "search-partnerships" }, "Filter by"),
158
- React.createElement(SearchInput, { className: "pf-u-flex-grow-1 pf-c-search-input pf-u-background-color-100 pf-u-mr-lg", id: "search-partnerships", placeholder: t('Search for an existing partnership'), value: searchString, onChange: setSearchString, onClear: () => setSearchString(''), "aria-label": t('Search for an existing partnership') })),
159
- isPartner() && requestCollaborationButton()),
160
- React.createElement(ManageTable, { ariaLabel: t('Partnerships list'), columns: columns, data: accountList.filter((account) => account.name.toLowerCase().includes(searchString.toLowerCase())), sortInfo: { column: 'customer-account-name', direction: 'asc' }, errorVariant: AlertVariant.warning, isFetching: isFetching, isError: hasError, errorTitle: t('Partnerships error'), errorComponent: React.createElement(Trans, null, "Could not get partnerships list"), noResultText: t('There are no results to display.') }),
161
- React.createElement(RequestCollaborationModal, { isOpen: isRequestCollabModalOpen, onClose: () => {
162
- setIsRequestCollabModalOpen(false);
163
- } })));
164
- }
@@ -1,2 +0,0 @@
1
- export declare const PartnershipsTermsModal: () => JSX.Element;
2
- //# sourceMappingURL=PartnershipsTermsModal.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PartnershipsTermsModal.d.ts","sourceRoot":"","sources":["../../../../src/components/ManagePartnerships/PartnershipsTermsModal.tsx"],"names":[],"mappings":"AAsBA,eAAO,MAAM,sBAAsB,mBAkLlC,CAAC"}
@@ -1,97 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { pcm } from '@cee-eng/hydrajs';
11
- import { Button, ButtonVariant, Checkbox, Modal, ModalVariant, Text, TextContent, TextVariants, } from '@patternfly/react-core';
12
- import { LoadingDots, ToastNotification } from '@rh-support/components';
13
- import React, { useEffect, useState } from 'react';
14
- import { Trans, useTranslation } from 'react-i18next';
15
- import { useParams } from 'react-router-dom';
16
- import { useManagePartnershipsDispatchContext } from '../../context/ManagePartnershipsProvider';
17
- import { setIsUpdatingAccounts } from '../../reducers/ManagePartnershipsReducer';
18
- export const PartnershipsTermsModal = () => {
19
- const [isContinueClicked, setIsContinueClicked] = useState(false);
20
- const [isTermsChecked, setIsTermsChecked] = useState(false);
21
- const [isUpdating, setIsUpdating] = useState(false);
22
- const [ackChoice, setAckChoice] = useState('');
23
- const [isTermsModalOpen, setIsTermsModalOpen] = useState(true);
24
- const [isVerifyingLink, setIsVerifyingLink] = useState(false);
25
- const [linkAccountName, setLinkAccountName] = useState('');
26
- const [verificationFailMessage, setVerificationFailMessage] = useState('');
27
- const dispatch = useManagePartnershipsDispatchContext();
28
- const onContinue = () => setIsContinueClicked(true);
29
- const { t } = useTranslation();
30
- const { linkHash } = useParams();
31
- const onClose = () => {
32
- setIsTermsModalOpen(false);
33
- setIsContinueClicked(false);
34
- setIsTermsChecked(false);
35
- setAckChoice('');
36
- setIsVerifyingLink(false);
37
- setVerificationFailMessage('');
38
- };
39
- const termAck = (ackResponse) => __awaiter(void 0, void 0, void 0, function* () {
40
- setIsUpdating(true);
41
- setAckChoice(ackResponse);
42
- try {
43
- yield pcm.partnerships.partnerLinkAckResponse(linkHash, ackResponse);
44
- setIsUpdating(false);
45
- setIsUpdatingAccounts(dispatch, true);
46
- }
47
- catch (e) {
48
- ToastNotification.addDangerMessage(ackResponse === 'accept' ? t('Failed to add partnership.') : t('Failed to decline partnership.'), React.createElement(Button, { variant: ButtonVariant.link, isInline: true, onClick: () => setIsTermsModalOpen(true) },
49
- React.createElement(Trans, null, "Try again")));
50
- setIsUpdating(false);
51
- }
52
- onClose();
53
- });
54
- const termAgrement = () => (React.createElement(React.Fragment, null,
55
- React.createElement("h2", null, "Lorem Ipsum"),
56
- React.createElement("p", null, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."),
57
- React.createElement("p", null, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."),
58
- React.createElement("p", null, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."),
59
- React.createElement(Checkbox, { className: "pf-u-mt-md", label: "I have read and agree to the terms", isChecked: isTermsChecked, onChange: () => setIsTermsChecked(!isTermsChecked), id: "terms-and-conditions-checkbox" })));
60
- useEffect(() => {
61
- const verifyLink = () => __awaiter(void 0, void 0, void 0, function* () {
62
- try {
63
- setIsVerifyingLink(true);
64
- setVerificationFailMessage('');
65
- const response = yield pcm.partnerships.verifyPartnerLink(linkHash);
66
- setLinkAccountName(response.accountName);
67
- setIsVerifyingLink(false);
68
- }
69
- catch (error) {
70
- const errorCode = parseInt((error === null || error === void 0 ? void 0 : error.code) || (error === null || error === void 0 ? void 0 : error.status)) || '';
71
- const errorMessage = errorCode === 400 ? (React.createElement(Trans, null, "You are not authorized to accept or reject partner link.")) : errorCode === 404 ? (React.createElement(Trans, null, "Partner link is invalid. The link has been used or expired.")) : (React.createElement(Trans, null, "There was a problem and partner link cannot be verified at this moment. Please try again later."));
72
- setVerificationFailMessage(errorMessage);
73
- }
74
- });
75
- verifyLink();
76
- }, [linkHash]);
77
- return (React.createElement(Modal, { id: "partnership-terms-and-conditions-modal", className: "pf-modal-overflow-visible", title: 'Confirm partnership collaboration', isOpen: isTermsModalOpen, onClose: onClose, showClose: true, onEscapePress: onClose, variant: ModalVariant.large, actions: [
78
- ...(!isContinueClicked
79
- ? [
80
- React.createElement(Button, { key: "continue", variant: ButtonVariant.primary, onClick: onContinue, isDisabled: isVerifyingLink },
81
- React.createElement(Trans, null, "Continue")),
82
- ]
83
- : [
84
- React.createElement(Button, { key: "back-to-prev", variant: ButtonVariant.primary, onClick: () => setIsContinueClicked(false) },
85
- React.createElement(Trans, null, "Back")),
86
- React.createElement(Button, { key: "acccept-partnership", variant: ButtonVariant.primary, isDisabled: !isTermsChecked || isUpdating, onClick: () => termAck('accept'), isLoading: isUpdating && ackChoice === 'accept' },
87
- React.createElement(Trans, null, "Accept")),
88
- React.createElement(Button, { key: "reject-partnership", variant: ButtonVariant.danger, onClick: () => termAck('decline'), isDisabled: isUpdating, isLoading: isUpdating && ackChoice === 'decline' },
89
- React.createElement(Trans, null, "Decline")),
90
- ]),
91
- ] },
92
- React.createElement(React.Fragment, null, !isContinueClicked && isVerifyingLink ? (React.createElement(React.Fragment, null, verificationFailMessage ? (React.createElement("p", { className: "pf-u-mt-xs pf-u-danger-color-100" }, verificationFailMessage)) : (React.createElement("p", { className: "pf-u-mt-xs" },
93
- React.createElement(LoadingDots, { show: true, message: t('Verifying partner link') }))))) : !isContinueClicked && !isVerifyingLink ? (React.createElement(React.Fragment, null,
94
- React.createElement("p", null, "A partner would like to collaborate on your company's technical support cases in concert with Red Hat support engineers. Please accept the request with the enclosed URL."),
95
- React.createElement(TextContent, { className: "pf-u-mt-lg" },
96
- React.createElement(Text, { component: TextVariants.h3 }, linkAccountName)))) : (termAgrement()))));
97
- };
@@ -1,3 +0,0 @@
1
- export declare const daysFromNow: (date: string) => number;
2
- export declare function PendingRequests(): JSX.Element;
3
- //# sourceMappingURL=PendingRequests.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PendingRequests.d.ts","sourceRoot":"","sources":["../../../../src/components/ManagePartnerships/PendingRequests.tsx"],"names":[],"mappings":"AA0BA,eAAO,MAAM,WAAW,SAAU,MAAM,WAMvC,CAAC;AACF,wBAAgB,eAAe,gBAwO9B"}
@@ -1,190 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { pcm } from '@cee-eng/hydrajs';
11
- import { AlertVariant, Badge, ButtonVariant, ExpandableSection, ExpandableSectionToggle, Label, Stack, StackItem, } from '@patternfly/react-core';
12
- import ExclamationCircleIcon from '@patternfly/react-icons/dist/js/icons/exclamation-circle-icon';
13
- import { LoadingIndicator, ToastNotification, useConfirmation } from '@rh-support/components';
14
- import { UserPreferencesKeys, useUserPreferences } from '@rh-support/react-context';
15
- import isEmpty from 'lodash/isEmpty';
16
- import React, { useEffect, useState } from 'react';
17
- import { Trans, useTranslation } from 'react-i18next';
18
- import { useLocation } from 'react-router';
19
- import { useManagePartnershipsContext } from '../../context/ManagePartnershipsProvider';
20
- import { ManageTable } from '../ManageTable';
21
- import { RequestCollaborationModal } from './RequestCollaborationModal';
22
- // returns number of days from now
23
- export const daysFromNow = (date) => {
24
- let now = new Date();
25
- let toDate = new Date(date);
26
- let difference = toDate.getTime() - now.getTime();
27
- let TotalDays = Math.ceil(difference / (1000 * 3600 * 24));
28
- return TotalDays;
29
- };
30
- export function PendingRequests() {
31
- const { t } = useTranslation();
32
- const confirmRemove = useConfirmation();
33
- const [isExpanded, setIsExpanded] = useState(false);
34
- const [statusList, setStatusList] = useState([]);
35
- const [isFetchingStatuses, setIsFetchingStatuses] = useState(false);
36
- const [isRequestAgainModalOpen, setIsRequestAgainModalOpen] = useState(false);
37
- const [selectedRowFriendlyName, setSelectedRowFriendlyName] = useState('');
38
- const { isUpdatingRequests } = useManagePartnershipsContext();
39
- const location = useLocation();
40
- const { getPreferenceByKey, updatePreferences } = useUserPreferences();
41
- const onToggle = (isExpanded) => {
42
- setIsExpanded(isExpanded);
43
- };
44
- const deleteRequest = (friendlyName) => __awaiter(this, void 0, void 0, function* () {
45
- try {
46
- yield confirmRemove({
47
- catchOnCancel: true,
48
- title: t('Are you sure?'),
49
- description: React.createElement(Trans, null, "You will not be able to undo this action after verifying."),
50
- confirmText: t('Delete'),
51
- confirmButtonVariant: ButtonVariant.danger,
52
- });
53
- try {
54
- yield pcm.partnerships.removePendingPartnerLink(friendlyName);
55
- setStatusList(statusList.filter((s) => s.friendlyName !== friendlyName));
56
- ToastNotification.addSuccessMessage(t('Partnership removed successfully'));
57
- }
58
- catch (e) {
59
- ToastNotification.addDangerMessage(t('Partnership failed to be removed'));
60
- }
61
- }
62
- catch (e) {
63
- // on confirm modal, cancel button is clicked
64
- }
65
- });
66
- const statusLabels = (data, prop) => {
67
- if (!data)
68
- return '';
69
- const statusObj = {
70
- PENDING: {
71
- label: `Expires in ${daysFromNow(data.expiryDate)} days`,
72
- color: 'gold',
73
- title: t('Link not used'),
74
- },
75
- DECLINED: { label: t('Rejected'), color: 'red', title: t('Link used') },
76
- EXPIRED: { label: t('Expired'), color: 'red', title: t('Link expired') },
77
- ACCEPTED: { label: t('Accepted'), color: 'green', title: t('Link accepted') },
78
- };
79
- return statusObj[data.status][prop] || '';
80
- };
81
- const columns = [
82
- {
83
- accessor: (data) => (data === null || data === void 0 ? void 0 : data.friendlyName) || '',
84
- sortable: false,
85
- id: 'frienly-name',
86
- cellWidth: 25,
87
- title: t('Name'),
88
- },
89
- {
90
- sortable: false,
91
- id: 'link-status',
92
- cellWidth: 25,
93
- cell: (data) => (React.createElement(Label, { icon: React.createElement(ExclamationCircleIcon, null), color: statusLabels(data, 'color') }, statusLabels(data, 'label'))),
94
- rowProps: (data) => ({
95
- status: (data === null || data === void 0 ? void 0 : data.status) || '',
96
- }),
97
- title: t('Status'),
98
- },
99
- {
100
- accessor: (data) => statusLabels(data, 'title'),
101
- sortable: false,
102
- id: 'link-description',
103
- cellWidth: 50,
104
- title: t('Description'),
105
- },
106
- ];
107
- const requestAgain = (friendlyName) => {
108
- setSelectedRowFriendlyName(friendlyName);
109
- setIsRequestAgainModalOpen(true);
110
- };
111
- const actionResolver = (rowData) => {
112
- var _a, _b, _c, _d;
113
- if (!rowData)
114
- return;
115
- const friendlyName = ((_a = rowData.cells) === null || _a === void 0 ? void 0 : _a[0]) || '';
116
- //@ts-ignore
117
- const status = ((_d = (_c = (_b = rowData.cells) === null || _b === void 0 ? void 0 : _b[1]) === null || _c === void 0 ? void 0 : _c.props) === null || _d === void 0 ? void 0 : _d.status) || '';
118
- return [
119
- ...(status === 'EXPIRED'
120
- ? [
121
- {
122
- title: t('Request Again'),
123
- onClick: () => requestAgain(friendlyName),
124
- itemKey: 'request-again',
125
- },
126
- ]
127
- : []),
128
- {
129
- title: (React.createElement("div", { className: "pf-u-danger-color-200" },
130
- React.createElement(Trans, null, "Delete"))),
131
- onClick: () => deleteRequest(friendlyName),
132
- itemKey: 'delete-request',
133
- },
134
- ];
135
- };
136
- const onRequestAgainModalClose = () => {
137
- setIsRequestAgainModalOpen(false);
138
- };
139
- useEffect(() => {
140
- // when a customer accepts a link, as soon as partner visits
141
- // the partnership page, a pop-up should show up and inform
142
- // partner that customer has accepted the link
143
- // to achieve this, we always save the latest accepted link in preferences
144
- const displayLinkIsVerifiedPopUp = (accepted) => {
145
- const latestAcceptedLik = JSON.parse(getPreferenceByKey(UserPreferencesKeys.partnershipLastestAcceptedLink));
146
- if (location.pathname !== '/manage/partnerships' ||
147
- !isEmpty(accepted) ||
148
- (latestAcceptedLik === null || latestAcceptedLik === void 0 ? void 0 : latestAcceptedLik.friendlyName) === (accepted === null || accepted === void 0 ? void 0 : accepted[0].friendlyName))
149
- return;
150
- try {
151
- updatePreferences(UserPreferencesKeys.partnershipLastestAcceptedLink, JSON.stringify(accepted[0]));
152
- ToastNotification.addSuccessMessage('Verified request', 'A customer has verified your collaboration. Find them in the table below.');
153
- }
154
- catch (e) {
155
- // silently fails
156
- }
157
- };
158
- const getStatuses = () => __awaiter(this, void 0, void 0, function* () {
159
- setIsFetchingStatuses(true);
160
- try {
161
- const statuses = yield pcm.partnerships.getPartnerLinksStatuses(1, 100);
162
- setStatusList(statuses.filter((s) => s.status !== 'ACCEPTED').reverse());
163
- displayLinkIsVerifiedPopUp(statuses.filter((s) => s.status === 'ACCEPTED').reverse());
164
- setIsFetchingStatuses(false);
165
- }
166
- catch (e) {
167
- setIsFetchingStatuses(false);
168
- ToastNotification.addDangerMessage(t('Failed to get partnership requests'));
169
- }
170
- });
171
- getStatuses();
172
- // eslint-disable-next-line react-hooks/exhaustive-deps
173
- }, [isUpdatingRequests]);
174
- const contentId = 'requests-detached-toggle-content';
175
- return (React.createElement(React.Fragment, null,
176
- React.createElement("section", { id: "manage-partnerships-pending-requests" },
177
- React.createElement(Stack, null,
178
- React.createElement(StackItem, { className: "toolbar" },
179
- React.createElement(ExpandableSectionToggle, { isExpanded: isExpanded, onToggle: onToggle, contentId: contentId },
180
- React.createElement("div", null,
181
- React.createElement("label", { className: "pf-u-color-100" },
182
- React.createElement(Trans, null, "Pending requests"),
183
- isFetchingStatuses ? (React.createElement(LoadingIndicator, { isInline: true, size: "sm", className: "pf-u-mx-sm" })) : (React.createElement(Badge, { className: "pf-u-mx-sm" }, statusList.length)))))),
184
- React.createElement(StackItem, null,
185
- React.createElement(ExpandableSection, { isIndented: false, isExpanded: isExpanded, isDetached: true, style: { padding: '0' }, contentId: contentId }, !isEmpty(statusList) ? (React.createElement(ManageTable, { ariaLabel: t('Pending requests'), columns: columns, data: statusList, errorVariant: AlertVariant.warning, isFetching: isFetchingStatuses, isError: false, errorTitle: t('Pending requests error'), errorComponent: React.createElement(Trans, null, "Could not get pending requests"), pagination: false, headless: true, actionResolver: statusList && !isFetchingStatuses && !isEmpty(statusList)
186
- ? actionResolver
187
- : null })) : (React.createElement("p", { className: "pf-u-p-md" },
188
- React.createElement(Trans, null, "No pending request"))))))),
189
- React.createElement(RequestCollaborationModal, { isOpen: isRequestAgainModalOpen, onClose: onRequestAgainModalClose, sendReqAgainFriendlyName: selectedRowFriendlyName })));
190
- }
@@ -1,8 +0,0 @@
1
- interface IProps {
2
- isOpen: boolean;
3
- onClose: () => void;
4
- sendReqAgainFriendlyName?: string;
5
- }
6
- export declare const RequestCollaborationModal: (props: IProps) => JSX.Element;
7
- export {};
8
- //# sourceMappingURL=RequestCollaborationModal.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"RequestCollaborationModal.d.ts","sourceRoot":"","sources":["../../../../src/components/ManagePartnerships/RequestCollaborationModal.tsx"],"names":[],"mappings":"AAUA,UAAU,MAAM;IACZ,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,wBAAwB,CAAC,EAAE,MAAM,CAAC;CACrC;AAGD,eAAO,MAAM,yBAAyB,UAAW,MAAM,gBAuKtD,CAAC"}
@@ -1,130 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { pcm } from '@cee-eng/hydrajs';
11
- import { Button, ButtonVariant, Modal, ModalVariant, Tooltip, TooltipPosition } from '@patternfly/react-core';
12
- import { ToastNotification, useCopyToClipboard } from '@rh-support/components';
13
- import { isEmpty } from 'lodash';
14
- import React, { useRef, useState } from 'react';
15
- import { Trans, useTranslation } from 'react-i18next';
16
- import { useManagePartnershipsDispatchContext } from '../../context/ManagePartnershipsProvider';
17
- import { setIsUpdatingRequests } from '../../reducers/ManagePartnershipsReducer';
18
- import { PartnerLinkNameForm } from './PartnerLinkNameForm';
19
- export const RequestCollaborationModal = (props) => {
20
- const { t } = useTranslation();
21
- const clipboardRef = useRef(null);
22
- const { clipboardText, copyToClipboard } = useCopyToClipboard(clipboardRef);
23
- const [validated, setValidated] = useState('default');
24
- const [isDuplicateLinkName, setIsDuplicateLinkName] = useState(false);
25
- const [friendlyName, setFriendlyName] = useState('');
26
- const [generatedUrl, setGeneratedUrl] = useState('');
27
- const [nextButtonIsClicked, setNextButtonIsClicked] = useState(false);
28
- const [showDone, setShowDone] = useState(false);
29
- const [isFetching, setIsFetching] = useState(false);
30
- const [isDoneClicked, setIsDoneClicked] = useState(false);
31
- const [isCopyClicked, setIsCopyClicked] = useState(false);
32
- const dispatch = useManagePartnershipsDispatchContext();
33
- const isRequestingAgain = !isEmpty(props.sendReqAgainFriendlyName);
34
- const reset = () => {
35
- setValidated('default');
36
- setIsDuplicateLinkName(false);
37
- setFriendlyName('');
38
- setGeneratedUrl('');
39
- setNextButtonIsClicked(false);
40
- setShowDone(false);
41
- setIsDoneClicked(false);
42
- setIsCopyClicked(false);
43
- };
44
- const onClose = () => {
45
- reset();
46
- props.onClose();
47
- };
48
- const onDone = () => {
49
- setIsDoneClicked(true);
50
- if (isCopyClicked) {
51
- reset();
52
- props.onClose();
53
- }
54
- };
55
- const onNext = () => __awaiter(void 0, void 0, void 0, function* () {
56
- setNextButtonIsClicked(true);
57
- if (isEmpty(friendlyName.trim())) {
58
- setValidated('error');
59
- return;
60
- }
61
- setIsFetching(true);
62
- try {
63
- // request again: delete the link to create new one
64
- if (isRequestingAgain) {
65
- yield pcm.partnerships.removePendingPartnerLink(props.sendReqAgainFriendlyName);
66
- }
67
- const url = yield pcm.partnerships.generatePartnerLink(friendlyName);
68
- const hash = url.message.replace(/(.*\/)*/, '');
69
- setGeneratedUrl('https://' + window.location.host + '/support/cases/#/manage/partnerships/partnerlink/' + hash);
70
- setIsUpdatingRequests(dispatch, true);
71
- setShowDone(true);
72
- setIsFetching(false);
73
- }
74
- catch (error) {
75
- setIsFetching(false);
76
- const errorCode = parseInt((error === null || error === void 0 ? void 0 : error.code) || (error === null || error === void 0 ? void 0 : error.status)) || '';
77
- if (errorCode === 400) {
78
- setValidated('error');
79
- setIsDuplicateLinkName(true);
80
- }
81
- else {
82
- onClose();
83
- ToastNotification.addSuccessMessage(t('Failed to generate partner link'));
84
- }
85
- }
86
- });
87
- const onLinkNameChange = (link) => {
88
- setFriendlyName(link);
89
- setIsDuplicateLinkName(false);
90
- const trimmedName = link.trim();
91
- if (trimmedName === '' && nextButtonIsClicked) {
92
- setValidated('error');
93
- }
94
- else {
95
- setValidated('success');
96
- }
97
- };
98
- const onClickOnCopyToClipboardButton = () => {
99
- copyToClipboard();
100
- setIsCopyClicked(true);
101
- };
102
- return (React.createElement(Modal, { id: "request-collaboration-modal", className: "pf-modal-overflow-visible", title: isRequestingAgain ? 'Request collaboration again' : 'Request collaboration', isOpen: props.isOpen, onClose: onClose, showClose: true, onEscapePress: onClose, variant: ModalVariant.large, actions: [
103
- ...(showDone
104
- ? [
105
- React.createElement(Button, { key: "done", variant: ButtonVariant.primary, onClick: onDone, isDisabled: validated === 'error' || (!isCopyClicked && isDoneClicked), "data-tracking-id": "request-collaboration-done-button" },
106
- React.createElement(Trans, null, "Done")),
107
- ]
108
- : [
109
- React.createElement(Button, { key: "next", variant: ButtonVariant.primary, onClick: onNext, isDisabled: validated === 'error' || isFetching, isLoading: isFetching },
110
- React.createElement(Trans, null, "Next")),
111
- ]),
112
- ] },
113
- React.createElement(React.Fragment, null,
114
- React.createElement("p", null, "Initiate a new collaboration by generating a unique link for your customer. Check the status under your requests to see if they accept or reject your collaboration."),
115
- React.createElement(PartnerLinkNameForm, { onLinkNameChange: onLinkNameChange, isDuplicateLinkName: isDuplicateLinkName, validated: validated, currentLinkName: props.sendReqAgainFriendlyName }),
116
- showDone && (React.createElement(React.Fragment, null,
117
- React.createElement("h4", null,
118
- React.createElement("strong", null, "Copy and send")),
119
- React.createElement("div", { className: "clipboard-wrapper" },
120
- React.createElement("div", { className: "clip-content-wrapper code-block" },
121
- React.createElement("code", { ref: clipboardRef }, generatedUrl)),
122
- React.createElement(Tooltip, { position: TooltipPosition.top, content: clipboardText, trigger: "click" },
123
- React.createElement("button", { className: "nimbus-icon-clipboard clip-code-raw-btn xs-icon", "aria-hidden": "true", onClick: onClickOnCopyToClipboardButton, "data-tracking-id": "request-collaboration-link-copy-button" }))),
124
- React.createElement("p", { className: !isCopyClicked && isDoneClicked ? 'pf-u-danger-color-100' : '' },
125
- React.createElement(Trans, null,
126
- ' ',
127
- "Please ",
128
- React.createElement("strong", null, "copy and send"),
129
- " this unique link to your customer for approval.")))))));
130
- };
@@ -1,2 +0,0 @@
1
- export declare function ManagePartnerships(): JSX.Element;
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/ManagePartnerships/index.tsx"],"names":[],"mappings":"AAYA,wBAAgB,kBAAkB,gBAuCjC"}