mirror of
https://github.com/Noooste/garage-ui.git
synced 2026-07-26 07:48:13 +00:00
5d33382e30
* feat(backend,frontend): recursive delete of key prefixes in bulk actions
Bulk object selection previously only supported deleting individually
listed object keys — folders ("prefixes") could not be selected or
deleted, leaving no way to remove a directory and all of its contents.
Backend:
- Add S3Service.DeleteObjectsByPrefix, which recursively lists every
object under a prefix and batch-deletes them, returning the count.
- Extend the delete-multiple endpoint to accept a "prefixes" array
alongside "keys"; keys are batch-deleted and each prefix is deleted
recursively. Response now reports the total objects removed.
Frontend:
- Enable folder checkboxes and add a per-folder "Delete folder" action.
- Select-all now covers both files and folders.
- Route all bulk/folder deletes through a confirmation dialog that
spells out the file/folder counts and warns that folders are removed
recursively (previously bulk delete fired with no confirmation).
- api/hook send "prefixes"; optimistic update drops objects under any
deleted prefix.
* fix(backend): validate delete prefixes and count actual removals
Addresses maintainer review on the recursive prefix-delete endpoint:
- Reject blank/whitespace-only prefixes with a 400 instead of a 500, and
normalize each prefix to have a trailing "/" so "photos/2024" can no
longer also delete siblings like "photos/2024-old/..." on this
irreversible public endpoint.
- DeleteMultipleObjects now returns the number of objects actually
removed (requested keys minus failures) rather than assuming every
requested key was deleted; the handler sums real counts across the
keys and prefix paths. Draining the full RemoveObjects error channel
also fixes a potential sender-goroutine leak on early return.
- Add tests: blank-prefix -> 400, prefix trailing-slash normalization,
and S3Service.DeleteObjectsByPrefix (list-then-delete, empty prefix,
no-match, and list-error propagation).
* fix(frontend): align select-all with the active search filter
The header "select all" checkbox derived its checked state from the
filtered (searched) rows, but handleSelectAll operated on the full,
unfiltered object list — so with a search active it selected hidden
items and the checkbox state disagreed with the selection.
ObjectsTable now passes the keys of the currently visible (filtered)
rows to onSelectAll, and its checked state reflects whether every
visible row is selected. handleSelectAll toggles only those visible
rows, leaving any off-screen selection intact.
* fix(frontend): scope select-all to the visible page
After merging upstream's client-side deep-search pagination, the rendered
rows are pageObjects (one page slice) while select-all still operated on
filteredObjects (every match across hidden pages). Scope the header
checkbox's state and its select-all action to pageObjects so one click
never selects off-screen rows for a destructive bulk delete. In
normal/prefix browsing pageObjects === filteredObjects, so behavior there
is unchanged.
---------
Authored-by: Camilo Hollanda <775409+prem-prakash@users.noreply.github.com>
74 lines
3.8 KiB
Go
74 lines
3.8 KiB
Go
package services
|
|
|
|
import (
|
|
"context"
|
|
"io"
|
|
"time"
|
|
|
|
"Noooste/garage-ui/internal/models"
|
|
)
|
|
|
|
// AdminService is the set of Garage Admin API operations used by HTTP handlers.
|
|
// It is implemented by *GarageV2AdminService in admin_v2.go. Kept narrow so that
|
|
// hand-rolled mocks in tests don't need to cover admin methods the handlers
|
|
// never call.
|
|
type AdminService interface {
|
|
// Access keys
|
|
ListKeys(ctx context.Context) ([]models.ListKeysResponseItem, error)
|
|
CreateKey(ctx context.Context, req models.CreateKeyRequest) (*models.GarageKeyInfo, error)
|
|
GetKeyInfo(ctx context.Context, keyID string, showSecret bool) (*models.GarageKeyInfo, error)
|
|
UpdateKey(ctx context.Context, keyID string, req models.UpdateKeyRequest) (*models.GarageKeyInfo, error)
|
|
DeleteKey(ctx context.Context, keyID string) error
|
|
|
|
// Buckets
|
|
ListBuckets(ctx context.Context) ([]models.ListBucketsResponseItem, error)
|
|
GetBucketInfo(ctx context.Context, bucketID string) (*models.GarageBucketInfo, error)
|
|
GetBucketInfoByAlias(ctx context.Context, globalAlias string) (*models.GarageBucketInfo, error)
|
|
CreateBucket(ctx context.Context, req models.CreateBucketAdminRequest) (*models.GarageBucketInfo, error)
|
|
UpdateBucket(ctx context.Context, bucketID string, req models.UpdateBucketRequest) (*models.GarageBucketInfo, error)
|
|
DeleteBucket(ctx context.Context, bucketID string) error
|
|
AllowBucketKey(ctx context.Context, req models.BucketKeyPermRequest) (*models.GarageBucketInfo, error)
|
|
DenyBucketKey(ctx context.Context, req models.BucketKeyPermRequest) (*models.GarageBucketInfo, error)
|
|
|
|
// Cluster
|
|
GetClusterHealth(ctx context.Context) (*models.ClusterHealth, error)
|
|
GetClusterStatus(ctx context.Context) (*models.ClusterStatus, error)
|
|
GetClusterStatistics(ctx context.Context) (*models.ClusterStatistics, error)
|
|
GetNodeInfo(ctx context.Context, nodeID string) (*models.MultiNodeResponse, error)
|
|
GetNodeStatistics(ctx context.Context, nodeID string) (*models.MultiNodeResponse, error)
|
|
|
|
// Monitoring
|
|
HealthCheck(ctx context.Context) error
|
|
GetMetrics(ctx context.Context) (string, error)
|
|
}
|
|
|
|
// S3Storage is the set of S3 operations used by HTTP handlers. It is
|
|
// implemented by *S3Service in s3.go. Methods on *S3Service that are not
|
|
// called by handlers (ListBuckets, CreateBucket, DeleteBucket,
|
|
// GetBucketStatistics) are intentionally excluded.
|
|
type S3Storage interface {
|
|
ListObjects(ctx context.Context, bucketName, prefix string, maxKeys int, continuationToken string) (*models.ObjectListResponse, error)
|
|
SearchObjects(ctx context.Context, bucketName, prefix, search string) (*models.ObjectListResponse, error)
|
|
UploadObject(ctx context.Context, bucketName, key string, body io.Reader, contentType string) (*models.ObjectUploadResponse, error)
|
|
CreateDirectoryMarker(ctx context.Context, bucketName, key string) (*models.ObjectUploadResponse, error)
|
|
GetObject(ctx context.Context, bucketName, key string) (io.ReadCloser, *models.ObjectInfo, error)
|
|
ObjectExists(ctx context.Context, bucketName, key string) (bool, error)
|
|
DeleteObject(ctx context.Context, bucketName, key string) error
|
|
GetObjectMetadata(ctx context.Context, bucketName, key string) (*models.ObjectInfo, error)
|
|
GetPresignedURL(ctx context.Context, bucketName, key string, expiresIn time.Duration) (string, error)
|
|
DeleteMultipleObjects(ctx context.Context, bucketName string, keys []string) (int, error)
|
|
DeleteObjectsByPrefix(ctx context.Context, bucketName, prefix string) (int, error)
|
|
UploadMultipleObjects(ctx context.Context, bucketName string, files []struct {
|
|
Key string
|
|
Body io.Reader
|
|
ContentType string
|
|
}) []UploadResult
|
|
}
|
|
|
|
// Compile-time guarantees that the concrete services implement the interfaces.
|
|
var (
|
|
_ AdminService = (*GarageV2AdminService)(nil)
|
|
_ AdminService = (*GarageV1AdminService)(nil)
|
|
_ S3Storage = (*S3Service)(nil)
|
|
)
|