-
Notifications
You must be signed in to change notification settings - Fork 303
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into floating-rate
- Loading branch information
Showing
10 changed files
with
355 additions
and
282 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
packages/bot-web-ui/src/components/network-toast-popup/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import NetworkToastPopup from './network-toast-popup.jsx'; | ||
|
||
export default NetworkToastPopup; |
56 changes: 56 additions & 0 deletions
56
packages/bot-web-ui/src/components/network-toast-popup/network-toast-popup.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import classNames from 'classnames'; | ||
import PropTypes from 'prop-types'; | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import { MobileWrapper, Toast } from '@deriv/components'; | ||
import { connect } from 'Stores/connect'; | ||
|
||
|
||
// TODO: Need to sanitize, | ||
// Same sort of component is being used inside DTrader, | ||
// In Future we might move the `NetworkStatusToastError` to the core packages for resuability. | ||
|
||
/** | ||
* Network status Toast components | ||
*/ | ||
const NetworkStatusToastError = ({ status, portal_id, message }) => { | ||
const [is_open, setIsOpen] = React.useState(false); | ||
|
||
if (!document.getElementById(portal_id) || !message) return null; | ||
|
||
if (!is_open && status !== 'online') { | ||
setIsOpen(true); // open if status === 'blinker' or 'offline' | ||
} else if (is_open && status === 'online') { | ||
setTimeout(() => { | ||
setIsOpen(false); | ||
}, 1500); | ||
} | ||
|
||
return ReactDOM.createPortal( | ||
<MobileWrapper> | ||
<Toast | ||
className={classNames({ | ||
'dc-toast--blinker': status === 'blinker', | ||
})} | ||
is_open={is_open} | ||
timeout={0} | ||
type='error' | ||
> | ||
{message} | ||
</Toast> | ||
</MobileWrapper>, | ||
document.getElementById(portal_id) | ||
); | ||
}; | ||
|
||
NetworkStatusToastError.propTypes = { | ||
portal_id: PropTypes.string, | ||
status: PropTypes.string, | ||
message: PropTypes.string, | ||
}; | ||
|
||
export default connect(({ common }) => ({ | ||
network_status: common.network_status, | ||
}))(({ network_status }) => ( | ||
<NetworkStatusToastError portal_id='popup_root' message={network_status.tooltip} status={network_status.class} /> | ||
)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.