Skip to content

Commit

Permalink
Added new implementation for error handling (#901)
Browse files Browse the repository at this point in the history
Now errors will display detailed information, modal box errors will prioritize detailed errors
  • Loading branch information
bexsoft committed Jul 28, 2021
1 parent 87917e6 commit 13844e1
Show file tree
Hide file tree
Showing 33 changed files with 370 additions and 67 deletions.
14 changes: 7 additions & 7 deletions portal-ui/build/asset-manifest.json
@@ -1,25 +1,25 @@
{
"files": {
"main.css": "/static/css/main.8cfac526.chunk.css",
"main.js": "/static/js/main.926c7b22.chunk.js",
"main.js.map": "/static/js/main.926c7b22.chunk.js.map",
"main.js": "/static/js/main.6ca7d2e8.chunk.js",
"main.js.map": "/static/js/main.6ca7d2e8.chunk.js.map",
"runtime-main.js": "/static/js/runtime-main.43a31377.js",
"runtime-main.js.map": "/static/js/runtime-main.43a31377.js.map",
"static/css/2.60e04a19.chunk.css": "/static/css/2.60e04a19.chunk.css",
"static/js/2.1bafa615.chunk.js": "/static/js/2.1bafa615.chunk.js",
"static/js/2.1bafa615.chunk.js.map": "/static/js/2.1bafa615.chunk.js.map",
"static/js/2.da0353b6.chunk.js": "/static/js/2.da0353b6.chunk.js",
"static/js/2.da0353b6.chunk.js.map": "/static/js/2.da0353b6.chunk.js.map",
"index.html": "/index.html",
"static/css/2.60e04a19.chunk.css.map": "/static/css/2.60e04a19.chunk.css.map",
"static/css/main.8cfac526.chunk.css.map": "/static/css/main.8cfac526.chunk.css.map",
"static/js/2.1bafa615.chunk.js.LICENSE.txt": "/static/js/2.1bafa615.chunk.js.LICENSE.txt",
"static/js/2.da0353b6.chunk.js.LICENSE.txt": "/static/js/2.da0353b6.chunk.js.LICENSE.txt",
"static/media/minio_console_logo.0837460e.svg": "/static/media/minio_console_logo.0837460e.svg",
"static/media/minio_operator_logo.1312b7c9.svg": "/static/media/minio_operator_logo.1312b7c9.svg"
},
"entrypoints": [
"static/js/runtime-main.43a31377.js",
"static/css/2.60e04a19.chunk.css",
"static/js/2.1bafa615.chunk.js",
"static/js/2.da0353b6.chunk.js",
"static/css/main.8cfac526.chunk.css",
"static/js/main.926c7b22.chunk.js"
"static/js/main.6ca7d2e8.chunk.js"
]
}
2 changes: 1 addition & 1 deletion portal-ui/build/index.html
@@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="MinIO Console"/><link href="https://fonts.googleapis.com/css2?family=Lato:wght@400;500;700;900&display=swap" rel="stylesheet"/><link href="/styles/root-styles.css" rel="stylesheet"/><link rel="apple-touch-icon" sizes="180x180" href="/apple-icon-180x180.png"/><link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png"/><link rel="icon" type="image/png" sizes="96x96" href="/favicon-96x96.png"/><link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png"/><link rel="manifest" href="/manifest.json"/><link rel="mask-icon" href="/safari-pinned-tab.svg" color="#3a4e54"/><title>MinIO Console</title><link href="/static/css/2.60e04a19.chunk.css" rel="stylesheet"><link href="/static/css/main.8cfac526.chunk.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"><div id="loader-block"><svg class="loader-svg-container" viewBox="22 22 44 44"><circle class="loader-style MuiCircularProgress-circle MuiCircularProgress-circleIndeterminate" cx="44" cy="44" r="20.2" fill="none" stroke-width="3.6"></circle></svg></div></div><script>!function(e){function r(r){for(var n,l,i=r[0],a=r[1],p=r[2],c=0,s=[];c<i.length;c++)l=i[c],Object.prototype.hasOwnProperty.call(o,l)&&o[l]&&s.push(o[l][0]),o[l]=0;for(n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n]);for(f&&f(r);s.length;)s.shift()();return u.push.apply(u,p||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,i=1;i<t.length;i++){var a=t[i];0!==o[a]&&(n=!1)}n&&(u.splice(r--,1),e=l(l.s=t[0]))}return e}var n={},o={1:0},u=[];function l(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,l),t.l=!0,t.exports}l.m=e,l.c=n,l.d=function(e,r,t){l.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},l.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},l.t=function(e,r){if(1&r&&(e=l(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(l.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)l.d(t,n,function(r){return e[r]}.bind(null,n));return t},l.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return l.d(r,"a",r),r},l.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},l.p="/";var i=this["webpackJsonpportal-ui"]=this["webpackJsonpportal-ui"]||[],a=i.push.bind(i);i.push=r,i=i.slice();for(var p=0;p<i.length;p++)r(i[p]);var f=a;t()}([])</script><script src="/static/js/2.1bafa615.chunk.js"></script><script src="/static/js/main.926c7b22.chunk.js"></script></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="MinIO Console"/><link href="https://fonts.googleapis.com/css2?family=Lato:wght@400;500;700;900&display=swap" rel="stylesheet"/><link href="/styles/root-styles.css" rel="stylesheet"/><link rel="apple-touch-icon" sizes="180x180" href="/apple-icon-180x180.png"/><link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png"/><link rel="icon" type="image/png" sizes="96x96" href="/favicon-96x96.png"/><link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png"/><link rel="manifest" href="/manifest.json"/><link rel="mask-icon" href="/safari-pinned-tab.svg" color="#3a4e54"/><title>MinIO Console</title><link href="/static/css/2.60e04a19.chunk.css" rel="stylesheet"><link href="/static/css/main.8cfac526.chunk.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"><div id="loader-block"><svg class="loader-svg-container" viewBox="22 22 44 44"><circle class="loader-style MuiCircularProgress-circle MuiCircularProgress-circleIndeterminate" cx="44" cy="44" r="20.2" fill="none" stroke-width="3.6"></circle></svg></div></div><script>!function(e){function r(r){for(var n,l,i=r[0],a=r[1],p=r[2],c=0,s=[];c<i.length;c++)l=i[c],Object.prototype.hasOwnProperty.call(o,l)&&o[l]&&s.push(o[l][0]),o[l]=0;for(n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n]);for(f&&f(r);s.length;)s.shift()();return u.push.apply(u,p||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,i=1;i<t.length;i++){var a=t[i];0!==o[a]&&(n=!1)}n&&(u.splice(r--,1),e=l(l.s=t[0]))}return e}var n={},o={1:0},u=[];function l(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,l),t.l=!0,t.exports}l.m=e,l.c=n,l.d=function(e,r,t){l.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},l.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},l.t=function(e,r){if(1&r&&(e=l(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(l.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)l.d(t,n,function(r){return e[r]}.bind(null,n));return t},l.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return l.d(r,"a",r),r},l.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},l.p="/";var i=this["webpackJsonpportal-ui"]=this["webpackJsonpportal-ui"]||[],a=i.push.bind(i);i.push=r,i=i.slice();for(var p=0;p<i.length;p++)r(i[p]);var f=a;t()}([])</script><script src="/static/js/2.da0353b6.chunk.js"></script><script src="/static/js/main.6ca7d2e8.chunk.js"></script></body></html>
3 changes: 0 additions & 3 deletions portal-ui/build/static/js/2.1bafa615.chunk.js

