From a8bba655592e844b9634f7eac84d25e4ebed7f48 Mon Sep 17 00:00:00 2001 From: Kristof Csillag Date: Fri, 10 Jan 2025 13:00:50 +0100 Subject: [PATCH] Extend transaction method filtering to consensus and validators --- .changelog/1679.trivial.md | 2 +- .../ConsensusTransactionMethod/index.tsx | 8 ++- .../ConsensusTransactionTypeFilter.tsx | 41 ++++++++++++++++ .../Transactions/ConsensusTransactions.tsx | 3 ++ .../ConsensusAccountEventsCard.tsx | 4 +- .../ConsensusAccountTransactionsCard.tsx | 49 ++++++++++--------- .../ConsensusAccountDetailsPage/hooks.tsx | 3 ++ .../ConsensusAccountDetailsPage/index.tsx | 7 ++- .../ConsensusBlockTransactionsCard.tsx | 28 +++++++++-- .../LatestConsensusTransactions.tsx | 42 +++++++++++++--- .../pages/ConsensusDashboardPage/index.tsx | 5 +- .../pages/ConsensusTransactionsPage/index.tsx | 23 ++++++++- src/app/pages/ValidatorDetailsPage/hooks.ts | 3 ++ src/app/pages/ValidatorDetailsPage/index.tsx | 8 ++- src/stories/Transactions.stories.tsx | 1 + 15 files changed, 185 insertions(+), 42 deletions(-) create mode 100644 src/app/components/Transactions/ConsensusTransactionTypeFilter.tsx diff --git a/.changelog/1679.trivial.md b/.changelog/1679.trivial.md index c79d4d9db..04b3a718e 100644 --- a/.changelog/1679.trivial.md +++ b/.changelog/1679.trivial.md @@ -1 +1 @@ -Add support for filtering latest TX list for method type +Add support for filtering transactions by method type diff --git a/src/app/components/ConsensusTransactionMethod/index.tsx b/src/app/components/ConsensusTransactionMethod/index.tsx index bdb1adee8..3dddb014a 100644 --- a/src/app/components/ConsensusTransactionMethod/index.tsx +++ b/src/app/components/ConsensusTransactionMethod/index.tsx @@ -16,7 +16,7 @@ import PriceChangeIcon from '@mui/icons-material/PriceChange' import QuestionMarkIcon from '@mui/icons-material/QuestionMark' import Tooltip from '@mui/material/Tooltip' import { tooltipDelay } from '../../../styles/theme' -import { ConsensusTxMethod } from '../../../oasis-nexus/api' +import { ConsensusTxMethod, GetConsensusTransactionsParams } from '../../../oasis-nexus/api' import { COLORS } from '../../../styles/theme/colors' import { SelectOptionBase } from '../Select' import { exhaustedTypeWarning } from '../../../types/errors' @@ -358,3 +358,9 @@ export const ConsensusTransactionMethod: FC = ( return <>{getConsensusTransactionMethod(t, method, truncate)} } + +export type WantedConsensusTxMethod = ConsensusTxMethod | 'all' + +export const getConsensusTransactionMethodFilteringParam = ( + method: WantedConsensusTxMethod, +): Partial => (method === 'all' ? {} : { method }) diff --git a/src/app/components/Transactions/ConsensusTransactionTypeFilter.tsx b/src/app/components/Transactions/ConsensusTransactionTypeFilter.tsx new file mode 100644 index 000000000..22534040f --- /dev/null +++ b/src/app/components/Transactions/ConsensusTransactionTypeFilter.tsx @@ -0,0 +1,41 @@ +import { FC } from 'react' +import { getConsensusTxMethodOptions, WantedConsensusTxMethod } from '../ConsensusTransactionMethod' +import { useTranslation } from 'react-i18next' +import { Select } from '../Select' +import Typography from '@mui/material/Typography' + +const FilterLabel: FC = () => { + const { t } = useTranslation() + return ( + + {t('transactions.filterByType')} + + ) +} + +export const ConsensusTransactionTypeFilter: FC<{ + value: WantedConsensusTxMethod + setValue: (value: WantedConsensusTxMethod) => void + expand?: boolean +}> = ({ value, setValue, expand }) => { + const { t } = useTranslation() + return ( +