From 499b6e3556f2c5fe2c77f079ef227588a01e909b Mon Sep 17 00:00:00 2001 From: Aleksey Voskresenskiy Date: Mon, 19 Nov 2018 13:54:24 +0300 Subject: [PATCH 1/3] custom error, warning, info pages --- public/locales/ru-RU.json | 4 +++ src/app/lib/en-US.json | 4 +++ src/app/modules/modal/epics/modalPageEpic.ts | 19 ++++++++--- src/app/modules/tx/epics/txExecFailedEpic.ts | 33 +++++++++++++++----- src/defs/modal.d.ts | 1 + 5 files changed, 50 insertions(+), 11 deletions(-) diff --git a/public/locales/ru-RU.json b/public/locales/ru-RU.json index 63bd51204..4f5ae8f51 100644 --- a/public/locales/ru-RU.json +++ b/public/locales/ru-RU.json @@ -188,6 +188,10 @@ "tx.error.txError.desc": "{error}", "tx.error.warning": "Предупреждение", "tx.error.warning.desc": "{error}", + "tx.error.errorPageParam": "Ошибка", + "tx.error.errorPageParam.desc": "Не задан параметр экосистемы '{0}'", + "tx.error.errorPageNotFound": "Ошибка", + "tx.error.errorPageNotFound.desc": "Страница ошибки '{0}' не найдена", "tx.error.E_CONTRACT": "Ошибка вызова", "tx.error.E_DELETEDKEY": "Ошибка вызова", "tx.error.E_INVALID_PASSWORD": "Ошибка вызова", diff --git a/src/app/lib/en-US.json b/src/app/lib/en-US.json index c40b3720b..71cab2885 100644 --- a/src/app/lib/en-US.json +++ b/src/app/lib/en-US.json @@ -188,6 +188,10 @@ "tx.error.txError.desc": "{error}", "tx.error.warning": "Warning", "tx.error.warning.desc": "{error}", + "tx.error.errorPageParam": "Error", + "tx.error.errorPageParam.desc": "Ecosystem '{0}' parameter is not defined", + "tx.error.errorPageNotFound": "Error", + "tx.error.errorPageNotFound.desc": "Error page '{0}' not found", "tx.error.E_CONTRACT": "Execution failed", "tx.error.E_DELETEDKEY": "Execution failed", "tx.error.E_INVALID_PASSWORD": "Execution failed", diff --git a/src/app/modules/modal/epics/modalPageEpic.ts b/src/app/modules/modal/epics/modalPageEpic.ts index 87fdb46dc..35fc3bf18 100644 --- a/src/app/modules/modal/epics/modalPageEpic.ts +++ b/src/app/modules/modal/epics/modalPageEpic.ts @@ -44,12 +44,23 @@ const modalPageEpic: Epic = (action$, store, { api }) => action$.ofAction(modalP width: action.payload.width, tree: payload.tree } - }) - ).catch(e => - Observable.empty() - ); + ).catch(e => { + if (action.payload.showError) { + return Observable.of(modalShow({ + id: 'TX_ERROR', + type: 'TX_ERROR', + params: { + type: 'errorPageNotFound', + params: [action.payload.name] + } + })); + } + else { + return Observable.empty(); + } + }); }); export default modalPageEpic; \ No newline at end of file diff --git a/src/app/modules/tx/epics/txExecFailedEpic.ts b/src/app/modules/tx/epics/txExecFailedEpic.ts index 5fd3089dc..4a532fbb5 100644 --- a/src/app/modules/tx/epics/txExecFailedEpic.ts +++ b/src/app/modules/tx/epics/txExecFailedEpic.ts @@ -24,13 +24,13 @@ import { IRootState } from 'modules'; import { Epic } from 'redux-observable'; import { Action } from 'redux'; import { txExec } from '../actions'; -import { modalShow } from '../../modal/actions'; +import { modalShow, modalPage } from '../../modal/actions'; import { navigatePage } from '../../sections/actions'; export const txExecFailedEpic: Epic = - (action$, store) => action$.ofAction(txExec.failed) + (action$, store, { api }) => action$.ofAction(txExec.failed) .filter(l => !l.payload.params.silent) - .map(action => { + .flatMap(action => { if (action.payload.error.id && action.payload.params.errorRedirects) { const errorRedirect = action.payload.params.errorRedirects[action.payload.error.id]; if (errorRedirect) { @@ -41,10 +41,29 @@ export const txExecFailedEpic: Epic = }); } } - return modalShow({ - id: 'TX_ERROR', - type: 'TX_ERROR', - params: action.payload.error + + const state = store.getState(); + const client = api(state.auth.session); + const errorPageName = 'error_page'; + + return client.getParam({ name: errorPageName }).then((l: any) => { + return modalPage({ + name: l.value, + title: action.payload.error.type, + params: action.payload.error, + showError: true + }); + + }) + .catch((e: any) => { + return modalShow({ + id: 'TX_ERROR', + type: 'TX_ERROR', + params: { + type: 'errorPageParam', + params: [errorPageName] + } + }); }); }); diff --git a/src/defs/modal.d.ts b/src/defs/modal.d.ts index f5cf7e808..c79ac862e 100644 --- a/src/defs/modal.d.ts +++ b/src/defs/modal.d.ts @@ -59,6 +59,7 @@ declare module 'genesis/modal' { params: { [key: string]: any; }; + showError?: boolean; } interface IModal { From 21a13ab5ee8f9f014a2b11e359f822b714f0fcd0 Mon Sep 17 00:00:00 2001 From: Aleksey Voskresenskiy Date: Mon, 19 Nov 2018 14:36:27 +0300 Subject: [PATCH 2/3] popup close button --- public/settings.json.dist | 5 ----- src/app/components/Modal/PageModal.tsx | 22 ++++++++++++++++++++ src/app/modules/modal/epics/modalPageEpic.ts | 1 + src/app/modules/tx/epics/txExecFailedEpic.ts | 3 ++- src/defs/modal.d.ts | 2 ++ 5 files changed, 27 insertions(+), 6 deletions(-) delete mode 100644 public/settings.json.dist diff --git a/public/settings.json.dist b/public/settings.json.dist deleted file mode 100644 index 7c4a62037..000000000 --- a/public/settings.json.dist +++ /dev/null @@ -1,5 +0,0 @@ -{ - "fullNodes": [ - "http://127.0.0.1:7079" - ] -} \ No newline at end of file diff --git a/src/app/components/Modal/PageModal.tsx b/src/app/components/Modal/PageModal.tsx index 50ee9c9ef..a1d41ff6b 100644 --- a/src/app/components/Modal/PageModal.tsx +++ b/src/app/components/Modal/PageModal.tsx @@ -25,13 +25,30 @@ import React from 'react'; import Modal from './'; import Protypo from 'containers/Widgets/Protypo'; import { TProtypoElement } from 'genesis/protypo'; +import themed from 'components/Theme/themed'; export interface IPageModalProps { title: string; width?: number; + closeButton?: boolean; tree: TProtypoElement[]; } +const CloseButton = themed.a` + float: right; + font-size: 30px; + line-height: 40px; + text-decoration: none; + color: white; + opacity: 0.8; + transition: opacity .5s ease-in-out; + &:hover { + opacity: 1; + text-decoration: none; + color: white; + } +`; + class PageModal extends Modal { onSuccess(values: { [key: string]: any }) { this.props.onResult(true); @@ -42,6 +59,11 @@ class PageModal extends Modal {
{this.props.params.title} + {this.props.params.closeButton && + + × + + } diff --git a/src/app/modules/modal/epics/modalPageEpic.ts b/src/app/modules/modal/epics/modalPageEpic.ts index 35fc3bf18..a3bf41dd8 100644 --- a/src/app/modules/modal/epics/modalPageEpic.ts +++ b/src/app/modules/modal/epics/modalPageEpic.ts @@ -42,6 +42,7 @@ const modalPageEpic: Epic = (action$, store, { api }) => action$.ofAction(modalP params: { title: action.payload.title || action.payload.name, width: action.payload.width, + closeButton: action.payload.closeButton, tree: payload.tree } }) diff --git a/src/app/modules/tx/epics/txExecFailedEpic.ts b/src/app/modules/tx/epics/txExecFailedEpic.ts index 4a532fbb5..d2e4d23e9 100644 --- a/src/app/modules/tx/epics/txExecFailedEpic.ts +++ b/src/app/modules/tx/epics/txExecFailedEpic.ts @@ -51,7 +51,8 @@ export const txExecFailedEpic: Epic = name: l.value, title: action.payload.error.type, params: action.payload.error, - showError: true + showError: true, + closeButton: true }); }) diff --git a/src/defs/modal.d.ts b/src/defs/modal.d.ts index c79ac862e..538ab8164 100644 --- a/src/defs/modal.d.ts +++ b/src/defs/modal.d.ts @@ -42,6 +42,7 @@ declare module 'genesis/modal' { interface IModalCall { id: string; type: string; + closeButton?: boolean; params: { [key: string]: any; } @@ -60,6 +61,7 @@ declare module 'genesis/modal' { [key: string]: any; }; showError?: boolean; + closeButton?: boolean; } interface IModal { From 1789f2fc85173d08119c93cd72083ffa0a066e9a Mon Sep 17 00:00:00 2001 From: Aleksey Voskresenskiy Date: Mon, 19 Nov 2018 14:43:56 +0300 Subject: [PATCH 3/3] settings.json.dist --- public/settings.json.dist | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 public/settings.json.dist diff --git a/public/settings.json.dist b/public/settings.json.dist new file mode 100644 index 000000000..7c4a62037 --- /dev/null +++ b/public/settings.json.dist @@ -0,0 +1,5 @@ +{ + "fullNodes": [ + "http://127.0.0.1:7079" + ] +} \ No newline at end of file