@rh-support/troubleshoot 0.2.84 → 0.2.85
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/components/CaseEditView/Tabs/CaseDiscussion/PostComment/useMarkdownFileUploader.d.ts +1 -0
- package/lib/esm/components/CaseEditView/Tabs/CaseDiscussion/PostComment/useMarkdownFileUploader.d.ts.map +1 -1
- package/lib/esm/components/CaseEditView/Tabs/CaseDiscussion/PostComment/useMarkdownFileUploader.js +25 -4
- package/lib/esm/components/CaseEditView/Tabs/CaseDiscussion/PostComment.d.ts.map +1 -1
- package/lib/esm/components/CaseEditView/Tabs/CaseDiscussion/PostComment.js +2 -1
- package/lib/esm/hooks/useS3Upload.d.ts +1 -1
- package/lib/esm/hooks/useS3Upload.d.ts.map +1 -1
- package/lib/esm/hooks/useS3Upload.js +3 -2
- package/lib/esm/scss/_pf4-overrides.scss +4 -0
- package/package.json +2 -2
package/lib/esm/components/CaseEditView/Tabs/CaseDiscussion/PostComment/useMarkdownFileUploader.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export declare function useMarkdownFileUploader({ caseNumber, secureSupport, onA
|
|
|
12
12
|
onFileSelect: (selectedImage: any) => void;
|
|
13
13
|
onFileAttach: (files: any, isPublic: any) => Promise<void>;
|
|
14
14
|
onFileDelete: (attachment: Partial<IAttachment>) => Promise<void>;
|
|
15
|
+
cancelFileUpload: () => void;
|
|
15
16
|
};
|
|
16
17
|
export {};
|
|
17
18
|
//# sourceMappingURL=useMarkdownFileUploader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMarkdownFileUploader.d.ts","sourceRoot":"","sources":["../../../../../../../src/components/CaseEditView/Tabs/CaseDiscussion/PostComment/useMarkdownFileUploader.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,2CAA2C,CAAC;AAcxE,UAAU,MAAM;IACZ,iBAAiB,EAAE,MAAM,IAAI,CAAC;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,OAAO,CAAC;CAC1B;AAED,eAAO,MAAM,eAAe,QAAkB,CAAC;AAE/C,wBAAgB,uBAAuB,CAAC,EAAE,UAAU,EAAE,aAAa,EAAE,iBAAiB,EAAE,EAAE,MAAM;;;;;;+
|
|
1
|
+
{"version":3,"file":"useMarkdownFileUploader.d.ts","sourceRoot":"","sources":["../../../../../../../src/components/CaseEditView/Tabs/CaseDiscussion/PostComment/useMarkdownFileUploader.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,2CAA2C,CAAC;AAcxE,UAAU,MAAM;IACZ,iBAAiB,EAAE,MAAM,IAAI,CAAC;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,OAAO,CAAC;CAC1B;AAED,eAAO,MAAM,eAAe,QAAkB,CAAC;AAE/C,wBAAgB,uBAAuB,CAAC,EAAE,UAAU,EAAE,aAAa,EAAE,iBAAiB,EAAE,EAAE,MAAM;;;;;;+BAyDpD,QAAQ,WAAW,CAAC;;EA2C/D"}
|
package/lib/esm/components/CaseEditView/Tabs/CaseDiscussion/PostComment/useMarkdownFileUploader.js
CHANGED
|
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import { caseAttachments } from '@cee-eng/hydrajs';
|
|
11
11
|
import { ToastNotification, useConfirmation, useFetch } from '@rh-support/components';
|
|
12
12
|
import { pendoTrackEvent } from '@rh-support/utils';
|
|
13
|
-
import React, { useState } from 'react';
|
|
13
|
+
import React, { useRef, useState } from 'react';
|
|
14
14
|
import { Trans, useTranslation } from 'react-i18next';
|
|
15
15
|
import { useCaseDiscussionTabDispatchContext, useCaseDiscussionTabStateContext, } from '../../../../../context/CaseDiscussionTabContext';
|
|
16
16
|
import { useS3Upload } from '../../../../../hooks/useS3Upload';
|
|
@@ -19,6 +19,9 @@ import { markdownInlineFileSelectEvent } from '../../../../shared/Constants';
|
|
|
19
19
|
export const FILE_SIZE_LIMIT = 2 * 1024 * 1000;
|
|
20
20
|
export function useMarkdownFileUploader({ caseNumber, secureSupport, onAttachmentAdded }) {
|
|
21
21
|
const [isMarkdownFileUploadInProgress, setIsMarkdownFileUploadinProgress] = useState(false);
|
|
22
|
+
// We need one more state to check if user canceled current upload
|
|
23
|
+
// Reason to use `useRef` as we need up to date state value in callback
|
|
24
|
+
const isMarkdownFileUploadCanceled = useRef(false);
|
|
22
25
|
const { request: deleteAttachmentRequest, isFetching: isDeletingFile } = useFetch(caseAttachments.deleteAttachment, {
|
|
23
26
|
propgateErrors: true,
|
|
24
27
|
});
|
|
@@ -26,13 +29,23 @@ export function useMarkdownFileUploader({ caseNumber, secureSupport, onAttachmen
|
|
|
26
29
|
const dispatchDiscussion = useCaseDiscussionTabDispatchContext();
|
|
27
30
|
const confirm = useConfirmation();
|
|
28
31
|
const { uploadFile, isUploadingFile } = useS3Upload(caseNumber, secureSupport);
|
|
29
|
-
const markdownFileUploadListener = (progress) => {
|
|
30
|
-
|
|
32
|
+
const markdownFileUploadListener = (progress, abort) => {
|
|
33
|
+
// If user canceled upload then don't enable uploading label and abort
|
|
34
|
+
if (isMarkdownFileUploadCanceled.current) {
|
|
35
|
+
abort();
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
setIsMarkdownFileUploadinProgress(true);
|
|
39
|
+
}
|
|
31
40
|
};
|
|
32
41
|
const { t } = useTranslation();
|
|
33
42
|
const onImageUploadComplete = () => __awaiter(this, void 0, void 0, function* () {
|
|
34
|
-
|
|
43
|
+
// check if user canceled upload and if not start the upload sequence
|
|
44
|
+
if (!isMarkdownFileUploadCanceled.current) {
|
|
45
|
+
yield onAttachmentAdded();
|
|
46
|
+
}
|
|
35
47
|
setIsMarkdownFileUploadinProgress(false);
|
|
48
|
+
isMarkdownFileUploadCanceled.current = false;
|
|
36
49
|
});
|
|
37
50
|
const onFileAttach = (files, isPublic) => __awaiter(this, void 0, void 0, function* () {
|
|
38
51
|
setIsMarkdownFileUploadinProgress(true);
|
|
@@ -43,6 +56,13 @@ export function useMarkdownFileUploader({ caseNumber, secureSupport, onAttachmen
|
|
|
43
56
|
});
|
|
44
57
|
onImageUploadComplete();
|
|
45
58
|
});
|
|
59
|
+
/**
|
|
60
|
+
* Cancel upload function which will take care to abort current operation and marking upload progress false
|
|
61
|
+
*/
|
|
62
|
+
const cancelFileUpload = () => {
|
|
63
|
+
isMarkdownFileUploadCanceled.current = true;
|
|
64
|
+
setIsMarkdownFileUploadinProgress(false);
|
|
65
|
+
};
|
|
46
66
|
const onFileSelect = (selectedImage) => {
|
|
47
67
|
pendoTrackEvent(markdownInlineFileSelectEvent);
|
|
48
68
|
};
|
|
@@ -77,5 +97,6 @@ export function useMarkdownFileUploader({ caseNumber, secureSupport, onAttachmen
|
|
|
77
97
|
onFileSelect,
|
|
78
98
|
onFileAttach,
|
|
79
99
|
onFileDelete,
|
|
100
|
+
cancelFileUpload,
|
|
80
101
|
};
|
|
81
102
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PostComment.d.ts","sourceRoot":"","sources":["../../../../../../src/components/CaseEditView/Tabs/CaseDiscussion/PostComment.tsx"],"names":[],"mappings":"AAoCA,OAAO,EAAkB,WAAW,EAAE,MAAM,+CAA+C,CAAC;AAqB5F,UAAU,MAAM;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACrC,iBAAiB,CAAC,EAAE,MAAM,IAAI,CAAC;IAC/B,kBAAkB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5C,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,cAAc,EAAE,WAAW,EAAE,CAAC;CACjC;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"PostComment.d.ts","sourceRoot":"","sources":["../../../../../../src/components/CaseEditView/Tabs/CaseDiscussion/PostComment.tsx"],"names":[],"mappings":"AAoCA,OAAO,EAAkB,WAAW,EAAE,MAAM,+CAA+C,CAAC;AAqB5F,UAAU,MAAM;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACrC,iBAAiB,CAAC,EAAE,MAAM,IAAI,CAAC;IAC/B,kBAAkB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5C,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,cAAc,EAAE,WAAW,EAAE,CAAC;CACjC;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,eAkcxC"}
|
|
@@ -54,7 +54,7 @@ export function PostComment(props) {
|
|
|
54
54
|
const [isProcessing, setIsProcessing] = useState(isPostingComment || isUploadingAttachments);
|
|
55
55
|
const { globalMetadataState: { loggedInUser, loggedInUserRights, loggedInUsersAccount, pcmConfig }, } = useContext(GlobalMetadataStateContext);
|
|
56
56
|
const allowInlineImagesInMarkdown = getConfigField(pcmConfig.data, 'allowInlineImagesInMarkdown', PCM_CONFIG_FIELD_TYPE.FEATURE_FLAG);
|
|
57
|
-
const { onFileSelect, onFileAttach, onFileDelete, isUploadingFile, isMarkdownFileUploadInProgress } = useMarkdownFileUploader({
|
|
57
|
+
const { onFileSelect, onFileAttach, onFileDelete, isUploadingFile, isMarkdownFileUploadInProgress, cancelFileUpload, } = useMarkdownFileUploader({
|
|
58
58
|
caseNumber,
|
|
59
59
|
secureSupport: loggedInUsersAccount.data.secureSupport,
|
|
60
60
|
onAttachmentAdded: props.onAttachmentAdded,
|
|
@@ -112,6 +112,7 @@ export function PostComment(props) {
|
|
|
112
112
|
const onCancelClick = () => {
|
|
113
113
|
resetCommentSection();
|
|
114
114
|
resetAttachmentSection();
|
|
115
|
+
cancelFileUpload();
|
|
115
116
|
};
|
|
116
117
|
const loggedInUserSSO = loggedInUserRights.data.getSSOUsername();
|
|
117
118
|
// https://github.com/facebook/react/issues/19240
|
|
@@ -3,7 +3,7 @@ export declare function useS3Upload(idToUploadTo: any, isSecureSupport: any): {
|
|
|
3
3
|
file: any;
|
|
4
4
|
description?: string;
|
|
5
5
|
isPrivate?: boolean;
|
|
6
|
-
listenerFn?: (percent: any) => void;
|
|
6
|
+
listenerFn?: (percent: any, abort: any) => void;
|
|
7
7
|
}) => Promise<string>;
|
|
8
8
|
isUploadingFile: boolean;
|
|
9
9
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useS3Upload.d.ts","sourceRoot":"","sources":["../../../src/hooks/useS3Upload.ts"],"names":[],"mappings":"AASA,wBAAgB,WAAW,CAAC,YAAY,KAAA,EAAE,eAAe,KAAA;;;;;;;;
|
|
1
|
+
{"version":3,"file":"useS3Upload.d.ts","sourceRoot":"","sources":["../../../src/hooks/useS3Upload.ts"],"names":[],"mappings":"AASA,wBAAgB,WAAW,CAAC,YAAY,KAAA,EAAE,eAAe,KAAA;;;;;;;;EA0ExD"}
|
|
@@ -28,7 +28,7 @@ export function useS3Upload(idToUploadTo, isSecureSupport) {
|
|
|
28
28
|
reader.readAsArrayBuffer(file.slice(0, 10));
|
|
29
29
|
});
|
|
30
30
|
});
|
|
31
|
-
const uploadFile = ({ file, description = '', isPrivate = false, listenerFn = (percent) => { } }) => __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
const uploadFile = ({ file, description = '', isPrivate = false, listenerFn = (percent, abort) => { } }) => __awaiter(this, void 0, void 0, function* () {
|
|
32
32
|
try {
|
|
33
33
|
yield getFileAccessDetails(file);
|
|
34
34
|
}
|
|
@@ -43,7 +43,8 @@ export function useS3Upload(idToUploadTo, isSecureSupport) {
|
|
|
43
43
|
const percent = decimal * 100;
|
|
44
44
|
// const verifyingUpdate = decimal === 1;
|
|
45
45
|
const currentUploadProgress = Math.floor(percent);
|
|
46
|
-
|
|
46
|
+
// Forwarding abort single to parent callback function
|
|
47
|
+
listenerFn(currentUploadProgress, abort);
|
|
47
48
|
};
|
|
48
49
|
const putObjectRequest = {
|
|
49
50
|
Body: file,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rh-support/troubleshoot",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.85",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
@@ -143,5 +143,5 @@
|
|
|
143
143
|
"not ie <= 11",
|
|
144
144
|
"not op_mini all"
|
|
145
145
|
],
|
|
146
|
-
"gitHead": "
|
|
146
|
+
"gitHead": "1de6c9240e3b6ee20e698385182d64e4501c6fe5"
|
|
147
147
|
}
|