This file was deleted.

1 change: 0 additions & 1 deletion portal-ui/build/static/js/2.1bafa615.chunk.js.map

This file was deleted.

3 changes: 3 additions & 0 deletions portal-ui/build/static/js/2.da0353b6.chunk.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions portal-ui/build/static/js/2.da0353b6.chunk.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions portal-ui/build/static/js/main.6ca7d2e8.chunk.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions portal-ui/build/static/js/main.6ca7d2e8.chunk.js.map

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions portal-ui/build/static/js/main.926c7b22.chunk.js

This file was deleted.

1 change: 0 additions & 1 deletion portal-ui/build/static/js/main.926c7b22.chunk.js.map

This file was deleted.

5 changes: 3 additions & 2 deletions portal-ui/src/actions.ts
Expand Up @@ -14,6 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

import { ErrorResponseHandler } from "./common/types";
import {
MENU_OPEN,
OPERATOR_MODE,
Expand Down Expand Up @@ -85,7 +86,7 @@ export const setSnackBarMessage = (message: string) => {
};
};

export const setErrorSnackMessage = (message: string) => {
export const setErrorSnackMessage = (message: ErrorResponseHandler) => {
return {
type: SET_ERROR_SNACK_MESSAGE,
message,
Expand All @@ -99,7 +100,7 @@ export const setModalSnackMessage = (message: string) => {
};
};

export const setModalErrorSnackMessage = (message: string) => {
export const setModalErrorSnackMessage = (message: ErrorResponseHandler) => {
return {
type: SET_MODAL_ERROR_MESSAGE,
message,
Expand Down
18 changes: 16 additions & 2 deletions portal-ui/src/common/api/index.ts
Expand Up @@ -18,6 +18,7 @@ import request from "superagent";
import get from "lodash/get";
import { clearSession } from "../utils";
import { baseUrl } from "../../history";
import { ErrorResponseHandler } from "../types";

export class API {
invoke(method: string, url: string, data?: object) {
Expand All @@ -42,11 +43,24 @@ export class API {
const errMessage = get(
err.response,
"body.message",
err.status.toString()
`Error ${err.status.toString()}`
);

const throwMessage =
let detailedMessage = get(err.response, "body.detailedMessage", "");

if (errMessage === detailedMessage) {
detailedMessage = "";
}

const capMessage =
errMessage.charAt(0).toUpperCase() + errMessage.slice(1);
const capDetailed =
detailedMessage.charAt(0).toUpperCase() + detailedMessage.slice(1);

const throwMessage: ErrorResponseHandler = {
errorMessage: capMessage,
detailedError: capDetailed,
};

return Promise.reject(throwMessage);
} else {
Expand Down
5 changes: 5 additions & 0 deletions portal-ui/src/common/types.ts
Expand Up @@ -378,3 +378,8 @@ export interface AffinityConfiguration {
nodeSelectorLabels?: ILabelKeyPair[];
withPodAntiAffinity?: boolean;
}

export interface ErrorResponseHandler {
errorMessage: string;
detailedError: string;
}
24 changes: 20 additions & 4 deletions portal-ui/src/reducer.ts
Expand Up @@ -93,22 +93,38 @@ export function systemReducer(
case SET_SNACK_BAR_MESSAGE:
return {
...state,
snackBar: { message: action.message, type: "message" },
snackBar: {
message: action.message,
detailedErrorMsg: "",
type: "message",
},
};
case SET_ERROR_SNACK_MESSAGE:
return {
...state,
snackBar: { message: action.message, type: "error" },
snackBar: {
message: action.message.errorMessage,
detailedErrorMsg: action.message.detailedError,
type: "error",
},
};
case SET_SNACK_MODAL_MESSAGE:
return {
...state,
modalSnackBar: { message: action.message, type: "message" },
modalSnackBar: {
message: action.message,
detailedErrorMsg: "",
type: "message",
},
};
case SET_MODAL_ERROR_MESSAGE:
return {
...state,
modalSnackBar: { message: action.message, type: "error" },
modalSnackBar: {
message: action.message.errorMessage,
detailedErrorMsg: action.message.detailedError,
type: "error",
},
};
case SET_SERVER_DIAG_STAT:
return {
Expand Down
12 changes: 9 additions & 3 deletions portal-ui/src/screens/Console/Account/ChangePasswordModal.tsx
Expand Up @@ -27,8 +27,8 @@ import {
modalBasic,
} from "../Common/FormComponents/common/styleLibrary";
import { ChangePasswordRequest } from "../Buckets/types";
import api from "../../../common/api";
import { setModalErrorSnackMessage } from "../../../actions";
import api from "../../../common/api";

const styles = (theme: Theme) =>
createStyles({
Expand Down Expand Up @@ -62,12 +62,18 @@ const ChangePassword = ({
event.preventDefault();

if (newPassword !== reNewPassword) {
setModalErrorSnackMessage("New passwords don't match");
setModalErrorSnackMessage({
errorMessage: "New passwords don't match",
detailedError: "",
});
return;
}

if (newPassword.length < 8) {
setModalErrorSnackMessage("Passwords must be at least 8 characters long");
setModalErrorSnackMessage({
errorMessage: "Passwords must be at least 8 characters long",
detailedError: "",
});
return;
}

Expand Down
Expand Up @@ -68,13 +68,10 @@ const ChangeUserPassword = ({
setLoading(true);

if (newPassword.length < 8) {
setModalErrorSnackMessage("Passwords must be at least 8 characters long");
setLoading(false);
return;
}

if (newPassword.length < 8) {
setModalErrorSnackMessage("Passwords must be at least 8 characters long");
setModalErrorSnackMessage({
errorMessage: "Passwords must be at least 8 characters long",
detailedError: "",
});
setLoading(false);
return;
}
Expand Down
Expand Up @@ -129,15 +129,21 @@ const AddReplicationModal = ({
setAddLoading(false);

if (itemVal.errorString && itemVal.errorString !== "") {
setModalErrorSnackMessage(itemVal.errorString);
setModalErrorSnackMessage({
errorMessage: itemVal.errorString,
detailedError: "",
});
return;
}

closeModalAndRefresh();

return;
}
setModalErrorSnackMessage("No changes applied");
setModalErrorSnackMessage({
errorMessage: "No changes applied",
detailedError: "",
});
})
.catch((err) => {
setAddLoading(false);
Expand Down
Expand Up @@ -75,7 +75,6 @@ import {
} from "../../../../../../actions";
import { BucketVersioning } from "../../../types";
import RewindEnable from "./RewindEnable";
import FileCopyIcon from "@material-ui/icons/FileCopy";
import DeleteIcon from "@material-ui/icons/Delete";
import DeleteMultipleObjects from "./DeleteMultipleObjects";

Expand Down
Expand Up @@ -93,19 +93,21 @@ const ShareFile = ({
const versID = distributedSetup ? dataObject.version_id : "null";

if (diffDate < 0) {
setModalErrorSnackMessage(
"Selected date must be greater than current time."
);
setModalErrorSnackMessage({
errorMessage: "Selected date must be greater than current time.",
detailedError: "",
});
setShareURL("");
setIsLoadingFile(false);

return;
}

if (diffDate > 604800000) {
setModalErrorSnackMessage(
"You can share a file only for less than 7 days."
);
setModalErrorSnackMessage({
errorMessage: "You can share a file only for less than 7 days.",
detailedError: "",
});
setShareURL("");
setIsLoadingFile(false);

Expand Down

0 comments on commit 13844e1

Please sign in to comment.