Skip to content

Commit

Permalink
fix: feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfreska committed Sep 26, 2024
1 parent 3a2519a commit 9be92a4
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 39 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CommandGroup, CommandItemSearch } from '../../../CmdRoot/Item'
import { Page } from '../../../CmdRoot/types'
import { useObjectList } from '@siafoundation/renterd-react'
import { useObjects } from '@siafoundation/renterd-react'
import { isDirectory } from '../../../../lib/paths'
import { Text } from '@siafoundation/design-system'
import { Document16, FolderIcon } from '@siafoundation/react-icons'
Expand Down Expand Up @@ -31,7 +31,7 @@ export function FilesSearchCmd({
useFilesManager()
const onSearchPage = currentPage?.namespace === filesSearchPage.namespace
const searchBucket = activeBucket || 'default'
const results = useObjectList({
const results = useObjects({
disabled: !onSearchPage,
params: {
bucket: searchBucket,
Expand Down
8 changes: 4 additions & 4 deletions apps/renterd/contexts/filesDirectory/dataset.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { useObjectList } from '@siafoundation/renterd-react'
import { useObjects } from '@siafoundation/renterd-react'
import { useDataset as useDatasetGeneric } from '../filesManager/dataset'
import { bucketAndKeyParamsFromPath } from '../../lib/paths'
import { useRouter } from 'next/router'
import { useMemo } from 'react'
import { useFilesManager } from '../filesManager'
import { defaultDatasetRefreshInterval } from '../../config/swr'
import { ObjectListParams } from '@siafoundation/renterd-types'
import { ObjectsParams } from '@siafoundation/renterd-types'

const defaultLimit = 50

Expand All @@ -30,7 +30,7 @@ export function useDataset() {
? fileNamePrefixFilter.slice(1)
: fileNamePrefixFilter
}
const p: ObjectListParams = {
const p: ObjectsParams = {
prefix,
bucket: pathParams.bucket,
sortBy: sortField,
Expand All @@ -51,7 +51,7 @@ export function useDataset() {
limit,
])

const response = useObjectList({
const response = useObjects({
disabled: !activeBucketName,
params,
config: {
Expand Down
8 changes: 4 additions & 4 deletions apps/renterd/contexts/filesFlat/dataset.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { useObjectList } from '@siafoundation/renterd-react'
import { useObjects } from '@siafoundation/renterd-react'
import { SortField } from '../filesManager/types'
import { useDataset as useDatasetGeneric } from '../filesManager/dataset'
import { useRouter } from 'next/router'
import { useMemo } from 'react'
import { useFilesManager } from '../filesManager'
import { defaultDatasetRefreshInterval } from '../../config/swr'
import { ObjectListParams } from '@siafoundation/renterd-types'
import { ObjectsParams } from '@siafoundation/renterd-types'

type Props = {
sortDirection: 'asc' | 'desc'
Expand All @@ -27,7 +27,7 @@ export function useDataset({ sortDirection, sortField }: Props) {
? fileNamePrefixFilter.slice(1)
: fileNamePrefixFilter
}
const p: ObjectListParams = {
const p: ObjectsParams = {
prefix,
bucket: activeBucketName,
sortBy: sortField,
Expand All @@ -48,7 +48,7 @@ export function useDataset({ sortDirection, sortField }: Props) {
limit,
])

const response = useObjectList({
const response = useObjects({
disabled: !activeBucketName,
params,
config: {
Expand Down
4 changes: 2 additions & 2 deletions apps/renterd/contexts/filesManager/uploads.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
useMultipartUploadPart,
useSettingsUpload,
} from '@siafoundation/renterd-react'
import { Bucket, busListObjectsRoute } from '@siafoundation/renterd-types'
import { Bucket, busObjectsRoute } from '@siafoundation/renterd-types'
import { MiBToBytes, minutesInMilliseconds } from '@siafoundation/units'
import { throttle } from '@technically/lodash'
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
Expand Down Expand Up @@ -133,7 +133,7 @@ export function useUploads({ activeDirectoryPath }: Props) {
}, 1000)
)
multipartUpload.setOnComplete(async () => {
await ref.current.mutate((key) => key.startsWith(busListObjectsRoute))
await ref.current.mutate((key) => key.startsWith(busObjectsRoute))
ref.current.removeUpload(uploadId)
setTimeout(() => {
ref.current.checkAndStartUploads()
Expand Down
4 changes: 2 additions & 2 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-20240916165251-0f09676f19ad
go.sia.tech/cluster v0.0.0-20240924203221-6c140b264895
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 @@ -33,7 +33,7 @@ require (
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.2.0.20240916134118-61ab4646ef37 // indirect
go.sia.tech/renterd v1.1.0-beta.4.0.20240924124211-9a4e6a3aab98 // 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
14 changes: 4 additions & 10 deletions internal/cluster/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/gabriel-vasile/mimetype v1.4.5 h1:J7wGKdGu33ocBOhGy0z653k/lFKLFDPJMG8Gql0kxn4=
github.com/gabriel-vasile/mimetype v1.4.5/go.mod h1:ibHel+/kbxn9x2407k1izTA1S81ku1z/DlgOW2QE0M4=
github.com/go-ini/ini v1.67.0 h1:z6ZrTEZqSWOTyH2FlglNbNgARyHG8oLW9gMELqKr06A=
github.com/go-ini/ini v1.67.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8=
github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpvNJ1Y=
github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg=
github.com/goccy/go-json v0.10.3 h1:KZ5WoDbxAIgm2HNbYckL0se1fHD6rz5j4ywS6ebzDqA=
Expand Down Expand Up @@ -40,10 +38,6 @@ github.com/mattn/go-sqlite3 v1.14.23 h1:gbShiuAP1W5j9UOksQ06aiiqPMxYecovVGwmTxWt
github.com/mattn/go-sqlite3 v1.14.23/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1 h1:lYpkrQH5ajf0OXOcUbGjvZxxijuBwbbmlSxLiuofa+g=
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1/go.mod h1:pD8RvIylQ358TN4wwqatJ8rNavkEINozVn9DtGI3dfQ=
github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34=
github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM=
github.com/minio/minio-go/v7 v7.0.76 h1:9nxHH2XDai61cT/EFhyIw/wW4vJfpPNvl7lSFpRt+Ng=
github.com/minio/minio-go/v7 v7.0.76/go.mod h1:AVM3IUN6WwKzmwBxVdjzhH8xq+f57JSbbvzqvUzR6eg=
github.com/montanaflynn/stats v0.7.1 h1:etflOAAHORrCC44V+aR6Ftzort912ZU+YLiSTuV8eaE=
github.com/montanaflynn/stats v0.7.1/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
Expand All @@ -59,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-20240916165251-0f09676f19ad h1:Grq6CclFRaYz8nPG3qYetPH6jYRiAgI8kFFR+U8bQM4=
go.sia.tech/cluster v0.0.0-20240916165251-0f09676f19ad/go.mod h1:2F+rb7oYoOX/584xR1s4eDRlBN7xmYQlm04V76EH6L4=
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/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 @@ -73,8 +67,8 @@ 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.2.0.20240916134118-61ab4646ef37 h1:OLgL41FjtaA13ZrL6V6v6zHaiFvcjmV9LfW055zXWCE=
go.sia.tech/renterd v1.1.0-beta.2.0.20240916134118-61ab4646ef37/go.mod h1:OvnYfShl7wpNIJQ4oJqAYURapS7ZUz+aDY/1MxIcGsQ=
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/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
2 changes: 1 addition & 1 deletion libs/renterd-js/src/bus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ export function Bus({ api, password }: { api: string; password?: string }) {
BucketDeletePayload,
BucketDeleteResponse
>(axios, 'delete', busBucketNameRoute),
objectList: buildRequestHandler<
objects: buildRequestHandler<
ObjectsParams,
ObjectsPayload,
ObjectsResponse
Expand Down
2 changes: 1 addition & 1 deletion libs/renterd-js/src/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('renterd-js', () => {
const bucket = 'default'
const name = 'test.txt'
const fileKey = `directory/${name}`
const url = `/worker/objects/${fileKey}?bucket=${bucket}`
const url = `/worker/object/${fileKey}?bucket=${bucket}`
const fullUrl = `${api}${url}`

mock.onPut(fullUrl).reply((config) => {
Expand Down
6 changes: 3 additions & 3 deletions libs/renterd-js/src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
WorkerStateResponse,
workerAccountIdResetdriftRoute,
workerMultipartKeyRoute,
workerObjectsKeyRoute,
workerObjectKeyRoute,
workerRhpScanRoute,
workerStateRoute,
} from '@siafoundation/renterd-types'
Expand All @@ -38,7 +38,7 @@ export function Worker({ api, password }: { api: string; password?: string }) {
ObjectDownloadParams,
ObjectDownloadPayload,
ObjectDownloadResponse
>(axios, 'get', workerObjectsKeyRoute, {
>(axios, 'get', workerObjectKeyRoute, {
config: {
responseType: 'blob',
},
Expand All @@ -47,7 +47,7 @@ export function Worker({ api, password }: { api: string; password?: string }) {
ObjectUploadParams,
ObjectUploadPayload,
ObjectUploadResponse
>(axios, 'put', workerObjectsKeyRoute, {
>(axios, 'put', workerObjectKeyRoute, {
config: {
headers: {
'Content-Type': 'multipart/form-data',
Expand Down
4 changes: 1 addition & 3 deletions libs/renterd-react/src/bus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -702,9 +702,7 @@ export function useBucketDelete(
)
}

export function useObjectList(
args: HookArgsSwr<ObjectsParams, ObjectsResponse>
) {
export function useObjects(args: HookArgsSwr<ObjectsParams, ObjectsResponse>) {
return useGetSwr({ ...args, route: busObjectsPrefixRoute })
}

Expand Down
7 changes: 3 additions & 4 deletions libs/renterd-react/src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@ import {
busHostsRoute,
workerAccountIdResetdriftRoute,
workerMultipartKeyRoute,
workerObjectsKeyRoute,
workerObjectKeyRoute,
workerRhpScanRoute,
workerStateRoute,
busObjectsRoute,
Host,
} from '@siafoundation/renterd-types'

Expand All @@ -54,7 +53,7 @@ export function useObjectDownloadFunc(
ObjectDownloadResponse
>
) {
return useGetDownloadFunc({ ...args, route: workerObjectsKeyRoute })
return useGetDownloadFunc({ ...args, route: workerObjectKeyRoute })
}

export function useObjectUpload(
Expand All @@ -76,7 +75,7 @@ export function useObjectUpload(
},
},
},
route: workerObjectsKeyRoute,
route: workerObjectKeyRoute,
},
async (mutate) => {
mutate((key) => key.startsWith(busObjectsRoute))
Expand Down
4 changes: 2 additions & 2 deletions libs/renterd-types/src/bus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -399,15 +399,15 @@ export type BucketDeletePayload = void
export type BucketDeleteResponse = void

export type ObjectsParams = {
bucket: string
bucket?: string
prefix?: string
delimiter?: string
limit?: number
marker?: string
sortBy?: 'name' | 'health' | 'size'
sortDir?: 'asc' | 'desc'
substring?: string
slabEncryptionKey: string
slabEncryptionKey?: string
}
export type ObjectsPayload = void
export type ObjectsResponse = {
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 @@ -2,7 +2,7 @@ import { HostSettings } from './types'
import { BusStateResponse } from './bus'

export const workerStateRoute = '/worker/state'
export const workerObjectsKeyRoute = '/worker/objects/:key'
export const workerObjectKeyRoute = '/worker/object/:key'
export const workerMultipartKeyRoute = '/worker/multipart/:key'
export const workerRhpScanRoute = '/worker/rhp/scan'
export const workerAccountIdResetdriftRoute = '/worker/account/:id/resetdrift'
Expand Down

0 comments on commit 9be92a4

Please sign in to comment.