From 396b075d5a6fd63f0aa2888ea10601db764e07e1 Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Wed, 26 Jun 2024 13:44:56 +0300 Subject: [PATCH 01/16] Improve logins cell states handling --- src/components/Logins/Logins.columns.js | 28 +++++++------------------ 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/src/components/Logins/Logins.columns.js b/src/components/Logins/Logins.columns.js index 41863c7f5..928977dfd 100644 --- a/src/components/Logins/Logins.columns.js +++ b/src/components/Logins/Logins.columns.js @@ -19,9 +19,7 @@ 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 ( @@ -37,9 +35,7 @@ export const getColumns = ({ nameStr: `${t('column.date')} (${timeOffset})`, width: getColumnWidth('time', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const timestamp = getFullTime(filteredData[rowIndex].time) return ( @@ -55,9 +51,7 @@ export const getColumns = ({ className: 'align-left', width: getColumnWidth('ip', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { ip } = filteredData[rowIndex] return ( @@ -73,9 +67,7 @@ export const getColumns = ({ className: 'align-left', width: getColumnWidth('browser', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { browser } = filteredData[rowIndex] return ( @@ -91,9 +83,7 @@ export const getColumns = ({ className: 'align-left', width: getColumnWidth('version', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { version } = filteredData[rowIndex] return ( @@ -109,9 +99,7 @@ export const getColumns = ({ className: 'align-left', width: getColumnWidth('mobile', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { mobile } = filteredData[rowIndex] return ( @@ -127,9 +115,7 @@ export const getColumns = ({ className: 'align-left', width: getColumnWidth('extra', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { extra } = filteredData[rowIndex] const formattedExtra = JSON.stringify(extra, undefined, 2) return ( From 99dfc28b18fc7fa581a5c0405e8a63c712fef5c2 Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Wed, 26 Jun 2024 13:49:09 +0300 Subject: [PATCH 02/16] Rework and optimize regular cell getters --- src/components/Logins/Logins.columns.js | 38 +++++-------------------- 1 file changed, 7 insertions(+), 31 deletions(-) diff --git a/src/components/Logins/Logins.columns.js b/src/components/Logins/Logins.columns.js index 928977dfd..9d77e9a64 100644 --- a/src/components/Logins/Logins.columns.js +++ b/src/components/Logins/Logins.columns.js @@ -2,7 +2,7 @@ import React from 'react' import { Cell } from '@blueprintjs/table' import JSONFormat from 'ui/JSONFormat' -import { getCellState, getColumnWidth, getTooltipContent } from 'utils/columns' +import { getCell, getCellState, getColumnWidth } from 'utils/columns' export const getColumns = ({ t, @@ -21,11 +21,7 @@ export const getColumns = ({ renderer: (rowIndex) => { if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { id } = filteredData[rowIndex] - return ( - - {id} - - ) + return getCell(id, t) }, copyText: rowIndex => filteredData[rowIndex].id, }, @@ -37,11 +33,7 @@ export const getColumns = ({ renderer: (rowIndex) => { if (isLoading || isNoData) return getCellState(isLoading, isNoData) const timestamp = getFullTime(filteredData[rowIndex].time) - return ( - - {timestamp} - - ) + return getCell(timestamp, t) }, copyText: rowIndex => getFullTime(filteredData[rowIndex].time), }, @@ -53,11 +45,7 @@ export const getColumns = ({ renderer: (rowIndex) => { if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { ip } = filteredData[rowIndex] - return ( - - {ip} - - ) + return getCell(ip, t) }, copyText: rowIndex => filteredData[rowIndex].ip, }, @@ -69,11 +57,7 @@ export const getColumns = ({ renderer: (rowIndex) => { if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { browser } = filteredData[rowIndex] - return ( - - {browser} - - ) + return getCell(browser, t) }, copyText: rowIndex => filteredData[rowIndex].browser, }, @@ -85,11 +69,7 @@ export const getColumns = ({ renderer: (rowIndex) => { if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { version } = filteredData[rowIndex] - return ( - - {version} - - ) + return getCell(version, t) }, copyText: rowIndex => filteredData[rowIndex].version, }, @@ -101,11 +81,7 @@ export const getColumns = ({ renderer: (rowIndex) => { if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { mobile } = filteredData[rowIndex] - return ( - - {mobile} - - ) + return getCell(mobile, t) }, copyText: rowIndex => filteredData[rowIndex].mobile, }, From cf274dd5d74ea8c23f76519227281d2821c40eae Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Wed, 26 Jun 2024 13:51:46 +0300 Subject: [PATCH 03/16] Improve metadata cell rendering and cleanup --- src/components/Logins/Logins.columns.js | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/components/Logins/Logins.columns.js b/src/components/Logins/Logins.columns.js index 9d77e9a64..911e93576 100644 --- a/src/components/Logins/Logins.columns.js +++ b/src/components/Logins/Logins.columns.js @@ -1,8 +1,9 @@ -import React from 'react' -import { Cell } from '@blueprintjs/table' - -import JSONFormat from 'ui/JSONFormat' -import { getCell, getCellState, getColumnWidth } from 'utils/columns' +import { + getCell, + getCellState, + getColumnWidth, + getJsonFormattedCell, +} from 'utils/columns' export const getColumns = ({ t, @@ -93,14 +94,7 @@ export const getColumns = ({ renderer: (rowIndex) => { if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { extra } = filteredData[rowIndex] - const formattedExtra = JSON.stringify(extra, undefined, 2) - return ( - - - {formattedExtra} - - - ) + return getJsonFormattedCell(extra) }, copyText: rowIndex => JSON.stringify(filteredData[rowIndex].extra, undefined, 2), }, From 598cd992be13a1873cc084dcfb418f4a8cb0e9ea Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Wed, 26 Jun 2024 13:54:22 +0300 Subject: [PATCH 04/16] Enhance change logs cell states handling --- src/components/ChangeLogs/ChangeLogs.columns.js | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/components/ChangeLogs/ChangeLogs.columns.js b/src/components/ChangeLogs/ChangeLogs.columns.js index ceb3b619c..5f8171d38 100644 --- a/src/components/ChangeLogs/ChangeLogs.columns.js +++ b/src/components/ChangeLogs/ChangeLogs.columns.js @@ -18,9 +18,7 @@ export const getColumns = ({ nameStr: `${t('column.date')} (${timeOffset})`, width: getColumnWidth('mtsCreate', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const timestamp = getFullTime(filteredData[rowIndex].mtsCreate) return ( @@ -35,9 +33,7 @@ export const getColumns = ({ name: 'column.description', width: getColumnWidth('log', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { log } = filteredData[rowIndex] return ( @@ -52,9 +48,7 @@ export const getColumns = ({ name: 'column.ip', width: getColumnWidth('ip', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { ip } = filteredData[rowIndex] return ( @@ -69,9 +63,7 @@ export const getColumns = ({ name: 'column.meta', width: getColumnWidth('userAgent', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { userAgent } = filteredData[rowIndex] return ( From 2738e198c7d35590675b1c5106c793fe4ad2bfc8 Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Wed, 26 Jun 2024 14:02:27 +0300 Subject: [PATCH 05/16] Rework and optimize change logs cells config getters --- .../ChangeLogs/ChangeLogs.columns.js | 38 +++++-------------- 1 file changed, 10 insertions(+), 28 deletions(-) diff --git a/src/components/ChangeLogs/ChangeLogs.columns.js b/src/components/ChangeLogs/ChangeLogs.columns.js index 5f8171d38..ce4a7ade4 100644 --- a/src/components/ChangeLogs/ChangeLogs.columns.js +++ b/src/components/ChangeLogs/ChangeLogs.columns.js @@ -1,8 +1,9 @@ -import React from 'react' -import { Cell } from '@blueprintjs/table' - -import JSONFormat from 'ui/JSONFormat' -import { getCellState, getColumnWidth, getTooltipContent } from 'utils/columns' +import { + getCell, + getCellState, + getColumnWidth, + getJsonFormattedCell, +} from 'utils/columns' export const getColumns = ({ t, @@ -20,11 +21,7 @@ export const getColumns = ({ renderer: (rowIndex) => { if (isLoading || isNoData) return getCellState(isLoading, isNoData) const timestamp = getFullTime(filteredData[rowIndex].mtsCreate) - return ( - - {timestamp} - - ) + return getCell(timestamp, t) }, copyText: rowIndex => getFullTime(filteredData[rowIndex].mtsCreate), }, @@ -35,11 +32,7 @@ export const getColumns = ({ renderer: (rowIndex) => { if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { log } = filteredData[rowIndex] - return ( - - {log} - - ) + return getCell(log, t) }, copyText: rowIndex => filteredData[rowIndex].log, }, @@ -50,11 +43,7 @@ export const getColumns = ({ renderer: (rowIndex) => { if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { ip } = filteredData[rowIndex] - return ( - - {ip} - - ) + return getCell(ip, t) }, copyText: rowIndex => filteredData[rowIndex].ip, }, @@ -65,14 +54,7 @@ export const getColumns = ({ renderer: (rowIndex) => { if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { userAgent } = filteredData[rowIndex] - - return ( - - - {userAgent} - - - ) + return getJsonFormattedCell(userAgent) }, copyText: rowIndex => filteredData[rowIndex].userAgent, }, From 4f259257245c38aa91cb836dc4d35a23690a6781 Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Thu, 1 Aug 2024 13:42:15 +0300 Subject: [PATCH 06/16] Implement customizable no data title support for get cell state helper --- src/utils/columns.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/columns.js b/src/utils/columns.js index 0b69a0396..5e3a52ae1 100644 --- a/src/utils/columns.js +++ b/src/utils/columns.js @@ -241,9 +241,9 @@ export const getCellNoData = (title = '--') => ( ) -export const getCellState = (isLoading, isNoData) => { +export const getCellState = (isLoading, isNoData, noDataTitle) => { if (isLoading) return getCellLoader(14, 72) - if (isNoData) return getCellNoData() + if (isNoData) return getCellNoData(noDataTitle) return null } From 5d0e190889b2fae14817b07d50397621d454b5a8 Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Thu, 1 Aug 2024 13:58:23 +0300 Subject: [PATCH 07/16] Rework and improve wallets cell states handling --- src/components/Wallets/Wallets.columns.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/components/Wallets/Wallets.columns.js b/src/components/Wallets/Wallets.columns.js index c153b8875..30d5d0d90 100644 --- a/src/components/Wallets/Wallets.columns.js +++ b/src/components/Wallets/Wallets.columns.js @@ -4,8 +4,7 @@ import { Cell } from '@blueprintjs/table' import { insertIf, fixedFloat } from 'ui/utils' import { COLUMN_WIDTHS, - getCellLoader, - getCellNoData, + getCellState, getTooltipContent, } from 'utils/columns' import config from 'config' @@ -25,8 +24,7 @@ export default function getColumns(props) { className: 'align-left', width: 100, renderer: (rowIndex) => { - if (isLoading) return getCellLoader(14, 72) - if (isNoData) return getCellNoData(t('column.noResults')) + if (isLoading || isNoData) return getCellState(isLoading, isNoData, t('column.noResults')) const { currency } = filteredData[rowIndex] return ( @@ -41,8 +39,7 @@ export default function getColumns(props) { name: 'column.balance', width: COLUMN_WIDTHS.amount, renderer: (rowIndex) => { - if (isLoading) return getCellLoader(14, 72) - if (isNoData) return getCellNoData() + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { balance } = filteredData[rowIndex] const fixedBalance = fixedFloat(balance) return ( @@ -63,8 +60,7 @@ export default function getColumns(props) { name: 'column.balanceUsd', width: COLUMN_WIDTHS.balanceUsd, renderer: (rowIndex) => { - if (isLoading) return getCellLoader(14, 72) - if (isNoData) return getCellNoData() + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { balanceUsd } = filteredData[rowIndex] const fixedBalanceUsd = fixedFloat(balanceUsd) return ( From 8b2598b2a2acd4e5a1adada0fd469f6e1561a056 Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Thu, 1 Aug 2024 14:02:57 +0300 Subject: [PATCH 08/16] Optimize cells renderers config --- src/components/Wallets/Wallets.columns.js | 31 +++++------------------ 1 file changed, 6 insertions(+), 25 deletions(-) diff --git a/src/components/Wallets/Wallets.columns.js b/src/components/Wallets/Wallets.columns.js index 30d5d0d90..5c92bd04b 100644 --- a/src/components/Wallets/Wallets.columns.js +++ b/src/components/Wallets/Wallets.columns.js @@ -1,13 +1,14 @@ import React from 'react' import { Cell } from '@blueprintjs/table' -import { insertIf, fixedFloat } from 'ui/utils' import { - COLUMN_WIDTHS, + getCell, getCellState, + COLUMN_WIDTHS, getTooltipContent, } from 'utils/columns' import config from 'config' +import { insertIf, fixedFloat } from 'ui/utils' export default function getColumns(props) { const { @@ -26,11 +27,7 @@ export default function getColumns(props) { renderer: (rowIndex) => { if (isLoading || isNoData) return getCellState(isLoading, isNoData, t('column.noResults')) const { currency } = filteredData[rowIndex] - return ( - - {currency} - - ) + return getCell(currency, t) }, copyText: rowIndex => filteredData[rowIndex].currency, }, @@ -41,15 +38,7 @@ export default function getColumns(props) { renderer: (rowIndex) => { if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { balance } = filteredData[rowIndex] - const fixedBalance = fixedFloat(balance) - return ( - - {fixedBalance} - - ) + return getCell(fixedFloat(balance), t) }, isNumericValue: true, copyText: rowIndex => fixedFloat(filteredData[rowIndex].balance), @@ -62,15 +51,7 @@ export default function getColumns(props) { renderer: (rowIndex) => { if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { balanceUsd } = filteredData[rowIndex] - const fixedBalanceUsd = fixedFloat(balanceUsd) - return ( - - {fixedBalanceUsd} - - ) + return getCell(fixedFloat(balanceUsd), t) }, isNumericValue: true, copyText: rowIndex => fixedFloat(filteredData[rowIndex].balanceUsd), From 8ac1f4816f12d57289bee9ad573761af4f7a2704 Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Thu, 1 Aug 2024 14:03:39 +0300 Subject: [PATCH 09/16] Cleanup --- src/components/Wallets/Wallets.columns.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/components/Wallets/Wallets.columns.js b/src/components/Wallets/Wallets.columns.js index 5c92bd04b..c63f008ca 100644 --- a/src/components/Wallets/Wallets.columns.js +++ b/src/components/Wallets/Wallets.columns.js @@ -1,11 +1,7 @@ -import React from 'react' -import { Cell } from '@blueprintjs/table' - import { getCell, getCellState, COLUMN_WIDTHS, - getTooltipContent, } from 'utils/columns' import config from 'config' import { insertIf, fixedFloat } from 'ui/utils' From 1512cdfc6fb75975cb708e08b274aa9c6b8162ae Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Thu, 1 Aug 2024 14:06:29 +0300 Subject: [PATCH 10/16] Improve wallets cols getters --- src/components/Wallets/Wallets.columns.js | 82 +++++++++++------------ 1 file changed, 39 insertions(+), 43 deletions(-) diff --git a/src/components/Wallets/Wallets.columns.js b/src/components/Wallets/Wallets.columns.js index c63f008ca..0ed7b73ad 100644 --- a/src/components/Wallets/Wallets.columns.js +++ b/src/components/Wallets/Wallets.columns.js @@ -6,52 +6,48 @@ import { import config from 'config' import { insertIf, fixedFloat } from 'ui/utils' -export default function getColumns(props) { - const { - t, - isNoData, - isLoading, - filteredData, - } = props - - return [ - { - id: 'currency', - name: 'column.currency', - className: 'align-left', - width: 100, - renderer: (rowIndex) => { - if (isLoading || isNoData) return getCellState(isLoading, isNoData, t('column.noResults')) - const { currency } = filteredData[rowIndex] - return getCell(currency, t) - }, - copyText: rowIndex => filteredData[rowIndex].currency, +export const getColumns = ({ + t, + isNoData, + isLoading, + filteredData, +}) => [ + { + id: 'currency', + name: 'column.currency', + className: 'align-left', + width: 100, + renderer: (rowIndex) => { + if (isLoading || isNoData) return getCellState(isLoading, isNoData, t('column.noResults')) + const { currency } = filteredData[rowIndex] + return getCell(currency, t) + }, + copyText: rowIndex => filteredData[rowIndex].currency, + }, + { + id: 'balance', + name: 'column.balance', + width: COLUMN_WIDTHS.amount, + renderer: (rowIndex) => { + if (isLoading || isNoData) return getCellState(isLoading, isNoData) + const { balance } = filteredData[rowIndex] + return getCell(fixedFloat(balance), t) }, + isNumericValue: true, + copyText: rowIndex => fixedFloat(filteredData[rowIndex].balance), + }, + ...insertIf(config.showFrameworkMode, ( { - id: 'balance', - name: 'column.balance', - width: COLUMN_WIDTHS.amount, + id: 'balanceUsd', + name: 'column.balanceUsd', + width: COLUMN_WIDTHS.balanceUsd, renderer: (rowIndex) => { if (isLoading || isNoData) return getCellState(isLoading, isNoData) - const { balance } = filteredData[rowIndex] - return getCell(fixedFloat(balance), t) + const { balanceUsd } = filteredData[rowIndex] + return getCell(fixedFloat(balanceUsd), t) }, isNumericValue: true, - copyText: rowIndex => fixedFloat(filteredData[rowIndex].balance), - }, - ...insertIf(config.showFrameworkMode, ( - { - id: 'balanceUsd', - name: 'column.balanceUsd', - width: COLUMN_WIDTHS.balanceUsd, - renderer: (rowIndex) => { - if (isLoading || isNoData) return getCellState(isLoading, isNoData) - const { balanceUsd } = filteredData[rowIndex] - return getCell(fixedFloat(balanceUsd), t) - }, - isNumericValue: true, - copyText: rowIndex => fixedFloat(filteredData[rowIndex].balanceUsd), - } - )), - ] -} + copyText: rowIndex => fixedFloat(filteredData[rowIndex].balanceUsd), + } + )), +] From f4d4e8ac43fc388e1e786dc659ee8607d4fa861d Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Thu, 1 Aug 2024 14:06:59 +0300 Subject: [PATCH 11/16] Actualize helper import --- src/components/Wallets/Wallets.data.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Wallets/Wallets.data.js b/src/components/Wallets/Wallets.data.js index 199a35bad..93105b622 100644 --- a/src/components/Wallets/Wallets.data.js +++ b/src/components/Wallets/Wallets.data.js @@ -5,7 +5,7 @@ import { isEmpty } from '@bitfinex/lib-js-util-base' import DataTable from 'ui/DataTable' -import getColumns from './Wallets.columns' +import { getColumns } from './Wallets.columns' import { WALLETS_ENTRIES_PROPS } from './Wallets.props' import constants from './var' From 3c853b3e322e54983cc44641bfdcebfd4aea3240 Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Fri, 2 Aug 2024 13:19:32 +0300 Subject: [PATCH 12/16] Actualize cols getter arguments --- src/components/ConcentrationRisk/ConcentrationRisk.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/ConcentrationRisk/ConcentrationRisk.js b/src/components/ConcentrationRisk/ConcentrationRisk.js index 4a029f181..b0bd77a9c 100644 --- a/src/components/ConcentrationRisk/ConcentrationRisk.js +++ b/src/components/ConcentrationRisk/ConcentrationRisk.js @@ -138,7 +138,9 @@ class ConcentrationRisk extends PureComponent { const filteredData = entries.filter(entry => entry.balanceUsd) const { tableData, chartData } = this.parseData(filteredData) - const tableColumns = getColumns({ data: tableData, isNoData, isLoading }) + const tableColumns = getColumns({ + data: tableData, isNoData, isLoading, t, + }) let showContent if (isNoData) { From 2e265b5547f0c527fd8352697e619037ca2f8234 Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Fri, 2 Aug 2024 13:21:25 +0300 Subject: [PATCH 13/16] Rework and optimize concentration risk cells config getters --- .../ConcentrationRisk.columns.js | 44 ++++--------------- 1 file changed, 8 insertions(+), 36 deletions(-) diff --git a/src/components/ConcentrationRisk/ConcentrationRisk.columns.js b/src/components/ConcentrationRisk/ConcentrationRisk.columns.js index 37876214a..91b928e2b 100644 --- a/src/components/ConcentrationRisk/ConcentrationRisk.columns.js +++ b/src/components/ConcentrationRisk/ConcentrationRisk.columns.js @@ -1,10 +1,8 @@ -import React from 'react' -import { Cell } from '@blueprintjs/table' - import { fixedFloat } from 'ui/utils' -import { getCellState } from 'utils/columns' +import { getCell, getCellState } from 'utils/columns' export const getColumns = ({ + t, data, isNoData, isLoading, @@ -15,15 +13,9 @@ export const getColumns = ({ className: 'align-left', width: 100, renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { currency } = data[rowIndex] - return ( - - {currency} - - ) + return getCell(currency, t) }, copyText: rowIndex => data[rowIndex].currency, }, @@ -32,19 +24,9 @@ export const getColumns = ({ name: 'column.balanceUsd', width: 150, renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { balanceUsd } = data[rowIndex] - const fixedBalanceUsd = fixedFloat(balanceUsd) - return ( - - {fixedBalanceUsd} - - ) + return getCell(fixedFloat(balanceUsd), t) }, copyText: rowIndex => fixedFloat(data[rowIndex].balanceUsd), }, @@ -53,19 +35,9 @@ export const getColumns = ({ name: 'column.percent', width: 150, renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { percent } = data[rowIndex] - const fixedPercent = fixedFloat(percent) - return ( - - {fixedPercent} - - ) + return getCell(fixedFloat(percent), t) }, copyText: rowIndex => fixedFloat(data[rowIndex].percent), }, From e981c72615bd98cd28b2360625ad5b4e69107159 Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Fri, 2 Aug 2024 13:26:46 +0300 Subject: [PATCH 14/16] Optimize wavgs cell states handling --- .../WeightedAverages.columns.js | 40 +++++-------------- 1 file changed, 10 insertions(+), 30 deletions(-) diff --git a/src/components/WeightedAverages/WeightedAverages.columns.js b/src/components/WeightedAverages/WeightedAverages.columns.js index f83bb61d6..133015c0a 100644 --- a/src/components/WeightedAverages/WeightedAverages.columns.js +++ b/src/components/WeightedAverages/WeightedAverages.columns.js @@ -18,9 +18,7 @@ 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 ( @@ -35,9 +33,7 @@ export const getColumns = ({ name: 'column.buyingWeightedPrice', width: getColumnWidth('buyingWeightedPrice', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { buyingWeightedPrice } = filteredData[rowIndex] const fixedPrice = fixedFloat(buyingWeightedPrice) return ( @@ -57,9 +53,7 @@ export const getColumns = ({ name: 'column.buyingAmount', width: getColumnWidth('buyingAmount', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { buyingAmount } = filteredData[rowIndex] const tooltip = fixedFloat(buyingAmount) return ( @@ -79,9 +73,7 @@ export const getColumns = ({ name: 'column.cost', width: getColumnWidth('cost', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { cost } = filteredData[rowIndex] const tooltip = fixedFloat(cost) return ( @@ -101,9 +93,7 @@ export const getColumns = ({ name: 'column.sellingWeightedPrice', width: getColumnWidth('sellingWeightedPrice', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { sellingWeightedPrice } = filteredData[rowIndex] const fixedPrice = fixedFloat(sellingWeightedPrice) return ( @@ -123,9 +113,7 @@ export const getColumns = ({ name: 'column.sellingAmount', width: getColumnWidth('sellingAmount', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { sellingAmount } = filteredData[rowIndex] const tooltip = fixedFloat(sellingAmount) return ( @@ -145,9 +133,7 @@ export const getColumns = ({ name: 'column.sale', width: getColumnWidth('sale', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { sale } = filteredData[rowIndex] const tooltip = fixedFloat(sale) return ( @@ -167,9 +153,7 @@ export const getColumns = ({ name: 'column.cumulativeAmount', width: getColumnWidth('cumulativeAmount', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { cumulativeAmount } = filteredData[rowIndex] const tooltip = fixedFloat(cumulativeAmount) return ( @@ -189,9 +173,7 @@ export const getColumns = ({ name: 'column.firstTrade', width: getColumnWidth('firstTradeMts', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const timestamp = getFullTime(filteredData[rowIndex].firstTradeMts) return ( @@ -206,9 +188,7 @@ export const getColumns = ({ name: 'column.lastTrade', width: getColumnWidth('lastTradeMts', columnsWidth), renderer: (rowIndex) => { - if (isLoading || isNoData) { - return getCellState(isLoading, isNoData) - } + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const timestamp = getFullTime(filteredData[rowIndex].lastTradeMts) return ( From bf753f4e02a94bb9ece528b3d61001af2a2ccbb5 Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Fri, 2 Aug 2024 13:35:42 +0300 Subject: [PATCH 15/16] Enhance weighted averages cell renderers --- .../WeightedAverages.columns.js | 90 +++---------------- 1 file changed, 11 insertions(+), 79 deletions(-) diff --git a/src/components/WeightedAverages/WeightedAverages.columns.js b/src/components/WeightedAverages/WeightedAverages.columns.js index 133015c0a..b8b420164 100644 --- a/src/components/WeightedAverages/WeightedAverages.columns.js +++ b/src/components/WeightedAverages/WeightedAverages.columns.js @@ -2,7 +2,7 @@ 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, getTooltipContent } from 'utils/columns' export const getColumns = ({ t, @@ -20,11 +20,7 @@ export const getColumns = ({ renderer: (rowIndex) => { if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { pair } = filteredData[rowIndex] - return ( - - {pair} - - ) + return getCell(pair, t) }, copyText: rowIndex => filteredData[rowIndex].pair, }, @@ -35,15 +31,7 @@ export const getColumns = ({ renderer: (rowIndex) => { if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { buyingWeightedPrice } = filteredData[rowIndex] - const fixedPrice = fixedFloat(buyingWeightedPrice) - return ( - - {fixedPrice} - - ) + return getCell(fixedFloat(buyingWeightedPrice), t) }, isNumericValue: true, copyText: rowIndex => fixedFloat(filteredData[rowIndex].buyingWeightedPrice), @@ -55,15 +43,7 @@ export const getColumns = ({ renderer: (rowIndex) => { if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { buyingAmount } = filteredData[rowIndex] - const tooltip = fixedFloat(buyingAmount) - return ( - - {formatAmount(buyingAmount)} - - ) + return getCell(formatAmount(buyingAmount), t, fixedFloat(buyingAmount)) }, isNumericValue: true, copyText: rowIndex => fixedFloat(filteredData[rowIndex].buyingAmount), @@ -75,15 +55,7 @@ export const getColumns = ({ renderer: (rowIndex) => { if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { cost } = filteredData[rowIndex] - const tooltip = fixedFloat(cost) - return ( - - {formatAmount(cost)} - - ) + return getCell(formatAmount(cost), t, fixedFloat(cost)) }, isNumericValue: true, copyText: rowIndex => fixedFloat(filteredData[rowIndex].cost), @@ -95,15 +67,7 @@ export const getColumns = ({ renderer: (rowIndex) => { if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { sellingWeightedPrice } = filteredData[rowIndex] - const fixedPrice = fixedFloat(sellingWeightedPrice) - return ( - - {fixedPrice} - - ) + return getCell(fixedFloat(sellingWeightedPrice), t) }, isNumericValue: true, copyText: rowIndex => fixedFloat(filteredData[rowIndex].sellingWeightedPrice), @@ -115,15 +79,7 @@ export const getColumns = ({ renderer: (rowIndex) => { if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { sellingAmount } = filteredData[rowIndex] - const tooltip = fixedFloat(sellingAmount) - return ( - - {formatAmount(sellingAmount)} - - ) + return getCell(formatAmount(sellingAmount), t, fixedFloat(sellingAmount)) }, isNumericValue: true, copyText: rowIndex => fixedFloat(filteredData[rowIndex].sellingAmount), @@ -135,15 +91,7 @@ export const getColumns = ({ renderer: (rowIndex) => { if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { sale } = filteredData[rowIndex] - const tooltip = fixedFloat(sale) - return ( - - {formatAmount(sale)} - - ) + return getCell(formatAmount(sale), t, fixedFloat(sale)) }, isNumericValue: true, copyText: rowIndex => fixedFloat(filteredData[rowIndex].sale), @@ -155,15 +103,7 @@ export const getColumns = ({ renderer: (rowIndex) => { if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { cumulativeAmount } = filteredData[rowIndex] - const tooltip = fixedFloat(cumulativeAmount) - return ( - - {formatAmount(cumulativeAmount)} - - ) + return getCell(formatAmount(cumulativeAmount), t, fixedFloat(cumulativeAmount)) }, isNumericValue: true, copyText: rowIndex => fixedFloat(filteredData[rowIndex].cumulativeAmount), @@ -175,11 +115,7 @@ export const getColumns = ({ renderer: (rowIndex) => { if (isLoading || isNoData) return getCellState(isLoading, isNoData) const timestamp = getFullTime(filteredData[rowIndex].firstTradeMts) - return ( - - {timestamp} - - ) + return getCell(timestamp, t) }, copyText: rowIndex => getFullTime(filteredData[rowIndex].firstTradeMts), }, @@ -190,11 +126,7 @@ export const getColumns = ({ renderer: (rowIndex) => { if (isLoading || isNoData) return getCellState(isLoading, isNoData) const timestamp = getFullTime(filteredData[rowIndex].lastTradeMts) - return ( - - {timestamp} - - ) + return getCell(timestamp, t) }, copyText: rowIndex => getFullTime(filteredData[rowIndex].lastTradeMts), }, From e265b903b7bf4981c315f978c1e78045b7e773b3 Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Fri, 2 Aug 2024 13:36:12 +0300 Subject: [PATCH 16/16] Cleanup --- src/components/WeightedAverages/WeightedAverages.columns.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/components/WeightedAverages/WeightedAverages.columns.js b/src/components/WeightedAverages/WeightedAverages.columns.js index b8b420164..fe0aa6ab1 100644 --- a/src/components/WeightedAverages/WeightedAverages.columns.js +++ b/src/components/WeightedAverages/WeightedAverages.columns.js @@ -1,8 +1,5 @@ -import React from 'react' -import { Cell } from '@blueprintjs/table' - import { formatAmount, fixedFloat } from 'ui/utils' -import { getCell, getCellState, getColumnWidth, getTooltipContent } from 'utils/columns' +import { getCell, getCellState, getColumnWidth } from 'utils/columns' export const getColumns = ({ t,