storj.io/minio@v0.0.0-20230509071714-0cbc90f649b1/browser/app/js/objects/ObjectItem.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 { connect } from "react-redux"
    19  import humanize from "humanize"
    20  import Moment from "moment"
    21  import { getDataType } from "../mime"
    22  import * as actions from "./actions"
    23  import { getCheckedList } from "./selectors"
    24  
    25  export const ObjectItem = ({
    26    name,
    27    contentType,
    28    size,
    29    lastModified,
    30    checked,
    31    checkObject,
    32    uncheckObject,
    33    actionButtons,
    34    onClick
    35  }) => {
    36    return (
    37      <div className={"fesl-row"} data-type={getDataType(name, contentType)}>
    38        <div className="fesl-item fesl-item-icon">
    39          <div className="fi-select">
    40            <input
    41              type="checkbox"
    42              name={name}
    43              checked={checked}
    44              onChange={() => {
    45                checked ? uncheckObject(name) : checkObject(name)
    46              }}
    47            />
    48            <i className="fis-icon" />
    49            <i className="fis-helper" />
    50          </div>
    51        </div>
    52        <div className="fesl-item fesl-item-name">
    53          <a
    54            href={getDataType(name, contentType) === "folder" ? name : "#"}
    55            onClick={e => {
    56              e.preventDefault()
    57              // onclick function is passed only when we have a prefix
    58              if (onClick) {
    59                onClick()
    60              } else {
    61                checked ? uncheckObject(name) : checkObject(name)
    62              }
    63            }}
    64          >
    65            {name}
    66          </a>
    67        </div>
    68        <div className="fesl-item fesl-item-size">{size}</div>
    69        <div className="fesl-item fesl-item-modified">{lastModified}</div>
    70        <div className="fesl-item fesl-item-actions">{actionButtons}</div>
    71      </div>
    72    )
    73  }
    74  
    75  const mapStateToProps = (state, ownProps) => {
    76    return {
    77      checked: getCheckedList(state).indexOf(ownProps.name) >= 0
    78    }
    79  }
    80  
    81  const mapDispatchToProps = dispatch => {
    82    return {
    83      checkObject: name => dispatch(actions.checkObject(name)),
    84      uncheckObject: name => dispatch(actions.uncheckObject(name))
    85    }
    86  }
    87  
    88  export default connect(mapStateToProps, mapDispatchToProps)(ObjectItem)