Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions public/locales/ru-RU.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "Ошибка вызова",
Expand Down
22 changes: 22 additions & 0 deletions src/app/components/Modal/PageModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<IPageModalProps, boolean> {
onSuccess(values: { [key: string]: any }) {
this.props.onResult(true);
Expand All @@ -42,6 +59,11 @@ class PageModal extends Modal<IPageModalProps, boolean> {
<div style={{ width: (this.props.params.width || 50) + 'vw', overflow: 'hidden' }}>
<Modal.Header>
{this.props.params.title}
{this.props.params.closeButton &&
<CloseButton href="#" onClick={this.props.onCancel.bind(this)}>
&times;
</CloseButton>
}
</Modal.Header>
<Modal.Body>
<Protypo context="page" content={this.props.params.tree} />
Expand Down
4 changes: 4 additions & 0 deletions src/app/lib/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
20 changes: 16 additions & 4 deletions src/app/modules/modal/epics/modalPageEpic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<never>()
);
).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<never>();
}
});
});

export default modalPageEpic;
34 changes: 27 additions & 7 deletions src/app/modules/tx/epics/txExecFailedEpic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, IRootState> =
(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) {
Expand All @@ -41,10 +41,30 @@ export const txExecFailedEpic: Epic<Action, IRootState> =
});
}
}
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]
}
});
});
});

Expand Down
3 changes: 3 additions & 0 deletions src/defs/modal.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ declare module 'genesis/modal' {
interface IModalCall {
id: string;
type: string;
closeButton?: boolean;
params: {
[key: string]: any;
}
Expand All @@ -59,6 +60,8 @@ declare module 'genesis/modal' {
params: {
[key: string]: any;
};
showError?: boolean;
closeButton?: boolean;
}

interface IModal {
Expand Down