+
+
+ )
+ }
+}
+
+const mapDispatchToProps = dispatch => {
+ return {
+ deleteBucket: bucket => dispatch(actionsBuckets.deleteBucket(bucket)),
+ showBucketPolicy: () => dispatch(actionsBuckets.showBucketPolicy())
+ }
+}
+
+export default connect(state => state, mapDispatchToProps)(BucketDropdown)
diff --git a/browser/app/js/buckets/BucketList.js b/browser/app/js/buckets/BucketList.js
index 303b7e73c..45e6cda14 100644
--- a/browser/app/js/buckets/BucketList.js
+++ b/browser/app/js/buckets/BucketList.js
@@ -28,7 +28,7 @@ export class BucketList extends React.Component {
componentWillMount() {
const { fetchBuckets, setBucketList, selectBucket } = this.props
if (web.LoggedIn()) {
- fetchBuckets()
+ fetchBuckets("list")
} else {
const { bucket, prefix } = pathSlice(history.location.pathname)
if (bucket) {
@@ -63,7 +63,7 @@ const mapStateToProps = state => {
const mapDispatchToProps = dispatch => {
return {
- fetchBuckets: () => dispatch(actionsBuckets.fetchBuckets()),
+ fetchBuckets: action => dispatch(actionsBuckets.fetchBuckets(action)),
setBucketList: buckets => dispatch(actionsBuckets.setList(buckets)),
selectBucket: bucket => dispatch(actionsBuckets.selectBucket(bucket))
}
diff --git a/browser/app/js/buckets/BucketPolicyModal.js b/browser/app/js/buckets/BucketPolicyModal.js
new file mode 100644
index 000000000..4b7d8ece0
--- /dev/null
+++ b/browser/app/js/buckets/BucketPolicyModal.js
@@ -0,0 +1,61 @@
+/*
+ * Minio Cloud Storage (C) 2018 Minio, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import React from "react"
+import { connect } from "react-redux"
+import { Modal, ModalHeader } from "react-bootstrap"
+import * as actionsBuckets from "./actions"
+import PolicyInput from "./PolicyInput"
+import Policy from "./Policy"
+
+export const BucketPolicyModal = ({ showBucketPolicy, currentBucket, hideBucketPolicy, policies }) => {
+ return (
+
+
+ Bucket Policy (
+ { currentBucket })
+
+
+
+
+ { policies.map((policy, i) =>
+ ) }
+
+
+ )
+}
+
+const mapStateToProps = state => {
+ return {
+ currentBucket: state.buckets.currentBucket,
+ showBucketPolicy: state.buckets.showBucketPolicy,
+ policies: state.buckets.policies
+ }
+}
+
+const mapDispatchToProps = dispatch => {
+ return {
+ hideBucketPolicy: () => dispatch(actionsBuckets.hideBucketPolicy())
+ }
+}
+
+export default connect(mapStateToProps, mapDispatchToProps)(BucketPolicyModal)
\ No newline at end of file
diff --git a/browser/app/js/buckets/Policy.js b/browser/app/js/buckets/Policy.js
new file mode 100644
index 000000000..2256a9ae5
--- /dev/null
+++ b/browser/app/js/buckets/Policy.js
@@ -0,0 +1,93 @@
+/*
+ * Minio Cloud Storage (C) 2018 Minio, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { READ_ONLY, WRITE_ONLY, READ_WRITE } from '../constants'
+
+import React from "react"
+import { connect } from "react-redux"
+import classnames from "classnames"
+import * as actionsBuckets from "./actions"
+import * as actionsAlert from "../alert/actions"
+import web from "../web"
+
+export class Policy extends React.Component {
+ removePolicy(e) {
+ e.preventDefault()
+ const {currentBucket, prefix, fetchPolicies, showAlert} = this.props
+ web.
+ SetBucketPolicy({
+ bucketName: currentBucket,
+ prefix: prefix,
+ policy: 'none'
+ })
+ .then(() => {
+ fetchPolicies(currentBucket)
+ })
+ .catch(e => showAlert('danger', e.message))
+ }
+
+ render() {
+ const {policy, prefix} = this.props
+ let newPrefix = prefix
+
+ if (newPrefix === '')
+ newPrefix = '*'
+
+ return (
+
+
+ { newPrefix }
+
+
+
+
+
+
+
+
+ )
+ }
+}
+
+const mapStateToProps = state => {
+ return {
+ currentBucket: state.buckets.currentBucket
+ }
+}
+
+const mapDispatchToProps = dispatch => {
+ return {
+ fetchPolicies: bucket => dispatch(actionsBuckets.fetchPolicies(bucket)),
+ showAlert: (type, message) =>
+ dispatch(actionsAlert.set({ type: type, message: message }))
+ }
+}
+
+export default connect(mapStateToProps, mapDispatchToProps)(Policy)
\ No newline at end of file
diff --git a/browser/app/js/buckets/PolicyInput.js b/browser/app/js/buckets/PolicyInput.js
new file mode 100644
index 000000000..2ed103262
--- /dev/null
+++ b/browser/app/js/buckets/PolicyInput.js
@@ -0,0 +1,115 @@
+/*
+ * Minio Cloud Storage (C) 2018 Minio, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { READ_ONLY, WRITE_ONLY, READ_WRITE } from '../constants'
+
+import React from "react"
+import { connect } from "react-redux"
+import classnames from "classnames"
+import * as actionsBuckets from "./actions"
+import * as actionsAlert from "../alert/actions"
+import web from "../web"
+
+export class PolicyInput extends React.Component {
+ componentDidMount() {
+ const { currentBucket, fetchPolicies } = this.props
+ fetchPolicies(currentBucket)
+ }
+
+ componentWillUnmount() {
+ const { setPolicies } = this.props
+ setPolicies([])
+ }
+
+ handlePolicySubmit(e) {
+ e.preventDefault()
+ const { currentBucket, fetchPolicies, showAlert } = this.props
+
+ if (this.prefix.value === "*")
+ this.prefix.value = ""
+
+ let policyAlreadyExists = this.props.policies.some(
+ elem => this.prefix.value === elem.prefix && this.policy.value === elem.policy
+ )
+ if (policyAlreadyExists) {
+ showAlert("danger", "Policy for this prefix already exists.")
+ return
+ }
+
+ web.
+ SetBucketPolicy({
+ bucketName: currentBucket,
+ prefix: this.prefix.value,
+ policy: this.policy.value
+ })
+ .then(() => {
+ fetchPolicies(currentBucket)
+ this.prefix.value = ''
+ })
+ .catch(e => showAlert("danger", e.message))
+ }
+
+ render() {
+ return (
+
+