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/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/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..a3bf41dd8 100644 --- a/src/app/modules/modal/epics/modalPageEpic.ts +++ b/src/app/modules/modal/epics/modalPageEpic.ts @@ -42,14 +42,26 @@ 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 } - }) - ).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..d2e4d23e9 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,30 @@ 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, + closeButton: 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..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; } @@ -59,6 +60,8 @@ declare module 'genesis/modal' { params: { [key: string]: any; }; + showError?: boolean; + closeButton?: boolean; } interface IModal {