Skip to content

Commit

Permalink
refactor(renterd): contracts no longer provide hostIP
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfreska committed Dec 20, 2024
1 parent 1f8a806 commit a5a5d09
Show file tree
Hide file tree
Showing 21 changed files with 36 additions and 344 deletions.
5 changes: 5 additions & 0 deletions .changeset/long-llamas-develop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'renterd': minor
---

The contracts explorer no longer supports filtering by host IP.
5 changes: 5 additions & 0 deletions .changeset/nine-crabs-beg.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'renterd': minor
---

The blocklist dialog no longer shows how many active contacts match a suggestion.
5 changes: 5 additions & 0 deletions .changeset/real-zebras-hang.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'renterd': minor
---

The contracts explorer no longer includes a column for host IP.
5 changes: 5 additions & 0 deletions .changeset/swift-seals-sin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'renterd': minor
---

The contracts multi-select menu no longer supports bulk blocklist actions.
34 changes: 0 additions & 34 deletions apps/renterd-e2e/src/specs/contracts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
35 changes: 9 additions & 26 deletions apps/renterd/components/Contracts/ContractContextMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
Delete16,
} from '@siafoundation/react-icons'
import {
useHost,
useHostsAllowlist,
useHostsBlocklist,
} from '@siafoundation/renterd-react'
Expand All @@ -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<typeof DropdownMenu>['contentProps']
buttonProps?: React.ComponentProps<typeof Button>
Expand All @@ -40,7 +39,6 @@ type Props = {
export function ContractContextMenu({
id,
trigger,
hostAddress,
hostKey,
contentProps,
buttonProps,
Expand All @@ -67,22 +65,16 @@ export function ContractContextMenu({
},
}}
>
<ContractContextMenuContent
id={id}
hostAddress={hostAddress}
hostKey={hostKey}
/>
<ContractContextMenuContent id={id} hostKey={hostKey} />
</DropdownMenu>
)
}

export function ContractContextMenuContent({
id,
hostAddress,
hostKey,
}: {
id: string
hostAddress?: string
hostKey?: string
}) {
const router = useRouter()
Expand All @@ -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 (
<>
<div className="px-1.5 py-1">
Expand All @@ -120,22 +119,6 @@ export function ContractContextMenuContent({
</DropdownMenuLeftSlot>
Filter hosts by host address
</DropdownMenuItem>
<DropdownMenuItem
disabled={!hostAddress}
onSelect={() => {
if (!hostAddress) {
return
}
resetContractsFilters()
setContractsFilter(addressContainsFilter(hostAddress))
router.push(routes.contracts.index)
}}
>
<DropdownMenuLeftSlot>
<Filter16 />
</DropdownMenuLeftSlot>
Filter contracts by host address
</DropdownMenuItem>
<DropdownMenuItem
disabled={!hostKey}
onSelect={() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,5 @@ function ContractContextMenuFromIdContent({ id }: Props) {
params: { id },
})

return (
<ContractContextMenuContent
id={id}
hostAddress={contract.data?.hostIP}
hostKey={contract.data?.hostKey}
/>
)
return <ContractContextMenuContent id={id} hostKey={contract.data?.hostKey} />
}

This file was deleted.

This file was deleted.

12 changes: 2 additions & 10 deletions apps/renterd/components/Contracts/ContractsBulkMenu/index.tsx
Original file line number Diff line number Diff line change
@@ -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'

Expand All @@ -12,14 +10,8 @@ export function ContractsBulkMenu() {

return (
<MultiSelectionMenu multiSelect={multiSelect} entityWord="contract">
<div className="flex flex-col gap-1">
<ContractsAddAllowlist />
<ContractsAddBlocklist />
</div>
<div className="flex flex-col gap-1">
<ContractsRemoveAllowlist />
<ContractsRemoveBlocklist />
</div>
<ContractsAddAllowlist />
<ContractsRemoveAllowlist />
<ContractsRescanHosts />
<ContractsBulkDelete />
</MultiSelectionMenu>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -13,7 +12,6 @@ type Props = {
export function ContractFilterCmdGroups({ currentPage, select }: Props) {
return (
<>
<AddressCmdGroup currentPage={currentPage} select={select} />
<PublicKeyCmdGroup currentPage={currentPage} select={select} />
<ExpiryCmdGroup currentPage={currentPage} select={select} />
<FormationCmdGroup currentPage={currentPage} select={select} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -26,12 +25,6 @@ export function ContractFilterNav({
}: Props) {
return (
<>
<AddressCmdNav
currentPage={currentPage}
parentPage={parentPage}
commandPage={commandPage}
select={select}
/>
<PublicKeyCmdNav
currentPage={currentPage}
parentPage={parentPage}
Expand Down
Loading

0 comments on commit a5a5d09

Please sign in to comment.