@rh-support/troubleshoot 2.2.24 → 2.2.26

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.
@@ -1 +1 @@
1
- {"version":3,"file":"NewProductVersionSelector.d.ts","sourceRoot":"","sources":["../../../../src/components/ProductSelector/NewProductVersionSelector.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AAYpE,UAAU,MAAM;IACZ,eAAe,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IACrC,eAAe,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,YAAY,EAAE,MAAM,CAAC;IACrB,qCAAqC,EAAE,OAAO,CAAC;CAClD;AAED,eAAO,MAAM,yBAAyB,UAAW,MAAM,gBA+HtD,CAAC"}
1
+ {"version":3,"file":"NewProductVersionSelector.d.ts","sourceRoot":"","sources":["../../../../src/components/ProductSelector/NewProductVersionSelector.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AAYpE,UAAU,MAAM;IACZ,eAAe,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IACrC,eAAe,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,YAAY,EAAE,MAAM,CAAC;IACrB,qCAAqC,EAAE,OAAO,CAAC;CAClD;AAED,eAAO,MAAM,yBAAyB,UAAW,MAAM,gBAiItD,CAAC"}
@@ -89,6 +89,9 @@ export const NewProductVersionSelector = (props) => {
89
89
  };
90
90
  useEffect(() => {
91
91
  const versionValidator = () => {
92
+ var _a;
93
+ if (!((_a = props.selectedProduct) === null || _a === void 0 ? void 0 : _a.versions))
94
+ return;
92
95
  const confirmMatchVersion = props.selectedProduct.versions.find((version) => version === props.versionState);
93
96
  if (isEmpty(confirmMatchVersion)) {
94
97
  setSelected('');
@@ -1 +1 @@
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;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;CACpB;AAYD,iBAAS,kBAAkB,CAAC,KAAK,EAAE,MAAM,eA+MxC;kBA/MQ,kBAAkB;;;AAmN3B,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
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;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;CACpB;AAYD,iBAAS,kBAAkB,CAAC,KAAK,EAAE,MAAM,eA4NxC;kBA5NQ,kBAAkB;;;AAgO3B,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
@@ -40,6 +40,7 @@ function WidgetFileUploader(props) {
40
40
  const [showViewRecBtn, setShowViewRecBtn] = useState(false);
41
41
  const { editFile, removeFile, retryUpload, uploadAll, retryAnalysis } = useFileUploader(props);
42
42
  const [unallowedLocalFileExists, setUnallowedLocalFileExists] = useState(false);
43
+ const [fileExceedInfo, setfileExceedInfo] = useState({ show: false, fileName: [] });
43
44
  useEffect(() => {
44
45
  if (rulesState.triggerRuleNotification) {
45
46
  !showViewRecBtn && setShowViewRecBtn(true);
@@ -53,6 +54,10 @@ function WidgetFileUploader(props) {
53
54
  if (isIdea) {
54
55
  unallowedFiles = selectedLocalFiles.filter((file) => !allowedTypesIdea.includes(file.type));
55
56
  }
57
+ if (selectedLocalFiles.some((file) => file.size > 5242880)) {
58
+ let files = selectedLocalFiles.filter((file) => file.size > 5242880).map((file) => file.name);
59
+ setfileExceedInfo({ show: true, fileName: files });
60
+ }
56
61
  let hasUnallowedFiles = unallowedFiles.length > 0;
57
62
  setUnallowedLocalFileExists(hasUnallowedFiles);
58
63
  };
@@ -66,11 +71,10 @@ function WidgetFileUploader(props) {
66
71
  });
67
72
  };
68
73
  useEffect(() => {
69
- if (props.isIdea)
70
- return;
71
74
  attachmentState.caseFiles.selectedLocalFiles.forEach((file, index) => {
72
75
  if (isRestoredFromSession(file.uploadProgress.uploadStatus) &&
73
76
  isAnalysisNotStarted(file.analysisMetadata.analysisStatus)) {
77
+ //need to analyze when props.isIdea changes
74
78
  props.needsAnalyzing &&
75
79
  doSosReportAnalysisForFile(dispatchToAttachmentReducer, props.idToUploadTo, file.attachmentId, file, true, index);
76
80
  }
@@ -138,7 +142,7 @@ function WidgetFileUploader(props) {
138
142
  return (React.createElement("div", { className: `card card-white card-support file-diag ${props.className || ''}`, onPaste: handlePaste },
139
143
  React.createElement("h3", { className: "card-heading" }, props.isIdea || props.isSecureSupport ? (React.createElement(Trans, null, "File uploader")) : (React.createElement(Trans, null, "Upload file to analyze"))),
140
144
  React.createElement("div", { className: "card-body" },
141
- React.createElement(WidgetFileSelector, { isSessionId: props.isSessionId, isPrivate: props.isPrivate, isIdea: props.isIdea }),
145
+ React.createElement(WidgetFileSelector, { isSessionId: props.isSessionId, isPrivate: props.isPrivate, isIdea: props.isIdea, showFileExceed: fileExceedInfo }),
142
146
  !hasSomeSelectedFiles(selectedLocalFiles) ? ((!props.isIdea && props.helperText) || (React.createElement("p", { className: "pf-u-mt-sm" },
143
147
  !props.isIdea ? (React.createElement(Trans, { i18nKey: "i18nUploadSosReport" },
144
148
  "Upload a",
@@ -3,7 +3,11 @@ interface IProps extends IDClassNameProps {
3
3
  isSessionId: boolean;
4
4
  isPrivate: boolean;
5
5
  isIdea?: boolean;
6
+ showFileExceed?: {
7
+ show: boolean;
8
+ fileName: string[];
9
+ };
6
10
  }
7
- declare function WidgetFileSelector({ id, className, isSessionId, isPrivate, isIdea }: IProps): JSX.Element;
11
+ declare function WidgetFileSelector({ id, className, isSessionId, isPrivate, isIdea, showFileExceed, }: IProps): JSX.Element;
8
12
  export default WidgetFileSelector;
9
13
  //# sourceMappingURL=WidgetFileSelector.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"WidgetFileSelector.d.ts","sourceRoot":"","sources":["../../../../../../src/components/shared/fileUpload/fileSelectors/WidgetFileSelector.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAS5D,UAAU,MAAO,SAAQ,gBAAgB;IACrC,WAAW,EAAE,OAAO,CAAC;IACrB,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,iBAAS,kBAAkB,CAAC,EAAE,EAAO,EAAE,SAAc,EAAE,WAAW,EAAE,SAAiB,EAAE,MAAc,EAAE,EAAE,MAAM,eAiE9G;AAED,eAAe,kBAAkB,CAAC"}
1
+ {"version":3,"file":"WidgetFileSelector.d.ts","sourceRoot":"","sources":["../../../../../../src/components/shared/fileUpload/fileSelectors/WidgetFileSelector.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAS5D,UAAU,MAAO,SAAQ,gBAAgB;IACrC,WAAW,EAAE,OAAO,CAAC;IACrB,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,cAAc,CAAC,EAAE;QACb,IAAI,EAAE,OAAO,CAAC;QACd,QAAQ,EAAE,MAAM,EAAE,CAAC;KACtB,CAAC;CACL;AAED,iBAAS,kBAAkB,CAAC,EACxB,EAAO,EACP,SAAc,EACd,WAAW,EACX,SAAiB,EACjB,MAAc,EACd,cAA8C,GACjD,EAAE,MAAM,eAuER;AAED,eAAe,kBAAkB,CAAC"}
@@ -4,7 +4,7 @@ import { useDropzone } from 'react-dropzone';
4
4
  import { Trans, useTranslation } from 'react-i18next';
5
5
  import { onDrop } from '../reducer/AttachmentHelper';
6
6
  import { AttachmentDispatchContext } from '../reducer/AttachmentReducerContext';
7
- function WidgetFileSelector({ id = '', className = '', isSessionId, isPrivate = false, isIdea = false }) {
7
+ function WidgetFileSelector({ id = '', className = '', isSessionId, isPrivate = false, isIdea = false, showFileExceed = { show: false, fileName: [] }, }) {
8
8
  const { t } = useTranslation();
9
9
  const MAX_SIZE = isIdea ? 5242880 : undefined;
10
10
  // Attachment Reducer Related
@@ -30,17 +30,25 @@ function WidgetFileSelector({ id = '', className = '', isSessionId, isPrivate =
30
30
  isDragActive ? (t(`Drop your file here...`)) : (React.createElement(Trans, null, "Drag and drop, paste, or browse to upload a file")),
31
31
  isIdea && (React.createElement("div", { className: "pf-u-text-align-center pf-u-color-300 pf-u-font-weight-normal" },
32
32
  React.createElement(Trans, null, "Files must be less than 5 MB.")))),
33
- isIdea && (React.createElement("p", { className: "pf-u-danger-color-200" }, rejectedFiles.map((rejectedFile) => {
34
- const isImage = /image\/(png|gif|jpe?g)/.test(rejectedFile.type);
35
- return !isImage ? (React.createElement("div", null,
36
- rejectedFile.name,
37
- " ",
38
- React.createElement(Trans, null, "is not an allowed file type or an image "))) : rejectedFile.size > MAX_SIZE ? (React.createElement("div", null,
39
- rejectedFile.name,
40
- " ",
41
- React.createElement(Trans, null, "exceeded max size limit of"),
42
- " ",
43
- humanizeSize(MAX_SIZE))) : ('');
44
- })))));
33
+ isIdea && (React.createElement("p", { className: "pf-u-danger-color-200" },
34
+ rejectedFiles.map((rejectedFile) => {
35
+ const isImage = /image\/(png|gif|jpe?g)/.test(rejectedFile.type);
36
+ return !isImage ? (React.createElement("div", null,
37
+ rejectedFile.name,
38
+ " ",
39
+ React.createElement(Trans, null, "is not an allowed file type or an image "))) : showFileExceed ? (React.createElement("div", null,
40
+ rejectedFile.name,
41
+ " ",
42
+ React.createElement(Trans, null, "exceeded max size limit of"),
43
+ " ",
44
+ humanizeSize(MAX_SIZE))) : ('');
45
+ }),
46
+ showFileExceed &&
47
+ showFileExceed.fileName.map((exceededFiles) => (React.createElement("div", null,
48
+ exceededFiles,
49
+ " ",
50
+ React.createElement(Trans, null, "exceeded max size limit of"),
51
+ " ",
52
+ humanizeSize(MAX_SIZE))))))));
45
53
  }
46
54
  export default WidgetFileSelector;
@@ -1 +1 @@
1
- {"version":3,"file":"useIsSectionValid.d.ts","sourceRoot":"","sources":["../../../../src/components/shared/useIsSectionValid.tsx"],"names":[],"mappings":"AAwBA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAInE,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,gBAAgB;;;;;EAyL9D"}
1
+ {"version":3,"file":"useIsSectionValid.d.ts","sourceRoot":"","sources":["../../../../src/components/shared/useIsSectionValid.tsx"],"names":[],"mappings":"AAwBA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAInE,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,gBAAgB;;;;;EA2L9D"}
@@ -42,7 +42,8 @@ export function useIsSectionValid(sectionName) {
42
42
  unallowedFiles = selectedLocalFiles.filter((file) => !allowedTypesIdea.includes(file.type));
43
43
  }
44
44
  let hasUnallowedFiles = (unallowedFiles === null || unallowedFiles === void 0 ? void 0 : unallowedFiles.length) > 0;
45
- return !hasUnallowedFiles; // we want it false to trigger the error if its true
45
+ const hasOversizeFiles = selectedLocalFiles.some((file) => file.size > 5242880);
46
+ return !hasUnallowedFiles && !hasOversizeFiles; // we want it false to trigger the error if its true
46
47
  };
47
48
  const isGetSupportSectionValidLocal = () => {
48
49
  return (!isEmpty(caseType) &&
@@ -1 +1 @@
1
- {"version":3,"file":"GlobalTroubleshootEffects.d.ts","sourceRoot":"","sources":["../../../../src/components/wizardLayout/GlobalTroubleshootEffects.tsx"],"names":[],"mappings":"AAWA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAUvD,OAAO,EAAqB,eAAe,EAAE,MAAM,iCAAiC,CAAC;AASrF,UAAU,MAAM;IACZ,UAAU,EAAE,mBAAmB,CAAC,eAAe,CAAC,CAAC;CACpD;AAED,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,MAAM,eAgVtD"}
1
+ {"version":3,"file":"GlobalTroubleshootEffects.d.ts","sourceRoot":"","sources":["../../../../src/components/wizardLayout/GlobalTroubleshootEffects.tsx"],"names":[],"mappings":"AAWA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAUvD,OAAO,EAAqB,eAAe,EAAE,MAAM,iCAAiC,CAAC;AASrF,UAAU,MAAM;IACZ,UAAU,EAAE,mBAAmB,CAAC,eAAe,CAAC,CAAC;CACpD;AAED,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,MAAM,eA6VtD"}
@@ -54,6 +54,7 @@ export function GlobalTroubleshootEffects(props) {
54
54
  const isCaseCreate = RouteUtils.getQueryParams(props.routeProps).caseCreate === 'true';
55
55
  const urlQueryParams = RouteUtils.getQueryParams(props.routeProps);
56
56
  const isFirstMount = useRef(true);
57
+ const isFirstMountProduct = useRef(true);
57
58
  const { getPreferredLanguage } = useUserPreferences();
58
59
  const rulesDispatch = useContext(RulesDispatchContext);
59
60
  const canAddAttachments = ability.can(resourceActions.PATCH, resources.CASE_CREATE, CaseListFields.ATTACHMENTS);
@@ -68,32 +69,44 @@ export function GlobalTroubleshootEffects(props) {
68
69
  * Setting product version on case details from url.
69
70
  */
70
71
  useEffect(() => {
71
- const productFromUrl = urlQueryParams.product;
72
- const versionFromUrl = urlQueryParams.version;
73
- if (!productFromUrl ||
74
- allProducts.isFetching ||
75
- allProducts.isError ||
76
- isEmpty(allProducts.data.productsResult))
72
+ if (!isFirstMountProduct.current && allProducts.isFetching)
77
73
  return;
78
- const index = findIndex(allProducts.data.productsResult, (p) => p.product === productFromUrl);
79
- if (index === -1) {
80
- // invalid product, reset url
81
- const newParams = {
82
- product: undefined,
83
- version: undefined,
84
- };
85
- RouteUtils.updateQueryParams(props.routeProps, newParams);
86
- return;
87
- }
88
- // product in url is valid check to see if version is valid
89
- const productVersions = allProducts.data.productsResult[index].versions;
90
- const isVersionFromURLValid = !isEmpty(versionFromUrl) && includes(productVersions, versionFromUrl);
91
- const versionToSet = isVersionFromURLValid ? versionFromUrl : undefined;
92
- if (product !== productFromUrl || version !== versionToSet) {
93
- setCaseDetails(caseDispatch, {
94
- product: productFromUrl,
95
- version: versionToSet,
96
- });
74
+ if (isFirstMountProduct.current) {
75
+ const productFromUrl = urlQueryParams.product;
76
+ const versionFromUrl = urlQueryParams.version;
77
+ if (!productFromUrl ||
78
+ allProducts.isFetching ||
79
+ allProducts.isError ||
80
+ isEmpty(allProducts.data.productsResult))
81
+ return;
82
+ const index = findIndex(allProducts.data.productsResult, (p) => p.product === productFromUrl);
83
+ if (index === -1) {
84
+ // invalid product, reset url
85
+ const newParams = {
86
+ product: undefined,
87
+ version: undefined,
88
+ };
89
+ RouteUtils.updateQueryParams(props.routeProps, newParams);
90
+ return;
91
+ }
92
+ // product in url is valid check to see if version is valid
93
+ const productVersions = allProducts.data.productsResult[index].versions;
94
+ let versionToSet;
95
+ if (productVersions) {
96
+ const isVersionFromURLValid = !isEmpty(versionFromUrl) && includes(productVersions, versionFromUrl);
97
+ versionToSet = isVersionFromURLValid ? versionFromUrl : undefined;
98
+ }
99
+ else {
100
+ // when productVersions is not available, it means se product api is down.
101
+ versionToSet = undefined;
102
+ }
103
+ if (product !== productFromUrl || version !== versionToSet) {
104
+ setCaseDetails(caseDispatch, {
105
+ product: productFromUrl,
106
+ version: versionToSet,
107
+ });
108
+ }
109
+ isFirstMountProduct.current = false;
97
110
  }
98
111
  // eslint-disable-next-line react-hooks/exhaustive-deps
99
112
  }, [allProducts.data.productsResult, caseDispatch, props.routeProps]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rh-support/troubleshoot",
3
- "version": "2.2.24",
3
+ "version": "2.2.26",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org"
@@ -133,5 +133,5 @@
133
133
  "defaults and supports es6-module",
134
134
  "maintained node versions"
135
135
  ],
136
- "gitHead": "3cb1c9deeb0f55a0df73b0f0845194a72cbac688"
136
+ "gitHead": "59ffadf54159c0aaa828c8684df1bbf33402a0ed"
137
137
  }