forked from bitfinexcom/bfx-hf-ui-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request bitfinexcom#394 from dmytroshch/fix/backtest-clear
(fix): When strategy changed, backtest results should be clear
- Loading branch information
Showing
8 changed files
with
92 additions
and
7 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
60 changes: 60 additions & 0 deletions
60
src/modals/Strategy/ClearBacktestResultsModal/ClearBacktestResultsModal.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,60 @@ | ||
import React, { memo } from 'react' | ||
import PropTypes from 'prop-types' | ||
import { useTranslation } from 'react-i18next' | ||
import { useDispatch } from 'react-redux' | ||
import Modal from '../../../ui/Modal' | ||
import WSActions from '../../../redux/actions/ws' | ||
|
||
const CleanBacktestResultsModal = ({ | ||
onClose, | ||
isOpen, | ||
nextStrategy, | ||
onLoadStrategy, | ||
}) => { | ||
const { t } = useTranslation() | ||
|
||
const dispatch = useDispatch() | ||
|
||
const clearBacktestOptions = () => { | ||
dispatch(WSActions.resetBacktestData()) | ||
} | ||
const onSubmitReset = () => { | ||
clearBacktestOptions() | ||
onLoadStrategy(nextStrategy, true) | ||
onClose() | ||
} | ||
|
||
return ( | ||
<Modal | ||
isOpen={isOpen} | ||
onClose={onClose} | ||
label={t('strategyEditor.clearBacktestResultsModalTitle')} | ||
onSubmit={onClose} | ||
> | ||
<p>{t('strategyEditor.clearBacktestResultsModalText')}</p> | ||
<Modal.Footer> | ||
<Modal.Button primary onClick={onClose}> | ||
{t('ui.cancel')} | ||
</Modal.Button> | ||
<Modal.Button secondary onClick={onSubmitReset}> | ||
{t('ui.proceed')} | ||
</Modal.Button> | ||
</Modal.Footer> | ||
</Modal> | ||
) | ||
} | ||
|
||
CleanBacktestResultsModal.propTypes = { | ||
onClose: PropTypes.func.isRequired, | ||
isOpen: PropTypes.bool.isRequired, | ||
nextStrategy: PropTypes.shape({ | ||
label: PropTypes.string, | ||
}), | ||
onLoadStrategy: PropTypes.func.isRequired, | ||
} | ||
|
||
CleanBacktestResultsModal.defaultProps = { | ||
nextStrategy: {}, | ||
} | ||
|
||
export default memo(CleanBacktestResultsModal) |
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 ClearBacktestResultsModal from './ClearBacktestResultsModal' | ||
|
||
export default ClearBacktestResultsModal |
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