From 0412c9df366ecff7ed8983da5246b63cdaf1bd9e Mon Sep 17 00:00:00 2001 From: Dmytro Shcherbonos Date: Wed, 18 Sep 2024 00:41:48 +0300 Subject: [PATCH 1/3] DMS removal disclaimer --- public/locales/en-US/translations.json | 4 ++ src/hooks/useCountdown.js | 23 +++++++++ .../DMSRemovalDisclaimerModal.container.js | 16 ++++++ .../DMSRemovalDisclaimerModal.js | 50 +++++++++++++++++++ src/modals/DMSRemovalDisclaimerModal/index.js | 3 ++ src/modals/ModalsWrapper/ModalsWrapper.js | 2 + src/redux/constants/modals.js | 1 + src/redux/reducers/ui/index.js | 5 ++ 8 files changed, 104 insertions(+) create mode 100644 src/hooks/useCountdown.js create mode 100644 src/modals/DMSRemovalDisclaimerModal/DMSRemovalDisclaimerModal.container.js create mode 100644 src/modals/DMSRemovalDisclaimerModal/DMSRemovalDisclaimerModal.js create mode 100644 src/modals/DMSRemovalDisclaimerModal/index.js diff --git a/public/locales/en-US/translations.json b/public/locales/en-US/translations.json index e07f89478..e754b0c2c 100644 --- a/public/locales/en-US/translations.json +++ b/public/locales/en-US/translations.json @@ -575,6 +575,10 @@ "text2": "From now on, each component, including the Order form and Ticker symbols, is independent and can be added or removed in the layout settings.", "text3": "If needed, you can add these components to your custom layout in the layout settings, sorry for the inconvenience." }, + "dmsRemovalDisclaimerModal": { + "title": "IMPORTANT NOTICE", + "text": "On November 6th 2024 the feature 'dead-man switch' ('DMS' for short) will no longer be supported in all versions of Bitfinex Honey, including past versions, independently of the version number and/or release date. After this date, if you stop your local environment, the orders you created using any version of this software will continue running unless you manually cancel them. This can lead to unexpected results in your trading experience." + }, "orderBookModal": { "title": "Order Book", "sumAmountsCheckbox": "Sum Amounts", diff --git a/src/hooks/useCountdown.js b/src/hooks/useCountdown.js new file mode 100644 index 000000000..675098fb1 --- /dev/null +++ b/src/hooks/useCountdown.js @@ -0,0 +1,23 @@ +import { useState, useEffect } from 'react' + +const useCountdown = (initialCount, isActive = true) => { + const [countdown, setCountdown] = useState(initialCount) + + useEffect(() => { + let timer + if (isActive && countdown > 0) { + timer = setInterval(() => { + setCountdown((prevCountdown) => prevCountdown - 1) + }, 1000) + } + return () => { + if (timer) clearInterval(timer) + } + }, [isActive, countdown]) + + const resetCountdown = () => setCountdown(initialCount) + + return { countdown, isFinished: countdown === 0, resetCountdown } +} + +export default useCountdown diff --git a/src/modals/DMSRemovalDisclaimerModal/DMSRemovalDisclaimerModal.container.js b/src/modals/DMSRemovalDisclaimerModal/DMSRemovalDisclaimerModal.container.js new file mode 100644 index 000000000..7b0d19631 --- /dev/null +++ b/src/modals/DMSRemovalDisclaimerModal/DMSRemovalDisclaimerModal.container.js @@ -0,0 +1,16 @@ +import { connect } from 'react-redux' + +import { changeUIModalState } from '../../redux/actions/ui' +import { UI_MODAL_KEYS } from '../../redux/constants/modals' +import { getUIModalStateForKey } from '../../redux/selectors/ui' +import DMSRemovalDisclaimerModal from './DMSRemovalDisclaimerModal' + +const mapStateToProps = (state = {}) => ({ + visible: getUIModalStateForKey(state, UI_MODAL_KEYS.DMS_REMOVAL_DISCLAIMER), +}) + +const mapDispatchToProps = { + changeUIModalState, +} + +export default connect(mapStateToProps, mapDispatchToProps)(DMSRemovalDisclaimerModal) diff --git a/src/modals/DMSRemovalDisclaimerModal/DMSRemovalDisclaimerModal.js b/src/modals/DMSRemovalDisclaimerModal/DMSRemovalDisclaimerModal.js new file mode 100644 index 000000000..27ef280b5 --- /dev/null +++ b/src/modals/DMSRemovalDisclaimerModal/DMSRemovalDisclaimerModal.js @@ -0,0 +1,50 @@ +import React, { memo } from 'react' +import PropTypes from 'prop-types' +import { useTranslation } from 'react-i18next' +import Modal from '../../ui/Modal' +import { UI_MODAL_KEYS } from '../../redux/constants/modals' +import { DO_NOT_SHOW_DMS_REMOVAL_DISCLAIMER } from '../../redux/reducers/ui' +import useCountdown from '../../hooks/useCountdown' + +const DMSRemovalDisclaimerModal = ({ changeUIModalState, visible }) => { + const { t } = useTranslation() + const { countdown, isFinished } = useCountdown(10, visible) + + const onSubmit = () => { + if (!isFinished) { + return + } + changeUIModalState(UI_MODAL_KEYS.DMS_REMOVAL_DISCLAIMER, false) + localStorage.setItem(DO_NOT_SHOW_DMS_REMOVAL_DISCLAIMER, 'true') + } + + return ( + +

{t('dmsRemovalDisclaimerModal.text')}

+ + + {!isFinished + ? `${t('ui.closeBtn')} (${countdown})` + : t('ui.closeBtn')} + + +
+ ) +} + +DMSRemovalDisclaimerModal.propTypes = { + changeUIModalState: PropTypes.func.isRequired, + visible: PropTypes.bool.isRequired, +} + +export default memo(DMSRemovalDisclaimerModal) diff --git a/src/modals/DMSRemovalDisclaimerModal/index.js b/src/modals/DMSRemovalDisclaimerModal/index.js new file mode 100644 index 000000000..51f2f3db5 --- /dev/null +++ b/src/modals/DMSRemovalDisclaimerModal/index.js @@ -0,0 +1,3 @@ +import DMSRemovalDisclaimerModal from './DMSRemovalDisclaimerModal.container' + +export default DMSRemovalDisclaimerModal diff --git a/src/modals/ModalsWrapper/ModalsWrapper.js b/src/modals/ModalsWrapper/ModalsWrapper.js index f6810ee19..a21bdaa38 100644 --- a/src/modals/ModalsWrapper/ModalsWrapper.js +++ b/src/modals/ModalsWrapper/ModalsWrapper.js @@ -2,6 +2,7 @@ import React, { lazy, memo } from 'react' import PropTypes from 'prop-types' import AppSettingsModal from '../AppSettingsModal' import CloseSessionModal from '../CloseSessionModal' +import DMSRemovalDisclaimerModal from '../DMSRemovalDisclaimerModal' const BadConnectionModal = lazy(() => import('../BadConnectionModal')) const NoConnectionActionModal = lazy(() => import('../NoConnectionActionModal')) @@ -33,6 +34,7 @@ const ModalsWrapper = ({ isElectronApp }) => { + ) } diff --git a/src/redux/constants/modals.js b/src/redux/constants/modals.js index 1c394afa3..6732aea63 100644 --- a/src/redux/constants/modals.js +++ b/src/redux/constants/modals.js @@ -14,4 +14,5 @@ export const UI_MODAL_KEYS = { RESET_LIVE_API_KEY_MODAL: 'ResetLiveApiKeyModal', RESET_PAPER_API_KEY_MODAL: 'ResetPaperApiKeyModal', HELP_US_IMPROVE_HONEY_MODAL: 'HelpUsImproveHoneyModal', + DMS_REMOVAL_DISCLAIMER: 'DMSRemovalDisclaimerModal', } diff --git a/src/redux/reducers/ui/index.js b/src/redux/reducers/ui/index.js index 81811b774..8d6a83a1b 100644 --- a/src/redux/reducers/ui/index.js +++ b/src/redux/reducers/ui/index.js @@ -48,6 +48,7 @@ export const ALLOWED_RC_VERSIONS = 'HF_UI_ALLOWED_RC_VERSIONS' export const IS_PAPER_TRADING = 'IS_PAPER_TRADING' export const PAPER_MODE = 'paper' export const MAIN_MODE = 'main' +export const DO_NOT_SHOW_DMS_REMOVAL_DISCLAIMER = 'DO_NOT_SHOW_DMS_REMOVAL_DISCLAIMER' let shownOldFormatModal = false export const BACKTEST_TAB_SECTIONS = { @@ -168,6 +169,10 @@ function getInitialState() { defaultState.isRCDisclaimerShown = showModal } + const doNotShowDmsRemovalDisclaimer = localStorage.getItem(DO_NOT_SHOW_DMS_REMOVAL_DISCLAIMER) === 'true' + if (!doNotShowDmsRemovalDisclaimer) { + defaultState.modals[`is${UI_MODAL_KEYS.DMS_REMOVAL_DISCLAIMER}Open`] = true + } defaultState.layouts = nextFormatLayouts } catch (e) { From 3ac9b35323a7b36ea043583653c84c4efbb28268 Mon Sep 17 00:00:00 2001 From: Dmytro Shcherbonos Date: Fri, 11 Oct 2024 14:46:09 +0300 Subject: [PATCH 2/3] update disclaimer text --- public/locales/en-US/translations.json | 2 +- .../DMSRemovalDisclaimerModal.js | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/public/locales/en-US/translations.json b/public/locales/en-US/translations.json index e754b0c2c..232307d35 100644 --- a/public/locales/en-US/translations.json +++ b/public/locales/en-US/translations.json @@ -577,7 +577,7 @@ }, "dmsRemovalDisclaimerModal": { "title": "IMPORTANT NOTICE", - "text": "On November 6th 2024 the feature 'dead-man switch' ('DMS' for short) will no longer be supported in all versions of Bitfinex Honey, including past versions, independently of the version number and/or release date. After this date, if you stop your local environment, the orders you created using any version of this software will continue running unless you manually cancel them. This can lead to unexpected results in your trading experience." + "text": "As announced, on November 6, 2024 Bitfinex Honey will no longer support the 'dead-man switch' or 'DMS' feature. This will apply to all versions of Bitfinex Honey. Your version of Bitfinex Honey will be affected. This change will mean that the orders you created using any version of Bitfinex Honey will continue running even if you turn off the machine running Bitfinex Honey. Previously, the DMS feature would have stopped those orders when you disconnected. If you do not want those orders to continue, you can close open orders before you disconnect Bitfinex Honey, or close them manually by logging into Bitfinex. Please plan accordingly for this change." }, "orderBookModal": { "title": "Order Book", diff --git a/src/modals/DMSRemovalDisclaimerModal/DMSRemovalDisclaimerModal.js b/src/modals/DMSRemovalDisclaimerModal/DMSRemovalDisclaimerModal.js index 27ef280b5..994b43aba 100644 --- a/src/modals/DMSRemovalDisclaimerModal/DMSRemovalDisclaimerModal.js +++ b/src/modals/DMSRemovalDisclaimerModal/DMSRemovalDisclaimerModal.js @@ -1,10 +1,12 @@ +/* eslint-disable jsx-a11y/anchor-has-content */ import React, { memo } from 'react' import PropTypes from 'prop-types' -import { useTranslation } from 'react-i18next' +import { Trans, useTranslation } from 'react-i18next' import Modal from '../../ui/Modal' import { UI_MODAL_KEYS } from '../../redux/constants/modals' import { DO_NOT_SHOW_DMS_REMOVAL_DISCLAIMER } from '../../redux/reducers/ui' import useCountdown from '../../hooks/useCountdown' +import { DISCONTINUE_DMS_SUPPORT_ARTICLE_DMS } from '../../redux/config' const DMSRemovalDisclaimerModal = ({ changeUIModalState, visible }) => { const { t } = useTranslation() @@ -26,7 +28,19 @@ const DMSRemovalDisclaimerModal = ({ changeUIModalState, visible }) => { onClose={onSubmit} onSubmit={onSubmit} > -

{t('dmsRemovalDisclaimerModal.text')}

+ + ), + }} + /> Date: Fri, 11 Oct 2024 17:04:37 +0300 Subject: [PATCH 3/3] fix missing export --- src/redux/config.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/redux/config.js b/src/redux/config.js index 869b4607c..13e0c0fef 100644 --- a/src/redux/config.js +++ b/src/redux/config.js @@ -55,6 +55,7 @@ const SETUP_TIMESTAMP_FORMAT_ARTICLE = 'https://bitfinex-honey.readme.io/docs/ti const METRICS_CODE_REF_URL = 'https://github.com/bitfinexcom/bfx-hf-ui-core/blob/main/src/redux/sagas/ui/on_log.js#L63-L65' const UNIQUE_ID_CODE_REF_URL = 'https://github.com/bitfinexcom/bfx-hf-server/blob/10d9db0a660661e8794d5c0a336ad04bbe52a467/lib/ws_servers/api/metrics_client.js#L154-L157' +const DISCONTINUE_DMS_SUPPORT_ARTICLE_DMS = 'https://www.bitfinex.com/posts/1072/' // product description link const HF_DESC_URL = 'https://support.bitfinex.com/hc/en-us/articles/900000096823-Honey-Framework' @@ -100,4 +101,5 @@ export { DISCORD_URL, METRICS_CODE_REF_URL, UNIQUE_ID_CODE_REF_URL, + DISCONTINUE_DMS_SUPPORT_ARTICLE_DMS, }