mirror of
https://github.com/minio/minio.git
synced 2025-01-11 15:03:22 -05:00
Prevent duplicate policy rows from being created (#4276)
This commit is contained in:
parent
fa3f6d75b6
commit
d1971b9a4d
@ -27,7 +27,7 @@ go get github.com/elazarl/go-bindata-assetfs/...
|
|||||||
yarn release
|
yarn release
|
||||||
```
|
```
|
||||||
|
|
||||||
This generates ui-assets.go in the current direcotry. Now do `make` in the parent directory to build the minio binary with the newly generated ``ui-assets.go``
|
This generates ui-assets.go in the current directory. Now do `make` in the parent directory to build the minio binary with the newly generated ``ui-assets.go``
|
||||||
|
|
||||||
### Run Minio Browser with live reload
|
### Run Minio Browser with live reload
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ import * as actions from '../actions'
|
|||||||
class PolicyInput extends Component {
|
class PolicyInput extends Component {
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const {web, dispatch} = this.props
|
const {web, dispatch} = this.props
|
||||||
|
this.prefix.focus()
|
||||||
web.ListAllBucketPolicies({
|
web.ListAllBucketPolicies({
|
||||||
bucketName: this.props.currentBucket
|
bucketName: this.props.currentBucket
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
@ -27,8 +28,23 @@ class PolicyInput extends Component {
|
|||||||
|
|
||||||
handlePolicySubmit(e) {
|
handlePolicySubmit(e) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
const {web, dispatch} = this.props
|
const {web, dispatch, currentBucket} = this.props
|
||||||
|
|
||||||
|
let prefix = currentBucket + '/' + this.prefix.value
|
||||||
|
let policy = this.policy.value
|
||||||
|
|
||||||
|
if (!prefix.endsWith('*')) prefix = prefix + '*'
|
||||||
|
|
||||||
|
let prefixAlreadyExists = this.props.policies.some(elem => prefix === elem.prefix)
|
||||||
|
|
||||||
|
if (prefixAlreadyExists) {
|
||||||
|
dispatch(actions.showAlert({
|
||||||
|
type: 'danger',
|
||||||
|
message: "Policy for this prefix already exists."
|
||||||
|
}))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
web.SetBucketPolicy({
|
web.SetBucketPolicy({
|
||||||
bucketName: this.props.currentBucket,
|
bucketName: this.props.currentBucket,
|
||||||
prefix: this.prefix.value,
|
prefix: this.prefix.value,
|
||||||
@ -36,8 +52,7 @@ class PolicyInput extends Component {
|
|||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
dispatch(actions.setPolicies([{
|
dispatch(actions.setPolicies([{
|
||||||
policy: this.policy.value,
|
policy, prefix
|
||||||
prefix: this.prefix.value + '*',
|
|
||||||
}, ...this.props.policies]))
|
}, ...this.props.policies]))
|
||||||
this.prefix.value = ''
|
this.prefix.value = ''
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user