@rh-support/manage 1.0.29 → 1.0.301-beta.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 (33) hide show
  1. package/lib/esm/ManageTabs.d.ts.map +1 -1
  2. package/lib/esm/ManageTabs.js +21 -4
  3. package/lib/esm/Routes.d.ts +1 -0
  4. package/lib/esm/Routes.d.ts.map +1 -1
  5. package/lib/esm/Routes.js +6 -0
  6. package/lib/esm/components/ManagePartnerships/PartnerLinkNameForm.d.ts +12 -0
  7. package/lib/esm/components/ManagePartnerships/PartnerLinkNameForm.d.ts.map +1 -0
  8. package/lib/esm/components/ManagePartnerships/PartnerLinkNameForm.js +21 -0
  9. package/lib/esm/components/ManagePartnerships/PartnershipsList.d.ts +2 -0
  10. package/lib/esm/components/ManagePartnerships/PartnershipsList.d.ts.map +1 -0
  11. package/lib/esm/components/ManagePartnerships/PartnershipsList.js +161 -0
  12. package/lib/esm/components/ManagePartnerships/PartnershipsTermsModal.d.ts +2 -0
  13. package/lib/esm/components/ManagePartnerships/PartnershipsTermsModal.d.ts.map +1 -0
  14. package/lib/esm/components/ManagePartnerships/PartnershipsTermsModal.js +97 -0
  15. package/lib/esm/components/ManagePartnerships/PendingRequests.d.ts +3 -0
  16. package/lib/esm/components/ManagePartnerships/PendingRequests.d.ts.map +1 -0
  17. package/lib/esm/components/ManagePartnerships/PendingRequests.js +166 -0
  18. package/lib/esm/components/ManagePartnerships/RequestCollaborationModal.d.ts +8 -0
  19. package/lib/esm/components/ManagePartnerships/RequestCollaborationModal.d.ts.map +1 -0
  20. package/lib/esm/components/ManagePartnerships/RequestCollaborationModal.js +129 -0
  21. package/lib/esm/components/ManagePartnerships/index.d.ts +2 -0
  22. package/lib/esm/components/ManagePartnerships/index.d.ts.map +1 -0
  23. package/lib/esm/components/ManagePartnerships/index.js +26 -0
  24. package/lib/esm/components/ManageTable/ManageTable.d.ts +1 -0
  25. package/lib/esm/components/ManageTable/ManageTable.d.ts.map +1 -1
  26. package/lib/esm/components/ManageTable/ManageTable.js +4 -3
  27. package/lib/esm/context/ManagePartnershipsProvider.d.ts +11 -0
  28. package/lib/esm/context/ManagePartnershipsProvider.d.ts.map +1 -0
  29. package/lib/esm/context/ManagePartnershipsProvider.js +26 -0
  30. package/lib/esm/reducers/ManagePartnershipsReducer.d.ts +16 -0
  31. package/lib/esm/reducers/ManagePartnershipsReducer.d.ts.map +1 -0
  32. package/lib/esm/reducers/ManagePartnershipsReducer.js +30 -0
  33. package/package.json +8 -8
