mirror of
https://github.com/minio/minio.git
synced 2025-02-03 09:55:59 -05:00
allow direct access to bucket from browser with limited permissions (#9580)
This commit is contained in:
parent
2d7a96342c
commit
26cfd52e7e
@ -31,19 +31,38 @@ export const SET_POLICIES = "buckets/SET_POLICIES"
|
|||||||
|
|
||||||
export const fetchBuckets = () => {
|
export const fetchBuckets = () => {
|
||||||
return function(dispatch) {
|
return function(dispatch) {
|
||||||
|
const { bucket, prefix } = pathSlice(history.location.pathname)
|
||||||
return web.ListBuckets().then(res => {
|
return web.ListBuckets().then(res => {
|
||||||
const buckets = res.buckets ? res.buckets.map(bucket => bucket.name) : []
|
const buckets = res.buckets ? res.buckets.map(bucket => bucket.name) : []
|
||||||
dispatch(setList(buckets))
|
|
||||||
if (buckets.length > 0) {
|
if (buckets.length > 0) {
|
||||||
const { bucket, prefix } = pathSlice(history.location.pathname)
|
dispatch(setList(buckets))
|
||||||
if (bucket && buckets.indexOf(bucket) > -1) {
|
if (bucket && buckets.indexOf(bucket) > -1) {
|
||||||
dispatch(selectBucket(bucket, prefix))
|
dispatch(selectBucket(bucket, prefix))
|
||||||
} else {
|
} else {
|
||||||
dispatch(selectBucket(buckets[0]))
|
dispatch(selectBucket(buckets[0]))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
dispatch(selectBucket(""))
|
if (bucket) {
|
||||||
history.replace("/")
|
dispatch(setList([bucket]))
|
||||||
|
dispatch(selectBucket(bucket, prefix))
|
||||||
|
} else {
|
||||||
|
dispatch(selectBucket(""))
|
||||||
|
history.replace("/")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
if (bucket && err.message === "Access Denied." || err.message.indexOf('Prefix access is denied') > -1 ) {
|
||||||
|
dispatch(setList([bucket]))
|
||||||
|
dispatch(selectBucket(bucket, prefix))
|
||||||
|
} else {
|
||||||
|
dispatch(
|
||||||
|
alertActions.set({
|
||||||
|
type: "danger",
|
||||||
|
message: err.message,
|
||||||
|
autoClear: true,
|
||||||
|
})
|
||||||
|
)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user