Skip to content

Commit

Permalink
refactor(renterd): query param consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfreska committed Oct 1, 2024
1 parent 2a1d787 commit ee6e18c
Show file tree
Hide file tree
Showing 15 changed files with 55 additions and 40 deletions.
7 changes: 7 additions & 0 deletions .changeset/few-deers-appear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@siafoundation/renterd-types': minor
'@siafoundation/renterd-js': minor
'@siafoundation/renterd-react': minor
---

All query parameters are now lowercased for API consistency.
11 changes: 7 additions & 4 deletions apps/hostd-e2e/src/fixtures/clearToasts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ import { Page } from '@playwright/test'
export async function clearToasts({ page }: { page: Page }) {
const clearButtons = page.getByTestId('toasts').locator('button')
while ((await clearButtons.count()) > 0) {
await clearButtons.first().click()
// Timeout required because the toast animation is not instantaneous.
// eslint-disable-next-line playwright/no-wait-for-timeout
await page.waitForTimeout(1000)
try {
await clearButtons.first().click({
timeout: 1000,
})
} catch (e) {
console.log('Toast already detached.')
}
}
}
11 changes: 7 additions & 4 deletions apps/renterd-e2e/src/fixtures/clearToasts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ import { Page } from '@playwright/test'
export async function clearToasts({ page }: { page: Page }) {
const clearButtons = page.getByTestId('toasts').locator('button')
while ((await clearButtons.count()) > 0) {
await clearButtons.first().click()
// Timeout required because the toast animation is not instantaneous.
// eslint-disable-next-line playwright/no-wait-for-timeout
await page.waitForTimeout(1000)
try {
await clearButtons.first().click({
timeout: 1000,
})
} catch (e) {
console.log('Attempted to clear toast, but it is already detached.')
}
}
}
6 changes: 4 additions & 2 deletions apps/renterd-e2e/src/fixtures/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,10 @@ export async function createDirectoryIfNotExists(page: Page, name: string) {
}
}