@@ -1 +1 @@
1
- {"version":3,"file":"ManageTabs.d.ts","sourceRoot":"","sources":["../../src/ManageTabs.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAmBvD,UAAU,MAAM;IACZ,UAAU,EAAE,mBAAmB,CAAC,EAAE,CAAC,CAAC;CACvC;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,eAqIvC"}
1
+ {"version":3,"file":"ManageTabs.d.ts","sourceRoot":"","sources":["../../src/ManageTabs.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAoBvD,UAAU,MAAM;IACZ,UAAU,EAAE,mBAAmB,CAAC,EAAE,CAAC,CAAC;CACvC;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,eAgKvC"}
@@ -1,11 +1,13 @@
1
1
  import { ErrorBoundary, useDocumentTitle } from '@rh-support/components';
2
+ import { GlobalMetadataStateContext } from '@rh-support/react-context';
2
3
  import { ability, CaseDetailsFields, resourceActions, resources } from '@rh-support/user-permissions';
3
- import { CustomElements, requireCustomElement } from '@rh-support/utils';
4
+ import { CustomElements, getConfigField, PCM_CONFIG_FIELD_TYPE, requireCustomElement } from '@rh-support/utils';
4
5
  import map from 'lodash/map';
5
- import React from 'react';
6
+ import React, { useContext } from 'react';
6
7
  import { ConfigsTable } from './components/Configs/ConfigsTable';
7
8
  import { ManageGroupUsers } from './components/Groups/ManageGroupUsers';
8
9
  import { ManageGroupedBookmarkedAccountsTab } from './components/ManageBookmarkedAccountsTab';
10
+ import { ManagePartnerships } from './components/ManagePartnerships/index';
9
11
  import { ManagePreferences } from './components/ManagePreferences';
10
12
  import { NotificationEmails } from './components/NotificationEmails/index';
11
13
  import { TopContentManagement } from './components/TopContentManagement';
@@ -21,7 +23,9 @@ requireCustomElement([
21
23
  export function ManageTabs(props) {
22
24
  var _a, _b;
23
25
  const history = props.routeProps.history;
24
- const { groupsRoute, bookmarkedAccountsRoute, topContentRoute, notificationEmailsRoute, preferencesRoute, configsRoute, } = Routes.getPaths();
26
+ const { groupsRoute, bookmarkedAccountsRoute, topContentRoute, notificationEmailsRoute, preferencesRoute, configsRoute, partnershipsRoute, } = Routes.getPaths();
27
+ const { globalMetadataState: { pcmConfig }, } = useContext(GlobalMetadataStateContext);
28
+ const isPartnershipsEnabled = getConfigField(pcmConfig.data, 'isPartnershipEnabled', PCM_CONFIG_FIELD_TYPE.FEATURE_FLAG);
25
29
  // Changes route and saves the current path to the url query params
26
30
  const isOnlyBasePath = history.location.pathname === Routes.basePath;
27
31
  useDocumentTitle(PageTitle.MANAGE);
@@ -34,6 +38,7 @@ export function ManageTabs(props) {
34
38
  const canViewCaseGroups = ability.can(resourceActions.READ, resources.CASE_GROUPS) && canViewManageTab;
35
39
  const canManageBookmarkAccounts = ability.can(resourceActions.CREATE, resources.BOOKMARK_ACCOUNTS) && canViewManageTab;
36
40
  const canViewEmailNotificationTab = ability.can(resourceActions.READ, resources.NOTIFICATION_EMAIL);
41
+ const canViewPartnershipsTab = ability.can(resourceActions.READ, resources.PARTNERSHIPS);
37
42
  const canAddCustomNotification = ability.can(resourceActions.PATCH, resources.CASE_DETAILS, CaseDetailsFields.CASE_DETAILS_SEND_NOTIFICATIONS);
38
43
  const canViewConfigsTab = ability.can(resourceActions.READ, resources.APP_INTERNAL_CONFIGS);
39
44
  const tabsToRender = [];
@@ -71,6 +76,18 @@ export function ManageTabs(props) {
71
76
  },
72
77
  component: React.createElement(NotificationEmails, null),
73
78
  });
79
+ canViewPartnershipsTab &&
80
+ isPartnershipsEnabled &&
81
+ tabsToRender.push({
82
+ title: 'Partnerships',
83
+ key: 'partnerships-tab',
84
+ 'data-tracking-id': 'partnerships-tab',
85
+ routePath: partnershipsRoute,
86
+ onClick: () => {
87
+ changeRouteThunk(partnershipsRoute);
88
+ },
89
+ component: React.createElement(ManagePartnerships, null),
90
+ });
74
91
  tabsToRender.push({
75
92
  title: 'Preferences',
76
93
  key: 'preferences-tab',
@@ -112,7 +129,7 @@ export function ManageTabs(props) {
112
129
  const getSelectedIndex = () => {
113
130
  if (isOnlyBasePath)
114
131
  return 0;
115
- const tabIndex = tabsToRender.findIndex((tab) => tab.routePath === history.location.pathname);
132
+ const tabIndex = tabsToRender.findIndex((tab) => tab.routePath === history.location.pathname.substring(0, tab.routePath.length));
116
133
  return tabIndex > -1 ? tabIndex : 0;
117
134
  };
118
135
  /**
@@ -14,6 +14,7 @@ interface ManageRoutes {
14
14
  savedSearches: Route;
15
15
  topContent: Route;
16
16
  preferences: Route;
17
+ partnerships: Route;
17
18
  notificationEmails: Route;
18
19
  configs: Route;
19
20
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Routes.d.ts","sourceRoot":"","sources":["../../src/Routes.ts"],"names":[],"mappings":"AAAA,UAAU,KAAK;IACX,QAAQ,CAAC,OAAO,EAAE,MAAM,MAAM,CAAC;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACzB;AAED,UAAU,YAAY;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,kBAAkB,EAAE,KAAK,CAAC;IAC1B,eAAe,EAAE,KAAK,CAAC;IACvB,QAAQ,EAAE,MAAM;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IAC1C,aAAa,EAAE,MAAM,MAAM,EAAE,CAAC;IAC9B,MAAM,EAAE,KAAK,CAAC;IACd,aAAa,EAAE,KAAK,CAAC;IACrB,UAAU,EAAE,KAAK,CAAC;IAClB,WAAW,EAAE,KAAK,CAAC;IACnB,kBAAkB,EAAE,KAAK,CAAC;IAC1B,OAAO,EAAE,KAAK,CAAC;CAClB;AAED,eAAO,MAAM,MAAM,EAAE,YAmEpB,CAAC"}
1
+ {"version":3,"file":"Routes.d.ts","sourceRoot":"","sources":["../../src/Routes.ts"],"names":[],"mappings":"AAAA,UAAU,KAAK;IACX,QAAQ,CAAC,OAAO,EAAE,MAAM,MAAM,CAAC;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACzB;AAED,UAAU,YAAY;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,kBAAkB,EAAE,KAAK,CAAC;IAC1B,eAAe,EAAE,KAAK,CAAC;IACvB,QAAQ,EAAE,MAAM;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IAC1C,aAAa,EAAE,MAAM,MAAM,EAAE,CAAC;IAC9B,MAAM,EAAE,KAAK,CAAC;IACd,aAAa,EAAE,KAAK,CAAC;IACrB,UAAU,EAAE,KAAK,CAAC;IAClB,WAAW,EAAE,KAAK,CAAC;IACnB,YAAY,EAAE,KAAK,CAAC;IACpB,kBAAkB,EAAE,KAAK,CAAC;IAC1B,OAAO,EAAE,KAAK,CAAC;CAClB;AAED,eAAO,MAAM,MAAM,EAAE,YAyEpB,CAAC"}
package/lib/esm/Routes.js CHANGED
@@ -36,6 +36,12 @@ export const Routes = {
36
36
  return getPath(this);
37
37
  },
38
38
  },
39
+ partnerships: {
40
+ path: '/partnerships',
41
+ getPath() {
42
+ return getPath(this);
43
+ },
44
+ },
39
45
  notificationEmails: {
40
46
  path: '/notification-emails',
41
47
  getPath() {
@@ -0,0 +1,12 @@
1
+ declare type validate = 'success' | 'warning' | 'error' | 'default';
2
+ interface IProps {
3
+ onLinkNameChange: (linkName: string) => void;
4
+ isDuplicateLinkName: boolean;
5
+ validated: validate;
6
+ currentLinkName?: string;
7
+ inputLabel?: string;
8
+ friendlyName?: string;
9
+ }
10
+ export declare function PartnerLinkNameForm(props: IProps): JSX.Element;
11
+ export {};
12
+ //# sourceMappingURL=PartnerLinkNameForm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PartnerLinkNameForm.d.ts","sourceRoot":"","sources":["../../../../src/components/ManagePartnerships/PartnerLinkNameForm.tsx"],"names":[],"mappings":"AAKA,aAAK,QAAQ,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;AAE5D,UAAU,MAAM;IACZ,gBAAgB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C,mBAAmB,EAAE,OAAO,CAAC;IAC7B,SAAS,EAAE,QAAQ,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,eAgDhD"}
@@ -0,0 +1,21 @@
1
+ import { Form, FormGroup, FormHelperText, Grid, GridItem, TextInput } from '@patternfly/react-core';
2
+ import ExclamationCircleIcon from '@patternfly/react-icons/dist/js/icons/exclamation-circle-icon';
3
+ import React, { useState } from 'react';
4
+ import { Trans, useTranslation } from 'react-i18next';
5
+ export function PartnerLinkNameForm(props) {
6
+ const [localLinkName, setLocalLinkName] = useState('');
7
+ const { t } = useTranslation();
8
+ const handleLinkNameChange = (link, _event) => {
9
+ setLocalLinkName(link);
10
+ props.onLinkNameChange(link);
11
+ };
12
+ const partnershipLinkId = 'partnership-link-id';
13
+ return (React.createElement(Form, { className: "pf-u-my-md" },
14
+ React.createElement(Grid, { sm: 12, md: 6, lg: 6 },
15
+ React.createElement(GridItem, null,
16
+ React.createElement(FormGroup, { label: props.inputLabel || t('Name your link'), type: "string", helperText: React.createElement(FormHelperText, { isHidden: props.validated === 'error' },
17
+ React.createElement(Trans, null, "Please enter a name for your request")), helperTextInvalid: props.isDuplicateLinkName
18
+ ? t('Link name already used. Please enter a unique name')
19
+ : t('Please enter a name for your request'), helperTextInvalidIcon: React.createElement(ExclamationCircleIcon, null), fieldId: partnershipLinkId, validated: props.validated, isRequired: true },
20
+ React.createElement(TextInput, { isRequired: true, validated: props.validated, value: localLinkName || props.currentLinkName, id: partnershipLinkId, "aria-describedby": "age-1-helper", onChange: handleLinkNameChange, placeholder: t('e.g. Customer name') }))))));
21
+ }
@@ -0,0 +1,2 @@
1
+ export declare function PartnershipsList(): JSX.Element;
2
+ //# sourceMappingURL=PartnershipsList.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PartnershipsList.d.ts","sourceRoot":"","sources":["../../../../src/components/ManagePartnerships/PartnershipsList.tsx"],"names":[],"mappings":"AAwBA,wBAAgB,gBAAgB,gBAwM/B"}
@@ -0,0 +1,161 @@
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 } from '../../context/ManagePartnershipsProvider';
19
+ import { ManageTable } from '../ManageTable';
20
+ import { RequestCollaborationModal } from './RequestCollaborationModal';
21
+ export function PartnershipsList() {
22
+ const { t } = useTranslation();
23
+ const confirmRemove = useConfirmation();
24
+ const [searchString, setSearchString] = useState('');
25
+ const [isRequestCollabModalOpen, setIsRequestCollabModalOpen] = useState(false);
26
+ const [accountList, setAccountList] = useState([]);
27
+ const [isFetching, setIsFetching] = useState(false);
28
+ const [hasError, setHasError] = useState(false);
29
+ const [isDeleting, setIsdeleting] = useState(false);
30
+ const [isDeletingAccountNum, setIsdeletingAccountNum] = useState('');
31
+ const { isUpdatingPartnerAccountList } = useManagePartnershipsContext();
32
+ const { globalMetadataState: { loggedInUserRights, managedAccounts, accountManagers, loggedInUserJwtToken }, } = useGlobalStateContext();
33
+ const dispatchToGlobalMetadataReducer = useContext(GlobalMetadataDispatchContext);
34
+ const isPartner = () => loggedInUserRights.data.isPartner();
35
+ const isCustomerOrgAdmin = () => loggedInUserRights.data.isCustomerOrgAdmin();
36
+ console.log('isPartner= ' + isPartner());
37
+ const removePartnership = (data) => __awaiter(this, void 0, void 0, function* () {
38
+ try {
39
+ yield confirmRemove({
40
+ catchOnCancel: true,
41
+ title: t('Are you sure?'),
42
+ description: React.createElement(Trans, null, "You will not be able to undo this action after verifying."),
43
+ confirmText: t('Delete'),
44
+ confirmButtonVariant: ButtonVariant.danger,
45
+ });
46
+ try {
47
+ setIsdeleting(true);
48
+ setIsdeletingAccountNum(data.accountNum);
49
+ if (isPartner()) {
50
+ yield pcm.partnerships.deleteCustomerAccountByPartner(data.accountNum);
51
+ }
52
+ else {
53
+ yield pcm.partnerships.deletePartnerAccountByCustomer(data.accountNum);
54
+ }
55
+ setAccountList(accountList.filter((a) => a.accountNum !== data.accountNum));
56
+ ToastNotification.addSuccessMessage(t('Partnership removed successfully'));
57
+ setIsdeleting(false);
58
+ setIsdeletingAccountNum('');
59
+ }
60
+ catch (e) {
61
+ ToastNotification.addDangerMessage(t('Partnership failed to be removed'));
62
+ setIsdeleting(false);
63
+ setIsdeletingAccountNum('');
64
+ }
65
+ }
66
+ catch (e) {
67
+ // on confirm modal, cancel button is clicked
68
+ }
69
+ });
70
+ const columns = [
71
+ {
72
+ accessor: (data) => data.name,
73
+ sortable: false,
74
+ id: 'customer-account-name',
75
+ title: t('Account name'),
76
+ cellWidth: 40,
77
+ sortMethod: (a, b) => defaultTableSortMethod(a.toLowerCase(), b.toLowerCase()),
78
+ },
79
+ {
80
+ id: 'customer-account-number',
81
+ title: t('Account number'),
82
+ sortable: false,
83
+ cellWidth: 20,
84
+ cell: (data) => data.accountNum,
85
+ },
86
+ {
87
+ id: 'customer-partnership-access-level',
88
+ title: t('Access level'),
89
+ sortable: false,
90
+ cellWidth: 30,
91
+ cell: (data) => data.partnerCaseAccess,
92
+ },
93
+ {
94
+ id: 'partnership-delete',
95
+ title: ' ',
96
+ sortable: false,
97
+ cellWidth: 10,
98
+ cell: (data) => (React.createElement(Button, { variant: ButtonVariant.plain, "aria-label": t('Remove partnership'), onClick: () => removePartnership(data) },
99
+ React.createElement(LoadingIndicator, { isInline: true, show: isDeleting && data.accountNum === isDeletingAccountNum, size: "xs" }),
100
+ React.createElement(TrashIcon, null))),
101
+ },
102
+ ];
103
+ const requestCollaborationButton = () => (React.createElement("div", { className: "toolbar-right pf-u-mt-xs" },
104
+ React.createElement(Button, { variant: ButtonVariant.primary, isInline: true, onClick: () => setIsRequestCollabModalOpen(true), "data-tracking-id": "request-collaboration-button", isDisabled: false },
105
+ React.createElement(Trans, null, "Request Collaboration"))));
106
+ // Get Customer Accounts For A Partner
107
+ useEffect(() => {
108
+ const getManagedAccounts = () => __awaiter(this, void 0, void 0, function* () {
109
+ try {
110
+ setIsFetching(true);
111
+ setHasError(false);
112
+ yield fetchManagedAccounts(dispatchToGlobalMetadataReducer, loggedInUserJwtToken);
113
+ }
114
+ catch (e) {
115
+ setHasError(true);
116
+ }
117
+ setIsFetching(false);
118
+ });
119
+ if (isPartner() && haventLoadedMetadata(managedAccounts, (data) => data === undefined))
120
+ getManagedAccounts();
121
+ // eslint-disable-next-line react-hooks/exhaustive-deps
122
+ }, [managedAccounts]);
123
+ //Get Partner Accounts For A Customer
124
+ useEffect(() => {
125
+ const getAccountManagers = () => __awaiter(this, void 0, void 0, function* () {
126
+ try {
127
+ setIsFetching(true);
128
+ setHasError(false);
129
+ yield fetchAccountManagers(dispatchToGlobalMetadataReducer, loggedInUserJwtToken);
130
+ }
131
+ catch (e) {
132
+ setHasError(true);
133
+ }
134
+ setIsFetching(false);
135
+ });
136
+ // when customer accepts a link, need to fetch account data
137
+ if (isCustomerOrgAdmin() &&
138
+ (haventLoadedMetadata(accountManagers, (data) => data === undefined) || isUpdatingPartnerAccountList))
139
+ getAccountManagers();
140
+ // eslint-disable-next-line react-hooks/exhaustive-deps
141
+ }, [accountManagers, isUpdatingPartnerAccountList]);
142
+ useEffect(() => {
143
+ if (isPartner()) {
144
+ setAccountList(managedAccounts.data);
145
+ }
146
+ else if (isCustomerOrgAdmin()) {
147
+ setAccountList(accountManagers.data);
148
+ }
149
+ // eslint-disable-next-line react-hooks/exhaustive-deps
150
+ }, [managedAccounts, accountManagers]);
151
+ return (React.createElement("section", { id: "manage-partnerships-list" },
152
+ React.createElement("div", { className: "toolbar" },
153
+ React.createElement("div", { className: "toolbar-left" },
154
+ React.createElement("label", { htmlFor: "search-partnerships" }, "Filter by"),
155
+ 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') })),
156
+ isPartner() && requestCollaborationButton()),
157
+ 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.') }),
158
+ React.createElement(RequestCollaborationModal, { isOpen: isRequestCollabModalOpen, onClose: () => {
159
+ setIsRequestCollabModalOpen(false);
160
+ } })));
161
+ }
@@ -0,0 +1,2 @@
1
+ export declare const PartnershipsTermsModal: () => JSX.Element;
2
+ //# sourceMappingURL=PartnershipsTermsModal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PartnershipsTermsModal.d.ts","sourceRoot":"","sources":["../../../../src/components/ManagePartnerships/PartnershipsTermsModal.tsx"],"names":[],"mappings":"AAsBA,eAAO,MAAM,sBAAsB,mBAkLlC,CAAC"}
@@ -0,0 +1,97 @@
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
+ };
@@ -0,0 +1,3 @@
1
+ export declare const daysFromNow: (date: string) => number;
2
+ export declare function PendingRequests(): JSX.Element;
3
+ //# sourceMappingURL=PendingRequests.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PendingRequests.d.ts","sourceRoot":"","sources":["../../../../src/components/ManagePartnerships/PendingRequests.tsx"],"names":[],"mappings":"AAuBA,eAAO,MAAM,WAAW,SAAU,MAAM,WAMvC,CAAC;AACF,wBAAgB,eAAe,gBAyM9B"}
@@ -0,0 +1,166 @@
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 React, { useEffect, useState } from 'react';
15
+ import { Trans, useTranslation } from 'react-i18next';
16
+ import { useManagePartnershipsContext } from '../../context/ManagePartnershipsProvider';
17
+ import { ManageTable } from '../ManageTable';
18
+ import { RequestCollaborationModal } from './RequestCollaborationModal';
19
+ // returns number of days from now
20
+ export const daysFromNow = (date) => {
21
+ let now = new Date();
22
+ let toDate = new Date(date);
23
+ let difference = toDate.getTime() - now.getTime();
24
+ let TotalDays = Math.ceil(difference / (1000 * 3600 * 24));
25
+ return TotalDays;
26
+ };
27
+ export function PendingRequests() {
28
+ const { t } = useTranslation();
29
+ const confirmRemove = useConfirmation();
30
+ const [isExpanded, setIsExpanded] = useState(false);
31
+ const [statusList, setStatusList] = useState([]);
32
+ const [isFetchingStatuses, setIsFetchingStatuses] = useState(false);
33
+ const [isRequestAgainModalOpen, setIsRequestAgainModalOpen] = useState(false);
34
+ const [selectedRowFriendlyName, setSelectedRowFriendlyName] = useState('');
35
+ const { isUpdatingRequests } = useManagePartnershipsContext();
36
+ const onToggle = (isExpanded) => {
37
+ setIsExpanded(isExpanded);
38
+ };
39
+ const deleteRequest = (friendlyName) => __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
+ yield pcm.partnerships.removePendingPartnerLink(friendlyName);
50
+ setStatusList(statusList.filter((s) => s.friendlyName !== friendlyName));
51
+ ToastNotification.addSuccessMessage(t('Partnership removed successfully'));
52
+ }
53
+ catch (e) {
54
+ ToastNotification.addDangerMessage(t('Partnership failed to be removed'));
55
+ }
56
+ }
57
+ catch (e) {
58
+ // on confirm modal, cancel button is clicked
59
+ }
60
+ });
61
+ const statusLabels = (data, prop) => {
62
+ if (!data)
63
+ return '';
64
+ const statusObj = {
65
+ PENDING: {
66
+ label: `Expires in ${daysFromNow(data.expiryDate)} days`,
67
+ color: 'gold',
68
+ title: t('Link not used'),
69
+ },
70
+ DECLINED: { label: t('Rejected'), color: 'red', title: t('Link used') },
71
+ EXPIRED: { label: t('Expired'), color: 'red', title: t('Link expired') },
72
+ ACCEPTED: { label: t('Accepted'), color: 'green', title: t('Link accepted') },
73
+ };
74
+ return statusObj[data.status][prop] || '';
75
+ };
76
+ const columns = [
77
+ {
78
+ accessor: (data) => (data === null || data === void 0 ? void 0 : data.friendlyName) || '',
79
+ sortable: false,
80
+ id: 'frienly-name',
81
+ cellWidth: 25,
82
+ title: t('Name'),
83
+ },
84
+ {
85
+ sortable: false,
86
+ id: 'link-status',
87
+ cellWidth: 25,
88
+ cell: (data) => (React.createElement(Label, { icon: React.createElement(ExclamationCircleIcon, null), color: statusLabels(data, 'color') }, statusLabels(data, 'label'))),
89
+ rowProps: (data) => ({
90
+ status: (data === null || data === void 0 ? void 0 : data.status) || '',
91
+ }),
92
+ title: t('Status'),
93
+ },
94
+ {
95
+ accessor: (data) => statusLabels(data, 'title'),
96
+ sortable: false,
97
+ id: 'link-description',
98
+ cellWidth: 50,
99
+ title: t('Description'),
100
+ },
101
+ ];
102
+ const requestAgain = (friendlyName) => {
103
+ setSelectedRowFriendlyName(friendlyName);
104
+ setIsRequestAgainModalOpen(true);
105
+ };
106
+ const actionResolver = (rowData) => {
107
+ var _a, _b, _c, _d;
108
+ if (!rowData)
109
+ return;
110
+ const friendlyName = ((_a = rowData.cells) === null || _a === void 0 ? void 0 : _a[0]) || '';
111
+ //@ts-ignore
112
+ 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) || '';
113
+ return [
114
+ ...(status === 'EXPIRED'
115
+ ? [
116
+ {
117
+ title: t('Request Again'),
118
+ onClick: () => requestAgain(friendlyName),
119
+ itemKey: 'request-again',
120
+ },
121
+ ]
122
+ : []),
123
+ {
124
+ title: (React.createElement("div", { className: "pf-u-danger-color-200" },
125
+ React.createElement(Trans, null, "Delete"))),
126
+ onClick: () => deleteRequest(friendlyName),
127
+ itemKey: 'delete-request',
128
+ },
129
+ ];
130
+ };
131
+ const onRequestAgainModalClose = () => {
132
+ setIsRequestAgainModalOpen(false);
133
+ };
134
+ useEffect(() => {
135
+ const getStatuses = () => __awaiter(this, void 0, void 0, function* () {
136
+ setIsFetchingStatuses(true);
137
+ try {
138
+ const statuses = yield pcm.partnerships.getPartnerLinksStatuses(100, 1);
139
+ setStatusList(statuses.filter((s) => s.status !== 'ACCEPTED').reverse());
140
+ setIsFetchingStatuses(false);
141
+ }
142
+ catch (e) {
143
+ setIsFetchingStatuses(false);
144
+ ToastNotification.addDangerMessage(t('Failed to get partnership requests'));
145
+ }
146
+ });
147
+ getStatuses();
148
+ // eslint-disable-next-line react-hooks/exhaustive-deps
149
+ }, [isUpdatingRequests]);
150
+ const contentId = 'requests-detached-toggle-content';
151
+ return (React.createElement(React.Fragment, null,
152
+ React.createElement("section", { id: "manage-partnerships-pending-requests" },
153
+ React.createElement(Stack, null,
154
+ React.createElement(StackItem, { className: "toolbar" },
155
+ React.createElement(ExpandableSectionToggle, { isExpanded: isExpanded, onToggle: onToggle, contentId: contentId },
156
+ React.createElement("div", null,
157
+ React.createElement("label", { className: "pf-u-color-100" },
158
+ React.createElement(Trans, null, "Pending requests"),
159
+ isFetchingStatuses ? (React.createElement(LoadingIndicator, { isInline: true, size: "sm", className: "pf-u-mx-sm" })) : (React.createElement(Badge, { className: "pf-u-mx-sm" }, statusList.length)))))),
160
+ React.createElement(StackItem, null,
161
+ React.createElement(ExpandableSection, { isIndented: false, isExpanded: isExpanded, isDetached: true, style: { padding: '0' }, contentId: contentId }, statusList.length !== 0 ? (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 && statusList.length !== 0
162
+ ? actionResolver
163
+ : null })) : (React.createElement("p", { className: "pf-u-p-md" },
164
+ React.createElement(Trans, null, "No pending request"))))))),
165
+ React.createElement(RequestCollaborationModal, { isOpen: isRequestAgainModalOpen, onClose: onRequestAgainModalClose, sendReqAgainFriendlyName: selectedRowFriendlyName })));
166
+ }
@@ -0,0 +1,8 @@
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
@@ -0,0 +1 @@
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,gBAkKtD,CAAC"}
@@ -0,0 +1,129 @@
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
+ setGeneratedUrl(url.message);
69
+ setIsUpdatingRequests(dispatch, true);
70
+ setShowDone(true);
71
+ setIsFetching(false);
72
+ }
73
+ catch (error) {
74
+ setIsFetching(false);
75
+ const errorCode = parseInt((error === null || error === void 0 ? void 0 : error.code) || (error === null || error === void 0 ? void 0 : error.status)) || '';
76
+ if (errorCode === 400) {
77
+ setValidated('error');
78
+ setIsDuplicateLinkName(true);
79
+ }
80
+ else {
81
+ onClose();
82
+ ToastNotification.addSuccessMessage(t('Failed to generate partner link'));
83
+ }
84
+ }
85
+ });
86
+ const onLinkNameChange = (link) => {
87
+ setFriendlyName(link);
88
+ setIsDuplicateLinkName(false);
89
+ const trimmedName = link.trim();
90
+ if (trimmedName === '' && nextButtonIsClicked) {
91
+ setValidated('error');
92
+ }
93
+ else {
94
+ setValidated('success');
95
+ }
96
+ };
97
+ const onClickOnCopyToClipboardButton = () => {
98
+ copyToClipboard();
99
+ setIsCopyClicked(true);
100
+ };
101
+ 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: [
102
+ ...(showDone
103
+ ? [
104
+ React.createElement(Button, { key: "done", variant: ButtonVariant.primary, onClick: onDone, isDisabled: validated === 'error' || (!isCopyClicked && isDoneClicked) },
105
+ React.createElement(Trans, null, "Done")),
106
+ ]
107
+ : [
108
+ React.createElement(Button, { key: "next", variant: ButtonVariant.primary, onClick: onNext, isDisabled: validated === 'error' || isFetching, isLoading: isFetching },
109
+ React.createElement(Trans, null, "Next")),
110
+ ]),
111
+ ] },
112
+ React.createElement(React.Fragment, null,
113
+ 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."),
114
+ React.createElement(PartnerLinkNameForm, { onLinkNameChange: onLinkNameChange, isDuplicateLinkName: isDuplicateLinkName, validated: validated, currentLinkName: props.sendReqAgainFriendlyName }),
115
+ showDone && (React.createElement(React.Fragment, null,
116
+ React.createElement("h4", null,
117
+ React.createElement("strong", null, "Copy and send")),
118
+ React.createElement("div", { className: "clipboard-wrapper" },
119
+ React.createElement("div", { className: "clip-content-wrapper code-block" },
120
+ React.createElement("code", { ref: clipboardRef }, generatedUrl)),
121
+ React.createElement(Tooltip, { position: TooltipPosition.top, content: clipboardText, trigger: "click" },
122
+ React.createElement("button", { className: "nimbus-icon-clipboard clip-code-raw-btn xs-icon", "aria-hidden": "true", onClick: onClickOnCopyToClipboardButton }))),
123
+ React.createElement("p", { className: !isCopyClicked && isDoneClicked ? 'pf-u-danger-color-100' : '' },
124
+ React.createElement(Trans, null,
125
+ ' ',
126
+ "Please ",
127
+ React.createElement("strong", null, "copy and send"),
128
+ " this unique link to your customer for approval.")))))));
129
+ };
@@ -0,0 +1,2 @@
1
+ export declare function ManagePartnerships(): JSX.Element;
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/ManagePartnerships/index.tsx"],"names":[],"mappings":"AAWA,wBAAgB,kBAAkB,gBAuCjC"}
@@ -0,0 +1,26 @@
1
+ import { ErrorBoundary } from '@rh-support/components';
2
+ import { useGlobalStateContext } from '@rh-support/react-context';
3
+ import React from 'react';
4
+ import { Trans, useTranslation } from 'react-i18next';
5
+ import { Route, Switch } from 'react-router-dom';
6
+ import { ManagePartnershipsProvider } from '../../context/ManagePartnershipsProvider';
7
+ import { PartnershipsList } from './PartnershipsList';
8
+ import { PartnershipsTermsModal } from './PartnershipsTermsModal';
9
+ import { PendingRequests } from './PendingRequests';
10
+ export function ManagePartnerships() {
11
+ const { t } = useTranslation();
12
+ const { globalMetadataState: { loggedInUserRights }, } = useGlobalStateContext();
13
+ return (React.createElement(React.Fragment, null,
14
+ React.createElement("header", { className: "pf-u-mt-md pf-u-mb-xs" },
15
+ React.createElement("h2", null,
16
+ React.createElement(Trans, null, "Partnerships")),
17
+ React.createElement("p", null,
18
+ loggedInUserRights.data.isPartner() && (React.createElement(Trans, null, "Add, edit, or remove customer partnerships and manage your pending requests.")),
19
+ loggedInUserRights.data.isCustomer() && (React.createElement(Trans, null, "Confirm, filter, or remove partnerships and manage collaboration requests.")))),
20
+ React.createElement(ErrorBoundary, { errorMsgInfo: { message: t('There was an error loading partnerships list') } },
21
+ React.createElement(ManagePartnershipsProvider, null,
22
+ loggedInUserRights.data.isPartner() && React.createElement(PendingRequests, null),
23
+ React.createElement(PartnershipsList, null),
24
+ React.createElement(Switch, null,
25
+ React.createElement(Route, { path: `/manage/partnerships/partnerlink/:linkHash?` }, loggedInUserRights.data.isCustomerOrgAdmin() ? (React.createElement(PartnershipsTermsModal, null)) : (React.createElement(React.Fragment, null, "Todo: a modal to tell user only or admin customers can use the link"))))))));
26
+ }
@@ -14,6 +14,7 @@ interface IProps {
14
14
  isError: boolean;
15
15
  pagination?: boolean;
16
16
  keepPageNumberOnDataChange?: boolean;
17
+ headless?: boolean;
17
18
  actions?: IActions;
18
19
  areActionsDisabled?: IAreActionsDisabled;
19
20
  actionResolver?: IActionsResolver;
@@ -1 +1 @@
1
- {"version":3,"file":"ManageTable.d.ts","sourceRoot":"","sources":["../../../../src/components/ManageTable/ManageTable.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGH,YAAY,EAQf,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC1F,OAAO,EAAE,OAAO,EAAE,SAAS,EAAmC,MAAM,wBAAwB,CAAC;AAC7F,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,UAAU,MAAM;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE,SAAS,CAAC;IAGrB,cAAc,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC;IAClC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,OAAO,EAAE,OAAO,CAAC;IAEjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,0BAA0B,CAAC,EAAE,OAAO,CAAC;IAErC,OAAO,CAAC,EAAE,QAAQ,CAAC;IACnB,kBAAkB,CAAC,EAAE,mBAAmB,CAAC;IACzC,cAAc,CAAC,EAAE,gBAAgB,CAAC;IAElC,YAAY,CAAC,EAAE,MAAM,CAAC;CACzB;AA0BD,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,eA4CxC"}
1
+ {"version":3,"file":"ManageTable.d.ts","sourceRoot":"","sources":["../../../../src/components/ManageTable/ManageTable.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGH,YAAY,EAQf,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC1F,OAAO,EAAE,OAAO,EAAE,SAAS,EAAmC,MAAM,wBAAwB,CAAC;AAC7F,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,UAAU,MAAM;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE,SAAS,CAAC;IAGrB,cAAc,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC;IAClC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,OAAO,EAAE,OAAO,CAAC;IAEjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,0BAA0B,CAAC,EAAE,OAAO,CAAC;IACrC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,OAAO,CAAC,EAAE,QAAQ,CAAC;IACnB,kBAAkB,CAAC,EAAE,mBAAmB,CAAC;IACzC,cAAc,CAAC,EAAE,gBAAgB,CAAC;IAElC,YAAY,CAAC,EAAE,MAAM,CAAC;CACzB;AA0BD,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,eAgDxC"}
@@ -31,12 +31,13 @@ const noResultFoundRow = (noResultString = '') => [
31
31
  },
32
32
  ];
33
33
  export function ManageTable(props) {
34
- const { ariaLabel, errorComponent, errorTitle, errorVariant, isError, isFetching, sortInfo, actions, keepPageNumberOnDataChange, areActionsDisabled, actionResolver } = props, tableProps = __rest(props, ["ariaLabel", "errorComponent", "errorTitle", "errorVariant", "isError", "isFetching", "sortInfo", "actions", "keepPageNumberOnDataChange", "areActionsDisabled", "actionResolver"]);
34
+ const { ariaLabel, errorComponent, errorTitle, errorVariant, isError, isFetching, sortInfo, actions, keepPageNumberOnDataChange, areActionsDisabled, actionResolver, headless } = props, tableProps = __rest(props, ["ariaLabel", "errorComponent", "errorTitle", "errorVariant", "isError", "isFetching", "sortInfo", "actions", "keepPageNumberOnDataChange", "areActionsDisabled", "actionResolver", "headless"]);
35
+ const pagination = () => (props.pagination !== undefined ? props.pagination : true);
35
36
  return (React.createElement("div", { className: "table-wrapper" },
36
37
  isError && (React.createElement(React.Fragment, null,
37
38
  React.createElement(Alert, { variant: errorVariant, title: errorTitle, actionClose: React.createElement(AlertActionCloseButton, null) }, errorComponent))),
38
39
  React.createElement(Table, Object.assign({}, tableProps),
39
- React.createElement(PFTable, { sortInfo: sortInfo, "aria-label": ariaLabel, pagination: true, emptyStateRow: noResultFoundRow(props.noResultText), actions: actions, areActionsDisabled: areActionsDisabled, actionResolver: actionResolver, isLoading: isFetching, keepPageNumberOnDataChange: keepPageNumberOnDataChange }),
40
- tableProps.data.length > 0 && (React.createElement("footer", null,
40
+ React.createElement(PFTable, { sortInfo: sortInfo, "aria-label": ariaLabel, pagination: pagination(), emptyStateRow: noResultFoundRow(props.noResultText), actions: actions, areActionsDisabled: areActionsDisabled, actionResolver: actionResolver, isLoading: isFetching, keepPageNumberOnDataChange: keepPageNumberOnDataChange, headless: headless }),
41
+ tableProps.data.length > 0 && pagination() && (React.createElement("footer", null,
41
42
  React.createElement(TablePagination, { variant: PaginationVariant.bottom }))))));
42
43
  }
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { IManagePartnershipsState, ManagePartnershipsReducerDispatchType } from '../reducers/ManagePartnershipsReducer';
3
+ export declare const intialManagePartnershipsContext: IManagePartnershipsState;
4
+ export declare const ManagePartnershipsStateContext: React.Context<IManagePartnershipsState>;
5
+ export declare const ManagePartnershipsDispatchContext: React.Context<ManagePartnershipsReducerDispatchType>;
6
+ export declare function useManagePartnershipsContext(): IManagePartnershipsState;
7
+ export declare function useManagePartnershipsDispatchContext(): ManagePartnershipsReducerDispatchType;
8
+ export declare function ManagePartnershipsProvider({ children }: {
9
+ children: any;
10
+ }): JSX.Element;
11
+ //# sourceMappingURL=ManagePartnershipsProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ManagePartnershipsProvider.d.ts","sourceRoot":"","sources":["../../../src/context/ManagePartnershipsProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAiC,MAAM,OAAO,CAAC;AAEtD,OAAO,EACH,wBAAwB,EAExB,qCAAqC,EACxC,MAAM,uCAAuC,CAAC;AAE/C,eAAO,MAAM,+BAA+B,EAAE,wBAG7C,CAAC;AAGF,eAAO,MAAM,8BAA8B,yCAE1C,CAAC;AACF,eAAO,MAAM,iCAAiC,sDAA6C,CAAC;AAE5F,wBAAgB,4BAA4B,6BAM3C;AAED,wBAAgB,oCAAoC,0CAMnD;AAED,wBAAgB,0BAA0B,CAAC,EAAE,QAAQ,EAAE;;CAAA,eAStD"}
@@ -0,0 +1,26 @@
1
+ import React, { useContext, useReducer } from 'react';
2
+ import { ManagePartnershipsReducer, } from '../reducers/ManagePartnershipsReducer';
3
+ export const intialManagePartnershipsContext = {
4
+ isUpdatingPartnerAccountList: false,
5
+ isUpdatingRequests: false,
6
+ };
7
+ const initalDispatchContext = null;
8
+ export const ManagePartnershipsStateContext = React.createContext(intialManagePartnershipsContext);
9
+ export const ManagePartnershipsDispatchContext = React.createContext(initalDispatchContext);
10
+ export function useManagePartnershipsContext() {
11
+ if (ManagePartnershipsStateContext === undefined) {
12
+ throw new Error(`useManagePartnershipsContext must be used within a ManagePartnershipsContextProvider`);
13
+ }
14
+ return useContext(ManagePartnershipsStateContext);
15
+ }
16
+ export function useManagePartnershipsDispatchContext() {
17
+ if (ManagePartnershipsDispatchContext === undefined) {
18
+ throw new Error(`useManagePartnershipsContext must be used within a ManagePartnershipsContextProvider`);
19
+ }
20
+ return useContext(ManagePartnershipsDispatchContext);
21
+ }
22
+ export function ManagePartnershipsProvider({ children }) {
23
+ const [managePartnershipsState, dispatch] = useReducer(ManagePartnershipsReducer, intialManagePartnershipsContext);
24
+ return (React.createElement(ManagePartnershipsStateContext.Provider, { value: Object.assign({}, managePartnershipsState) },
25
+ React.createElement(ManagePartnershipsDispatchContext.Provider, { value: dispatch }, children)));
26
+ }
@@ -0,0 +1,16 @@
1
+ import { IAction } from '@rh-support/types/shared';
2
+ export interface IManagePartnershipsState {
3
+ isUpdatingPartnerAccountList: boolean;
4
+ isUpdatingRequests: boolean;
5
+ }
6
+ export declare enum ManagePartnershipsReducerConstants {
7
+ setIsUpdatingAccounts = "setIsUpdatingAccounts",
8
+ setIsUpdatingRequests = "setIsUpdatingRequests"
9
+ }
10
+ declare type IActionType = IAction<ManagePartnershipsReducerConstants, IManagePartnershipsState>;
11
+ export declare type ManagePartnershipsReducerDispatchType = (value: IActionType) => void;
12
+ export declare const ManagePartnershipsReducer: (state: IManagePartnershipsState, action: IActionType) => IManagePartnershipsState;
13
+ export declare const setIsUpdatingAccounts: (dispatch: ManagePartnershipsReducerDispatchType, isUpdatingPartnerAccountList: boolean) => void;
14
+ export declare const setIsUpdatingRequests: (dispatch: ManagePartnershipsReducerDispatchType, isUpdatingRequests: boolean) => void;
15
+ export {};
16
+ //# sourceMappingURL=ManagePartnershipsReducer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ManagePartnershipsReducer.d.ts","sourceRoot":"","sources":["../../../src/reducers/ManagePartnershipsReducer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAEnD,MAAM,WAAW,wBAAwB;IACrC,4BAA4B,EAAE,OAAO,CAAC;IACtC,kBAAkB,EAAE,OAAO,CAAC;CAC/B;AAED,oBAAY,kCAAkC;IAC1C,qBAAqB,0BAA0B;IAC/C,qBAAqB,0BAA0B;CAClD;AAED,aAAK,WAAW,GAAG,OAAO,CAAC,kCAAkC,EAAE,wBAAwB,CAAC,CAAC;AACzF,oBAAY,qCAAqC,GAAG,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;AAEjF,eAAO,MAAM,yBAAyB,UAC3B,wBAAwB,0BAEhC,wBAYF,CAAC;AAEF,eAAO,MAAM,qBAAqB,aACpB,qCAAqC,gCACjB,OAAO,SAMxC,CAAC;AAEF,eAAO,MAAM,qBAAqB,aAAc,qCAAqC,sBAAsB,OAAO,SAKjH,CAAC"}
@@ -0,0 +1,30 @@
1
+ export var ManagePartnershipsReducerConstants;
2
+ (function (ManagePartnershipsReducerConstants) {
3
+ ManagePartnershipsReducerConstants["setIsUpdatingAccounts"] = "setIsUpdatingAccounts";
4
+ ManagePartnershipsReducerConstants["setIsUpdatingRequests"] = "setIsUpdatingRequests";
5
+ })(ManagePartnershipsReducerConstants || (ManagePartnershipsReducerConstants = {}));
6
+ export const ManagePartnershipsReducer = (state, action) => {
7
+ switch (action.type) {
8
+ case ManagePartnershipsReducerConstants.setIsUpdatingAccounts: {
9
+ return Object.assign(Object.assign({}, state), { isUpdatingPartnerAccountList: action.payload.isUpdatingPartnerAccountList });
10
+ }
11
+ case ManagePartnershipsReducerConstants.setIsUpdatingRequests: {
12
+ return Object.assign(Object.assign({}, state), { isUpdatingRequests: action.payload.isUpdatingRequests });
13
+ }
14
+ default: {
15
+ return state;
16
+ }
17
+ }
18
+ };
19
+ export const setIsUpdatingAccounts = (dispatch, isUpdatingPartnerAccountList) => {
20
+ dispatch({
21
+ type: ManagePartnershipsReducerConstants.setIsUpdatingAccounts,
22
+ payload: { isUpdatingPartnerAccountList },
23
+ });
24
+ };
25
+ export const setIsUpdatingRequests = (dispatch, isUpdatingRequests) => {
26
+ dispatch({
27
+ type: ManagePartnershipsReducerConstants.setIsUpdatingRequests,
28
+ payload: { isUpdatingRequests },
29
+ });
30
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rh-support/manage",
3
- "version": "1.0.29",
3
+ "version": "1.0.301-beta.0",
4
4
  "description": "Customer Support Manage App",
5
5
  "author": "Jordan Eudy <jeudy100@gmail.com>",
6
6
  "homepage": "",
@@ -51,7 +51,7 @@
51
51
  "not op_mini all"
52
52
  ],
53
53
  "peerDependencies": {
54
- "@cee-eng/hydrajs": "4.14.53",
54
+ "@cee-eng/hydrajs": "4.15.0",
55
55
  "@patternfly/patternfly": "4.196.7",
56
56
  "@patternfly/pfe-accordion": "1.12.3",
57
57
  "@patternfly/pfe-collapse": "1.12.3",
@@ -87,19 +87,19 @@
87
87
  "typescript": "4.3.5"
88
88
  },
89
89
  "dependencies": {
90
- "@cee-eng/hydrajs": "4.14.53",
90
+ "@cee-eng/hydrajs": "4.15.0",
91
91
  "@patternfly/patternfly": "4.196.7",
92
92
  "@patternfly/pfe-accordion": "1.12.3",
93
93
  "@patternfly/pfe-collapse": "1.12.3",
94
94
  "@patternfly/pfe-tabs": "1.12.3",
95
95
  "@patternfly/react-core": "4.264.0",
96
96
  "@patternfly/react-table": "4.111.33",
97
- "@rh-support/components": "1.2.14",
97
+ "@rh-support/components": "1.2.141-beta.0",
98
98
  "@rh-support/configs": "1.0.0",
99
- "@rh-support/react-context": "1.0.20",
99
+ "@rh-support/react-context": "1.0.211-beta.0",
100
100
  "@rh-support/types": "0.2.0",
101
- "@rh-support/user-permissions": "1.0.11",
102
- "@rh-support/utils": "1.0.9",
101
+ "@rh-support/user-permissions": "1.0.111-beta.0",
102
+ "@rh-support/utils": "1.0.91-beta.0",
103
103
  "@types/react-beautiful-dnd": "^13.0.0",
104
104
  "i18next": ">=17.0.1",
105
105
  "lodash": ">=4.17.15",
@@ -109,5 +109,5 @@
109
109
  "react-i18next": ">=10.11.0",
110
110
  "react-router-dom": ">=5.1.2"
111
111
  },
112
- "gitHead": "0fd7c3e88b2360bbb751379ac0fae4d67b832591"
112
+ "gitHead": "62737e41a047c7211cf65ca9c1c6bccff8dee121"
113
113
  }