@rh-support/troubleshoot 1.0.42 → 1.0.43
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/CaseDiscussion.js +1 -1
- package/lib/esm/components/CaseInformation/FileDiag.d.ts.map +1 -1
- package/lib/esm/components/CaseInformation/FileDiag.js +1 -1
- package/lib/esm/components/shared/fileUpload/WidgetFileUploader.d.ts +2 -0
- package/lib/esm/components/shared/fileUpload/WidgetFileUploader.d.ts.map +1 -1
- package/lib/esm/components/shared/fileUpload/WidgetFileUploader.js +68 -2
- package/lib/esm/components/shared/fileUpload/fileSelectors/WidgetFileSelector.js +1 -1
- package/package.json +4 -4
|
@@ -24,7 +24,7 @@ import { AutoSizer, CellMeasurer, CellMeasurerCache, List, WindowScroller } from
|
|
|
24
24
|
import { useCaseDetailsPageStateContext } from '../../../../context/CaseDetailsPageContext';
|
|
25
25
|
import { useCaseDiscussionTabDispatchContext, useCaseDiscussionTabStateContext, } from '../../../../context/CaseDiscussionTabContext';
|
|
26
26
|
import { clearReplyComment, discussionSortOrderConst, DiscussionType, setCommentText, setDiscussions, setFilter, setSort, updateAttachment, updateAttacmentsAfterRemoval, updateCommentStateFeedback, updateDiscussionStateAttachments, updateDiscussionStateComments, } from '../../../../reducers/CaseDiscussionTabReducer';
|
|
27
|
-
import { AttachmentContextProvider } from '../../../shared/fileUpload';
|
|
27
|
+
import { AttachmentContextProvider } from '../../../shared/fileUpload/reducer/AttachmentReducerContext';
|
|
28
28
|
import { PDFContext } from '../../PDFContainer';
|
|
29
29
|
import CaseAttachment from './CaseAttachment';
|
|
30
30
|
import CaseChat from './CaseChat';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileDiag.d.ts","sourceRoot":"","sources":["../../../../src/components/CaseInformation/FileDiag.tsx"],"names":[],"mappings":"AASA,wBAAgB,QAAQ,
|
|
1
|
+
{"version":3,"file":"FileDiag.d.ts","sourceRoot":"","sources":["../../../../src/components/CaseInformation/FileDiag.tsx"],"names":[],"mappings":"AASA,wBAAgB,QAAQ,gBAwBvB"}
|
|
@@ -13,5 +13,5 @@ export function FileDiag() {
|
|
|
13
13
|
if (!canAddAttachments)
|
|
14
14
|
return null;
|
|
15
15
|
return (React.createElement(React.Fragment, null,
|
|
16
|
-
React.createElement(WidgetFileUploader, { idToUploadTo: activeSessionId, needsAnalyzing: true, isSessionId: true, isSecureSupport: loggedInUsersAccount.data.secureSupport, autoUploadOnSelect: loggedInUsersAccount.data.secureSupport ? false : true, helperText: getValidAttachmentRules(rulesState.EARules.rules).length > 0 ? React.createElement(FileEARule, null) : null })));
|
|
16
|
+
React.createElement(WidgetFileUploader, { idToUploadTo: activeSessionId, isPrivate: false, needsAnalyzing: true, isSessionId: true, isSecureSupport: loggedInUsersAccount.data.secureSupport, autoUploadOnSelect: loggedInUsersAccount.data.secureSupport ? false : true, helperText: getValidAttachmentRules(rulesState.EARules.rules).length > 0 ? React.createElement(FileEARule, null) : null })));
|
|
17
17
|
}
|
|
@@ -3,6 +3,8 @@ import React from 'react';
|
|
|
3
3
|
import { IFileUploaderCommonProps } from './types';
|
|
4
4
|
interface IProps extends IFileUploaderCommonProps, IDClassNameProps {
|
|
5
5
|
helperText?: string | React.ReactNode;
|
|
6
|
+
isSessionId: boolean;
|
|
7
|
+
isPrivate: boolean;
|
|
6
8
|
}
|
|
7
9
|
declare function WidgetFileUploader(props: IProps): JSX.Element;
|
|
8
10
|
declare namespace WidgetFileUploader {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WidgetFileUploader.d.ts","sourceRoot":"","sources":["../../../../../src/components/shared/fileUpload/WidgetFileUploader.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"WidgetFileUploader.d.ts","sourceRoot":"","sources":["../../../../../src/components/shared/fileUpload/WidgetFileUploader.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D,OAAO,KAA0C,MAAM,OAAO,CAAC;AA0B/D,OAAO,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAInD,UAAU,MAAO,SAAQ,wBAAwB,EAAE,gBAAgB;IAC/D,UAAU,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC,SAAS,CAAC;IACtC,WAAW,EAAE,OAAO,CAAC;IACrB,SAAS,EAAE,OAAO,CAAC;CACtB;AAUD,iBAAS,kBAAkB,CAAC,KAAK,EAAE,MAAM,eAwKxC;kBAxKQ,kBAAkB;;;AA4K3B,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|
|
@@ -1,11 +1,23 @@
|
|
|
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 { Button } from '@patternfly/react-core';
|
|
11
|
+
import { ToastNotification } from '@rh-support/components';
|
|
12
|
+
import { getText } from '@rh-support/utils';
|
|
2
13
|
import React, { useContext, useEffect, useState } from 'react';
|
|
3
|
-
import { Trans } from 'react-i18next';
|
|
14
|
+
import { Trans, useTranslation } from 'react-i18next';
|
|
4
15
|
import { RulesDispatchContext, RulesStateContext } from '../../../context/RulesContext';
|
|
5
16
|
import { RulesReducerConstants } from '../../../reducers/RulesReducer';
|
|
6
17
|
import FileLister from './FileLister';
|
|
7
18
|
import WidgetFileSelector from './fileSelectors/WidgetFileSelector';
|
|
8
19
|
import { doSosReportAnalysisForFile, hasAnalysedSomeAttachments, hasSomeSelectedFiles, hasUploadedSomeAttachments, isAnalysingAnyAttachment, isAnalysisNotStarted, isRestoredFromSession, } from './reducer/AttachmentHelper';
|
|
20
|
+
import { defaultAnalysisMetadata, defaultUploadMetadata, onFilesSelect, UploadStatusConstants, } from './reducer/AttachmentReducer';
|
|
9
21
|
import { AttachmentDispatchContext, AttachmentStateContext } from './reducer/AttachmentReducerContext';
|
|
10
22
|
import { FileUploadButton } from './UploadButton';
|
|
11
23
|
import { useFileUploader } from './useFileUploader';
|
|
@@ -17,6 +29,7 @@ const defaultProps = {
|
|
|
17
29
|
isPrivate: false,
|
|
18
30
|
};
|
|
19
31
|
function WidgetFileUploader(props) {
|
|
32
|
+
const { t } = useTranslation();
|
|
20
33
|
const { attachmentState } = useContext(AttachmentStateContext);
|
|
21
34
|
const dispatchToAttachmentReducer = useContext(AttachmentDispatchContext);
|
|
22
35
|
const selectedLocalFiles = attachmentState.caseFiles.selectedLocalFiles;
|
|
@@ -50,7 +63,60 @@ function WidgetFileUploader(props) {
|
|
|
50
63
|
dispatchToAttachmentReducer,
|
|
51
64
|
props.needsAnalyzing,
|
|
52
65
|
]);
|
|
53
|
-
|
|
66
|
+
const getFileAccessDetails = (file) => __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
const fileName = (file === null || file === void 0 ? void 0 : file.name) || '';
|
|
68
|
+
if (file.size === 0) {
|
|
69
|
+
return Promise.reject({
|
|
70
|
+
ableToUpload: false,
|
|
71
|
+
ableToUploadMessage: t(`${fileName} ${getText('is empty')}`),
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
const reader = new FileReader();
|
|
75
|
+
return new Promise((resolve, reject) => {
|
|
76
|
+
reader.onloadend = () => resolve({ ableToUpload: true, ableToUploadMessage: t('File attached, but not yet uploaded') });
|
|
77
|
+
reader.onerror = (ev) => reject({ ableToUpload: false, ableToUploadMessage: t(`${fileName} ${getText("Can't be selected")}`) });
|
|
78
|
+
// only read the first 10 bytes. readAsBinaryString is not supported in IE 11
|
|
79
|
+
reader.readAsArrayBuffer(file.slice(0, 10));
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
// To handle pasting of screenshots in uploader
|
|
83
|
+
const handlePaste = (event) => __awaiter(this, void 0, void 0, function* () {
|
|
84
|
+
let file;
|
|
85
|
+
for (let i = 0; i < event.clipboardData.items.length; ++i) {
|
|
86
|
+
let item = event.clipboardData.items[i];
|
|
87
|
+
if (item.kind === 'file' && item.type.startsWith('image/')) {
|
|
88
|
+
event.preventDefault();
|
|
89
|
+
file = item.getAsFile();
|
|
90
|
+
const onFilesSelectLocal = (caseFiles) => {
|
|
91
|
+
onFilesSelect(dispatchToAttachmentReducer, caseFiles);
|
|
92
|
+
};
|
|
93
|
+
try {
|
|
94
|
+
const fileAccessDetails = yield getFileAccessDetails(file);
|
|
95
|
+
const localFile = {
|
|
96
|
+
name: file.name,
|
|
97
|
+
size: file.size,
|
|
98
|
+
lastModified: file.lastModified,
|
|
99
|
+
type: file.type,
|
|
100
|
+
description: '',
|
|
101
|
+
isPrivate: props.isPrivate,
|
|
102
|
+
uploadProgress: Object.assign(Object.assign({}, defaultUploadMetadata), { uploadStatus: props.isSessionId
|
|
103
|
+
? UploadStatusConstants.attachedOnSession
|
|
104
|
+
: UploadStatusConstants.attachedOnCase }),
|
|
105
|
+
analysisMetadata: Object.assign({}, defaultAnalysisMetadata),
|
|
106
|
+
uploadability: Object.assign({}, fileAccessDetails),
|
|
107
|
+
includeResults: true,
|
|
108
|
+
};
|
|
109
|
+
onFilesSelectLocal({ selectedLocalFiles: [localFile], selectedOriginalFiles: [file] });
|
|
110
|
+
}
|
|
111
|
+
catch (e) {
|
|
112
|
+
if (!e.ableToUpload) {
|
|
113
|
+
ToastNotification.addDangerMessage(e.ableToUploadMessage);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
return (React.createElement("div", { className: `card card-white card-support file-diag ${props.className || ''}`, onPaste: handlePaste },
|
|
54
120
|
React.createElement("h3", { className: "card-heading" },
|
|
55
121
|
React.createElement(Trans, null, "File uploader and analyzer")),
|
|
56
122
|
React.createElement("div", { className: "card-body" },
|
|
@@ -24,6 +24,6 @@ function WidgetFileSelector({ id = '', className = '', isSessionId, isPrivate =
|
|
|
24
24
|
React.createElement("input", Object.assign({ id: "file-diag-selector" }, getInputProps())),
|
|
25
25
|
isDragActive ? (t(`Drop your file here...`)) : (React.createElement(React.Fragment, null,
|
|
26
26
|
React.createElement("span", null,
|
|
27
|
-
React.createElement(Trans, null, "Drag and drop, or browse to upload a file"))))));
|
|
27
|
+
React.createElement(Trans, null, "Drag and drop, paste, or browse to upload a file"))))));
|
|
28
28
|
}
|
|
29
29
|
export default WidgetFileSelector;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rh-support/troubleshoot",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.43",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
@@ -73,8 +73,8 @@
|
|
|
73
73
|
"@patternfly/react-core": "4.264.0",
|
|
74
74
|
"@progress/kendo-drawing": "^1.6.0",
|
|
75
75
|
"@progress/kendo-react-pdf": "^3.12.0",
|
|
76
|
-
"@rh-support/components": "1.2.
|
|
77
|
-
"@rh-support/react-context": "1.0.
|
|
76
|
+
"@rh-support/components": "1.2.19",
|
|
77
|
+
"@rh-support/react-context": "1.0.26",
|
|
78
78
|
"@rh-support/types": "0.2.0",
|
|
79
79
|
"@rh-support/user-permissions": "1.0.11",
|
|
80
80
|
"@rh-support/utils": "1.0.9",
|
|
@@ -145,5 +145,5 @@
|
|
|
145
145
|
"not ie <= 11",
|
|
146
146
|
"not op_mini all"
|
|
147
147
|
],
|
|
148
|
-
"gitHead": "
|
|
148
|
+
"gitHead": "34d2dec5c3f91b58ef2cdd7378f776997e755dfc"
|
|
149
149
|
}
|