From f5405381a35bbb0cf442726705766580bbea74d7 Mon Sep 17 00:00:00 2001 From: Alex Freska Date: Fri, 20 Dec 2024 11:25:31 -0500 Subject: [PATCH] refactor(renterd): contracts no longer provide hostIP --- .changeset/long-llamas-develop.md | 5 ++ .changeset/nine-crabs-beg.md | 5 ++ .changeset/real-zebras-hang.md | 5 ++ .changeset/swift-seals-sin.md | 5 ++ apps/renterd-e2e/src/specs/contracts.spec.ts | 34 ------- .../Contracts/ContractContextMenu.tsx | 35 ++------ .../Contracts/ContractContextMenuFromId.tsx | 8 +- .../ContractsAddBlocklist.tsx | 15 ---- .../ContractsRemoveBlocklist.tsx | 19 ---- .../Contracts/ContractsBulkMenu/index.tsx | 12 +-- .../ContractFilterCmdGroups/Address.tsx | 68 -------------- .../ContractFilterCmdGroups/index.tsx | 2 - .../ContractFilterNav/index.tsx | 7 -- .../ContractsFilterAddressDialog.tsx | 90 ------------------- .../components/Hosts/HostContextMenu.tsx | 17 ---- .../HostsAllowBlockDialog/BlocklistForm.tsx | 18 +--- apps/renterd/contexts/contracts/columns.tsx | 19 +--- apps/renterd/contexts/contracts/dataset.tsx | 1 - apps/renterd/contexts/contracts/types.ts | 9 -- apps/renterd/contexts/dialog.tsx | 5 -- libs/renterd-types/src/types.ts | 1 - 21 files changed, 36 insertions(+), 344 deletions(-) create mode 100644 .changeset/long-llamas-develop.md create mode 100644 .changeset/nine-crabs-beg.md create mode 100644 .changeset/real-zebras-hang.md create mode 100644 .changeset/swift-seals-sin.md delete mode 100644 apps/renterd/components/Contracts/ContractsBulkMenu/ContractsAddBlocklist.tsx delete mode 100644 apps/renterd/components/Contracts/ContractsBulkMenu/ContractsRemoveBlocklist.tsx delete mode 100644 apps/renterd/components/Contracts/ContractsCmd/ContractsFilterCmd/ContractFilterCmdGroups/Address.tsx delete mode 100644 apps/renterd/components/Contracts/ContractsFilterAddressDialog.tsx diff --git a/.changeset/long-llamas-develop.md b/.changeset/long-llamas-develop.md new file mode 100644 index 000000000..a9185e211 --- /dev/null +++ b/.changeset/long-llamas-develop.md @@ -0,0 +1,5 @@ +--- +'renterd': minor +--- + +The contracts explorer no longer supports filtering by host IP. diff --git a/.changeset/nine-crabs-beg.md b/.changeset/nine-crabs-beg.md new file mode 100644 index 000000000..49b3de3d0 --- /dev/null +++ b/.changeset/nine-crabs-beg.md @@ -0,0 +1,5 @@ +--- +'renterd': minor +--- + +The blocklist dialog no longer shows how many active contacts match a suggestion. diff --git a/.changeset/real-zebras-hang.md b/.changeset/real-zebras-hang.md new file mode 100644 index 000000000..6a1dca7ad --- /dev/null +++ b/.changeset/real-zebras-hang.md @@ -0,0 +1,5 @@ +--- +'renterd': minor +--- + +The contracts explorer no longer includes a column for host IP. diff --git a/.changeset/swift-seals-sin.md b/.changeset/swift-seals-sin.md new file mode 100644 index 000000000..6e69b6c27 --- /dev/null +++ b/.changeset/swift-seals-sin.md @@ -0,0 +1,5 @@ +--- +'renterd': minor +--- + +The contracts multi-select menu no longer supports bulk blocklist actions. diff --git a/apps/renterd-e2e/src/specs/contracts.spec.ts b/apps/renterd-e2e/src/specs/contracts.spec.ts index 03e03fb7f..34be50b33 100644 --- a/apps/renterd-e2e/src/specs/contracts.spec.ts +++ b/apps/renterd-e2e/src/specs/contracts.spec.ts @@ -125,40 +125,6 @@ test('contracts bulk allowlist', async ({ page }) => { await expect(dialog.getByText('The allowlist is empty')).toBeVisible() }) -test('contracts bulk blocklist', async ({ page }) => { - await navigateToContracts({ page }) - const rows = await getContractRowsAll(page) - rows.at(0).click() - rows.at(-1).click({ modifiers: ['Shift'] }) - - const menu = page.getByLabel('contract multi-select menu') - const dialog = page.getByRole('dialog') - - // Add selected contract hosts to the allowlist. - await menu.getByLabel('add host addresses to blocklist').click() - await dialog.getByRole('button', { name: 'Add to blocklist' }).click() - - await openManageListsDialog(page) - await expect( - dialog.getByTestId('blocklistAddresses').getByTestId('item') - ).toHaveCount(3) - await dialog.getByLabel('view allowlist').click() - await expect(dialog.getByText('The allowlist is empty')).toBeVisible() - await dialog.getByLabel('close').click() - - rows.at(0).click() - rows.at(-1).click({ modifiers: ['Shift'] }) - - // Remove selected contract hosts from the blocklist. - await menu.getByLabel('remove host addresses from blocklist').click() - await dialog.getByRole('button', { name: 'Remove from blocklist' }).click() - - await openManageListsDialog(page) - await expect(dialog.getByText('The blocklist is empty')).toBeVisible() - await dialog.getByLabel('view allowlist').click() - await expect(dialog.getByText('The allowlist is empty')).toBeVisible() -}) - test('new contracts do not show a renewed from', async ({ page }) => { await navigateToContracts({ page }) await expect(getContractRows(page).getByTestId('renewedFrom')).toBeHidden() diff --git a/apps/renterd/components/Contracts/ContractContextMenu.tsx b/apps/renterd/components/Contracts/ContractContextMenu.tsx index 5c6cb5bec..a6760ca65 100644 --- a/apps/renterd/components/Contracts/ContractContextMenu.tsx +++ b/apps/renterd/components/Contracts/ContractContextMenu.tsx @@ -15,6 +15,7 @@ import { Delete16, } from '@siafoundation/react-icons' import { + useHost, useHostsAllowlist, useHostsBlocklist, } from '@siafoundation/renterd-react' @@ -24,14 +25,12 @@ import { useContracts } from '../../contexts/contracts' import { useHosts } from '../../contexts/hosts' import { useAllowlistUpdate } from '../../hooks/useAllowlistUpdate' import { useBlocklistUpdate } from '../../hooks/useBlocklistUpdate' -import { addressContainsFilter } from './ContractsFilterAddressDialog' import { publicKeyContainsFilter } from './ContractsFilterPublicKeyDialog' import { useContractConfirmDelete } from './useContractConfirmDelete' type Props = { id: string trigger?: React.ReactNode - hostAddress: string hostKey: string contentProps?: React.ComponentProps['contentProps'] buttonProps?: React.ComponentProps @@ -40,7 +39,6 @@ type Props = { export function ContractContextMenu({ id, trigger, - hostAddress, hostKey, contentProps, buttonProps, @@ -67,22 +65,16 @@ export function ContractContextMenu({ }, }} > - + ) } export function ContractContextMenuContent({ id, - hostAddress, hostKey, }: { id: string - hostAddress?: string hostKey?: string }) { const router = useRouter() @@ -95,6 +87,13 @@ export function ContractContextMenuContent({ const blocklistUpdate = useBlocklistUpdate() const allowlistUpdate = useAllowlistUpdate() const contractConfirmDelete = useContractConfirmDelete() + const host = useHost({ + disabled: !hostKey, + params: { + hostkey: hostKey || '', + }, + }) + const hostAddress = host.data?.netAddress return ( <>
@@ -120,22 +119,6 @@ export function ContractContextMenuContent({ Filter hosts by host address - { - if (!hostAddress) { - return - } - resetContractsFilters() - setContractsFilter(addressContainsFilter(hostAddress)) - router.push(routes.contracts.index) - }} - > - - - - Filter contracts by host address - { diff --git a/apps/renterd/components/Contracts/ContractContextMenuFromId.tsx b/apps/renterd/components/Contracts/ContractContextMenuFromId.tsx index fe585086b..a7d09171d 100644 --- a/apps/renterd/components/Contracts/ContractContextMenuFromId.tsx +++ b/apps/renterd/components/Contracts/ContractContextMenuFromId.tsx @@ -44,11 +44,5 @@ function ContractContextMenuFromIdContent({ id }: Props) { params: { id }, }) - return ( - - ) + return } diff --git a/apps/renterd/components/Contracts/ContractsBulkMenu/ContractsAddBlocklist.tsx b/apps/renterd/components/Contracts/ContractsBulkMenu/ContractsAddBlocklist.tsx deleted file mode 100644 index 6ce7aee73..000000000 --- a/apps/renterd/components/Contracts/ContractsBulkMenu/ContractsAddBlocklist.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import { useMemo } from 'react' -import { useContracts } from '../../../contexts/contracts' -import { BulkAddBlocklist } from '../../bulkActions/BulkAddBlocklist' - -export function ContractsAddBlocklist() { - const { multiSelect } = useContracts() - - const hostAddresses = useMemo( - () => Object.entries(multiSelect.selection).map(([_, item]) => item.hostIp), - [multiSelect.selection] - ) - return ( - - ) -} diff --git a/apps/renterd/components/Contracts/ContractsBulkMenu/ContractsRemoveBlocklist.tsx b/apps/renterd/components/Contracts/ContractsBulkMenu/ContractsRemoveBlocklist.tsx deleted file mode 100644 index b66ff06fa..000000000 --- a/apps/renterd/components/Contracts/ContractsBulkMenu/ContractsRemoveBlocklist.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import { useMemo } from 'react' -import { useContracts } from '../../../contexts/contracts' -import { BulkRemoveBlocklist } from '../../bulkActions/BulkRemoveBlocklist' - -export function ContractsRemoveBlocklist() { - const { multiSelect } = useContracts() - - const hostAddresses = useMemo( - () => Object.entries(multiSelect.selection).map(([_, item]) => item.hostIp), - [multiSelect.selection] - ) - - return ( - - ) -} diff --git a/apps/renterd/components/Contracts/ContractsBulkMenu/index.tsx b/apps/renterd/components/Contracts/ContractsBulkMenu/index.tsx index b9c1e7e11..dceba3ddc 100644 --- a/apps/renterd/components/Contracts/ContractsBulkMenu/index.tsx +++ b/apps/renterd/components/Contracts/ContractsBulkMenu/index.tsx @@ -1,9 +1,7 @@ import { MultiSelectionMenu } from '@siafoundation/design-system' import { useContracts } from '../../../contexts/contracts' import { ContractsBulkDelete } from './ContractsBulkDelete' -import { ContractsAddBlocklist } from './ContractsAddBlocklist' import { ContractsAddAllowlist } from './ContractsAddAllowlist' -import { ContractsRemoveBlocklist } from './ContractsRemoveBlocklist' import { ContractsRemoveAllowlist } from './ContractsRemoveAllowlist' import { ContractsRescanHosts } from './ContractsRescanHosts' @@ -12,14 +10,8 @@ export function ContractsBulkMenu() { return ( -
- - -
-
- - -
+ +
diff --git a/apps/renterd/components/Contracts/ContractsCmd/ContractsFilterCmd/ContractFilterCmdGroups/Address.tsx b/apps/renterd/components/Contracts/ContractsCmd/ContractsFilterCmd/ContractFilterCmdGroups/Address.tsx deleted file mode 100644 index f8edbec0b..000000000 --- a/apps/renterd/components/Contracts/ContractsCmd/ContractsFilterCmd/ContractFilterCmdGroups/Address.tsx +++ /dev/null @@ -1,68 +0,0 @@ -import { - CommandGroup, - CommandItemNav, - CommandItemSearch, -} from '../../../../CmdRoot/Item' -import { Page } from '../../../../CmdRoot/types' -import { useDialog } from '../../../../../contexts/dialog' -import { addressContainsFilter } from '../../../ContractsFilterAddressDialog' - -export const contractsFilterAddressPage = { - namespace: 'contracts/filterAddress', - label: 'Contracts filter by address', -} - -export function AddressCmdGroup({ - select, - currentPage, -}: { - currentPage: Page - select: () => void -}) { - const { openDialog } = useDialog() - const filter = addressContainsFilter('') - return ( - - { - select() - openDialog('contractsFilterAddress') - }} - > - {filter.label} - - - ) -} - -export function AddressCmdNav({ - select, - currentPage, - parentPage, - commandPage, -}: { - currentPage: Page - parentPage?: Page - commandPage: Page - select: () => void -}) { - const { openDialog } = useDialog() - return ( - { - select() - openDialog('contractsFilterAddress') - }} - > - {contractsFilterAddressPage.label} - - ) -} diff --git a/apps/renterd/components/Contracts/ContractsCmd/ContractsFilterCmd/ContractFilterCmdGroups/index.tsx b/apps/renterd/components/Contracts/ContractsCmd/ContractsFilterCmd/ContractFilterCmdGroups/index.tsx index 0788dfe87..d3ff7eea8 100644 --- a/apps/renterd/components/Contracts/ContractsCmd/ContractsFilterCmd/ContractFilterCmdGroups/index.tsx +++ b/apps/renterd/components/Contracts/ContractsCmd/ContractsFilterCmd/ContractFilterCmdGroups/index.tsx @@ -2,7 +2,6 @@ import { ExpiryCmdGroup } from './Expiry' import { FormationCmdGroup } from './Formation' import { RenewCmdGroup } from './Renew' import { Page } from '../../../../CmdRoot/types' -import { AddressCmdGroup } from './Address' import { PublicKeyCmdGroup } from './PublicKey' type Props = { @@ -13,7 +12,6 @@ type Props = { export function ContractFilterCmdGroups({ currentPage, select }: Props) { return ( <> - diff --git a/apps/renterd/components/Contracts/ContractsCmd/ContractsFilterCmd/ContractFilterNav/index.tsx b/apps/renterd/components/Contracts/ContractsCmd/ContractsFilterCmd/ContractFilterNav/index.tsx index 503b1c7b1..9ddd88efb 100644 --- a/apps/renterd/components/Contracts/ContractsCmd/ContractsFilterCmd/ContractFilterNav/index.tsx +++ b/apps/renterd/components/Contracts/ContractsCmd/ContractsFilterCmd/ContractFilterNav/index.tsx @@ -3,7 +3,6 @@ import { contractFilterExpiryPage } from '../ContractFilterCmdGroups/Expiry' import { contractFilterFormationPage } from '../ContractFilterCmdGroups/Formation' import { contractFilterRenewPage } from '../ContractFilterCmdGroups/Renew' import { Page } from '../../../../CmdRoot/types' -import { AddressCmdNav } from '../ContractFilterCmdGroups/Address' import { PublicKeyCmdNav } from '../ContractFilterCmdGroups/PublicKey' export const commandPage = { @@ -26,12 +25,6 @@ export function ContractFilterNav({ }: Props) { return ( <> - { - return d.hostIp.includes(address) - }, - } -} - -const initialValues = { - address: '', -} - -const validationSchema = Yup.object().shape({ - address: Yup.string().required('Required'), -}) - -type Props = { - trigger?: React.ReactNode - open: boolean - onOpenChange: (val: boolean) => void -} - -export function ContractsFilterAddressDialog({ - trigger, - open, - onOpenChange, -}: Props) { - const { closeDialog } = useDialog() - const { setFilter } = useContracts() - const formik = useFormik({ - initialValues, - validationSchema, - onSubmit: (values) => { - setFilter(addressContainsFilter(values.address)) - formik.resetForm() - closeDialog() - }, - }) - - return ( - { - if (!open) { - formik.resetForm() - } - onOpenChange(open) - }} - contentVariants={{ - className: 'w-[400px]', - }} - onSubmit={formik.handleSubmit} - > -
-
- - - Filter - -
-
-
- ) -} diff --git a/apps/renterd/components/Hosts/HostContextMenu.tsx b/apps/renterd/components/Hosts/HostContextMenu.tsx index 0d18622ed..0725d3640 100644 --- a/apps/renterd/components/Hosts/HostContextMenu.tsx +++ b/apps/renterd/components/Hosts/HostContextMenu.tsx @@ -28,7 +28,6 @@ import { useContracts } from '../../contexts/contracts' import { useHosts } from '../../contexts/hosts' import { useAllowlistUpdate } from '../../hooks/useAllowlistUpdate' import { useBlocklistUpdate } from '../../hooks/useBlocklistUpdate' -import { addressContainsFilter } from '../Contracts/ContractsFilterAddressDialog' import { publicKeyContainsFilter } from '../Contracts/ContractsFilterPublicKeyDialog' import { filterPublicKeyEquals } from './HostsFilterPublicKeyDialog' import { secondsInMilliseconds } from '@siafoundation/units' @@ -133,22 +132,6 @@ export function HostContextMenuContent({ Filter hosts by public key
- { - if (!address) { - return - } - resetContractsFilters() - setContractsFilter(addressContainsFilter(address)) - router.push(routes.contracts.index) - }} - > - - - - Filter contracts by host address - { resetContractsFilters() diff --git a/apps/renterd/components/Hosts/HostsAllowBlockDialog/BlocklistForm.tsx b/apps/renterd/components/Hosts/HostsAllowBlockDialog/BlocklistForm.tsx index 63bc92697..7aafaa0bf 100644 --- a/apps/renterd/components/Hosts/HostsAllowBlockDialog/BlocklistForm.tsx +++ b/apps/renterd/components/Hosts/HostsAllowBlockDialog/BlocklistForm.tsx @@ -5,13 +5,11 @@ import { ScrollArea, Text, Separator, - Tooltip, FormTextFieldFormik, FieldGroupFormik, } from '@siafoundation/design-system' import { ListChecked32, Filter32 } from '@siafoundation/react-icons' import { useHostsBlocklist } from '@siafoundation/renterd-react' -import { useContracts } from '../../../contexts/contracts' import { useFormik } from 'formik' import { useEffect, useMemo } from 'react' import * as Yup from 'yup' @@ -69,16 +67,14 @@ export function BlocklistForm() { [blockListResponse.data, formik.values.address] ) - const { dataset } = useContracts() const suggestionsNotOnList = useMemo( () => suggestions .filter((s) => !blockListResponse.data?.find((a) => a === s)) .map((s) => ({ address: s, - contractCount: dataset?.filter((d) => d.hostIp === s).length, })), - [blockListResponse.data, dataset] + [blockListResponse.data] ) return ( @@ -122,7 +118,7 @@ export function BlocklistForm() { Suggestions: - {suggestionsNotOnList.map(({ address, contractCount }, i) => { + {suggestionsNotOnList.map(({ address }, i) => { return ( formik.setFieldValue('address', address)} > {address} - {!!contractCount && ( - <> - {' '} - - ({contractCount}) - - - )} {i !== suggestionsNotOnList.length - 1 && ( , )} diff --git a/apps/renterd/contexts/contracts/columns.tsx b/apps/renterd/contexts/contracts/columns.tsx index 0e9d632ec..28632909f 100644 --- a/apps/renterd/contexts/contracts/columns.tsx +++ b/apps/renterd/contexts/contracts/columns.tsx @@ -49,8 +49,8 @@ export const columns: ContractsTableColumn[] = [ checked={multiSelect.isPageAllSelected} /> ), - render: ({ data: { id, hostIp, hostKey } }) => ( - + render: ({ data: { id, hostKey } }) => ( + ), }, { @@ -132,21 +132,6 @@ export const columns: ContractsTableColumn[] = [ ) }, }, - { - id: 'hostIp', - label: 'host address', - category: 'general', - render: ({ data: { hostIp }, context: { siascanUrl } }) => { - return ( - - ) - }, - }, { id: 'hostKey', label: 'host public key', diff --git a/apps/renterd/contexts/contracts/dataset.tsx b/apps/renterd/contexts/contracts/dataset.tsx index 51ecb51ef..4b0621815 100644 --- a/apps/renterd/contexts/contracts/dataset.tsx +++ b/apps/renterd/contexts/contracts/dataset.tsx @@ -42,7 +42,6 @@ export function useDataset() { const datum: ContractDataWithoutPrunable = { id: c.id, state: c.state, - hostIp: c.hostIP, hostKey: c.hostKey, location: geoHosts.find((h) => h.public_key === c.hostKey)?.location, timeline: startTime, diff --git a/apps/renterd/contexts/contracts/types.ts b/apps/renterd/contexts/contracts/types.ts index 16937f3b9..88bb96bea 100644 --- a/apps/renterd/contexts/contracts/types.ts +++ b/apps/renterd/contexts/contracts/types.ts @@ -21,7 +21,6 @@ export type ContractTableContext = { export type ContractData = { id: string - hostIp: string hostKey: string state: ContractState location?: [number, number] @@ -67,7 +66,6 @@ export type TableColumnId = | 'actions' | 'contractId' | 'usability' - | 'hostIp' | 'hostKey' | 'state' | 'timeline' @@ -84,7 +82,6 @@ export type TableColumnId = export const columnsDefaultVisible: TableColumnId[] = [ 'contractId', 'usability', - 'hostIp', 'hostKey', 'state', 'timeline', @@ -99,7 +96,6 @@ export const columnsDefaultVisible: TableColumnId[] = [ export type SortField = | 'contractId' - | 'hostIp' | 'hostKey' | 'state' | 'timeline' @@ -125,11 +121,6 @@ export const sortOptions: { label: 'contract ID', category: 'general', }, - { - id: 'hostIp', - label: 'host address', - category: 'general', - }, { id: 'hostKey', label: 'host public key', diff --git a/apps/renterd/contexts/dialog.tsx b/apps/renterd/contexts/dialog.tsx index d70ce5726..a89dde1bc 100644 --- a/apps/renterd/contexts/dialog.tsx +++ b/apps/renterd/contexts/dialog.tsx @@ -9,7 +9,6 @@ import { CmdKDialog } from '../components/CmdKDialog' import { FilesCreateDirectoryDialog } from '../dialogs/FilesCreateDirectoryDialog' import { HostsAllowBlockDialog } from '../components/Hosts/HostsAllowBlockDialog' import { HostsFilterAddressDialog } from '../components/Hosts/HostsFilterAddressDialog' -import { ContractsFilterAddressDialog } from '../components/Contracts/ContractsFilterAddressDialog' import { ContractsFilterPublicKeyDialog } from '../components/Contracts/ContractsFilterPublicKeyDialog' import { FilesSearchBucketDialog } from '../dialogs/FilesSearchBucketDialog' import { useSyncerConnect, useWallet } from '@siafoundation/renterd-react' @@ -196,10 +195,6 @@ export function Dialogs() { open={dialog === 'hostsFilterPublicKey'} onOpenChange={onOpenChange} /> -