storj.io/minio@v0.0.0-20230509071714-0cbc90f649b1/browser/app/js/buckets/BucketDropdown.js (about)

     1  /*
     2   * MinIO Cloud Storage (C) 2018 MinIO, Inc.
     3   *
     4   * Licensed under the Apache License, Version 2.0 (the "License");
     5   * you may not use this file except in compliance with the License.
     6   * You may obtain a copy of the License at
     7   *
     8   *     http://www.apache.org/licenses/LICENSE-2.0
     9   *
    10   * Unless required by applicable law or agreed to in writing, software
    11   * distributed under the License is distributed on an "AS IS" BASIS,
    12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13   * See the License for the specific language governing permissions and
    14   * limitations under the License.
    15   */
    16  
    17  import React from "react"
    18  import classNames from "classnames"
    19  import { connect } from "react-redux"
    20  import * as actionsBuckets from "./actions"
    21  import { getCurrentBucket } from "./selectors"
    22  import Dropdown from "react-bootstrap/lib/Dropdown"
    23  
    24  export class BucketDropdown extends React.Component {
    25    constructor(props) {
    26      super(props)
    27      this.state = {
    28        showBucketDropdown: false
    29      }
    30    }
    31  
    32    toggleDropdown() {
    33      if (this.state.showBucketDropdown) {
    34        this.setState({
    35          showBucketDropdown: false
    36        })
    37      } else {
    38        this.setState({
    39          showBucketDropdown: true
    40        })
    41      }
    42    }
    43  
    44    render() {
    45      const { bucket, showBucketPolicy, deleteBucket, currentBucket } = this.props
    46      return (
    47        <Dropdown 
    48          open = {this.state.showBucketDropdown}
    49          onToggle = {this.toggleDropdown.bind(this)}
    50          className="bucket-dropdown" 
    51          id="bucket-dropdown"
    52        >
    53          <Dropdown.Toggle noCaret>
    54            <i className="zmdi zmdi-more-vert" />
    55          </Dropdown.Toggle>
    56          <Dropdown.Menu className="dropdown-menu-right">
    57            <li>
    58              <a 
    59                onClick={e => {
    60                  e.stopPropagation()
    61                  this.toggleDropdown()
    62                  showBucketPolicy()
    63                }}
    64              >
    65                Edit policy
    66              </a>
    67            </li>
    68            <li>
    69              <a 
    70                onClick={e => {
    71                  e.stopPropagation()
    72                  this.toggleDropdown()
    73                  deleteBucket(bucket)
    74                }}
    75              >
    76                Delete
    77              </a>
    78            </li>
    79          </Dropdown.Menu>
    80        </Dropdown>
    81      )
    82    }
    83  }
    84  
    85  const mapDispatchToProps = dispatch => {
    86    return {
    87      deleteBucket: bucket => dispatch(actionsBuckets.deleteBucket(bucket)),
    88      showBucketPolicy: () => dispatch(actionsBuckets.showBucketPolicy())
    89    }
    90  }
    91  
    92  export default connect(state => state, mapDispatchToProps)(BucketDropdown)