From 7ca0fb08b772f22d909e426f3e18948ce0af3cf9 Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Tue, 18 Oct 2022 12:27:33 +0300 Subject: [PATCH 01/20] Add src types/default --- src/state/base/constants.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/state/base/constants.js b/src/state/base/constants.js index ff03e3ed3..1e11cebf6 100644 --- a/src/state/base/constants.js +++ b/src/state/base/constants.js @@ -9,10 +9,12 @@ export default { 'YY-MM-DD', 'YYYY-MM-DD', ], + DEFAULT_SRC: 'bfx', DEFAULT_TIMEZONE: 'Etc/UTC', SET_SYNC_STATE: 'BITFINEX/SYNC/SET_STATE', SET_DATE_FORMAT: 'BITFINEX/DATEFORMAT/SET', SET_LANG: 'BITFINEX/LANG/SET', + SET_SRC: 'BITFINEX/SRC/SET', SET_THEME: 'BITFINEX/THEME/SET', SET_TIMEZONE: 'BITFINEX/TIMEZONE/SET', UPDATE_THEME: 'BITFINEX/THEME/UPDATE', From b64a50dd9916fefdb824206952b26dd968810c0c Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Tue, 18 Oct 2022 13:10:12 +0300 Subject: [PATCH 02/20] Implement setSrc action --- src/state/base/actions.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/state/base/actions.js b/src/state/base/actions.js index 2f2b786d2..f9bfc1896 100644 --- a/src/state/base/actions.js +++ b/src/state/base/actions.js @@ -73,9 +73,17 @@ export function toggleTableScroll() { } } +export function setSrc(src) { + return { + type: types.SET_SRC, + payload: src, + } +} + export default { setDateFormat, setLang, + setSrc, setTheme, setTimezone, showMilliseconds, From 4bc3ec6f50efba5f6a6282c61a4d0e19966efe5f Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Tue, 18 Oct 2022 13:26:04 +0300 Subject: [PATCH 03/20] Update base reducers initial state and cases --- src/state/base/reducer.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/state/base/reducer.js b/src/state/base/reducer.js index 52b88f706..c240c3c79 100644 --- a/src/state/base/reducer.js +++ b/src/state/base/reducer.js @@ -8,6 +8,7 @@ const initialState = { theme: types.DEFAULT_THEME, timezone: types.DEFAULT_TIMEZONE, milliseconds: false, + src: types.DEFAULT_SRC, tableScroll: getDefaultTableScrollSetting(), } @@ -34,6 +35,11 @@ export function baseReducer(state = initialState, action) { ...state, dateFormat: payload, } + case types.SET_SRC: + return { + ...state, + src: payload, + } case types.SHOW_MILLISECONDS: return { ...state, From edaa8b8b7a5d3fb3460239e7a9f388d054382eb5 Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Tue, 18 Oct 2022 13:58:28 +0300 Subject: [PATCH 04/20] Add src selector --- src/state/base/selectors.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/state/base/selectors.js b/src/state/base/selectors.js index a1214dcdf..449bc1f36 100644 --- a/src/state/base/selectors.js +++ b/src/state/base/selectors.js @@ -12,6 +12,7 @@ export const getTimezone = state => getBase(state).timezone export const getDateFormat = state => getBase(state).dateFormat || types.DATE_FORMATS[0] export const getShowMilliseconds = state => getBase(state).milliseconds || false export const getTableScroll = state => getBase(state).tableScroll || false +export const getSrc = state => getBase(state)?.src ?? types.DEFAULT_SRC export const getTimeOffset = state => timeOffset(getTimezone(state)) @@ -45,6 +46,7 @@ export default { getFullTime, getLocale, getShowMilliseconds, + getSrc, getTheme, getTimeOffset, getTimezone, From d585f5d9f79bb6233937e2d8e18ee6507dcf1660 Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Tue, 18 Oct 2022 14:02:14 +0300 Subject: [PATCH 05/20] Update base conatsnts --- src/state/base/constants.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/state/base/constants.js b/src/state/base/constants.js index 1e11cebf6..650ff542d 100644 --- a/src/state/base/constants.js +++ b/src/state/base/constants.js @@ -10,6 +10,7 @@ export default { 'YYYY-MM-DD', ], DEFAULT_SRC: 'bfx', + TR_SRC: 'bfx-tr', DEFAULT_TIMEZONE: 'Etc/UTC', SET_SYNC_STATE: 'BITFINEX/SYNC/SET_STATE', SET_DATE_FORMAT: 'BITFINEX/DATEFORMAT/SET', From 34e607de31b6acffbf56dbdf70c604189562854a Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Wed, 19 Oct 2022 11:35:12 +0300 Subject: [PATCH 06/20] Implement src handling and persisting on UI load --- src/state/ui/saga.js | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/state/ui/saga.js b/src/state/ui/saga.js index faf58d1bd..e2097bd60 100644 --- a/src/state/ui/saga.js +++ b/src/state/ui/saga.js @@ -3,20 +3,23 @@ import { } from 'redux-saga/effects' import { REHYDRATE } from 'redux-persist' -import { setTimezone, setTheme, setLang } from 'state/base/actions' -import { checkAuth, updateAuth } from 'state/auth/actions' -import { setTimeRange } from 'state/timeRange/actions' -import { getParsedUrlParams, isValidTimezone, removeUrlParams } from 'state/utils' -import { getNewTheme, getThemeClass, verifyTheme } from 'utils/themes' import config from 'config' -import timeRangeTypes from 'state/timeRange/constants' -import { getTheme } from 'state/base/selectors' import { LANGUAGES } from 'locales/i18n' +import { + setTimezone, setTheme, setLang, setSrc, +} from 'state/base/actions' +import { getTheme } from 'state/base/selectors' +import { setTimeRange } from 'state/timeRange/actions' +import timeRangeTypes from 'state/timeRange/constants' import handleElectronLoad from 'utils/handleElectronLoad' +import { checkAuth, updateAuth } from 'state/auth/actions' +import { getNewTheme, getThemeClass, verifyTheme } from 'utils/themes' +import { getParsedUrlParams, isValidTimezone, removeUrlParams } from 'state/utils' import types from './constants' -import { togglePaginationDialog } from './actions' import selectors from './selectors' +import { togglePaginationDialog } from './actions' + function* uiLoaded() { if (config.isElectronApp) { @@ -25,9 +28,13 @@ function* uiLoaded() { const parsed = getParsedUrlParams(window.location.search) const { - authToken, apiKey, apiSecret, timezone, theme, locale, range, + authToken, apiKey, apiSecret, timezone, theme, locale, range, src, } = parsed + if (src) { + yield put(setSrc(src)) + } + removeUrlParams(['timezone', 'theme', 'locale', 'authToken', 'apiKey', 'apiSecret']) // handle custom timezone From 393320b1b3f7496f7df8c2ea5297320dc095066c Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Wed, 19 Oct 2022 11:52:10 +0300 Subject: [PATCH 07/20] Add turkish site redirection checker --- src/state/base/selectors.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/state/base/selectors.js b/src/state/base/selectors.js index 449bc1f36..c83356572 100644 --- a/src/state/base/selectors.js +++ b/src/state/base/selectors.js @@ -1,4 +1,5 @@ import memoizeOne from 'memoize-one' +import _isEqual from 'lodash/isEqual' import { formatTime, timeOffset } from 'state/utils' @@ -13,6 +14,7 @@ export const getDateFormat = state => getBase(state).dateFormat || types.DATE_FO export const getShowMilliseconds = state => getBase(state).milliseconds || false export const getTableScroll = state => getBase(state).tableScroll || false export const getSrc = state => getBase(state)?.src ?? types.DEFAULT_SRC +export const getIsTurkishSite = state => _isEqual(getSrc(state), types.TR_SRC) export const getTimeOffset = state => timeOffset(getTimezone(state)) @@ -44,6 +46,7 @@ export default { getBase, getDateFormat, getFullTime, + getIsTurkishSite, getLocale, getShowMilliseconds, getSrc, From e266f666d23cf4a593262545c731580818ab5483 Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Wed, 19 Oct 2022 11:53:38 +0300 Subject: [PATCH 08/20] Actualize main container mapped props --- src/components/Main/Main.container.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/Main/Main.container.js b/src/components/Main/Main.container.js index 07ada1020..5932131f2 100644 --- a/src/components/Main/Main.container.js +++ b/src/components/Main/Main.container.js @@ -1,13 +1,15 @@ import { connect } from 'react-redux' -import { getAuthStatus, getIsShown } from 'state/auth/selectors' +import { getIsTurkishSite } from 'state/base/selectors' import { getIsErrorDialogDisabled } from 'state/ui/selectors' +import { getAuthStatus, getIsShown } from 'state/auth/selectors' import Main from './Main' const mapStateToProps = state => ({ authIsShown: getIsShown(state), authStatus: getAuthStatus(state), + isTurkishSite: getIsTurkishSite(state), errorDialogDisabled: getIsErrorDialogDisabled(state), }) From b7c745a93a27769552ba68dfa26ae8c8c8690abc Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Wed, 19 Oct 2022 12:02:43 +0300 Subject: [PATCH 09/20] Rework main routes for Turkey site users --- src/components/Main/Main.js | 91 +++++++++++++++++++++---------------- 1 file changed, 51 insertions(+), 40 deletions(-) diff --git a/src/components/Main/Main.js b/src/components/Main/Main.js index ee0b2685a..0fe44fede 100644 --- a/src/components/Main/Main.js +++ b/src/components/Main/Main.js @@ -122,6 +122,7 @@ class Main extends PureComponent { const { authStatus, authIsShown, + isTurkishSite, errorDialogDisabled, } = this.props @@ -135,11 +136,13 @@ class Main extends PureComponent { path={PATHS.MENU_LEDGERS} component={Ledgers} /> - + {!isTurkishSite && ( + + )} - - - - - + {!isTurkishSite && ( + <> + + + + + + + )} - + {!isTurkishSite && ( + + )} - + {!isTurkishSite && ( + + )} Date: Wed, 19 Oct 2022 12:03:59 +0300 Subject: [PATCH 10/20] Update nav menu container --- src/ui/NavMenu/NavMenu.container.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ui/NavMenu/NavMenu.container.js b/src/ui/NavMenu/NavMenu.container.js index 201c6e715..08ad43aba 100644 --- a/src/ui/NavMenu/NavMenu.container.js +++ b/src/ui/NavMenu/NavMenu.container.js @@ -2,11 +2,13 @@ import { connect } from 'react-redux' import { withRouter } from 'react-router-dom' import { getWindowWidth } from 'state/ui/selectors' +import { getIsTurkishSite } from 'state/base/selectors' import NavMenu from './NavMenu' const mapStateToProps = state => ({ windowWidth: getWindowWidth(state), + isTurkishSite: getIsTurkishSite(state), }) From 3ecc8413ec17ee8de0b829b3a1a52693bf816438 Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Wed, 19 Oct 2022 12:04:44 +0300 Subject: [PATCH 11/20] Optimize fragments usage --- src/components/Main/Main.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/Main/Main.js b/src/components/Main/Main.js index 0fe44fede..27aa48905 100644 --- a/src/components/Main/Main.js +++ b/src/components/Main/Main.js @@ -1,4 +1,4 @@ -import React, { Fragment, PureComponent } from 'react' +import React, { PureComponent } from 'react' import { Route, Switch } from 'react-router-dom' import AccountBalance from 'components/AccountBalance' @@ -127,7 +127,7 @@ class Main extends PureComponent { } = this.props return authStatus && !authIsShown ? ( - + <>
@@ -334,7 +334,7 @@ class Main extends PureComponent { - + ) : '' } } From a140ff725b8990f5e95caa9aad2a9c3587862705 Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Wed, 19 Oct 2022 12:52:03 +0300 Subject: [PATCH 12/20] Fix optional routing --- src/components/Main/Main.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/components/Main/Main.js b/src/components/Main/Main.js index 27aa48905..42fe3d475 100644 --- a/src/components/Main/Main.js +++ b/src/components/Main/Main.js @@ -169,33 +169,33 @@ class Main extends PureComponent { component={Movements} /> {!isTurkishSite && ( - <> + [ + />, + />, + />, + />, - + />, + ] )} Date: Wed, 19 Oct 2022 12:54:12 +0300 Subject: [PATCH 13/20] Update summary mapped props --- src/components/AccountSummary/AccountSummary.container.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/AccountSummary/AccountSummary.container.js b/src/components/AccountSummary/AccountSummary.container.js index c729f4c2d..f0e3b1fed 100644 --- a/src/components/AccountSummary/AccountSummary.container.js +++ b/src/components/AccountSummary/AccountSummary.container.js @@ -12,6 +12,7 @@ import { getPageLoading, getDataReceived, } from 'state/accountSummary/selectors' +import { getIsTurkishSite } from 'state/base/selectors' import AccountSummary from './AccountSummary' @@ -19,6 +20,7 @@ const mapStateToProps = state => ({ data: getData(state), pageLoading: getPageLoading(state), dataReceived: getDataReceived(state), + isTurkishSite: getIsTurkishSite(state), }) const mapDispatchToProps = { From 60c4ae293b272cbbc00c7b0178efee49057d3e2d Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Wed, 19 Oct 2022 12:57:52 +0300 Subject: [PATCH 14/20] Actualize nav menu for TR users --- src/ui/NavMenu/NavMenu.js | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/ui/NavMenu/NavMenu.js b/src/ui/NavMenu/NavMenu.js index f20839d08..0fb6acf8d 100644 --- a/src/ui/NavMenu/NavMenu.js +++ b/src/ui/NavMenu/NavMenu.js @@ -60,26 +60,26 @@ class NavMenu extends PureComponent { static defaultProps = defaultProps - sections = [ + getSections = (isTurkishSite) => [ [MENU_LEDGERS, 'ledgers.title'], - [MENU_INVOICES, 'invoices.title'], + [MENU_INVOICES, 'invoices.title', isTurkishSite], [[MENU_TRADES, MENU_CANDLES], 'trades.title'], [[MENU_ORDERS, MENU_ORDER_TRADES], 'orders.title'], [MENU_MOVEMENTS, 'movements.title'], [[MENU_POSITIONS, MENU_POSITIONS_ACTIVE, MENU_POSITIONS_AUDIT], 'positions.title'], [MENU_WALLETS, 'wallets.title'], ['divider'], - [MENU_FOFFER, 'foffer.title'], - [MENU_FLOAN, 'floan.title'], - [MENU_FCREDIT, 'fcredit.title'], - [MENU_FPAYMENT, 'fpayment.title'], - [MENU_SPAYMENTS, 'spayments.title'], + [MENU_FOFFER, 'foffer.title', isTurkishSite], + [MENU_FLOAN, 'floan.title', isTurkishSite], + [MENU_FCREDIT, 'fcredit.title', isTurkishSite], + [MENU_FPAYMENT, 'fpayment.title', isTurkishSite], + [MENU_SPAYMENTS, 'spayments.title', isTurkishSite], [MENU_AFFILIATES_EARNINGS, 'affiliatesearnings.title'], - ['divider'], + ['divider', '', isTurkishSite], [MENU_PUBLIC_TRADES, 'publictrades.title'], - [MENU_PUBLIC_FUNDING, 'publicfunding.title'], + [MENU_PUBLIC_FUNDING, 'publicfunding.title', isTurkishSite], [MENU_TICKERS, 'tickers.title'], - [MENU_DERIVATIVES, 'derivatives.title'], + [MENU_DERIVATIVES, 'derivatives.title', isTurkishSite], ['divider', '', !showFrameworkMode], [MENU_ACCOUNT_BALANCE, 'accountbalance.title', !showFrameworkMode], [MENU_LOAN_REPORT, 'loanreport.title', !showFrameworkMode], @@ -122,10 +122,11 @@ class NavMenu extends PureComponent { render() { const { - className, + t, history, + className, + isTurkishSite, showMenuPopover, - t, } = this.props const target = getTarget(history.location.pathname, false) @@ -134,7 +135,7 @@ class NavMenu extends PureComponent { return ( {showMenuPopover && window.innerWidth > 390 && window.innerWidth <= 1024 && } - {this.sections.map((section, index) => { + {this.getSections(isTurkishSite).map((section, index) => { const [type, title, isSkipped] = section if (isSkipped) { From 70002cab373555e6ee2d9d1988ba117539173621 Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Wed, 19 Oct 2022 12:58:47 +0300 Subject: [PATCH 15/20] Update account summary sections visibility for Turkey --- .../AccountSummary/AccountSummary.js | 30 +++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/components/AccountSummary/AccountSummary.js b/src/components/AccountSummary/AccountSummary.js index b46d1648a..96410bc0f 100644 --- a/src/components/AccountSummary/AccountSummary.js +++ b/src/components/AccountSummary/AccountSummary.js @@ -40,6 +40,7 @@ class AccountSummary extends PureComponent { }), dataReceived: PropTypes.bool.isRequired, fetchData: PropTypes.func.isRequired, + isTurkishSite: PropTypes.bool.isRequired, pageLoading: PropTypes.bool.isRequired, refresh: PropTypes.func.isRequired, t: PropTypes.func.isRequired, @@ -65,6 +66,7 @@ class AccountSummary extends PureComponent { refresh, pageLoading, dataReceived, + isTurkishSite, } = this.props let showContent @@ -84,19 +86,23 @@ class AccountSummary extends PureComponent { data={data} title='accountsummary.fees' /> - + {!isTurkishSite && ( + <> + + + + )}
- Date: Thu, 20 Oct 2022 12:03:50 +0300 Subject: [PATCH 16/20] Actualize main types/defaults, improve linting, fix warnings --- src/components/Main/Main.js | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/components/Main/Main.js b/src/components/Main/Main.js index 42fe3d475..a17787bba 100644 --- a/src/components/Main/Main.js +++ b/src/components/Main/Main.js @@ -1,4 +1,5 @@ import React, { PureComponent } from 'react' +import PropTypes from 'prop-types' import { Route, Switch } from 'react-router-dom' import AccountBalance from 'components/AccountBalance' @@ -47,8 +48,6 @@ import { getPath } from 'state/query/utils' import NavMenu from 'ui/NavMenu' import config from 'config' -import { propTypes, defaultProps } from './Main.props' - const { MENU_ACCOUNT_BALANCE, MENU_ACCOUNT_SUMMARY, @@ -118,6 +117,17 @@ const PATHS = { } class Main extends PureComponent { + static propTypes = { + authIsShown: PropTypes.bool, + authStatus: PropTypes.bool.isRequired, + isTurkishSite: PropTypes.bool.isRequired, + errorDialogDisabled: PropTypes.bool.isRequired, + } + + static defaultProps = { + authIsShown: false, + } + render() { const { authStatus, @@ -174,26 +184,31 @@ class Main extends PureComponent { exact path={PATHS.MENU_FCREDIT} component={FundingCreditHistory} + key={PATHS.MENU_FCREDIT} />, , , , , ] )} @@ -339,7 +354,4 @@ class Main extends PureComponent { } } -Main.propTypes = propTypes -Main.defaultProps = defaultProps - export default Main From c1448d686190b3c4e98e7e188e4b66af0fca3c46 Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Thu, 20 Oct 2022 12:10:30 +0300 Subject: [PATCH 17/20] Improve nav sections mapping, lint fixes --- src/ui/NavMenu/NavMenu.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/ui/NavMenu/NavMenu.js b/src/ui/NavMenu/NavMenu.js index 0fb6acf8d..983da2535 100644 --- a/src/ui/NavMenu/NavMenu.js +++ b/src/ui/NavMenu/NavMenu.js @@ -7,12 +7,13 @@ import { MenuDivider, MenuItem, } from '@blueprintjs/core' -import _castArray from 'lodash/castArray' +import _map from 'lodash/map' import _includes from 'lodash/includes' +import _castArray from 'lodash/castArray' +import config from 'config' import queryType from 'state/query/constants' import { getIcon, getPath, getTarget } from 'state/query/utils' -import config from 'config' import NavMenuPopover from './NavMenuPopover' import { propTypes, defaultProps } from './NavMenu.props' @@ -135,7 +136,7 @@ class NavMenu extends PureComponent { return ( {showMenuPopover && window.innerWidth > 390 && window.innerWidth <= 1024 && } - {this.getSections(isTurkishSite).map((section, index) => { + {_map(this.getSections(isTurkishSite), (section, index) => { const [type, title, isSkipped] = section if (isSkipped) { @@ -147,7 +148,6 @@ class NavMenu extends PureComponent { return } - const types = _castArray(type) const mainType = types[0] @@ -156,12 +156,12 @@ class NavMenu extends PureComponent { return ( } + href={path} key={mainType} text={t(title)} - onClick={(e) => this.handleClick(e, mainType)} - href={path} + icon={} active={_includes(types, target)} + onClick={(e) => this.handleClick(e, mainType)} /> ) })} From 010208730bb7af22164672436647b8e17b377ad5 Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Thu, 20 Oct 2022 12:14:58 +0300 Subject: [PATCH 18/20] Optimize exports, cleanup --- src/components/Main/Main.props.js | 11 ----------- src/components/Main/index.js | 4 +--- src/ui/NavMenu/NavMenu.props.js | 20 -------------------- src/ui/NavMenu/index.js | 4 +--- 4 files changed, 2 insertions(+), 37 deletions(-) delete mode 100644 src/components/Main/Main.props.js delete mode 100644 src/ui/NavMenu/NavMenu.props.js diff --git a/src/components/Main/Main.props.js b/src/components/Main/Main.props.js deleted file mode 100644 index 1f04da574..000000000 --- a/src/components/Main/Main.props.js +++ /dev/null @@ -1,11 +0,0 @@ -import PropTypes from 'prop-types' - -export const propTypes = { - authIsShown: PropTypes.bool.isRequired, - authStatus: PropTypes.bool.isRequired, - errorDialogDisabled: PropTypes.bool.isRequired, -} - -export const defaultProps = { - authIsShown: false, -} diff --git a/src/components/Main/index.js b/src/components/Main/index.js index 062a1615e..eb3b39f1c 100644 --- a/src/components/Main/index.js +++ b/src/components/Main/index.js @@ -1,3 +1 @@ -import Main from './Main.container' - -export default Main +export { default } from './Main.container' diff --git a/src/ui/NavMenu/NavMenu.props.js b/src/ui/NavMenu/NavMenu.props.js deleted file mode 100644 index 1aaa6f67a..000000000 --- a/src/ui/NavMenu/NavMenu.props.js +++ /dev/null @@ -1,20 +0,0 @@ -import PropTypes from 'prop-types' - -export const propTypes = { - className: PropTypes.string, - history: PropTypes.shape({ - location: PropTypes.shape({ - pathname: PropTypes.string.isRequired, - search: PropTypes.string.isRequired, - }).isRequired, - push: PropTypes.func.isRequired, - }).isRequired, - showMenuPopover: PropTypes.bool, - t: PropTypes.func.isRequired, - windowWidth: PropTypes.number.isRequired, -} - -export const defaultProps = { - className: '', - showMenuPopover: true, -} diff --git a/src/ui/NavMenu/index.js b/src/ui/NavMenu/index.js index cadebf6d8..7d57b918c 100644 --- a/src/ui/NavMenu/index.js +++ b/src/ui/NavMenu/index.js @@ -1,3 +1 @@ -import NavMenu from './NavMenu.container' - -export default NavMenu +export { default } from './NavMenu.container' From 2fafc29e1d5e05b1056c65ca6bd0f5fa6439bf41 Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Thu, 20 Oct 2022 12:16:26 +0300 Subject: [PATCH 19/20] Enchance nav menu decorators composition --- src/ui/NavMenu/NavMenu.container.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/ui/NavMenu/NavMenu.container.js b/src/ui/NavMenu/NavMenu.container.js index 08ad43aba..1b267e8d9 100644 --- a/src/ui/NavMenu/NavMenu.container.js +++ b/src/ui/NavMenu/NavMenu.container.js @@ -1,5 +1,7 @@ +import { compose } from 'redux' import { connect } from 'react-redux' import { withRouter } from 'react-router-dom' +import { withTranslation } from 'react-i18next' import { getWindowWidth } from 'state/ui/selectors' import { getIsTurkishSite } from 'state/base/selectors' @@ -11,7 +13,8 @@ const mapStateToProps = state => ({ isTurkishSite: getIsTurkishSite(state), }) - -const NavMenuContainer = connect(mapStateToProps)(withRouter(NavMenu)) - -export default NavMenuContainer +export default compose( + withTranslation('translations'), + connect(mapStateToProps), + withRouter, +)(NavMenu) From 1c364fb55834973f9e9e4ad84c07c937707790f3 Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Thu, 20 Oct 2022 12:17:14 +0300 Subject: [PATCH 20/20] Actualize nav menu types/defaults & improve props linting --- src/ui/NavMenu/NavMenu.js | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/ui/NavMenu/NavMenu.js b/src/ui/NavMenu/NavMenu.js index 983da2535..7edb8a029 100644 --- a/src/ui/NavMenu/NavMenu.js +++ b/src/ui/NavMenu/NavMenu.js @@ -1,5 +1,5 @@ import React, { PureComponent } from 'react' -import { withTranslation } from 'react-i18next' +import PropTypes from 'prop-types' import classNames from 'classnames' import { Classes, @@ -16,7 +16,6 @@ import queryType from 'state/query/constants' import { getIcon, getPath, getTarget } from 'state/query/utils' import NavMenuPopover from './NavMenuPopover' -import { propTypes, defaultProps } from './NavMenu.props' const { showFrameworkMode } = config @@ -57,9 +56,26 @@ const { } = queryType class NavMenu extends PureComponent { - static propTypes = propTypes + static propTypes = { + target: PropTypes.string, + className: PropTypes.string, + history: PropTypes.shape({ + location: PropTypes.shape({ + pathname: PropTypes.string.isRequired, + search: PropTypes.string.isRequired, + }).isRequired, + push: PropTypes.func.isRequired, + }).isRequired, + showMenuPopover: PropTypes.bool, + t: PropTypes.func.isRequired, + isTurkishSite: PropTypes.bool.isRequired, + } - static defaultProps = defaultProps + static defaultProps = { + className: '', + target: undefined, + showMenuPopover: true, + } getSections = (isTurkishSite) => [ [MENU_LEDGERS, 'ledgers.title'], @@ -170,4 +186,4 @@ class NavMenu extends PureComponent { } } -export default withTranslation('translations')(NavMenu) +export default NavMenu