diff --git a/package-lock.json b/package-lock.json index 8626319f9..bfebb70b0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "bfx-report-ui", - "version": "2.41.0", + "version": "2.42.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "bfx-report-ui", - "version": "2.41.0", + "version": "2.42.0", "license": "Apache-2.0", "dependencies": { "@bitfinex/lib-js-util-base": "git+https://github.com/bitfinexcom/lib-js-util-base.git", @@ -5798,10 +5798,11 @@ } }, "node_modules/braces": { - "version": "3.0.2", - "license": "MIT", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", "dependencies": { - "fill-range": "^7.0.1" + "fill-range": "^7.1.1" }, "engines": { "node": ">=8" @@ -8995,8 +8996,9 @@ } }, "node_modules/fill-range": { - "version": "7.0.1", - "license": "MIT", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", "dependencies": { "to-regex-range": "^5.0.1" }, @@ -10626,7 +10628,8 @@ }, "node_modules/is-number": { "version": "7.0.0", - "license": "MIT", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", "engines": { "node": ">=0.12.0" } @@ -19307,7 +19310,8 @@ }, "node_modules/to-regex-range": { "version": "5.0.1", - "license": "MIT", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", "dependencies": { "is-number": "^7.0.0" }, diff --git a/package.json b/package.json index b03fea7bb..f94c0a58c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bfx-report-ui", - "version": "2.42.0", + "version": "2.42.1", "description": "Report page to overview the user actions in Bitfinex and download related csv files", "repository": { "type": "git", diff --git a/src/components/AffiliatesEarnings/AffiliatesEarnings.js b/src/components/AffiliatesEarnings/AffiliatesEarnings.js index e0229df4b..e604e1531 100644 --- a/src/components/AffiliatesEarnings/AffiliatesEarnings.js +++ b/src/components/AffiliatesEarnings/AffiliatesEarnings.js @@ -13,7 +13,7 @@ import { toggleSymbol, clearAllSymbols, } from 'state/utils' -import getColumns from 'components/Ledgers/Ledgers.columns' +import { getColumns } from 'components/Ledgers/Ledgers.columns' import AffiliatesLink from './AffiliatesEarnings.link' diff --git a/src/components/Derivatives/Derivatives.columns.js b/src/components/Derivatives/Derivatives.columns.js index 040d65e2d..f46a2c0fd 100644 --- a/src/components/Derivatives/Derivatives.columns.js +++ b/src/components/Derivatives/Derivatives.columns.js @@ -1,8 +1,5 @@ -import React from 'react' -import { Cell } from '@blueprintjs/table' - import { formatAmount, fixedFloat } from 'ui/utils' -import { getCellState, getColumnWidth, getTooltipContent } from 'utils/columns' +import { getCell, getCellState, getColumnWidth } from 'utils/columns' export const getColumns = ({ t, @@ -19,15 +16,9 @@ export const getColumns = ({ className: 'align-left', width: getColumnWidth('pair', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { pair } = filteredData[rowIndex] - return ( - - {pair} - - ) + return getCell(pair, t) }, copyText: rowIndex => filteredData[rowIndex].pair, }, @@ -36,19 +27,9 @@ export const getColumns = ({ name: 'column.priceDeriv', width: getColumnWidth('price', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { price } = filteredData[rowIndex] - const fixedPrice = fixedFloat(price) - return ( - - {fixedPrice} - - ) + return getCell(fixedFloat(price), t) }, isNumericValue: true, copyText: rowIndex => fixedFloat(filteredData[rowIndex].price), @@ -58,19 +39,9 @@ export const getColumns = ({ name: 'column.priceSpot', width: getColumnWidth('priceSpot', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { priceSpot } = filteredData[rowIndex] - const fixedPrice = fixedFloat(priceSpot) - return ( - - {fixedPrice} - - ) + return getCell(fixedFloat(priceSpot), t) }, isNumericValue: true, copyText: rowIndex => fixedFloat(filteredData[rowIndex].priceSpot), @@ -80,19 +51,9 @@ export const getColumns = ({ name: 'column.fundBalance', width: getColumnWidth('fundBal', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { fundBal } = filteredData[rowIndex] - const fixedBalance = fixedFloat(fundBal) - return ( - - {fixedBalance} - - ) + return getCell(fixedFloat(fundBal), t) }, isNumericValue: true, copyText: rowIndex => fixedFloat(filteredData[rowIndex].fundBal), @@ -102,19 +63,9 @@ export const getColumns = ({ name: 'column.fundingAccrued', width: getColumnWidth('fundingAccrued', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { fundingAccrued } = filteredData[rowIndex] - const fixedFunding = fixedFloat(fundingAccrued) - return ( - - {formatAmount(fundingAccrued)} - - ) + return getCell(formatAmount(fundingAccrued), t, fixedFloat(fundingAccrued)) }, isNumericValue: true, copyText: rowIndex => fixedFloat(filteredData[rowIndex].fundingAccrued), @@ -124,18 +75,9 @@ export const getColumns = ({ name: 'column.fundingStep', width: getColumnWidth('fundingStep', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { fundingStep } = filteredData[rowIndex] - return ( - - {fundingStep} - - ) + return getCell(fundingStep, t) }, copyText: rowIndex => filteredData[rowIndex].fundingStep, }, @@ -145,15 +87,9 @@ export const getColumns = ({ nameStr: `${t('column.updated')} (${timeOffset})`, width: getColumnWidth('timestamp', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const timestamp = getFullTime(filteredData[rowIndex].timestamp) - return ( - - {timestamp} - - ) + return getCell(timestamp, t) }, copyText: rowIndex => getFullTime(filteredData[rowIndex].timestamp), }, @@ -162,18 +98,9 @@ export const getColumns = ({ name: 'column.clampMin', width: getColumnWidth('clampMin', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { clampMin } = filteredData[rowIndex] - return ( - - {clampMin} - - ) + return getCell(clampMin, t) }, copyText: rowIndex => filteredData[rowIndex].clampMin, }, @@ -182,18 +109,9 @@ export const getColumns = ({ name: 'column.clampMax', width: getColumnWidth('clampMax', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { clampMax } = filteredData[rowIndex] - return ( - - {clampMax} - - ) + return getCell(clampMax, t) }, copyText: rowIndex => filteredData[rowIndex].clampMax, }, diff --git a/src/components/FundingCreditHistory/FundingCreditHistory.columns.js b/src/components/FundingCreditHistory/FundingCreditHistory.columns.js index 163e2a607..06b3c299a 100644 --- a/src/components/FundingCreditHistory/FundingCreditHistory.columns.js +++ b/src/components/FundingCreditHistory/FundingCreditHistory.columns.js @@ -1,9 +1,6 @@ -import React from 'react' -import { Cell } from '@blueprintjs/table' - import { getSideMsg, getSideColor } from 'state/utils' import { formatAmount, formatColor, fixedFloat } from 'ui/utils' -import { getCellState, getColumnWidth, getTooltipContent } from 'utils/columns' +import { getCell, getCellState, getColumnWidth } from 'utils/columns' export const getColumns = ({ t, @@ -20,15 +17,9 @@ export const getColumns = ({ className: 'align-left', width: getColumnWidth('id', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { id } = filteredData[rowIndex] - return ( - - {id} - - ) + return getCell(id, t) }, copyText: rowIndex => filteredData[rowIndex].id, }, @@ -38,15 +29,9 @@ export const getColumns = ({ className: 'align-left', width: getColumnWidth('symbol', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { symbol } = filteredData[rowIndex] - return ( - - {symbol} - - ) + return getCell(symbol, t) }, copyText: rowIndex => filteredData[rowIndex].symbol, }, @@ -56,16 +41,10 @@ export const getColumns = ({ className: 'align-left', width: getColumnWidth('side', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { side } = filteredData[rowIndex] const formattedSide = t(`fcredit.side.${getSideMsg(side)}`) - return ( - - {formatColor(formattedSide, getSideColor(side))} - - ) + return getCell(formatColor(formattedSide, getSideColor(side)), t, formattedSide) }, copyText: rowIndex => t(`fcredit.side.${getSideMsg(filteredData[rowIndex].side)}`), }, @@ -74,18 +53,9 @@ export const getColumns = ({ name: 'column.amount', width: getColumnWidth('amount', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { amount } = filteredData[rowIndex] - return ( - - {formatAmount(amount)} - - ) + return getCell(formatAmount(amount), t, fixedFloat(amount)) }, isNumericValue: true, copyText: rowIndex => fixedFloat(filteredData[rowIndex].amount), @@ -96,15 +66,9 @@ export const getColumns = ({ className: 'align-left', width: getColumnWidth('status', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { status } = filteredData[rowIndex] - return ( - - {status} - - ) + return getCell(status, t) }, copyText: rowIndex => filteredData[rowIndex].status, }, @@ -114,15 +78,9 @@ export const getColumns = ({ className: 'align-left', width: getColumnWidth('type', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { type } = filteredData[rowIndex] - return ( - - {type} - - ) + return getCell(type, t) }, copyText: rowIndex => filteredData[rowIndex].type, }, @@ -131,18 +89,9 @@ export const getColumns = ({ name: 'column.rateperc', width: getColumnWidth('rate', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { rate } = filteredData[rowIndex] - return ( - - {fixedFloat(rate)} - - ) + return getCell(fixedFloat(rate), t) }, isNumericValue: true, copyText: rowIndex => fixedFloat(filteredData[rowIndex].rate), @@ -153,18 +102,9 @@ export const getColumns = ({ className: 'align-left', width: getColumnWidth('period', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const period = `${filteredData[rowIndex].period} ${t('column.days')}` - return ( - - {period} - - ) + return getCell(period, t) }, copyText: (rowIndex) => { const days = t('column.days') @@ -177,15 +117,9 @@ export const getColumns = ({ nameStr: `${t('column.opened')} (${timeOffset})`, width: getColumnWidth('mtsOpening', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const timestamp = getFullTime(filteredData[rowIndex].mtsOpening) - return ( - - {timestamp} - - ) + return getCell(timestamp, t) }, copyText: rowIndex => getFullTime(filteredData[rowIndex].mtsOpening), }, @@ -195,15 +129,9 @@ export const getColumns = ({ nameStr: `${t('column.lastpayout')} (${timeOffset})`, width: getColumnWidth('mtsLastPayout', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const timestamp = getFullTime(filteredData[rowIndex].mtsLastPayout) - return ( - - {timestamp} - - ) + return getCell(timestamp, t) }, copyText: rowIndex => getFullTime(filteredData[rowIndex].mtsLastPayout), }, @@ -213,15 +141,9 @@ export const getColumns = ({ className: 'align-left', width: getColumnWidth('positionPair', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { positionPair } = filteredData[rowIndex] - return ( - - {positionPair} - - ) + return getCell(positionPair, t) }, copyText: rowIndex => filteredData[rowIndex].positionPair, }, @@ -231,15 +153,9 @@ export const getColumns = ({ nameStr: `${t('column.date')} (${timeOffset})`, width: getColumnWidth('mtsUpdate', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const timestamp = getFullTime(filteredData[rowIndex].mtsUpdate) - return ( - - {timestamp} - - ) + return getCell(timestamp, t) }, copyText: rowIndex => getFullTime(filteredData[rowIndex].mtsUpdate), }, diff --git a/src/components/FundingLoanHistory/FundingLoanHistory.columns.js b/src/components/FundingLoanHistory/FundingLoanHistory.columns.js index a7ac073a0..38f752918 100644 --- a/src/components/FundingLoanHistory/FundingLoanHistory.columns.js +++ b/src/components/FundingLoanHistory/FundingLoanHistory.columns.js @@ -1,9 +1,6 @@ -import React from 'react' -import { Cell } from '@blueprintjs/table' - import { getSideMsg, getSideColor } from 'state/utils' import { formatAmount, formatColor, fixedFloat } from 'ui/utils' -import { getCellState, getColumnWidth, getTooltipContent } from 'utils/columns' +import { getCell, getCellState, getColumnWidth } from 'utils/columns' export const getColumns = ({ t, @@ -20,15 +17,9 @@ export const getColumns = ({ className: 'align-left', width: getColumnWidth('id', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { id } = filteredData[rowIndex] - return ( - - {id} - - ) + return getCell(id, t) }, copyText: rowIndex => filteredData[rowIndex].id, }, @@ -38,15 +29,9 @@ export const getColumns = ({ className: 'align-left', width: getColumnWidth('symbol', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { symbol } = filteredData[rowIndex] - return ( - - {symbol} - - ) + return getCell(symbol, t) }, copyText: rowIndex => filteredData[rowIndex].symbol, }, @@ -56,16 +41,10 @@ export const getColumns = ({ className: 'align-left', width: getColumnWidth('side', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { side } = filteredData[rowIndex] const formattedSide = t(`floan.side.${getSideMsg(side)}`) - return ( - - {formatColor(formattedSide, getSideColor(side))} - - ) + return getCell(formatColor(formattedSide, getSideColor(side)), t, formattedSide) }, copyText: rowIndex => t(`floan.side.${getSideMsg(filteredData[rowIndex].side)}`), }, @@ -74,18 +53,9 @@ export const getColumns = ({ name: 'column.amount', width: getColumnWidth('amount', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { amount } = filteredData[rowIndex] - return ( - - {formatAmount(amount)} - - ) + return getCell(formatAmount(amount), t, fixedFloat(amount)) }, isNumericValue: true, copyText: rowIndex => fixedFloat(filteredData[rowIndex].amount), @@ -96,15 +66,9 @@ export const getColumns = ({ className: 'align-left', width: getColumnWidth('status', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { status } = filteredData[rowIndex] - return ( - - {status} - - ) + return getCell(status, t) }, copyText: rowIndex => filteredData[rowIndex].status, }, @@ -114,15 +78,9 @@ export const getColumns = ({ className: 'align-left', width: getColumnWidth('type', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { type } = filteredData[rowIndex] - return ( - - {type} - - ) + return getCell(type, t) }, copyText: rowIndex => filteredData[rowIndex].type, }, @@ -131,19 +89,9 @@ export const getColumns = ({ name: 'column.rateperc', width: getColumnWidth('rate', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { rate } = filteredData[rowIndex] - const fixedRate = fixedFloat(rate) - return ( - - {fixedRate} - - ) + return getCell(fixedFloat(rate), t) }, isNumericValue: true, copyText: rowIndex => fixedFloat(filteredData[rowIndex].rate), @@ -154,18 +102,9 @@ export const getColumns = ({ className: 'align-left', width: getColumnWidth('period', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const period = `${filteredData[rowIndex].period} ${t('column.days')}` - return ( - - {period} - - ) + return getCell(period, t) }, copyText: rowIndex => `${filteredData[rowIndex].period} ${t('column.days')}`, }, @@ -179,11 +118,7 @@ export const getColumns = ({ return getCellState(isLoading, isNoData) } const timestamp = getFullTime(filteredData[rowIndex].mtsOpening) - return ( - - {timestamp} - - ) + return getCell(timestamp, t) }, copyText: rowIndex => getFullTime(filteredData[rowIndex].mtsOpening), }, @@ -193,15 +128,9 @@ export const getColumns = ({ nameStr: `${t('column.closed')} (${timeOffset})`, width: getColumnWidth('mtsLastPayout', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const timestamp = getFullTime(filteredData[rowIndex].mtsLastPayout) - return ( - - {timestamp} - - ) + return getCell(timestamp, t) }, copyText: rowIndex => getFullTime(filteredData[rowIndex].mtsLastPayout), }, @@ -211,15 +140,9 @@ export const getColumns = ({ nameStr: `${t('column.date')} (${timeOffset})`, width: getColumnWidth('mtsUpdate', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const timestamp = getFullTime(filteredData[rowIndex].mtsUpdate) - return ( - - {timestamp} - - ) + return getCell(timestamp, t) }, copyText: rowIndex => getFullTime(filteredData[rowIndex].mtsUpdate), }, diff --git a/src/components/FundingOfferHistory/FundingOfferHistory.columns.js b/src/components/FundingOfferHistory/FundingOfferHistory.columns.js index 11ba1fa12..32d13d1f8 100644 --- a/src/components/FundingOfferHistory/FundingOfferHistory.columns.js +++ b/src/components/FundingOfferHistory/FundingOfferHistory.columns.js @@ -1,8 +1,5 @@ -import React from 'react' -import { Cell } from '@blueprintjs/table' - import { formatAmount, fixedFloat } from 'ui/utils' -import { getCellState, getColumnWidth, getTooltipContent } from 'utils/columns' +import { getCell, getCellState, getColumnWidth } from 'utils/columns' export const getColumns = ({ t, @@ -19,15 +16,9 @@ export const getColumns = ({ className: 'align-left', width: getColumnWidth('id', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { id } = filteredData[rowIndex] - return ( - - {id} - - ) + return getCell(id, t) }, copyText: rowIndex => filteredData[rowIndex].id, }, @@ -37,15 +28,9 @@ export const getColumns = ({ className: 'align-left', width: getColumnWidth('symbol', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { symbol } = filteredData[rowIndex] - return ( - - {symbol} - - ) + return getCell(symbol, t) }, copyText: rowIndex => filteredData[rowIndex].symbol, }, @@ -54,19 +39,9 @@ export const getColumns = ({ name: 'column.amount', width: getColumnWidth('amountOrig', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { amountOrig } = filteredData[rowIndex] - const fixedAmount = fixedFloat(amountOrig) - return ( - - {fixedAmount} - - ) + return getCell(formatAmount(amountOrig), t, fixedFloat(amountOrig)) }, isNumericValue: true, copyText: rowIndex => fixedFloat(filteredData[rowIndex].amountOrig), @@ -76,18 +51,9 @@ export const getColumns = ({ name: 'column.amount-exe', width: getColumnWidth('amountExecuted', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { amountExecuted } = filteredData[rowIndex] - return ( - - {formatAmount(amountExecuted)} - - ) + return getCell(formatAmount(amountExecuted), t, fixedFloat(amountExecuted)) }, isNumericValue: true, copyText: rowIndex => fixedFloat(filteredData[rowIndex].amountExecuted), @@ -98,15 +64,9 @@ export const getColumns = ({ className: 'align-left', width: getColumnWidth('type', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { type } = filteredData[rowIndex] - return ( - - {type} - - ) + return getCell(type, t) }, copyText: rowIndex => filteredData[rowIndex].type, }, @@ -116,15 +76,9 @@ export const getColumns = ({ className: 'align-left', width: getColumnWidth('status', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { status } = filteredData[rowIndex] - return ( - - {status} - - ) + return getCell(status, t) }, copyText: rowIndex => filteredData[rowIndex].status, }, @@ -133,19 +87,9 @@ export const getColumns = ({ name: 'column.rateperc', width: getColumnWidth('rate', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { rate } = filteredData[rowIndex] - const fixedRate = fixedFloat(rate) - return ( - - {fixedRate} - - ) + return getCell(fixedFloat(rate), t) }, isNumericValue: true, copyText: rowIndex => fixedFloat(filteredData[rowIndex].rate), @@ -156,18 +100,9 @@ export const getColumns = ({ className: 'align-left', width: getColumnWidth('period', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const period = `${filteredData[rowIndex].period} ${t('column.days')}` - return ( - - {period} - - ) + return getCell(period, t) }, copyText: (rowIndex) => { const days = t('column.days') @@ -180,15 +115,9 @@ export const getColumns = ({ nameStr: `${t('column.date')} (${timeOffset})`, width: getColumnWidth('mtsUpdate', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const timestamp = getFullTime(filteredData[rowIndex].mtsUpdate) - return ( - - {timestamp} - - ) + return getCell(timestamp, t) }, copyText: rowIndex => getFullTime(filteredData[rowIndex].mtsUpdate), }, diff --git a/src/components/FundingPayment/FundingPayment.js b/src/components/FundingPayment/FundingPayment.js index e335ad372..03628ca34 100644 --- a/src/components/FundingPayment/FundingPayment.js +++ b/src/components/FundingPayment/FundingPayment.js @@ -17,7 +17,7 @@ import { clearAllSymbols, } from 'state/utils' -import getColumns from 'components/Ledgers/Ledgers.columns' +import { getColumns } from 'components/Ledgers/Ledgers.columns' const TYPE = queryConstants.MENU_FPAYMENT diff --git a/src/components/Header/Export/Export.container.js b/src/components/Header/Export/Export.container.js deleted file mode 100644 index 7f7d5d314..000000000 --- a/src/components/Header/Export/Export.container.js +++ /dev/null @@ -1,18 +0,0 @@ -import { compose } from 'redux' -import { connect } from 'react-redux' -import { withRouter } from 'react-router-dom' -import { withTranslation } from 'react-i18next' - -import { toggleExportDialog } from 'state/ui/actions' - -import Export from './Export' - -const mapDispatchToProps = { - toggleDialog: toggleExportDialog, -} - -export default compose( - connect(null, mapDispatchToProps), - withTranslation('translations'), - withRouter, -)(Export) diff --git a/src/components/Header/Export/Export.js b/src/components/Header/Export/Export.js index b4b1afc93..3190d7399 100644 --- a/src/components/Header/Export/Export.js +++ b/src/components/Header/Export/Export.js @@ -1,19 +1,23 @@ -import React, { memo } from 'react' -import PropTypes from 'prop-types' +import React from 'react' +import { useDispatch } from 'react-redux' +import { useTranslation } from 'react-i18next' import Icon from 'icons' import { tracker } from 'utils/trackers' +import { toggleExportDialog } from 'state/ui/actions' -const Export = ({ t, toggleDialog }) => { +const Export = () => { + const { t } = useTranslation() + const dispatch = useDispatch() const toggleExport = () => { tracker.trackEvent('Export', 'Navigation') - toggleDialog() + dispatch(toggleExportDialog()) } return (
toggleExport()} + onClick={toggleExport} > @@ -23,9 +27,4 @@ const Export = ({ t, toggleDialog }) => { ) } -Export.propTypes = { - t: PropTypes.func.isRequired, - toggleDialog: PropTypes.func.isRequired, -} - -export default memo(Export) +export default Export diff --git a/src/components/Header/Export/index.js b/src/components/Header/Export/index.js index 8ef2ccbd7..0b1d2f19d 100644 --- a/src/components/Header/Export/index.js +++ b/src/components/Header/Export/index.js @@ -1 +1 @@ -export { default } from './Export.container' +export { default } from './Export' diff --git a/src/components/Invoices/Invoices.columns.js b/src/components/Invoices/Invoices.columns.js index 31ed6276a..1c0d0c1a8 100644 --- a/src/components/Invoices/Invoices.columns.js +++ b/src/components/Invoices/Invoices.columns.js @@ -1,9 +1,11 @@ -import React from 'react' -import { Cell } from '@blueprintjs/table' - -import JSONFormat from 'ui/JSONFormat' +import { + getCell, + getLinkCell, + getCellState, + getColumnWidth, + getJsonFormattedCell, +} from 'utils/columns' import { fixedFloat, formatAmount } from 'ui/utils' -import { getCellState, getColumnWidth, getTooltipContent } from 'utils/columns' export const getColumns = ({ t, @@ -20,15 +22,9 @@ export const getColumns = ({ className: 'align-left', width: getColumnWidth('id', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { id } = filteredData[rowIndex] - return ( - - {id} - - ) + return getCell(id, t) }, copyText: rowIndex => filteredData[rowIndex].id, }, @@ -37,19 +33,9 @@ export const getColumns = ({ name: 'column.amount', width: getColumnWidth('amount', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { amount, currency } = filteredData[rowIndex] - const tooltip = `${fixedFloat(amount)} ${currency}` - return ( - - {formatAmount(amount)} - - ) + return getCell(formatAmount(amount), t, `${fixedFloat(amount)} ${currency}`) }, isNumericValue: true, copyText: rowIndex => fixedFloat(filteredData[rowIndex].amount), @@ -60,15 +46,9 @@ export const getColumns = ({ className: 'align-left', width: getColumnWidth('currency', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { currency } = filteredData[rowIndex] - return ( - - {currency} - - ) + return getCell(currency, t) }, copyText: rowIndex => filteredData[rowIndex].currency, }, @@ -78,15 +58,9 @@ export const getColumns = ({ className: 'align-left', width: getColumnWidth('orderId', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { orderId } = filteredData[rowIndex] - return ( - - {orderId} - - ) + return getCell(orderId, t) }, copyText: rowIndex => filteredData[rowIndex].orderId, }, @@ -95,18 +69,9 @@ export const getColumns = ({ name: 'column.payCurrencies', width: getColumnWidth('payCurrencies', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { payCurrencies } = filteredData[rowIndex] - const formattedPayCurrenciesInfo = JSON.stringify(payCurrencies, undefined, 2) - return ( - - - {formattedPayCurrenciesInfo} - - - ) + return getJsonFormattedCell(payCurrencies) }, copyText: rowIndex => JSON.stringify(filteredData[rowIndex].payCurrencies, undefined, 2), }, @@ -116,15 +81,9 @@ export const getColumns = ({ className: 'align-left', width: getColumnWidth('status', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { status } = filteredData[rowIndex] - return ( - - {status} - - ) + return getCell(status, t) }, copyText: rowIndex => filteredData[rowIndex].status, }, @@ -134,18 +93,9 @@ export const getColumns = ({ className: 'align-left', width: getColumnWidth('customerInfo', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { customerInfo } = filteredData[rowIndex] - const formattedCustomerInfo = JSON.stringify(customerInfo, undefined, 2) - return ( - - - {formattedCustomerInfo} - - - ) + return getJsonFormattedCell(customerInfo) }, copyText: rowIndex => JSON.stringify(filteredData[rowIndex].customerInfo, undefined, 2), }, @@ -155,18 +105,9 @@ export const getColumns = ({ className: 'align-left', width: getColumnWidth('invoices', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { invoices } = filteredData[rowIndex] - const formattedInvoicesInfo = JSON.stringify(invoices, undefined, 2) - return ( - - - {formattedInvoicesInfo} - - - ) + return getJsonFormattedCell(invoices) }, copyText: rowIndex => JSON.stringify(filteredData[rowIndex].invoices, undefined, 2), }, @@ -176,18 +117,9 @@ export const getColumns = ({ className: 'align-left', width: getColumnWidth('payment', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { payment } = filteredData[rowIndex] - const formattedPayment = JSON.stringify(payment, undefined, 2) - return ( - - - {formattedPayment} - - - ) + return getJsonFormattedCell(payment) }, copyText: rowIndex => JSON.stringify(filteredData[rowIndex].payment, undefined, 2), }, @@ -197,15 +129,9 @@ export const getColumns = ({ className: 'align-left', width: getColumnWidth('duration', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { duration } = filteredData[rowIndex] - return ( - - {duration} - - ) + return getCell(duration, t) }, copyText: rowIndex => filteredData[rowIndex].duration, }, @@ -215,15 +141,9 @@ export const getColumns = ({ className: 'align-left', width: getColumnWidth('merchantName', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { merchantName } = filteredData[rowIndex] - return ( - - {merchantName} - - ) + return getCell(merchantName, t) }, copyText: rowIndex => filteredData[rowIndex].merchantName, }, @@ -233,23 +153,9 @@ export const getColumns = ({ className: 'align-left', width: getColumnWidth('redirectUrl', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { redirectUrl } = filteredData[rowIndex] - return ( - - <> - - {redirectUrl} - - - - ) + return getLinkCell(redirectUrl) }, copyText: rowIndex => filteredData[rowIndex].redirectUrl, }, @@ -259,15 +165,9 @@ export const getColumns = ({ nameStr: `${t('column.date')} (${timeOffset})`, width: getColumnWidth('mts', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const timestamp = getFullTime(filteredData[rowIndex].mts) - return ( - - {timestamp} - - ) + return getCell(timestamp, t) }, copyText: rowIndex => getFullTime(filteredData[rowIndex].mts), }, @@ -277,23 +177,9 @@ export const getColumns = ({ className: 'align-left', width: getColumnWidth('webhook', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { webhook } = filteredData[rowIndex] - return ( - - <> - - {webhook} - - - - ) + return getLinkCell(webhook) }, copyText: rowIndex => filteredData[rowIndex].webhook, }, diff --git a/src/components/Ledgers/Ledgers.columns.js b/src/components/Ledgers/Ledgers.columns.js index a7f18d007..f7cb49176 100644 --- a/src/components/Ledgers/Ledgers.columns.js +++ b/src/components/Ledgers/Ledgers.columns.js @@ -1,210 +1,135 @@ -import React from 'react' -import { Cell } from '@blueprintjs/table' +import { isEqual } from '@bitfinex/lib-js-util-base' -import { insertIf, fixedFloat, formatAmount } from 'ui/utils' -import queryConstants from 'state/query/constants' import config from 'config' -import { getCellState, getColumnWidth, getTooltipContent } from 'utils/columns' - +import queryConstants from 'state/query/constants' +import { insertIf, fixedFloat, formatAmount } from 'ui/utils' +import { getCell, getCellState, getColumnWidth } from 'utils/columns' -export default function getColumns(props) { - const { - t, - target, - isNoData, - isLoading, - timeOffset, - getFullTime, - filteredData, - columnsWidth, - } = props +const { showFrameworkMode } = config +const { MENU_FPAYMENT } = queryConstants - return [ - { - id: 'id', - name: 'column.id', - className: 'align-left', - width: getColumnWidth('id', columnsWidth), - renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } - const { id } = filteredData[rowIndex] - return ( - - {id} - - ) - }, - copyText: rowIndex => filteredData[rowIndex].id, +export const getColumns = ({ + t, + target, + isNoData, + isLoading, + timeOffset, + getFullTime, + filteredData, + columnsWidth, +}) => [ + { + id: 'id', + name: 'column.id', + className: 'align-left', + width: getColumnWidth('id', columnsWidth), + renderer: (rowIndex) => { + if (isLoading || isNoData) return getCellState(isLoading, isNoData) + const { id } = filteredData[rowIndex] + return getCell(id, t) }, - ...insertIf(target !== queryConstants.MENU_FPAYMENT, ( - { - id: 'description', - name: 'column.description', - className: 'align-left', - width: getColumnWidth('description', columnsWidth), - renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } - const { description } = filteredData[rowIndex] - return ( - - {description} - - ) - }, - copyText: rowIndex => filteredData[rowIndex].description, - } - )), + copyText: rowIndex => filteredData[rowIndex].id, + }, + ...insertIf(!isEqual(target, MENU_FPAYMENT), ( { - id: 'currency', - name: 'column.currency', + id: 'description', + name: 'column.description', className: 'align-left', - width: getColumnWidth('currency', columnsWidth), + width: getColumnWidth('description', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } - const { currency } = filteredData[rowIndex] - return ( - - {currency} - - ) + if (isLoading || isNoData) return getCellState(isLoading, isNoData) + const { description } = filteredData[rowIndex] + return getCell(description, t) }, - copyText: rowIndex => filteredData[rowIndex].currency, + copyText: rowIndex => filteredData[rowIndex].description, + } + )), + { + id: 'currency', + name: 'column.currency', + className: 'align-left', + width: getColumnWidth('currency', columnsWidth), + renderer: (rowIndex) => { + if (isLoading || isNoData) return getCellState(isLoading, isNoData) + const { currency } = filteredData[rowIndex] + return getCell(currency, t) }, - { - id: 'amount', - name: 'column.amount', - width: getColumnWidth('amount', columnsWidth), - renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } - const { amount, currency } = filteredData[rowIndex] - const tooltip = getTooltipContent(`${fixedFloat(amount)} ${currency}`, t) - return ( - - {formatAmount(amount)} - - ) - }, - isNumericValue: true, - copyText: rowIndex => fixedFloat(filteredData[rowIndex].amount), + copyText: rowIndex => filteredData[rowIndex].currency, + }, + { + id: 'amount', + name: 'column.amount', + width: getColumnWidth('amount', columnsWidth), + renderer: (rowIndex) => { + if (isLoading || isNoData) return getCellState(isLoading, isNoData) + const { amount, currency } = filteredData[rowIndex] + return getCell(formatAmount(amount), t, `${fixedFloat(amount)} ${currency}`) }, - ...insertIf(config.showFrameworkMode, ( - { - id: 'amountUsd', - name: 'column.amountUsd', - width: getColumnWidth('amountUsd', columnsWidth), - renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } - const { amountUsd } = filteredData[rowIndex] - const tooltip = getTooltipContent(`${fixedFloat(amountUsd)} ${t('column.usd')}`, t) - return ( - - {formatAmount(amountUsd)} - - ) - }, - isNumericValue: true, - copyText: rowIndex => fixedFloat(filteredData[rowIndex].amountUsd), - } - )), + isNumericValue: true, + copyText: rowIndex => fixedFloat(filteredData[rowIndex].amount), + }, + ...insertIf(showFrameworkMode, ( { - id: 'balance', - name: 'column.balance', - width: getColumnWidth('balance', columnsWidth), + id: 'amountUsd', + name: 'column.amountUsd', + width: getColumnWidth('amountUsd', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } - const { balance, currency } = filteredData[rowIndex] - const fixedBalance = fixedFloat(balance) - const tooltip = getTooltipContent(`${fixedBalance} ${currency}`, t) - return ( - - {fixedBalance} - - ) + if (isLoading || isNoData) return getCellState(isLoading, isNoData) + const { amountUsd } = filteredData[rowIndex] + return getCell(formatAmount(amountUsd), t, `${fixedFloat(amountUsd)} ${t('column.usd')}`) }, isNumericValue: true, - copyText: rowIndex => fixedFloat(filteredData[rowIndex].balance), + copyText: rowIndex => fixedFloat(filteredData[rowIndex].amountUsd), + } + )), + { + id: 'balance', + name: 'column.balance', + width: getColumnWidth('balance', columnsWidth), + renderer: (rowIndex) => { + if (isLoading || isNoData) return getCellState(isLoading, isNoData) + const { balance, currency } = filteredData[rowIndex] + return getCell(fixedFloat(balance), t, `${fixedFloat(balance)} ${currency}`) }, - ...insertIf(config.showFrameworkMode, ( - { - id: 'balanceUsd', - name: 'column.balanceUsd', - width: getColumnWidth('balanceUsd', columnsWidth), - renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } - const { balanceUsd } = filteredData[rowIndex] - const fixedBalanceUsd = fixedFloat(balanceUsd) - const tooltip = getTooltipContent(`${fixedBalanceUsd} ${t('column.usd')}`, t) - return ( - - {fixedBalanceUsd} - - ) - }, - isNumericValue: true, - copyText: rowIndex => fixedFloat(filteredData[rowIndex].balanceUsd), - } - )), + isNumericValue: true, + copyText: rowIndex => fixedFloat(filteredData[rowIndex].balance), + }, + ...insertIf(showFrameworkMode, ( { - id: 'mts', - nameStr: `${t('column.date')} (${timeOffset})`, - className: 'align-left', - width: getColumnWidth('mts', columnsWidth), + id: 'balanceUsd', + name: 'column.balanceUsd', + width: getColumnWidth('balanceUsd', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } - const timestamp = getFullTime(filteredData[rowIndex].mts) - return ( - - {timestamp} - - ) + if (isLoading || isNoData) return getCellState(isLoading, isNoData) + const { balanceUsd } = filteredData[rowIndex] + return getCell(fixedFloat(balanceUsd), t, `${fixedFloat(balanceUsd)} ${t('column.usd')}`) }, - copyText: rowIndex => getFullTime(filteredData[rowIndex].mts), + isNumericValue: true, + copyText: rowIndex => fixedFloat(filteredData[rowIndex].balanceUsd), + } + )), + { + id: 'mts', + nameStr: `${t('column.date')} (${timeOffset})`, + className: 'align-left', + width: getColumnWidth('mts', columnsWidth), + renderer: (rowIndex) => { + if (isLoading || isNoData) return getCellState(isLoading, isNoData) + const timestamp = getFullTime(filteredData[rowIndex].mts) + return getCell(timestamp, t) }, - { - id: 'wallet', - name: 'column.wallet', - className: 'align-left', - width: getColumnWidth('wallet', columnsWidth), - renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } - const { wallet } = filteredData[rowIndex] - return ( - - {wallet} - - ) - }, - copyText: rowIndex => filteredData[rowIndex].wallet, + copyText: rowIndex => getFullTime(filteredData[rowIndex].mts), + }, + { + id: 'wallet', + name: 'column.wallet', + className: 'align-left', + width: getColumnWidth('wallet', columnsWidth), + renderer: (rowIndex) => { + if (isLoading || isNoData) return getCellState(isLoading, isNoData) + const { wallet } = filteredData[rowIndex] + return getCell(wallet, t) }, - ] -} + copyText: rowIndex => filteredData[rowIndex].wallet, + }, +] diff --git a/src/components/Ledgers/Ledgers.js b/src/components/Ledgers/Ledgers.js index 24e52e94b..0df177324 100644 --- a/src/components/Ledgers/Ledgers.js +++ b/src/components/Ledgers/Ledgers.js @@ -26,7 +26,7 @@ import { clearAllSymbols, } from 'state/utils' -import getColumns from './Ledgers.columns' +import { getColumns } from './Ledgers.columns' const TYPE = queryConstants.MENU_LEDGERS diff --git a/src/components/PublicFunding/PublicFunding.columns.js b/src/components/PublicFunding/PublicFunding.columns.js index 5172d8cf3..ef1ca4a15 100644 --- a/src/components/PublicFunding/PublicFunding.columns.js +++ b/src/components/PublicFunding/PublicFunding.columns.js @@ -1,141 +1,88 @@ -import React from 'react' -import { Cell } from '@blueprintjs/table' - import { fixedFloat, formatAmount } from 'ui/utils' -import { getCellState, getColumnWidth, getTooltipContent } from 'utils/columns' - -export default function getColumns(props) { - const { - t, - isNoData, - isLoading, - timeOffset, - getFullTime, - filteredData, - targetSymbol, - columnsWidth, - } = props +import { getCell, getCellState, getColumnWidth } from 'utils/columns' - return [ - { - id: 'id', - name: 'column.id', - className: 'align-left', - width: getColumnWidth('id', columnsWidth), - renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } - const { id } = filteredData[rowIndex] - return ( - - {id} - - ) - }, - copyText: rowIndex => filteredData[rowIndex].id, +export const getColumns = ({ + t, + isNoData, + isLoading, + timeOffset, + getFullTime, + filteredData, + targetSymbol, + columnsWidth, +}) => [ + { + id: 'id', + name: 'column.id', + className: 'align-left', + width: getColumnWidth('id', columnsWidth), + renderer: (rowIndex) => { + if (isLoading || isNoData) return getCellState(isLoading, isNoData) + const { id } = filteredData[rowIndex] + return getCell(id, t) + }, + copyText: rowIndex => filteredData[rowIndex].id, + }, + { + id: 'mts', + className: 'align-left', + nameStr: `${t('column.time')} (${timeOffset})`, + width: getColumnWidth('mts', columnsWidth), + renderer: (rowIndex) => { + if (isLoading || isNoData) return getCellState(isLoading, isNoData) + const timestamp = getFullTime(filteredData[rowIndex].mts) + return getCell(timestamp, t) }, - { - id: 'mts', - className: 'align-left', - nameStr: `${t('column.time')} (${timeOffset})`, - width: getColumnWidth('mts', columnsWidth), - renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } - const timestamp = getFullTime(filteredData[rowIndex].mts) - return ( - - {timestamp} - - ) - }, - copyText: rowIndex => getFullTime(filteredData[rowIndex].mts), + copyText: rowIndex => getFullTime(filteredData[rowIndex].mts), + }, + { + id: 'amount', + name: 'column.amount', + width: getColumnWidth('amount', columnsWidth), + renderer: (rowIndex) => { + if (isLoading || isNoData) return getCellState(isLoading, isNoData) + const { amount } = filteredData[rowIndex] + return getCell(formatAmount(amount), t, fixedFloat(amount)) }, - { - id: 'amount', - name: 'column.amount', - width: getColumnWidth('amount', columnsWidth), - renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } - const { amount } = filteredData[rowIndex] - const fixedAmount = fixedFloat(amount) - return ( - - {formatAmount(amount)} - - ) - }, - isNumericValue: true, - copyText: rowIndex => fixedFloat(filteredData[rowIndex].amount), + isNumericValue: true, + copyText: rowIndex => fixedFloat(filteredData[rowIndex].amount), + }, + { + id: 'rate', + name: 'column.rateperc', + width: getColumnWidth('rate', columnsWidth), + renderer: (rowIndex) => { + if (isLoading || isNoData) return getCellState(isLoading, isNoData) + const { rate } = filteredData[rowIndex] + return getCell(formatAmount(rate, { color: 'red' }), t, fixedFloat(rate)) }, - { - id: 'rate', - name: 'column.rateperc', - width: getColumnWidth('rate', columnsWidth), - renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } - const { rate } = filteredData[rowIndex] - return ( - - {formatAmount(rate, { color: 'red' })} - - ) - }, - isNumericValue: true, - copyText: rowIndex => fixedFloat(filteredData[rowIndex].rate), + isNumericValue: true, + copyText: rowIndex => fixedFloat(filteredData[rowIndex].rate), + }, + { + id: 'period', + name: 'column.period', + className: 'align-left', + width: getColumnWidth('period', columnsWidth), + renderer: (rowIndex) => { + if (isLoading || isNoData) return getCellState(isLoading, isNoData) + const period = `${filteredData[rowIndex].period} ${t('column.days')}` + return getCell(period, t) }, - { - id: 'period', - name: 'column.period', - className: 'align-left', - width: getColumnWidth('period', columnsWidth), - renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } - const period = `${filteredData[rowIndex].period} ${t('column.days')}` - return ( - - {period} - - ) - }, - copyText: (rowIndex) => { - const days = t('column.days') - return `${filteredData[rowIndex].period} ${days}` - }, + copyText: (rowIndex) => { + const days = t('column.days') + return `${filteredData[rowIndex].period} ${days}` }, - { - id: 'currency', - name: 'column.currency', - className: 'align-left', - width: getColumnWidth('currency', columnsWidth), - renderer: () => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } - return ( - - {targetSymbol} - - ) - }, - copyText: () => targetSymbol, + }, + { + id: 'currency', + name: 'column.currency', + className: 'align-left', + width: getColumnWidth('currency', columnsWidth), + renderer: () => { + if (isLoading || isNoData) return getCellState(isLoading, isNoData) + return getCell(targetSymbol, t) }, - ] -} + copyText: () => targetSymbol, + }, +] diff --git a/src/components/PublicFunding/PublicFunding.js b/src/components/PublicFunding/PublicFunding.js index 054b5e623..e3af7fa1e 100644 --- a/src/components/PublicFunding/PublicFunding.js +++ b/src/components/PublicFunding/PublicFunding.js @@ -21,7 +21,7 @@ import queryConstants from 'state/query/constants' import { getPath } from 'state/query/utils' import { checkInit, checkFetch } from 'state/utils' -import getColumns from './PublicFunding.columns' +import { getColumns } from './PublicFunding.columns' import { propTypes, defaultProps } from './PublicFunding.props' const TYPE = queryConstants.MENU_PUBLIC_FUNDING diff --git a/src/components/PublicTrades/PublicTrades.columns.js b/src/components/PublicTrades/PublicTrades.columns.js index ceb9f0aa2..7bd6d0016 100644 --- a/src/components/PublicTrades/PublicTrades.columns.js +++ b/src/components/PublicTrades/PublicTrades.columns.js @@ -1,145 +1,86 @@ -import React from 'react' -import { Cell } from '@blueprintjs/table' - import { formatPair } from 'state/symbols/utils' -import { formatAmount, fixedFloat, amountStyle } from 'ui/utils' -import { getCellState, getColumnWidth, getTooltipContent } from 'utils/columns' - -export default function getColumns(props) { - const { - t, - isNoData, - isLoading, - targetPair, - timeOffset, - getFullTime, - filteredData, - columnsWidth, - } = props +import { formatAmount, fixedFloat, formatType } from 'ui/utils' +import { getCell, getCellState, getColumnWidth } from 'utils/columns' - return [ - { - id: 'id', - name: 'column.id', - className: 'align-left', - width: getColumnWidth('id', columnsWidth), - renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } - const { id } = filteredData[rowIndex] - return ( - - {id} - - ) - }, - copyText: rowIndex => filteredData[rowIndex].id, +export const getColumns = ({ + t, + isNoData, + isLoading, + targetPair, + timeOffset, + getFullTime, + filteredData, + columnsWidth, +}) => [ + { + id: 'id', + name: 'column.id', + className: 'align-left', + width: getColumnWidth('id', columnsWidth), + renderer: (rowIndex) => { + if (isLoading || isNoData) return getCellState(isLoading, isNoData) + const { id } = filteredData[rowIndex] + return getCell(id, t) }, - { - id: 'mts', - className: 'align-left', - nameStr: `${t('column.time')} (${timeOffset})`, - width: getColumnWidth('mts', columnsWidth), - renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } - const timestamp = getFullTime(filteredData[rowIndex].mts) - return ( - - {timestamp} - - ) - }, - copyText: rowIndex => getFullTime(filteredData[rowIndex].mts), + copyText: rowIndex => filteredData[rowIndex].id, + }, + { + id: 'mts', + className: 'align-left', + nameStr: `${t('column.time')} (${timeOffset})`, + width: getColumnWidth('mts', columnsWidth), + renderer: (rowIndex) => { + if (isLoading || isNoData) return getCellState(isLoading, isNoData) + const timestamp = getFullTime(filteredData[rowIndex].mts) + return getCell(timestamp, t) }, - { - id: 'type', - name: 'column.type', - className: 'align-left', - width: getColumnWidth('type', columnsWidth), - renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } - const { type, amount } = filteredData[rowIndex] - const classes = amountStyle(amount) - return ( - - <> - - {type} - - - - ) - }, - copyText: rowIndex => filteredData[rowIndex].type, + copyText: rowIndex => getFullTime(filteredData[rowIndex].mts), + }, + { + id: 'type', + name: 'column.type', + className: 'align-left', + width: getColumnWidth('type', columnsWidth), + renderer: (rowIndex) => { + if (isLoading || isNoData) return getCellState(isLoading, isNoData) + const { type, amount } = filteredData[rowIndex] + return getCell(formatType(type, amount), t, type) }, - { - id: 'price', - name: 'column.price', - width: getColumnWidth('price', columnsWidth), - renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } - const { price, amount } = filteredData[rowIndex] - const color = (amount > 0) - ? 'green' - : 'red' - return ( - - {formatAmount(price, { color })} - - ) - }, - isNumericValue: true, - copyText: rowIndex => fixedFloat(filteredData[rowIndex].price), + copyText: rowIndex => filteredData[rowIndex].type, + }, + { + id: 'price', + name: 'column.price', + width: getColumnWidth('price', columnsWidth), + renderer: (rowIndex) => { + if (isLoading || isNoData) return getCellState(isLoading, isNoData) + const { price } = filteredData[rowIndex] + return getCell(formatAmount(price), t, fixedFloat(price)) }, - { - id: 'amount', - name: 'column.amount', - width: getColumnWidth('amount', columnsWidth), - renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } - const { amount } = filteredData[rowIndex] - const fixedAmount = fixedFloat(amount) - return ( - - {formatAmount(amount)} - - ) - }, - isNumericValue: true, - copyText: rowIndex => fixedFloat(filteredData[rowIndex].amount), + isNumericValue: true, + copyText: rowIndex => fixedFloat(filteredData[rowIndex].price), + }, + { + id: 'amount', + name: 'column.amount', + width: getColumnWidth('amount', columnsWidth), + renderer: (rowIndex) => { + if (isLoading || isNoData) return getCellState(isLoading, isNoData) + const { amount } = filteredData[rowIndex] + return getCell(formatAmount(amount), t, fixedFloat(amount)) }, - { - id: 'pair', - name: 'column.pair', - className: 'align-left', - width: getColumnWidth('pair', columnsWidth), - renderer: () => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } - const formattedCurrentPair = formatPair(targetPair) - return ( - - {formattedCurrentPair} - - ) - }, - copyText: () => formatPair(targetPair), + isNumericValue: true, + copyText: rowIndex => fixedFloat(filteredData[rowIndex].amount), + }, + { + id: 'pair', + name: 'column.pair', + className: 'align-left', + width: getColumnWidth('pair', columnsWidth), + renderer: () => { + if (isLoading || isNoData) return getCellState(isLoading, isNoData) + return getCell(formatPair(targetPair), t) }, - ] -} + copyText: () => formatPair(targetPair), + }, +] diff --git a/src/components/PublicTrades/PublicTrades.js b/src/components/PublicTrades/PublicTrades.js index f036b4e85..c8a383a02 100644 --- a/src/components/PublicTrades/PublicTrades.js +++ b/src/components/PublicTrades/PublicTrades.js @@ -20,7 +20,7 @@ import SyncPrefButton from 'ui/SyncPrefButton' import queryConstants from 'state/query/constants' import { checkInit, checkFetch, setPair } from 'state/utils' -import getColumns from './PublicTrades.columns' +import { getColumns } from './PublicTrades.columns' import { propTypes, defaultProps } from './PublicTrades.props' const TYPE = queryConstants.MENU_PUBLIC_TRADES diff --git a/src/components/StakingPayments/StakingPayments.js b/src/components/StakingPayments/StakingPayments.js index 8e86f517d..b96656dc6 100644 --- a/src/components/StakingPayments/StakingPayments.js +++ b/src/components/StakingPayments/StakingPayments.js @@ -17,7 +17,7 @@ import { clearAllSymbols, } from 'state/utils' -import getColumns from 'components/Ledgers/Ledgers.columns' +import { getColumns } from 'components/Ledgers/Ledgers.columns' const TYPE = queryConstants.MENU_SPAYMENTS diff --git a/src/components/Tickers/Tickers.columns.js b/src/components/Tickers/Tickers.columns.js index c61fb3548..84938d8c1 100644 --- a/src/components/Tickers/Tickers.columns.js +++ b/src/components/Tickers/Tickers.columns.js @@ -1,100 +1,61 @@ -import React from 'react' -import { Cell } from '@blueprintjs/table' - import { fixedFloat } from 'ui/utils' -import { getCellState, getColumnWidth, getTooltipContent } from 'utils/columns' - -export default function getColumns(props) { - const { - t, - isNoData, - isLoading, - timeOffset, - getFullTime, - columnsWidth, - filteredData, - } = props +import { getCell, getCellState, getColumnWidth } from 'utils/columns' - return [ - { - id: 'symbol', - name: 'column.pair', - className: 'align-left', - width: getColumnWidth('symbol', columnsWidth), - renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } - const { pair } = filteredData[rowIndex] - return ( - - {pair} - - ) - }, - copyText: rowIndex => filteredData[rowIndex].pair, +export const getColumns = ({ + t, + isNoData, + isLoading, + timeOffset, + getFullTime, + columnsWidth, + filteredData, +}) => [ + { + id: 'symbol', + name: 'column.pair', + className: 'align-left', + width: getColumnWidth('symbol', columnsWidth), + renderer: (rowIndex) => { + if (isLoading || isNoData) return getCellState(isLoading, isNoData) + const { pair } = filteredData[rowIndex] + return getCell(pair, t) }, - { - id: 'bid', - name: 'column.bid', - width: getColumnWidth('bid', columnsWidth), - renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } - const { bid } = filteredData[rowIndex] - const fixedBid = fixedFloat(bid) - return ( - - {fixedBid} - - ) - }, - isNumericValue: true, - copyText: rowIndex => fixedFloat(filteredData[rowIndex].bid), + copyText: rowIndex => filteredData[rowIndex].pair, + }, + { + id: 'bid', + name: 'column.bid', + width: getColumnWidth('bid', columnsWidth), + renderer: (rowIndex) => { + if (isLoading || isNoData) return getCellState(isLoading, isNoData) + const { bid } = filteredData[rowIndex] + return getCell(fixedFloat(bid), t) }, - { - id: 'ask', - name: 'column.ask', - width: getColumnWidth('ask', columnsWidth), - renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } - const { ask } = filteredData[rowIndex] - const fixedAsk = fixedFloat(ask) - return ( - - {fixedAsk} - - ) - }, - isNumericValue: true, - copyText: rowIndex => fixedFloat(filteredData[rowIndex].ask), + isNumericValue: true, + copyText: rowIndex => fixedFloat(filteredData[rowIndex].bid), + }, + { + id: 'ask', + name: 'column.ask', + width: getColumnWidth('ask', columnsWidth), + renderer: (rowIndex) => { + if (isLoading || isNoData) return getCellState(isLoading, isNoData) + const { ask } = filteredData[rowIndex] + return getCell(fixedFloat(ask), t) }, - { - id: 'mtsUpdate', - className: 'align-left', - nameStr: `${t('column.time')} (${timeOffset})`, - width: getColumnWidth('mtsUpdate', columnsWidth), - renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } - const timestamp = getFullTime(filteredData[rowIndex].mtsUpdate) - return ( - - {timestamp} - - ) - }, - copyText: rowIndex => getFullTime(filteredData[rowIndex].mtsUpdate), + isNumericValue: true, + copyText: rowIndex => fixedFloat(filteredData[rowIndex].ask), + }, + { + id: 'mtsUpdate', + className: 'align-left', + nameStr: `${t('column.time')} (${timeOffset})`, + width: getColumnWidth('mtsUpdate', columnsWidth), + renderer: (rowIndex) => { + if (isLoading || isNoData) return getCellState(isLoading, isNoData) + const timestamp = getFullTime(filteredData[rowIndex].mtsUpdate) + return getCell(timestamp, t) }, - ] -} + copyText: rowIndex => getFullTime(filteredData[rowIndex].mtsUpdate), + }, +] diff --git a/src/components/Tickers/Tickers.js b/src/components/Tickers/Tickers.js index 01da2a59d..26ab5b5fc 100644 --- a/src/components/Tickers/Tickers.js +++ b/src/components/Tickers/Tickers.js @@ -26,7 +26,7 @@ import { clearAllPairs, } from 'state/utils' -import getColumns from './Tickers.columns' +import { getColumns } from './Tickers.columns' import { propTypes, defaultProps } from './Tickers.props' const TYPE = queryConstants.MENU_TICKERS diff --git a/src/ui/CollapsedTable/CollapsedTable.js b/src/ui/CollapsedTable/CollapsedTable.js index 0b09b6f4a..5fad72913 100644 --- a/src/ui/CollapsedTable/CollapsedTable.js +++ b/src/ui/CollapsedTable/CollapsedTable.js @@ -1,56 +1,55 @@ -import React, { PureComponent } from 'react' -import { withTranslation } from 'react-i18next' +import React, { memo } from 'react' +import { useTranslation } from 'react-i18next' import PropTypes from 'prop-types' +import _map from 'lodash/map' import _times from 'lodash/times' -class CollapsedTable extends PureComponent { - render() { - const { numRows, tableColumns, t } = this.props +const CollapsedTable = ({ numRows, tableColumns }) => { + const { t } = useTranslation() - return ( -
- {_times(numRows, rowIndex => ( -
- {tableColumns.map((column) => { - const { - id, name, nameStr, renderer, description, - } = column - const cell = renderer(rowIndex) - return ( -
-
- {nameStr || t(name)} -
- {description && ( - - {t(description)} - - )} -
-
{cell.props.children}
+ return ( +
+ {_times(numRows, rowIndex => ( +
+ {_map(tableColumns, (column) => { + const { + id, name, nameStr, renderer, description, + } = column + const cell = renderer(rowIndex) + return ( +
+
+ {nameStr || t(name)} +
+ {description && ( + + {t(description)} + + )}
- ) - })} -
- ))} -
- ) - } +
{cell.props.children}
+
+ ) + })} +
+ ))} +
+ ) } -const TABLE_COLUMNS_PROPS = PropTypes.shape({ - name: PropTypes.string, - width: PropTypes.number, - nameStr: PropTypes.string, - id: PropTypes.string.isRequired, - renderer: PropTypes.func.isRequired, - copyText: PropTypes.func, -}) - CollapsedTable.propTypes = { - t: PropTypes.func.isRequired, numRows: PropTypes.number.isRequired, - tableColumns: PropTypes.arrayOf(TABLE_COLUMNS_PROPS).isRequired, + tableColumns: PropTypes.arrayOf(PropTypes.shape({ + name: PropTypes.string, + width: PropTypes.number, + nameStr: PropTypes.string, + id: PropTypes.string.isRequired, + renderer: PropTypes.func.isRequired, + copyText: PropTypes.func, + })).isRequired, } -export default withTranslation('translations')(CollapsedTable) +export default memo(CollapsedTable) diff --git a/src/ui/CollapsedTable/index.js b/src/ui/CollapsedTable/index.js index ef258041b..9dee05ca2 100644 --- a/src/ui/CollapsedTable/index.js +++ b/src/ui/CollapsedTable/index.js @@ -1,3 +1 @@ -import CollapsedTable from './CollapsedTable' - -export default CollapsedTable +export { default } from './CollapsedTable' diff --git a/src/ui/DateFormatSelector/DateFormatSelector.container.js b/src/ui/DateFormatSelector/DateFormatSelector.container.js deleted file mode 100644 index f8cbacb06..000000000 --- a/src/ui/DateFormatSelector/DateFormatSelector.container.js +++ /dev/null @@ -1,18 +0,0 @@ -import { connect } from 'react-redux' - -import { setDateFormat } from 'state/base/actions' -import { getDateFormat } from 'state/base/selectors' - -import DateFormatSelector from './DateFormatSelector' - -const mapStateToProps = state => ({ - dateFormat: getDateFormat(state), -}) - -const mapDispatchToProps = { - setDateFormat, -} - -const DateFormatSelectorContainer = connect(mapStateToProps, mapDispatchToProps)(DateFormatSelector) - -export default DateFormatSelectorContainer diff --git a/src/ui/DateFormatSelector/DateFormatSelector.js b/src/ui/DateFormatSelector/DateFormatSelector.js index a49398e1b..c79c4195a 100644 --- a/src/ui/DateFormatSelector/DateFormatSelector.js +++ b/src/ui/DateFormatSelector/DateFormatSelector.js @@ -1,35 +1,31 @@ -import React, { PureComponent } from 'react' +import React, { useCallback } from 'react' +import { useDispatch, useSelector } from 'react-redux' +import { isEqual } from '@bitfinex/lib-js-util-base' import Select from 'ui/Select' import types from 'state/base/constants' +import { setDateFormat } from 'state/base/actions' +import { getDateFormat } from 'state/base/selectors' -import { propTypes, defaultProps } from './DateFormatSelector.props' - -class DateFormatSelector extends PureComponent { - handleClick = (format) => { - const { dateFormat, setDateFormat } = this.props - if (dateFormat !== format) { - setDateFormat(format) +const DateFormatSelector = () => { + const dispatch = useDispatch() + const dateFormat = useSelector(getDateFormat) + const handleClick = useCallback((format) => { + if (!isEqual(dateFormat, format)) { + dispatch(setDateFormat(format)) } - } - - render() { - const { dateFormat } = this.props + }, [dispatch, dateFormat, setDateFormat]) - return ( - + ) } -DateFormatSelector.propTypes = propTypes -DateFormatSelector.defaultProps = defaultProps - export default DateFormatSelector diff --git a/src/ui/DateFormatSelector/DateFormatSelector.props.js b/src/ui/DateFormatSelector/DateFormatSelector.props.js deleted file mode 100644 index 9d09038a9..000000000 --- a/src/ui/DateFormatSelector/DateFormatSelector.props.js +++ /dev/null @@ -1,9 +0,0 @@ -import PropTypes from 'prop-types' - -export const propTypes = { - dateFormat: PropTypes.string.isRequired, - setDateFormat: PropTypes.func.isRequired, -} - -export const defaultProps = { -} diff --git a/src/ui/DateFormatSelector/index.js b/src/ui/DateFormatSelector/index.js index 32d80ddc5..a3a3fe0b6 100644 --- a/src/ui/DateFormatSelector/index.js +++ b/src/ui/DateFormatSelector/index.js @@ -1,3 +1 @@ -import DateFormatSelector from './DateFormatSelector.container' - -export default DateFormatSelector +export { default } from './DateFormatSelector' diff --git a/src/ui/ExportButton/ExportButton.container.js b/src/ui/ExportButton/ExportButton.container.js deleted file mode 100644 index 9ec2308c1..000000000 --- a/src/ui/ExportButton/ExportButton.container.js +++ /dev/null @@ -1,13 +0,0 @@ -import { connect } from 'react-redux' - -import { toggleExportDialog } from 'state/ui/actions' - -import ExportButton from './ExportButton' - -const mapDispatchToProps = { - toggleDialog: toggleExportDialog, -} - -const ExportButtonContainer = connect(null, mapDispatchToProps)(ExportButton) - -export default ExportButtonContainer diff --git a/src/ui/ExportButton/ExportButton.js b/src/ui/ExportButton/ExportButton.js deleted file mode 100644 index ce130d0d5..000000000 --- a/src/ui/ExportButton/ExportButton.js +++ /dev/null @@ -1,20 +0,0 @@ -import React from 'react' -import { withTranslation } from 'react-i18next' -import PropTypes from 'prop-types' -import { Button } from '@blueprintjs/core' -import { IconNames } from '@blueprintjs/icons' - -const ExportButton = ({ toggleDialog, t }) => ( - -) - -ExportButton.propTypes = { - toggleDialog: PropTypes.func.isRequired, - t: PropTypes.func.isRequired, -} - -ExportButton.defaultProps = {} - -export default withTranslation('translations')(ExportButton) diff --git a/src/ui/ExportButton/index.js b/src/ui/ExportButton/index.js deleted file mode 100644 index d797c39cc..000000000 --- a/src/ui/ExportButton/index.js +++ /dev/null @@ -1,3 +0,0 @@ -import ExportButton from './ExportButton.container' - -export default ExportButton diff --git a/src/ui/JSONFormat/_JSONFormat.scss b/src/ui/JSONFormat/_JSONFormat.scss index 92fa01aa6..0b16ca493 100644 --- a/src/ui/JSONFormat/_JSONFormat.scss +++ b/src/ui/JSONFormat/_JSONFormat.scss @@ -1,5 +1,5 @@ .json-format { - width: #{"max(500px, 40vw);"}; + max-width: 500px; overflow: hidden; white-space: pre-wrap; word-break: break-all; diff --git a/src/ui/LangMenu/LangMenu.container.js b/src/ui/LangMenu/LangMenu.container.js deleted file mode 100644 index 36957597a..000000000 --- a/src/ui/LangMenu/LangMenu.container.js +++ /dev/null @@ -1,18 +0,0 @@ -import { connect } from 'react-redux' - -import { setLang } from 'state/base/actions' -import { getLocale } from 'state/base/selectors' - -import LangMenu from './LangMenu' - -const mapStateToProps = state => ({ - value: getLocale(state), -}) - -const mapDispatchToProps = { - setLang, -} - -const LangMenuContainer = connect(mapStateToProps, mapDispatchToProps)(LangMenu) - -export default LangMenuContainer diff --git a/src/ui/LangMenu/LangMenu.js b/src/ui/LangMenu/LangMenu.js index b01f6e09d..60f14e5d3 100644 --- a/src/ui/LangMenu/LangMenu.js +++ b/src/ui/LangMenu/LangMenu.js @@ -1,30 +1,33 @@ -import React from 'react' +import React, { useCallback } from 'react' +import { useDispatch, useSelector } from 'react-redux' import _map from 'lodash/map' import _keys from 'lodash/keys' import Select from 'ui/Select' +import { setLang } from 'state/base/actions' import { LANGUAGE_NAMES } from 'locales/i18n' - -import { propTypes, defaultProps } from './LangMenu.props' +import { getLocale } from 'state/base/selectors' const items = _map(_keys(LANGUAGE_NAMES), (lang) => ({ value: lang, label: LANGUAGE_NAMES[lang] })) -const LangMenu = (props) => { - const { setLang, value } = props +const LangMenu = () => { + const dispatch = useDispatch() + const currentValue = useSelector(getLocale) + + const handleChange = useCallback((value) => { + dispatch(setLang(value)) + }, [dispatch]) return (