mizozobu 6 ani în urmă
părinte
comite
2f5c0ee806

+ 4 - 0
src/client/js/util/apiNotification.js

@@ -1,3 +1,5 @@
+// show API error/sucess toastr
+
 import * as toastr from 'toastr';
 import * as toastr from 'toastr';
 import toArrayIfNot from '../../../lib/util/toArrayIfNot';
 import toArrayIfNot from '../../../lib/util/toArrayIfNot';
 
 
@@ -20,6 +22,7 @@ const toastrOption = {
   },
   },
 };
 };
 
 
+// accepts both a single error and an array of errors
 export const toastError = (err, header = 'Error', option = toastrOption.error) => {
 export const toastError = (err, header = 'Error', option = toastrOption.error) => {
   const errs = toArrayIfNot(err);
   const errs = toArrayIfNot(err);
 
 
@@ -28,6 +31,7 @@ export const toastError = (err, header = 'Error', option = toastrOption.error) =
   }
   }
 };
 };
 
 
+// only accepts a single item
 export const toastSuccess = (body, header = 'Success', option = toastrOption.success) => {
 export const toastSuccess = (body, header = 'Success', option = toastrOption.success) => {
   toastr.success(body, header, option);
   toastr.success(body, header, option);
 };
 };

+ 3 - 0
src/client/js/util/apiv3ErrorHandler.js

@@ -1,3 +1,6 @@
+// API v3 sends an array of errors in res.data.errors.
+// API v3 errors need to extracted from an error object in order to properly handle them.
+
 import toArrayIfNot from '../../../lib/util/toArrayIfNot';
 import toArrayIfNot from '../../../lib/util/toArrayIfNot';
 
 
 const logger = require('@alias/logger')('growi:apiv3');
 const logger = require('@alias/logger')('growi:apiv3');

+ 2 - 0
src/lib/util/toArrayIfNot.js

@@ -1,3 +1,5 @@
+// converts non-array item to array
+
 const toArrayIfNot = (item) => {
 const toArrayIfNot = (item) => {
   if (item == null) {
   if (item == null) {
     return [];
     return [];