* client: add link to the update error

This commit is contained in:
Ildar Kamalov
2019-05-17 18:17:17 +03:00
committed by Simon Zolin
parent 24f582d36d
commit 967517316f
5 changed files with 38 additions and 11 deletions

View File

@@ -32,6 +32,12 @@
overflow: hidden;
}
.toast__content a {
font-weight: 600;
color: #fff;
text-decoration: underline;
}
.toast__dismiss {
display: block;
flex: 0 0 auto;

View File

@@ -4,7 +4,7 @@ import { Trans, withNamespaces } from 'react-i18next';
class Toast extends Component {
componentDidMount() {
const timeout = this.props.type === 'error' ? 30000 : 5000;
const timeout = this.props.type === 'success' ? 5000 : 30000;
setTimeout(() => {
this.props.removeToast(this.props.id);
@@ -15,13 +15,25 @@ class Toast extends Component {
return false;
}
showMessage(t, type, message) {
if (type === 'notice') {
return <span dangerouslySetInnerHTML={{ __html: t(message) }} />;
}
return <Trans>{message}</Trans>;
}
render() {
const {
type, id, t, message,
} = this.props;
return (
<div className={`toast toast--${this.props.type}`}>
<div className={`toast toast--${type}`}>
<p className="toast__content">
<Trans>{this.props.message}</Trans>
{this.showMessage(t, type, message)}
</p>
<button className="toast__dismiss" onClick={() => this.props.removeToast(this.props.id)}>
<button className="toast__dismiss" onClick={() => this.props.removeToast(id)}>
<svg stroke="#fff" fill="none" width="20" height="20" strokeWidth="2" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="m18 6-12 12"/><path d="m6 6 12 12"/></svg>
</button>
</div>
@@ -30,6 +42,7 @@ class Toast extends Component {
}
Toast.propTypes = {
t: PropTypes.func.isRequired,
id: PropTypes.string.isRequired,
message: PropTypes.string.isRequired,
type: PropTypes.string.isRequired,