@hmcts/ccd-case-ui-toolkit 7.0.17-error-message → 7.0.17-rework-on-file-upload-error2

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.
@@ -1241,14 +1241,9 @@ class HttpError {
1241
1241
  }
1242
1242
  static from(response) {
1243
1243
  const error = new HttpError();
1244
- if (response?.status === 429) {
1245
- error.error = HttpError.MESSAGE_ERROR_429;
1246
- error.status = response.status;
1247
- error.message = response.message;
1248
- }
1249
1244
  // Check that the HttpErrorResponse contains an "error" object before mapping the error properties
1250
1245
  if (!!(response && response.error)) {
1251
- Object.keys(error).forEach((key) => {
1246
+ Object.keys(error).forEach(key => {
1252
1247
  error[key] = response.error.hasOwnProperty(key) && response.error[key] ? response.error[key] : error[key];
1253
1248
  });
1254
1249
  }
@@ -1265,7 +1260,6 @@ class HttpError {
1265
1260
  HttpError.DEFAULT_ERROR = 'Unknown error';
1266
1261
  HttpError.DEFAULT_MESSAGE = 'Something unexpected happened, our technical staff have been automatically notified';
1267
1262
  HttpError.DEFAULT_STATUS = 500;
1268
- HttpError.MESSAGE_ERROR_429 = 'Your request was rate limited. Please wait a few seconds before retrying your document upload';
1269
1263
 
1270
1264
  /**
1271
1265
  * `Oauth2Service` and `AuthService` cannot be merged as it creates a cyclic dependency on `AuthService` through `HttpErrorService`.
@@ -13453,23 +13447,29 @@ class WriteDocumentFieldComponent extends AbstractFieldWriteComponent {
13453
13447
  this.uploadedDocument = this.registerControl(new FormGroup(documentFormGroup), true);
13454
13448
  }
13455
13449
  getErrorMessage(error) {
13456
- // Document Management unavailable
13457
- if (0 === error.status || 502 === error.status) {
13458
- return WriteDocumentFieldComponent.UPLOAD_ERROR_NOT_AVAILABLE;
13459
- }
13460
- // let errorMsg = 'Error uploading file';
13461
- // if (error?.error) {
13462
- // const fullError = error.error;
13463
- // const start = fullError.indexOf('{');
13464
- // if (start >= 0) {
13465
- // const json = fullError.substring(start, fullError.length - 1).split('<EOL>').join('');
13466
- // const obj = JSON.parse(json);
13467
- // if (obj?.error) {
13468
- // errorMsg = obj.error;
13469
- // }
13470
- // }
13471
- // }
13472
- return error.error;
13450
+ switch (error.status) {
13451
+ case 0:
13452
+ case 502:
13453
+ return WriteDocumentFieldComponent.UPLOAD_ERROR_NOT_AVAILABLE;
13454
+ case 422:
13455
+ let errorMsg = WriteDocumentFieldComponent.ERROR_UPLOADING_FILE;
13456
+ if (error?.error) {
13457
+ const fullError = error.error;
13458
+ const start = fullError.indexOf('{');
13459
+ if (start >= 0) {
13460
+ const json = fullError.substring(start, fullError.length - 1).split('<EOL>').join('');
13461
+ const obj = JSON.parse(json);
13462
+ if (obj?.error) {
13463
+ errorMsg = obj.error;
13464
+ }
13465
+ }
13466
+ }
13467
+ return errorMsg;
13468
+ case 429:
13469
+ return error?.error;
13470
+ default:
13471
+ return WriteDocumentFieldComponent.ERROR_UPLOADING_FILE;
13472
+ }
13473
13473
  }
13474
13474
  buildDocumentUploadData(selectedFile) {
13475
13475
  const documentUpload = new FormData();
@@ -13524,6 +13524,7 @@ WriteDocumentFieldComponent.DOCUMENT_HASH = 'document_hash';
13524
13524
  WriteDocumentFieldComponent.UPLOAD_ERROR_FILE_REQUIRED = 'File required';
13525
13525
  WriteDocumentFieldComponent.UPLOAD_ERROR_NOT_AVAILABLE = 'Document upload facility is not available at the moment';
13526
13526
  WriteDocumentFieldComponent.UPLOAD_WAITING_FILE_STATUS = 'Uploading...';
13527
+ WriteDocumentFieldComponent.ERROR_UPLOADING_FILE = 'Error Uploading File';
13527
13528
  WriteDocumentFieldComponent.ɵfac = function WriteDocumentFieldComponent_Factory(t) { return new (t || WriteDocumentFieldComponent)(i0.ɵɵdirectiveInject(AbstractAppConfig), i0.ɵɵdirectiveInject(CaseNotifier), i0.ɵɵdirectiveInject(DocumentManagementService), i0.ɵɵdirectiveInject(i1$3.MatLegacyDialog), i0.ɵɵdirectiveInject(FileUploadStateService), i0.ɵɵdirectiveInject(JurisdictionService)); };
13528
13529
  WriteDocumentFieldComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: WriteDocumentFieldComponent, selectors: [["ccd-write-document-field"]], viewQuery: function WriteDocumentFieldComponent_Query(rf, ctx) { if (rf & 1) {
13529
13530
  i0.ɵɵviewQuery(_c0$Q, 5);
@@ -32465,14 +32466,14 @@ class EventTriggerComponent {
32465
32466
  }
32466
32467
  }
32467
32468
  EventTriggerComponent.ɵfac = function EventTriggerComponent_Factory(t) { return new (t || EventTriggerComponent)(i0.ɵɵdirectiveInject(i3.FormBuilder), i0.ɵɵdirectiveInject(OrderService)); };
32468
- EventTriggerComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: EventTriggerComponent, selectors: [["ccd-event-trigger"]], inputs: { triggers: "triggers", triggerText: "triggerText", isDisabled: "isDisabled" }, outputs: { onTriggerSubmit: "onTriggerSubmit", onTriggerChange: "onTriggerChange" }, features: [i0.ɵɵNgOnChangesFeature], decls: 1, vars: 1, consts: [["class", "event-trigger", 3, "formGroup", "ngSubmit", 4, "ngIf"], [1, "event-trigger", 3, "formGroup", "ngSubmit"], [1, "form-group"], ["for", "next-step", 1, "form-label"], ["id", "next-step", "formControlName", "trigger", 1, "form-control", "ccd-dropdown", 3, "ngClass", "change"], ["value", "", "data-default", "", 4, "ngIf"], [3, "ngValue", "title", 4, "ngFor", "ngForOf"], ["type", "submit", 1, "button", 3, "disabled"], ["value", "", "data-default", ""], [3, "ngValue", "title"]], template: function EventTriggerComponent_Template(rf, ctx) { if (rf & 1) {
32469
+ EventTriggerComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: EventTriggerComponent, selectors: [["ccd-event-trigger"]], inputs: { triggers: "triggers", triggerText: "triggerText", isDisabled: "isDisabled" }, outputs: { onTriggerSubmit: "onTriggerSubmit", onTriggerChange: "onTriggerChange" }, features: [i0.ɵɵNgOnChangesFeature], decls: 1, vars: 1, consts: [["class", "event-trigger", 3, "formGroup", "ngSubmit", 4, "ngIf"], [1, "event-trigger", 3, "formGroup", "ngSubmit"], [1, "form-group", 2, "width", "350px !important"], ["for", "next-step", 1, "form-label"], ["id", "next-step", "formControlName", "trigger", 1, "form-control", "ccd-dropdown", 3, "ngClass", "change"], ["value", "", "data-default", "", 4, "ngIf"], [3, "ngValue", "title", 4, "ngFor", "ngForOf"], ["type", "submit", 1, "button", 3, "disabled"], ["value", "", "data-default", ""], [3, "ngValue", "title"]], template: function EventTriggerComponent_Template(rf, ctx) { if (rf & 1) {
32469
32470
  i0.ɵɵtemplate(0, EventTriggerComponent_form_0_Template, 11, 13, "form", 0);
32470
32471
  } if (rf & 2) {
32471
32472
  i0.ɵɵproperty("ngIf", ctx.triggers && ctx.triggers.length);
32472
32473
  } }, dependencies: [i4.NgClass, i4.NgForOf, i4.NgIf, i3.ɵNgNoValidate, i3.NgSelectOption, i3.ɵNgSelectMultipleOption, i3.SelectControlValueAccessor, i3.NgControlStatus, i3.NgControlStatusGroup, i3.FormGroupDirective, i3.FormControlName, i1.RpxTranslatePipe], styles: [".event-trigger[_ngcontent-%COMP%]{width:auto;margin-top:40px;margin-bottom:20px}.event-trigger[_ngcontent-%COMP%] .form-group[_ngcontent-%COMP%]{margin-top:3px;margin-right:10px;margin-bottom:0;float:left;text-align:right;width:325px}.event-trigger[_ngcontent-%COMP%] .form-group[_ngcontent-%COMP%] .form-label[_ngcontent-%COMP%]{float:left;margin-top:5px}.event-trigger[_ngcontent-%COMP%] select[_ngcontent-%COMP%]{width:250px}.event-trigger[_ngcontent-%COMP%] select.EventTrigger-empty[_ngcontent-%COMP%], .event-trigger[_ngcontent-%COMP%] select[_ngcontent-%COMP%] [data-default][_ngcontent-%COMP%]{color:#6f777b}"] });
32473
32474
  (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(EventTriggerComponent, [{
32474
32475
  type: Component,
32475
- args: [{ selector: 'ccd-event-trigger', template: "<form *ngIf=\"triggers && triggers.length\" class=\"event-trigger\" (ngSubmit)=\"triggerSubmit()\" [formGroup]=\"triggerForm\">\n <div class=\"form-group\">\n <label class=\"form-label\" for=\"next-step\">{{'Next step' | rpxTranslate}}</label>\n <select class=\"form-control ccd-dropdown\" id=\"next-step\" (change)=\"triggerChange()\" formControlName=\"trigger\" [ngClass]=\"{\n 'EventTrigger-empty': !triggerForm.value['trigger']\n }\">\n <option *ngIf=\"1 !== triggers.length\" value=\"\" data-default>{{'Select action' | rpxTranslate}}</option>\n <option *ngFor=\"let trigger of triggers\" [ngValue]=\"trigger\" [title]=\"trigger.description\">{{trigger.name | rpxTranslate}}</option>\n </select>\n </div>\n <button [disabled]=\"isButtonDisabled()\" type=\"submit\" class=\"button\">{{triggerText | rpxTranslate}}</button>\n</form>\n", styles: [".event-trigger{width:auto;margin-top:40px;margin-bottom:20px}.event-trigger .form-group{margin-top:3px;margin-right:10px;margin-bottom:0;float:left;text-align:right;width:325px}.event-trigger .form-group .form-label{float:left;margin-top:5px}.event-trigger select{width:250px}.event-trigger select.EventTrigger-empty,.event-trigger select [data-default]{color:#6f777b}\n"] }]
32476
+ args: [{ selector: 'ccd-event-trigger', template: "<form *ngIf=\"triggers && triggers.length\" class=\"event-trigger\" (ngSubmit)=\"triggerSubmit()\" [formGroup]=\"triggerForm\">\n <div class=\"form-group\" style=\"width: 350px !important;\">\n <label class=\"form-label\" for=\"next-step\">{{'Next step' | rpxTranslate}}</label>\n <select class=\"form-control ccd-dropdown\" id=\"next-step\" (change)=\"triggerChange()\" formControlName=\"trigger\" [ngClass]=\"{\n 'EventTrigger-empty': !triggerForm.value['trigger']\n }\">\n <option *ngIf=\"1 !== triggers.length\" value=\"\" data-default>{{'Select action' | rpxTranslate}}</option>\n <option *ngFor=\"let trigger of triggers\" [ngValue]=\"trigger\" [title]=\"trigger.description\">{{trigger.name | rpxTranslate}}</option>\n </select>\n </div>\n <button [disabled]=\"isButtonDisabled()\" type=\"submit\" class=\"button\">{{triggerText | rpxTranslate}}</button>\n</form>\n", styles: [".event-trigger{width:auto;margin-top:40px;margin-bottom:20px}.event-trigger .form-group{margin-top:3px;margin-right:10px;margin-bottom:0;float:left;text-align:right;width:325px}.event-trigger .form-group .form-label{float:left;margin-top:5px}.event-trigger select{width:250px}.event-trigger select.EventTrigger-empty,.event-trigger select [data-default]{color:#6f777b}\n"] }]
32476
32477
  }], function () { return [{ type: i3.FormBuilder }, { type: OrderService }]; }, { triggers: [{
32477
32478
  type: Input
32478
32479
  }], triggerText: [{