Skip to content

Commit

Permalink
[BRG-546] show error when extension not installed (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
kilochytsky-ppl authored and doomdabidon committed Jan 11, 2020
1 parent af068ec commit 3a72d12
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "bridge-landing",
"description": "Echo Bridge Landing",
"version": "1.16.0",
"version": "1.16.1",
"repository": {
"type": "git",
"url": "https://github.com/echoprotocol/bridge-website.git"
Expand Down
5 changes: 5 additions & 0 deletions src/actions/WidgetActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ class WidgetActions extends BaseActionsClass {
dispatch(this.setValue('error', 'Amount should be more than 0', false));
return;
}
if (!window.echojslib) {
dispatch(this.setValue('error', 'Install Bridge Extension to proceed', false));
dispatch(this.setValue('downloadLink', 'https://chrome.google.com/webstore/detail/echo-bridge/ginklfodpcgldnicehmlpehfmgjhbdcl', false));
return;
}
const access = await window.echojslib.extension.getAccess();

if (!access) {
Expand Down
10 changes: 6 additions & 4 deletions src/assets/scss/components/_toast.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.toast {
.toast {
@include futura-medium();
align-items: center;
justify-content: center;
Expand All @@ -7,6 +7,7 @@
bottom: 0;
left: 0;
display: flex;
flex-direction: column;
height: 77px;
font-size: 16px;

Expand All @@ -16,7 +17,8 @@
color: #bb3e51;
}

&-content {
padding-top: 20px;
}
}

.toast-content {
padding-top: 20px;
}
10 changes: 10 additions & 0 deletions src/components/QRCodeWidget/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class QRCodeWidget extends React.Component {
account, error,
currency,
isConnected,
downloadLink,
} = this.props;
return (
<div className="widget-page">
Expand Down Expand Up @@ -83,6 +84,10 @@ class QRCodeWidget extends React.Component {
<div className="toast-content">
{error}
</div>
{
downloadLink &&
<a className="toast-link" href={downloadLink}>Download</a>
}
</div>
}

Expand All @@ -95,12 +100,17 @@ class QRCodeWidget extends React.Component {

}

QRCodeWidget.defaultProps = {
downloadLink: null,
};

QRCodeWidget.propTypes = {
pay: PropTypes.func.isRequired,
isConnected: PropTypes.bool.isRequired,
account: PropTypes.string.isRequired,
currency: PropTypes.object.isRequired,
error: PropTypes.string.isRequired,
downloadLink: PropTypes.string,
};

export default QRCodeWidget;
7 changes: 7 additions & 0 deletions src/containers/QRCodeWidget/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class QRCodeWidget extends React.Component {
error,
isConnected,
pay,
downloadLink,
} = this.props;
return (
<QRCodeWidgetComponent
Expand All @@ -55,12 +56,16 @@ class QRCodeWidget extends React.Component {
currency={currency}
error={error}
isConnected={isConnected}
downloadLink={downloadLink}
/>
);
}

}

QRCodeWidget.defaultProps = {
downloadLink: null,
};
QRCodeWidget.propTypes = {
match: PropTypes.object.isRequired,
pay: PropTypes.func.isRequired,
Expand All @@ -69,13 +74,15 @@ QRCodeWidget.propTypes = {
currency: PropTypes.object.isRequired,
error: PropTypes.string.isRequired,
isConnected: PropTypes.bool.isRequired,
downloadLink: PropTypes.string,
};

export default withRouter(connect(
(state) => ({
currency: state.widget.get('currency'),
error: state.widget.get('error'),
isConnected: state.global.get('isConnected'),
downloadLink: state.widget.get('downloadLink'),
}),
(dispatch) => ({
pay: (account) => dispatch(WidgetActions.payWithBridge(account)),
Expand Down

0 comments on commit 3a72d12

Please sign in to comment.