@rh-support/components 2.5.62 → 2.5.64
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.
- package/lib/esm/AlertMessage/index.js +1 -0
- package/lib/esm/helperFunctions/errorMessage.d.ts +2 -2
- package/lib/esm/helperFunctions/errorMessage.d.ts.map +1 -1
- package/lib/esm/helperFunctions/errorMessage.js +20 -3
- package/lib/esm/hooks/useCopyToClipboard.d.ts +2 -3
- package/lib/esm/hooks/useCopyToClipboard.d.ts.map +1 -1
- package/lib/esm/hooks/useCopyToClipboard.js +15 -10
- package/package.json +4 -4
|
@@ -6,7 +6,7 @@ export interface IAppErrorObj {
|
|
|
6
6
|
export interface IAppError {
|
|
7
7
|
[key: string]: Partial<IAppErrorObj>;
|
|
8
8
|
}
|
|
9
|
-
declare function formattedApiErrorMessage(error: any, customMessage?: IAppError): string | JSX.Element;
|
|
10
|
-
declare function errorMessageTitle(error: any, customError?: IAppError): string;
|
|
9
|
+
declare function formattedApiErrorMessage(error: any, customMessage?: IAppError, canManageCase?: boolean): string | JSX.Element;
|
|
10
|
+
declare function errorMessageTitle(error: any, customError?: IAppError, canManageCase?: boolean): string;
|
|
11
11
|
export { formattedApiErrorMessage, errorMessageTitle };
|
|
12
12
|
//# sourceMappingURL=errorMessage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errorMessage.d.ts","sourceRoot":"","sources":["../../../src/helperFunctions/errorMessage.tsx"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAS7B,MAAM,WAAW,YAAY;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC;CACjC;AAED,MAAM,WAAW,SAAS;IACtB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;CACxC;
|
|
1
|
+
{"version":3,"file":"errorMessage.d.ts","sourceRoot":"","sources":["../../../src/helperFunctions/errorMessage.tsx"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAS7B,MAAM,WAAW,YAAY;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC;CACjC;AAED,MAAM,WAAW,SAAS;IACtB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;CACxC;AA8DD,iBAAS,wBAAwB,CAAC,KAAK,KAAA,EAAE,aAAa,CAAC,EAAE,SAAS,EAAE,aAAa,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,GAAG,CAAC,OAAO,CA2CjH;AAED,iBAAS,iBAAiB,CAAC,KAAK,KAAA,EAAE,WAAW,CAAC,EAAE,SAAS,EAAE,aAAa,CAAC,EAAE,OAAO,GAAG,MAAM,CAa1F;AAED,OAAO,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -34,9 +34,17 @@ const defaultErrorObj = {
|
|
|
34
34
|
React.createElement("a", { href: "/support/contact/customerService" }, "contact Customer Service"),
|
|
35
35
|
" if you think this is an error.")),
|
|
36
36
|
},
|
|
37
|
+
cannotManageCase: {
|
|
38
|
+
title: 'Access required to manage support cases',
|
|
39
|
+
message: (React.createElement("p", null,
|
|
40
|
+
"You currently do not have permission to manage support cases. To gain access, please contact your Organization Administrator, or reach out to",
|
|
41
|
+
' ',
|
|
42
|
+
React.createElement("a", { href: "/support/contact/customerService" }, "Customer Service"),
|
|
43
|
+
" for assistance.")),
|
|
44
|
+
},
|
|
37
45
|
};
|
|
38
46
|
// the error argument need a better typing here. We want to make sure that user is passing an error object and not an error string
|
|
39
|
-
function formattedApiErrorMessage(error, customMessage) {
|
|
47
|
+
function formattedApiErrorMessage(error, customMessage, canManageCase) {
|
|
40
48
|
var _a, _b, _c;
|
|
41
49
|
const errorCode = parseInt((error === null || error === void 0 ? void 0 : error.code) || (error === null || error === void 0 ? void 0 : error.status)) || '';
|
|
42
50
|
if (!customMessage)
|
|
@@ -71,6 +79,9 @@ function formattedApiErrorMessage(error, customMessage) {
|
|
|
71
79
|
defaultErrorObj[errorCode].message);
|
|
72
80
|
}
|
|
73
81
|
else {
|
|
82
|
+
if (canManageCase === false) {
|
|
83
|
+
return defaultErrorObj.cannotManageCase.message;
|
|
84
|
+
}
|
|
74
85
|
// api call error
|
|
75
86
|
const message = (error === null || error === void 0 ? void 0 : error.statusText) || (error === null || error === void 0 ? void 0 : error.responseText) || '';
|
|
76
87
|
// error.message -> javascript error
|
|
@@ -78,11 +89,17 @@ function formattedApiErrorMessage(error, customMessage) {
|
|
|
78
89
|
return isNotProperUXError ? defaultErrorMessage : message;
|
|
79
90
|
}
|
|
80
91
|
}
|
|
81
|
-
function errorMessageTitle(error, customError) {
|
|
92
|
+
function errorMessageTitle(error, customError, canManageCase) {
|
|
82
93
|
var _a, _b;
|
|
83
94
|
if (!customError)
|
|
84
95
|
customError = {};
|
|
85
96
|
const errorCode = parseInt((error === null || error === void 0 ? void 0 : error.code) || (error === null || error === void 0 ? void 0 : error.status)) || '';
|
|
86
|
-
|
|
97
|
+
if (errorCode) {
|
|
98
|
+
return ((_a = customError[errorCode]) === null || _a === void 0 ? void 0 : _a.title) || ((_b = defaultErrorObj[errorCode]) === null || _b === void 0 ? void 0 : _b.title) || defaultTitle;
|
|
99
|
+
}
|
|
100
|
+
if (canManageCase === false) {
|
|
101
|
+
return defaultErrorObj.cannotManageCase.title || defaultTitle;
|
|
102
|
+
}
|
|
103
|
+
return defaultTitle;
|
|
87
104
|
}
|
|
88
105
|
export { formattedApiErrorMessage, errorMessageTitle };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export declare
|
|
2
|
-
export declare function useCopyToClipboard(ref: any): {
|
|
1
|
+
export declare function useCopyToClipboard(ref: React.RefObject<HTMLInputElement>): {
|
|
3
2
|
clipboardText: string;
|
|
4
|
-
copyToClipboard: () => void
|
|
3
|
+
copyToClipboard: () => Promise<void>;
|
|
5
4
|
};
|
|
6
5
|
//# sourceMappingURL=useCopyToClipboard.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCopyToClipboard.d.ts","sourceRoot":"","sources":["../../../src/hooks/useCopyToClipboard.ts"],"names":[],"mappings":"AAGA,
|
|
1
|
+
{"version":3,"file":"useCopyToClipboard.d.ts","sourceRoot":"","sources":["../../../src/hooks/useCopyToClipboard.ts"],"names":[],"mappings":"AAGA,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,gBAAgB,CAAC;;;EA2BxE"}
|
|
@@ -1,19 +1,24 @@
|
|
|
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
|
+
};
|
|
1
10
|
import { useState } from 'react';
|
|
2
11
|
import { useTranslation } from 'react-i18next';
|
|
3
|
-
export const selectText = (elem) => {
|
|
4
|
-
var range = document.createRange();
|
|
5
|
-
range.selectNode(elem);
|
|
6
|
-
window.getSelection().removeAllRanges();
|
|
7
|
-
window.getSelection().addRange(range);
|
|
8
|
-
};
|
|
9
12
|
export function useCopyToClipboard(ref) {
|
|
10
13
|
const [clipboardText, setClipboardText] = useState('');
|
|
11
14
|
// @ts-ignore
|
|
12
15
|
const { t } = useTranslation();
|
|
13
|
-
const copyToClipboard = () => {
|
|
14
|
-
|
|
16
|
+
const copyToClipboard = () => __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
if (!ref.current)
|
|
18
|
+
return;
|
|
19
|
+
const textToCopy = ref.current.value;
|
|
15
20
|
try {
|
|
16
|
-
|
|
21
|
+
yield navigator.clipboard.writeText(textToCopy);
|
|
17
22
|
setClipboardText(t('Copied!'));
|
|
18
23
|
}
|
|
19
24
|
catch (error) {
|
|
@@ -27,7 +32,7 @@ export function useCopyToClipboard(ref) {
|
|
|
27
32
|
setClipboardText(t('Press Ctrl + C to copy'));
|
|
28
33
|
}
|
|
29
34
|
}
|
|
30
|
-
};
|
|
35
|
+
});
|
|
31
36
|
return {
|
|
32
37
|
clipboardText,
|
|
33
38
|
copyToClipboard,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rh-support/components",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.64",
|
|
4
4
|
"description": "Contains all reusabel components for support app",
|
|
5
5
|
"author": "Vikas Rathee <vrathee@redhat.com>",
|
|
6
6
|
"license": "ISC",
|
|
@@ -68,8 +68,8 @@
|
|
|
68
68
|
"@patternfly/react-table": "6.2.1",
|
|
69
69
|
"@patternfly/react-tokens": "6.2.1",
|
|
70
70
|
"@rh-support/types": "2.0.5",
|
|
71
|
-
"@rh-support/user-permissions": "2.5.
|
|
72
|
-
"@rh-support/utils": "2.5.
|
|
71
|
+
"@rh-support/user-permissions": "2.5.31",
|
|
72
|
+
"@rh-support/utils": "2.5.27",
|
|
73
73
|
"dompurify": "^2.2.6",
|
|
74
74
|
"js-worker-search": "^1.4.1",
|
|
75
75
|
"lazysizes": "^5.3.2",
|
|
@@ -106,5 +106,5 @@
|
|
|
106
106
|
"defaults and supports es6-module",
|
|
107
107
|
"maintained node versions"
|
|
108
108
|
],
|
|
109
|
-
"gitHead": "
|
|
109
|
+
"gitHead": "91b79ac9c0605961e2a0bc95f683e9c9c2a050f9"
|
|
110
110
|
}
|