Skip to content

Commit

Permalink
Merge pull request #1072 from autonomys/fix/fix-files-consensus-link-…
Browse files Browse the repository at this point in the history
…and-filters

Fix files consensus links (block&extrinsics) and fix filters
  • Loading branch information
marc-aurele-besner authored Jan 20, 2025
2 parents 730a31e + 568e6e5 commit a193e7b
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 90 deletions.
68 changes: 23 additions & 45 deletions explorer/src/components/Storage/Files/FileList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { FC, useCallback, useEffect, useMemo, useState } from 'react'
import { useInView } from 'react-intersection-observer'
import { hasValue, isLoading, useQueryStates } from 'states/query'
import { useTableStates } from 'states/tables'
import { Cell, ExtrinsicsFilters, TableSettingsTabs } from 'types/table'
import { Cell, FilesFilters, TableSettingsTabs } from 'types/table'
import { getTableColumns } from 'utils/table'
import { utcToLocalRelativeTime } from 'utils/time'
import { NotFound } from '../../layout/NotFound'
Expand All @@ -35,7 +35,7 @@ export const FileList: FC = () => {
const availableColumns = useTableStates((state) => state[TABLE].columns)
const selectedColumns = useTableStates((state) => state[TABLE].selectedColumns)
const filtersOptions = useTableStates((state) => state[TABLE].filtersOptions)
const filters = useTableStates((state) => state[TABLE].filters) as ExtrinsicsFilters
const filters = useTableStates((state) => state[TABLE].filters) as FilesFilters
const showTableSettings = useTableStates((state) => state[TABLE].showTableSettings)
const setColumns = useTableStates((state) => state.setColumns)
const setFilters = useTableStates((state) => state.setFilters)
Expand Down Expand Up @@ -70,29 +70,29 @@ export const FileList: FC = () => {
availableColumns
.filter((column) => column.searchable)
.forEach((column) => {
const searchKey = `search-${column.name}` as keyof ExtrinsicsFilters
const searchKey = `search-${column.name}` as keyof FilesFilters
const searchValue = filters[searchKey]
if (searchValue) {
conditions[column.name] = { _ilike: `%${searchValue}%` }
}
})

// Block Height
// if (filters.blockHeightMin || filters.blockHeightMax) {
// conditions['block_height'] = {}
// if (filters.blockHeightMin) conditions.block_height._gte = filters.blockHeightMin
// if (filters.blockHeightMax) conditions.block_height._lte = filters.blockHeightMax
// }
// CID
if (filters.cid) {
conditions['cid'] = { _ilike: `%${filters.cid}%` }
}

// // Section
// if (filters.section) {
// conditions['section'] = { _ilike: `%${filters.section}%` }
// }
// Name
if (filters.name) {
conditions['name'] = { _ilike: `%${filters.name}%` }
}

// // Module
// if (filters.module) {
// conditions['module'] = { _ilike: `%${filters.module}%` }
// }
// Block Height
if (filters.blockHeightMin || filters.blockHeightMax) {
conditions['block_height'] = {}
if (filters.blockHeightMin) conditions.block_height._gte = filters.blockHeightMin
if (filters.blockHeightMax) conditions.block_height._lte = filters.blockHeightMax
}

return conditions
}, [filters, availableColumns])
Expand Down Expand Up @@ -147,19 +147,15 @@ export const FileList: FC = () => {
</Link>
),
name: ({ row }: Cell<Row>) => `${row.original.name ?? ''}`,
// hash: ({ row }: Cell<Row>) => (
// <CopyButton value={row.original.hash} message='Hash copied'>
// {shortString(row.original.hash)}
// </CopyButton>
// ),
// section: ({ row }: Cell<Row>) => capitalizeFirstLetter(row.original.section),
// module: ({ row }: Cell<Row>) => capitalizeFirstLetter(row.original.module),
// name: ({ row }: Cell<Row>) => row.original.name.toUpperCase(),
blockHeight: ({ row }: Cell<Row>) => (
<Link
key={`${row.index}-file-block_height`}
className='hover:text-primaryAccent'
href={INTERNAL_ROUTES.blocks.id.page(network, section, row.original.cid?.blockHeight)}
href={INTERNAL_ROUTES.blocks.id.page(
network,
Routes.consensus,
row.original.cid?.blockHeight,
)}
>
<div>{row.original.cid?.blockHeight}</div>
</Link>
Expand All @@ -170,32 +166,14 @@ export const FileList: FC = () => {
className='hover:text-primaryAccent'
href={INTERNAL_ROUTES.extrinsics.id.page(
network,
section,
Routes.consensus,
row.original.cid?.extrinsicId ?? '',
)}
>
<div>{row.original.cid?.extrinsicId}</div>
</Link>
),
timestamp: ({ row }: Cell<Row>) => utcToLocalRelativeTime(row.original.cid?.timestamp),
// indexInBlock: ({ row }: Cell<Row>) => row.original.indexInBlock.toString(),
// success: ({ row }: Cell<Row>) => <StatusIcon status={row.original.success} />,
// nonce: ({ row }: Cell<Row>) => row.original.nonce,
// signer: ({ row }: Cell<Row>) => (
// <AccountIconWithLink
// address={row.original.signer}
// network={network}
// section={Routes.consensus}
// forceShortString={true}
// />
// ),
// signature: ({ row }: Cell<Row>) => (
// <CopyButton value={row.original.signature} message='Signature copied'>
// {shortString(row.original.signature)}
// </CopyButton>
// ),
// tip: ({ row }: Cell<Row>) => row.original.tip,
// fee: ({ row }: Cell<Row>) => row.original.fee,
}),
[network, section, selectedColumns],
)
Expand Down
68 changes: 23 additions & 45 deletions explorer/src/components/Storage/Folders/FolderList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { FC, useCallback, useEffect, useMemo, useState } from 'react'
import { useInView } from 'react-intersection-observer'
import { hasValue, isLoading, useQueryStates } from 'states/query'
import { useTableStates } from 'states/tables'
import { Cell, ExtrinsicsFilters, TableSettingsTabs } from 'types/table'
import { Cell, FilesFilters, TableSettingsTabs } from 'types/table'
import { getTableColumns } from 'utils/table'
import { utcToLocalRelativeTime } from 'utils/time'
import { NotFound } from '../../layout/NotFound'
Expand All @@ -35,7 +35,7 @@ export const FolderList: FC = () => {
const availableColumns = useTableStates((state) => state[TABLE].columns)
const selectedColumns = useTableStates((state) => state[TABLE].selectedColumns)
const filtersOptions = useTableStates((state) => state[TABLE].filtersOptions)
const filters = useTableStates((state) => state[TABLE].filters) as ExtrinsicsFilters
const filters = useTableStates((state) => state[TABLE].filters) as FilesFilters
const showTableSettings = useTableStates((state) => state[TABLE].showTableSettings)
const setColumns = useTableStates((state) => state.setColumns)
const setFilters = useTableStates((state) => state.setFilters)
Expand Down Expand Up @@ -70,29 +70,29 @@ export const FolderList: FC = () => {
availableColumns
.filter((column) => column.searchable)
.forEach((column) => {
const searchKey = `search-${column.name}` as keyof ExtrinsicsFilters
const searchKey = `search-${column.name}` as keyof FilesFilters
const searchValue = filters[searchKey]
if (searchValue) {
conditions[column.name] = { _ilike: `%${searchValue}%` }
}
})

// Block Height
// if (filters.blockHeightMin || filters.blockHeightMax) {
// conditions['block_height'] = {}
// if (filters.blockHeightMin) conditions.block_height._gte = filters.blockHeightMin
// if (filters.blockHeightMax) conditions.block_height._lte = filters.blockHeightMax
// }
// CID
if (filters.cid) {
conditions['cid'] = { _ilike: `%${filters.cid}%` }
}

// // Section
// if (filters.section) {
// conditions['section'] = { _ilike: `%${filters.section}%` }
// }
// Name
if (filters.name) {
conditions['name'] = { _ilike: `%${filters.name}%` }
}

// // Module
// if (filters.module) {
// conditions['module'] = { _ilike: `%${filters.module}%` }
// }
// Block Height
if (filters.blockHeightMin || filters.blockHeightMax) {
conditions['block_height'] = {}
if (filters.blockHeightMin) conditions.block_height._gte = filters.blockHeightMin
if (filters.blockHeightMax) conditions.block_height._lte = filters.blockHeightMax
}

return conditions
}, [filters, availableColumns])
Expand Down Expand Up @@ -149,19 +149,15 @@ export const FolderList: FC = () => {
</Link>
),
name: ({ row }: Cell<Row>) => `${row.original.name ?? ''}`,
// hash: ({ row }: Cell<Row>) => (
// <CopyButton value={row.original.hash} message='Hash copied'>
// {shortString(row.original.hash)}
// </CopyButton>
// ),
// section: ({ row }: Cell<Row>) => capitalizeFirstLetter(row.original.section),
// module: ({ row }: Cell<Row>) => capitalizeFirstLetter(row.original.module),
// name: ({ row }: Cell<Row>) => row.original.name.toUpperCase(),
blockHeight: ({ row }: Cell<Row>) => (
<Link
key={`${row.index}-file-block_height`}
className='hover:text-primaryAccent'
href={INTERNAL_ROUTES.blocks.id.page(network, section, row.original.cid?.blockHeight)}
href={INTERNAL_ROUTES.blocks.id.page(
network,
Routes.consensus,
row.original.cid?.blockHeight,
)}
>
<div>{row.original.cid?.blockHeight}</div>
</Link>
Expand All @@ -172,32 +168,14 @@ export const FolderList: FC = () => {
className='hover:text-primaryAccent'
href={INTERNAL_ROUTES.extrinsics.id.page(
network,
section,
Routes.consensus,
row.original.cid?.extrinsicId ?? '',
)}
>
<div>{row.original.cid?.extrinsicId}</div>
</Link>
),
timestamp: ({ row }: Cell<Row>) => utcToLocalRelativeTime(row.original.cid?.timestamp),
// indexInBlock: ({ row }: Cell<Row>) => row.original.indexInBlock.toString(),
// success: ({ row }: Cell<Row>) => <StatusIcon status={row.original.success} />,
// nonce: ({ row }: Cell<Row>) => row.original.nonce,
// signer: ({ row }: Cell<Row>) => (
// <AccountIconWithLink
// address={row.original.signer}
// network={network}
// section={Routes.consensus}
// forceShortString={true}
// />
// ),
// signature: ({ row }: Cell<Row>) => (
// <CopyButton value={row.original.signature} message='Signature copied'>
// {shortString(row.original.signature)}
// </CopyButton>
// ),
// tip: ({ row }: Cell<Row>) => row.original.tip,
// fee: ({ row }: Cell<Row>) => row.original.fee,
}),
[network, section, selectedColumns],
)
Expand Down

0 comments on commit a193e7b

Please sign in to comment.