From f017eb0a3ae32c6388dc1e30bf1bbf74e2e0e532 Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Wed, 14 Aug 2024 14:33:06 +0300 Subject: [PATCH 1/6] Actualize snapshots sections exporting --- src/components/Snapshots/PositionsSnapshot/index.js | 4 +--- src/components/Snapshots/TickersSnapshot/index.js | 4 +--- src/components/Snapshots/WalletsSnapshot/index.js | 4 +--- src/components/Snapshots/index.js | 4 +--- 4 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/components/Snapshots/PositionsSnapshot/index.js b/src/components/Snapshots/PositionsSnapshot/index.js index dd5cc5ffe..c6bbe0ef4 100644 --- a/src/components/Snapshots/PositionsSnapshot/index.js +++ b/src/components/Snapshots/PositionsSnapshot/index.js @@ -1,3 +1 @@ -import PositionsSnapshot from './PositionsSnapshot.container' - -export default PositionsSnapshot +export { default } from './PositionsSnapshot.container' diff --git a/src/components/Snapshots/TickersSnapshot/index.js b/src/components/Snapshots/TickersSnapshot/index.js index 8b49fed15..c73fe57a8 100644 --- a/src/components/Snapshots/TickersSnapshot/index.js +++ b/src/components/Snapshots/TickersSnapshot/index.js @@ -1,3 +1 @@ -import TickersSnapshot from './TickersSnapshot' - -export default TickersSnapshot +export { default } from './TickersSnapshot' diff --git a/src/components/Snapshots/WalletsSnapshot/index.js b/src/components/Snapshots/WalletsSnapshot/index.js index 857b75711..ae45d3458 100644 --- a/src/components/Snapshots/WalletsSnapshot/index.js +++ b/src/components/Snapshots/WalletsSnapshot/index.js @@ -1,3 +1 @@ -import WalletsSnapshot from './WalletsSnapshot' - -export default WalletsSnapshot +export { default } from './WalletsSnapshot' diff --git a/src/components/Snapshots/index.js b/src/components/Snapshots/index.js index 71b91114b..69f465d95 100644 --- a/src/components/Snapshots/index.js +++ b/src/components/Snapshots/index.js @@ -1,3 +1 @@ -import Snapshots from './Snapshots.container' - -export default Snapshots +export { default } from './Snapshots.container' From 2ee790244763dda129feb6be9d066dd2ba39d656 Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Wed, 14 Aug 2024 14:35:18 +0300 Subject: [PATCH 2/6] Redundant code cleanup --- .../WalletsSnapshot/Wallets.columns.js | 66 ------------------- 1 file changed, 66 deletions(-) delete mode 100644 src/components/Snapshots/WalletsSnapshot/Wallets.columns.js diff --git a/src/components/Snapshots/WalletsSnapshot/Wallets.columns.js b/src/components/Snapshots/WalletsSnapshot/Wallets.columns.js deleted file mode 100644 index 2d6dc432f..000000000 --- a/src/components/Snapshots/WalletsSnapshot/Wallets.columns.js +++ /dev/null @@ -1,66 +0,0 @@ -import React from 'react' -import { Cell } from '@blueprintjs/table' - -import { fixedFloat } from 'ui/utils' -import { getTooltipContent } from 'utils/columns' - -export default function getColumns(props) { - const { filteredData, t } = props - - return [ - { - id: 'currency', - name: 'column.currency', - className: 'align-left', - width: 100, - renderer: (rowIndex) => { - const { currency } = filteredData[rowIndex] - return ( - - {currency} - - ) - }, - copyText: rowIndex => filteredData[rowIndex].currency, - }, - { - id: 'balance', - name: 'column.balance', - width: 200, - renderer: (rowIndex) => { - const { balance } = filteredData[rowIndex] - const fixedBalance = fixedFloat(balance) - return ( - - {fixedBalance} - - ) - }, - copyText: rowIndex => filteredData[rowIndex].balance, - }, - { - id: 'balanceUsd', - name: 'column.balanceUsd', - width: 200, - renderer: (rowIndex) => { - const { balanceUsd } = filteredData[rowIndex] - const fixedBalanceUsd = fixedFloat(balanceUsd) - return ( - - {fixedBalanceUsd} - - ) - }, - copyText: (rowIndex) => { - const { balanceUsd } = filteredData[rowIndex] - return `${fixedFloat(balanceUsd)} ${t('column.usd')}` - }, - }, - ] -} From dc80cbd80d652d66b5553336b44707692e99dc5c Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Wed, 14 Aug 2024 14:42:53 +0300 Subject: [PATCH 3/6] Rework and optimize framework pos states handling --- src/utils/columns.js | 39 +++++++++++++-------------------------- 1 file changed, 13 insertions(+), 26 deletions(-) diff --git a/src/utils/columns.js b/src/utils/columns.js index 226728481..1119b9212 100644 --- a/src/utils/columns.js +++ b/src/utils/columns.js @@ -338,8 +338,7 @@ export const getFrameworkPositionsColumns = ({ 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 { id } = filteredData[rowIndex] return ( @@ -355,8 +354,7 @@ export const getFrameworkPositionsColumns = ({ className: 'align-left', width: COLUMN_WIDTHS.pair, renderer: (rowIndex) => { - if (isLoading) return getCellLoader(14, 72) - if (isNoData) return getCellNoData() + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { pair } = filteredData[rowIndex] return ( @@ -371,8 +369,7 @@ export const getFrameworkPositionsColumns = ({ name: 'column.amount', width: COLUMN_WIDTHS.amount, renderer: (rowIndex) => { - if (isLoading) return getCellLoader(14, 72) - if (isNoData) return getCellNoData() + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { amount } = filteredData[rowIndex] return ( { - if (isLoading) return getCellLoader(14, 72) - if (isNoData) return getCellNoData() + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { basePrice } = filteredData[rowIndex] const fixedPrice = fixedFloat(basePrice) return ( @@ -410,8 +406,7 @@ export const getFrameworkPositionsColumns = ({ name: 'column.actual-price', width: COLUMN_WIDTHS.actualPrice, renderer: (rowIndex) => { - if (isLoading) return getCellLoader(14, 72) - if (isNoData) return getCellNoData() + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { actualPrice } = filteredData[rowIndex] const fixedPrice = fixedFloat(actualPrice) return ( @@ -430,8 +425,7 @@ export const getFrameworkPositionsColumns = ({ name: 'column.liq-price', width: COLUMN_WIDTHS.priceLiq, renderer: (rowIndex) => { - if (isLoading) return getCellLoader(14, 72) - if (isNoData) return getCellNoData() + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { liquidationPrice } = filteredData[rowIndex] const fixedPrice = fixedFloat(liquidationPrice) return ( @@ -450,8 +444,7 @@ export const getFrameworkPositionsColumns = ({ name: 'column.pl', width: 100, renderer: (rowIndex) => { - if (isLoading) return getCellLoader(14, 72) - if (isNoData) return getCellNoData() + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { pl } = filteredData[rowIndex] return ( { - if (isLoading) return getCellLoader(14, 72) - if (isNoData) return getCellNoData() + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { plUsd } = filteredData[rowIndex] return ( { - if (isLoading) return getCellLoader(14, 72) - if (isNoData) return getCellNoData() + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { plPerc } = filteredData[rowIndex] return ( { - if (isLoading) return getCellLoader(14, 72) - if (isNoData) return getCellNoData() + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { marginFunding } = filteredData[rowIndex] const fixedSwap = fixedFloat(marginFunding) return ( @@ -528,8 +518,7 @@ export const getFrameworkPositionsColumns = ({ className: 'align-left', width: 120, renderer: (rowIndex) => { - if (isLoading) return getCellLoader(14, 72) - if (isNoData) return getCellNoData() + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const swapType = showType(filteredData[rowIndex].marginFundingType) return ( @@ -545,8 +534,7 @@ export const getFrameworkPositionsColumns = ({ className: 'align-left', width: 100, renderer: (rowIndex) => { - if (isLoading) return getCellLoader(14, 72) - if (isNoData) return getCellNoData() + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { status } = filteredData[rowIndex] return ( @@ -562,8 +550,7 @@ export const getFrameworkPositionsColumns = ({ nameStr: `${t('column.updated')} (${timeOffset})`, width: COLUMN_WIDTHS.mtsUpdate, renderer: (rowIndex) => { - if (isLoading) return getCellLoader(14, 72) - if (isNoData) return getCellNoData() + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const timestamp = getFullTime(filteredData[rowIndex].mtsUpdate) return ( From 5749db6e098a9baeb75a1395faa8a771586d14b8 Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Wed, 14 Aug 2024 14:53:19 +0300 Subject: [PATCH 4/6] Improve snap positions cells rendering --- src/utils/columns.js | 106 ++++++------------------------------------- 1 file changed, 13 insertions(+), 93 deletions(-) diff --git a/src/utils/columns.js b/src/utils/columns.js index 1119b9212..837f82ee4 100644 --- a/src/utils/columns.js +++ b/src/utils/columns.js @@ -340,11 +340,7 @@ export const getFrameworkPositionsColumns = ({ renderer: (rowIndex) => { if (isLoading || isNoData) return getCellState(isLoading, isNoData, t('column.noResults')) const { id } = filteredData[rowIndex] - return ( - - {id} - - ) + return getCell(id, t) }, copyText: rowIndex => filteredData[rowIndex].id, }, @@ -356,11 +352,7 @@ export const getFrameworkPositionsColumns = ({ renderer: (rowIndex) => { if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { pair } = filteredData[rowIndex] - return ( - - {pair} - - ) + return getCell(pair, t) }, copyText: rowIndex => filteredData[rowIndex].pair, }, @@ -371,14 +363,7 @@ export const getFrameworkPositionsColumns = ({ renderer: (rowIndex) => { if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { amount } = filteredData[rowIndex] - return ( - - {formatAmount(amount)} - - ) + return getCell(formatAmount(amount), t, fixedFloat(amount)) }, copyText: rowIndex => filteredData[rowIndex].amount, }, @@ -389,15 +374,7 @@ export const getFrameworkPositionsColumns = ({ renderer: (rowIndex) => { if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { basePrice } = filteredData[rowIndex] - const fixedPrice = fixedFloat(basePrice) - return ( - - {fixedPrice} - - ) + return getCell(fixedFloat(basePrice), t) }, copyText: rowIndex => filteredData[rowIndex].basePrice, }, @@ -408,15 +385,7 @@ export const getFrameworkPositionsColumns = ({ renderer: (rowIndex) => { if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { actualPrice } = filteredData[rowIndex] - const fixedPrice = fixedFloat(actualPrice) - return ( - - {fixedPrice} - - ) + return getCell(fixedFloat(actualPrice), t) }, copyText: rowIndex => filteredData[rowIndex].actualPrice, }, @@ -427,15 +396,7 @@ export const getFrameworkPositionsColumns = ({ renderer: (rowIndex) => { if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { liquidationPrice } = filteredData[rowIndex] - const fixedPrice = fixedFloat(liquidationPrice) - return ( - - {fixedPrice} - - ) + return getCell(fixedFloat(liquidationPrice), t) }, copyText: rowIndex => filteredData[rowIndex].liquidationPrice, }, @@ -446,14 +407,7 @@ export const getFrameworkPositionsColumns = ({ renderer: (rowIndex) => { if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { pl } = filteredData[rowIndex] - return ( - - {formatAmount(pl)} - - ) + return getCell(formatAmount(pl), t, fixedFloat(pl)) }, copyText: rowIndex => filteredData[rowIndex].pl, }, @@ -464,14 +418,7 @@ export const getFrameworkPositionsColumns = ({ renderer: (rowIndex) => { if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { plUsd } = filteredData[rowIndex] - return ( - - {formatAmount(plUsd)} - - ) + return getCell(formatAmount(plUsd), t, fixedFloat(plUsd)) }, copyText: rowIndex => filteredData[rowIndex].plUsd, }, @@ -482,14 +429,7 @@ export const getFrameworkPositionsColumns = ({ renderer: (rowIndex) => { if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { plPerc } = filteredData[rowIndex] - return ( - - {formatAmount(plPerc)} - - ) + return getCell(formatAmount(plPerc), t, fixedFloat(plPerc)) }, copyText: rowIndex => filteredData[rowIndex].plPerc, }, @@ -500,15 +440,7 @@ export const getFrameworkPositionsColumns = ({ renderer: (rowIndex) => { if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { marginFunding } = filteredData[rowIndex] - const fixedSwap = fixedFloat(marginFunding) - return ( - - {fixedSwap} - - ) + return getCell(fixedFloat(marginFunding), t) }, copyText: rowIndex => filteredData[rowIndex].marginFunding, }, @@ -520,11 +452,7 @@ export const getFrameworkPositionsColumns = ({ renderer: (rowIndex) => { if (isLoading || isNoData) return getCellState(isLoading, isNoData) const swapType = showType(filteredData[rowIndex].marginFundingType) - return ( - - {swapType} - - ) + return getCell(swapType, t) }, copyText: rowIndex => showType(filteredData[rowIndex].marginFundingType), }, @@ -536,11 +464,7 @@ export const getFrameworkPositionsColumns = ({ renderer: (rowIndex) => { if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { status } = filteredData[rowIndex] - return ( - - {status} - - ) + return getCell(status, t) }, copyText: rowIndex => filteredData[rowIndex].status, }, @@ -552,11 +476,7 @@ export const getFrameworkPositionsColumns = ({ renderer: (rowIndex) => { 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), }, From 27969c1d2ce38a285c30436251ff762081aaadbb Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Wed, 14 Aug 2024 14:58:30 +0300 Subject: [PATCH 5/6] Rework and optimize position tickers cells config getters --- src/utils/columns.js | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/src/utils/columns.js b/src/utils/columns.js index 837f82ee4..b9fef8d00 100644 --- a/src/utils/columns.js +++ b/src/utils/columns.js @@ -495,14 +495,9 @@ export const getPositionsTickersColumns = ({ className: 'align-left', width: COLUMN_WIDTHS.pair, 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 { pair } = filteredData[rowIndex] - return ( - - {pair} - - ) + return getCell(pair, t) }, copyText: rowIndex => filteredData[rowIndex].pair, }, @@ -511,17 +506,9 @@ export const getPositionsTickersColumns = ({ name: 'column.amount', width: COLUMN_WIDTHS.amount, renderer: (rowIndex) => { - if (isLoading) return getCellLoader(14, 72) - if (isNoData) return getCellNoData() + 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 => filteredData[rowIndex].amount, From 16d326023d3b65f5d84fa64c69fc50c6a76c6ab8 Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Wed, 14 Aug 2024 15:03:10 +0300 Subject: [PATCH 6/6] Improve wallets tickers cols generation flow --- src/utils/columns.js | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-) diff --git a/src/utils/columns.js b/src/utils/columns.js index b9fef8d00..d841e623b 100644 --- a/src/utils/columns.js +++ b/src/utils/columns.js @@ -527,15 +527,10 @@ export const getWalletsTickersColumns = ({ className: 'align-left', width: 80, 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 { walletType } = filteredData[rowIndex] const walletTypeText = t(`wallets.header.${walletType}`) - return ( - - {walletTypeText} - - ) + return getCell(walletTypeText, t) }, copyText: (rowIndex) => { const { walletType } = filteredData[rowIndex] @@ -548,14 +543,9 @@ export const getWalletsTickersColumns = ({ className: 'align-left', width: 100, renderer: (rowIndex) => { - if (isLoading) return getCellLoader(14, 72) - if (isNoData) return getCellNoData() + if (isLoading || isNoData) return getCellState(isLoading, isNoData) const { pair } = filteredData[rowIndex] - return ( - - {pair} - - ) + return getCell(pair, t) }, copyText: rowIndex => filteredData[rowIndex].pair, }, @@ -564,17 +554,9 @@ export const getWalletsTickersColumns = ({ name: 'column.amount', width: 120, renderer: (rowIndex) => { - if (isLoading) return getCellLoader(14, 72) - if (isNoData) return getCellNoData() + 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 => filteredData[rowIndex].amount,