export async function fileInList(page: Page, path: string) {
await expect(page.getByTestId('filesTable').getByTestId(path)).toBeVisible()
export async function fileInList(page: Page, path: string, timeout?: number) {
await expect(page.getByTestId('filesTable').getByTestId(path)).toBeVisible({
timeout,
})
}

export async function fileNotInList(page: Page, path: string) {
Expand Down
4 changes: 2 additions & 2 deletions apps/renterd-e2e/src/specs/files.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ test('can create directory, upload file, rename file, navigate, delete a file, d
path.join(__dirname, originalFileName),
originalFileName
)
await fileInList(page, originalFilePath)
await expect(page.getByText('100%')).toBeVisible()
await fileInList(page, originalFilePath)

// Rename file.
await openFileContextMenu(page, originalFilePath)
Expand All @@ -111,8 +111,8 @@ test('can create directory, upload file, rename file, navigate, delete a file, d
path.join(__dirname, originalFileName),
originalFileName
)
await fileInList(page, originalFilePath)
await expect(page.getByText('100%')).toBeVisible()
await fileInList(page, originalFilePath)

// Clean up the directory.
await navigateToParentDirectory(page)
Expand Down
2 changes: 1 addition & 1 deletion apps/renterd/components/Hosts/HostContextMenuFromKey.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export function HostContextMenuFromKey({
// Only trigger a fetch when the dropdown is opened
function HostContextMenuFromKeyContent({ hostKey }: { hostKey: string }) {
const host = useHost({
params: { hostKey },
params: { hostkey: hostKey },
})

return (
Expand Down
2 changes: 1 addition & 1 deletion apps/renterd/contexts/alerts/data.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export const dataFields: Record<
},
hostKey: {
render: function HostField({ value }: { value: string }) {
const host = useHost({ params: { hostKey: value } })
const host = useHost({ params: { hostkey: value } })
if (!host.data) {
return null
}
Expand Down
2 changes: 1 addition & 1 deletion apps/renterd/contexts/contracts/useContractMetrics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export function useContractMetrics({
n: periods,
}
if (contractId) {
p.contractID = contractId
p.contractid = contractId
}
return p
}, [start, interval, periods, contractId])
Expand Down
4 changes: 2 additions & 2 deletions apps/renterd/contexts/filesDirectory/dataset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ export function useDataset() {
const p: ObjectsParams = {
prefix,
bucket: pathParams.bucket,
sortBy: sortField,
sortDir: sortDirection,
sortby: sortField,
sortdir: sortDirection,
limit,
delimiter: '/',
}
Expand Down
4 changes: 2 additions & 2 deletions apps/renterd/contexts/filesFlat/dataset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ export function useDataset({ sortDirection, sortField }: Props) {
const p: ObjectsParams = {
prefix,
bucket: activeBucketName,
sortBy: sortField,
sortDir: sortDirection,
sortby: sortField,
sortdir: sortDirection,
limit,
delimiter: '',
}
Expand Down
2 changes: 1 addition & 1 deletion apps/renterd/lib/multipartUpload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ export class MultipartUpload {
key: this.#key.slice(1),
bucket: this.#bucket,
uploadid: this.#uploadId,
offset: partOffset,
encryptionoffset: partOffset,
partnumber: partNumber,
} as MultipartUploadPartParams,
payload: partData,
Expand Down
6 changes: 3 additions & 3 deletions internal/cluster/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module go.sia.tech/web/cluster
go 1.23.0

require (
go.sia.tech/cluster v0.0.0-20240924203221-6c140b264895
go.sia.tech/cluster v0.0.0-20241001143852-ff111abcfa0a
go.sia.tech/core v0.4.6
go.sia.tech/coreutils v0.3.2
go.uber.org/zap v1.27.0
Expand Down Expand Up @@ -32,8 +32,8 @@ require (
go.sia.tech/gofakes3 v0.0.5 // indirect
go.sia.tech/hostd v1.1.3-0.20240903081107-6e044db95238 // indirect
go.sia.tech/jape v0.12.1 // indirect
go.sia.tech/mux v1.2.0 // indirect
go.sia.tech/renterd v1.1.0-beta.4.0.20240924124211-9a4e6a3aab98 // indirect
go.sia.tech/mux v1.3.0 // indirect
go.sia.tech/renterd v1.1.0-beta.4.0.20240928114638-ea7682e6e3e6 // indirect
go.sia.tech/walletd v0.8.1-0.20240830193535-90d18cf2393c // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.27.0 // indirect
Expand Down
12 changes: 6 additions & 6 deletions internal/cluster/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
go.etcd.io/bbolt v1.3.11 h1:yGEzV1wPz2yVCLsD8ZAiGHhHVlczyC9d1rP43/VCRJ0=
go.etcd.io/bbolt v1.3.11/go.mod h1:dksAq7YMXoljX0xu6VF5DMZGbhYYoLUalEiSySYAS4I=
go.sia.tech/cluster v0.0.0-20240924203221-6c140b264895 h1:w6B8UG81XnKPiDheqTulctR7itjihOMK9q57gY5vEjk=
go.sia.tech/cluster v0.0.0-20240924203221-6c140b264895/go.mod h1:tmQVXHTsEC8fEEi8qkqvEmUMSABchg6fUf8UqM/XkE8=
go.sia.tech/cluster v0.0.0-20241001143852-ff111abcfa0a h1:ualMBOboRG2z81q1s0S2XJPLOgeb8fkSoR7myFO0io8=
go.sia.tech/cluster v0.0.0-20241001143852-ff111abcfa0a/go.mod h1:z8E+KNJJ0Ly+uncjy9fu1sJ+nLdTqkYFkzZjAiFBqo4=
go.sia.tech/core v0.4.6 h1:QLm97a7GWBonfnMEOokqWRAqsWCUPL7kzo6k3Adwx8E=
go.sia.tech/core v0.4.6/go.mod h1:Zuq0Tn2aIXJyO0bjGu8cMeVWe+vwQnUfZhG1LCmjD5c=
go.sia.tech/coreutils v0.3.2 h1:3gJqvs18n1FVZmcrnfIYyzS+rBu06OtIscDDAfUAYQI=
Expand All @@ -65,10 +65,10 @@ go.sia.tech/hostd v1.1.3-0.20240903081107-6e044db95238 h1:DP9o+TnNeS34EmxZ/zqZ4p
go.sia.tech/hostd v1.1.3-0.20240903081107-6e044db95238/go.mod h1:InmB5LdO6EP+ZW9uolUCO+zh+zVdbJF3iCgU7xokJxQ=
go.sia.tech/jape v0.12.1 h1:xr+o9V8FO8ScRqbSaqYf9bjj1UJ2eipZuNcI1nYousU=
go.sia.tech/jape v0.12.1/go.mod h1:wU+h6Wh5olDjkPXjF0tbZ1GDgoZ6VTi4naFw91yyWC4=
go.sia.tech/mux v1.2.0 h1:ofa1Us9mdymBbGMY2XH/lSpY8itFsKIo/Aq8zwe+GHU=
go.sia.tech/mux v1.2.0/go.mod h1:Yyo6wZelOYTyvrHmJZ6aQfRoer3o4xyKQ4NmQLJrBSo=
go.sia.tech/renterd v1.1.0-beta.4.0.20240924124211-9a4e6a3aab98 h1:pFS8D7Zq0nrFVYbO9X4PAn5XQAhjaiZ6hlUJBKZDlJM=
go.sia.tech/renterd v1.1.0-beta.4.0.20240924124211-9a4e6a3aab98/go.mod h1:SYRD/Xs7JHpdnhQ8VWMNZpNu63x6G+g0kaJfdSFTGhw=
go.sia.tech/mux v1.3.0 h1:hgR34IEkqvfBKUJkAzGi31OADeW2y7D6Bmy/Jcbop9c=
go.sia.tech/mux v1.3.0/go.mod h1:I46++RD4beqA3cW9Xm9SwXbezwPqLvHhVs9HLpDtt58=
go.sia.tech/renterd v1.1.0-beta.4.0.20240928114638-ea7682e6e3e6 h1:FBr4KhMYDVyrd+rehZ07fy/OButdxutnUNCTmzL0a10=
go.sia.tech/renterd v1.1.0-beta.4.0.20240928114638-ea7682e6e3e6/go.mod h1:1WelcQsJZlpHiu61rmJ2BLOqZDwtxAuI0el6/Y7naYQ=
go.sia.tech/walletd v0.8.1-0.20240830193535-90d18cf2393c h1:auulu0mwWRJK+OZRKoo+PQJNGFGubP2XGb8H4IWt2mc=
go.sia.tech/walletd v0.8.1-0.20240830193535-90d18cf2393c/go.mod h1:B5p/myztKW86MaL69hT3wfnuzhLW3CZCWQ2WJiLqbbU=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
Expand Down
20 changes: 10 additions & 10 deletions libs/renterd-types/src/bus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ export const busWalletSendRoute = '/bus/wallet/send'
export const busWalletPrepareFormRoute = '/bus/wallet/prepare/form'
export const busWalletPrepareRenewRoute = '/bus/wallet/prepare/renew'
export const busHostsRoute = '/bus/hosts'
export const busHostHostKeyRoute = '/bus/host/:hostKey'
export const busHostsHostKeyRoute = '/bus/hosts/:hostKey'
export const busHostHostKeyRoute = '/bus/host/:hostkey'
export const busHostsHostKeyRoute = '/bus/hosts/:hostkey'
export const busHostsBlocklistRoute = '/bus/hosts/blocklist'
export const busHostsAllowlistRoute = '/bus/hosts/allowlist'
export const busHostPublicKeyResetlostsectorsRoute =
'/bus/host/:publicKey/resetlostsectors'
'/bus/host/:publickey/resetlostsectors'
export const busContractsRoute = '/bus/contracts'
export const busContractIdAcquireRoute = '/bus/contract/:id/acquire'
export const busContractIdReleaseRoute = '/bus/contract/:id/release'
Expand Down Expand Up @@ -239,11 +239,11 @@ export type HostsPayload = {
}
export type HostsResponse = Host[]

export type HostParams = { hostKey: string }
export type HostParams = { hostkey: string }
export type HostPayload = Host
export type HostResponse = Host

export type HostInteractionParams = { hostKey: string }
export type HostInteractionParams = { hostkey: string }
export type HostInteractionPayload = {
timestamp: string
type: string
Expand Down Expand Up @@ -405,10 +405,10 @@ export type ObjectsParams = {
delimiter?: string
limit?: number
marker?: string
sortBy?: 'name' | 'health' | 'size'
sortDir?: 'asc' | 'desc'
sortby?: 'name' | 'health' | 'size'
sortdir?: 'asc' | 'desc'
substring?: string
slabEncryptionKey?: string
slabencryptionkey?: string
}
export type ObjectsPayload = void
export type ObjectsResponse = {
Expand Down Expand Up @@ -518,8 +518,8 @@ export type ContractMetric = {
}

export type ContractMetricsParams = MetricsParams & {
contractID?: string
hostKey?: string
contractid?: string
hostkey?: string
}
export type ContractMetricsPayload = void
export type ContractMetricsResponse = ContractMetric[]
Expand Down
2 changes: 1 addition & 1 deletion libs/renterd-types/src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export type MultipartUploadPartParams = {
key: string
uploadid: string
partnumber: number
offset: number
encryptionoffset: number
bucket?: string
contractset?: string
minshards?: number
Expand Down

0 comments on commit ee6e18c

Please sign in to comment.