Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
@filerobot/explorer / lib / components / AssetsList / ListView / FoldersSection / FoldersSectionTableRow.js
Size: Mime:
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
var _excluded = ["folderUuid", "handleNavigatingThroughArrows", "handleContextMenuToggle", "visibleColumns", "openFolderOnClick"];
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
import { useSelector, useDispatch } from 'react-redux';
import { TableCell, TooltipV2, IconButton } from '@scaleflex/ui/core';
import { useTheme } from '@scaleflex/ui/theme/hooks';
import { Folder, More } from '@scaleflex/icons';
import { PC } from '@filerobot/common';
import { LIST_VIEW_FOLDERS_COLS_IDS } from '@filerobot/utils/lib/constants';
import FileInfo from '@filerobot/explorer/lib/components/FileItem/FileInfo';
import humanReadableDateWithTranslations from '@filerobot/utils/lib/humanReadableDateWithTranslations';
import { getVisibilityObject } from '@filerobot/utils/lib/visibility';
import DnD from '../../../DnD';
import { useExplorer } from '../../../../hooks';
import { selectIsItemChecked, toggleSelection } from '../../../../slices/selections.slice';
import { selectRenameItemFor } from '../../../../slices/panels.slice';
import Styled from '../ListView.styled';
import { selectFolderByUuid } from '../../../../slices/folders.slice';
import ignoreEvent from '@filerobot/utils/lib/ignoreEvent';
import { selectIsShareboxView } from '../../../../slices/views.slice';
import { jsx as _jsx } from "react/jsx-runtime";
import { jsxs as _jsxs } from "react/jsx-runtime";
var checkboxOnChange = function checkboxOnChange() {};
var COL_EMPTY_PLACEHOLDER = '---';
var FoldersSectionTableRow = function FoldersSectionTableRow(_ref) {
  var folderUuid = _ref.folderUuid,
    handleNavigatingThroughArrows = _ref.handleNavigatingThroughArrows,
    handleContextMenuToggle = _ref.handleContextMenuToggle,
    visibleColumns = _ref.visibleColumns,
    openFolderOnClick = _ref.openFolderOnClick,
    props = _objectWithoutProperties(_ref, _excluded);
  var dispatch = useDispatch();
  var folder = useSelector(function (state) {
    return selectFolderByUuid(state, folderUuid) || {};
  });
  var uuid = folder.uuid,
    _folder$visibility = folder.visibility,
    visibility = _folder$visibility === void 0 ? {} : _folder$visibility,
    modifiedDate = folder.modifiedDate,
    modifiedAt = folder.modified_at,
    updatedAt = folder.updated_at,
    _folder$count = folder.count,
    _folder$count2 = _folder$count === void 0 ? {} : _folder$count,
    filesDirect = _folder$count2.files_direct,
    isLoading = folder.loading;
  var theme = useTheme();
  var _useExplorer = useExplorer(),
    i18n = _useExplorer.i18n,
    showMeta = _useExplorer.opts.showMeta;
  var isChecked = useSelector(function (state) {
    return selectIsItemChecked(state, uuid);
  });
  var renameItemFor = useSelector(selectRenameItemFor);
  var isShareboxView = useSelector(selectIsShareboxView);
  var _getVisibilityObject = getVisibilityObject(visibility),
    visibilityI18nLabel = _getVisibilityObject.i18nLabel,
    VisibilityIcon = _getVisibilityObject.icon;
  var lastModify = modifiedAt || updatedAt || modifiedDate;
  var lastModifyTime = lastModify ? humanReadableDateWithTranslations(lastModify, i18n) : COL_EMPTY_PLACEHOLDER;
  var isItemBeingRenamed = renameItemFor === uuid;
  var iconPrimaryColor = theme.palette[PC.IconsPrimary];
  var handleSelect = function handleSelect(event) {
    if (isLoading || isShareboxView) {
      return;
    }
    event.stopPropagation(); // for avoiding triggering the view's parent event which is resetting/clearing the selections.
    dispatch(toggleSelection({
      event: event,
      itemUuid: uuid,
      isMultiple: event.isMultiple
    }));
  };
  return /*#__PURE__*/_jsx(DnD, {
    disableDrag: isItemBeingRenamed || isLoading,
    disableDrop: isLoading,
    item: folder,
    children: /*#__PURE__*/_jsxs(Styled.TableRow, {
      hover: true,
      selected: isChecked,
      onClick: handleSelect,
      onDoubleClick: function onDoubleClick(e) {
        return isLoading ? ignoreEvent(e) : openFolderOnClick(folder);
      },
      onContextMenu: function onContextMenu(event) {
        return isLoading || isShareboxView ? ignoreEvent(event) : handleContextMenuToggle(event, folder);
      },
      onKeyDown: isLoading ? undefined : handleNavigatingThroughArrows,
      "data-filerobot-focusable-uuid": uuid,
      tabIndex: "-1",
      $loading: isLoading,
      children: [/*#__PURE__*/_jsx(TableCell, {
        style: {
          maxWidth: '300px'
        },
        children: /*#__PURE__*/_jsxs(Styled.HeaderCheckboxWrapper, {
          children: [!isShareboxView && /*#__PURE__*/_jsx(Styled.CheckBox, {
            // TODO: fix
            // we use onClick instead of onChange as onChange causes multiple rerenders
            // we add onChnage as empty function to avoid type warning
            onClick: function onClick(e) {
              e.isMultiple = true;
            },
            onChange: checkboxOnChange,
            checked: isChecked,
            onContextMenu: isLoading ? undefined : handleContextMenuToggle,
            size: "md"
          }), /*#__PURE__*/_jsx(Folder, {
            color: "#D8E0E8",
            width: "48px",
            height: "48px"
          }), /*#__PURE__*/_jsx(FileInfo, {
            file: folder,
            containerWidth: props.containerWidth,
            showMeta: showMeta,
            handleContextMenuToggle: isLoading ? undefined : props.handleContextMenuToggle,
            visibilities: props.visibilities,
            noTruncate: true,
            showFiles: props.showFiles,
            isListView: true
          })]
        })
      }), (visibleColumns === null || visibleColumns === void 0 ? void 0 : visibleColumns.includes(LIST_VIEW_FOLDERS_COLS_IDS.VISIBILITY)) && /*#__PURE__*/_jsx(TableCell, {
        children: VisibilityIcon && /*#__PURE__*/_jsx(TooltipV2, {
          arrow: true,
          position: "top",
          size: "md",
          title: i18n(visibilityI18nLabel),
          children: /*#__PURE__*/_jsx(VisibilityIcon, {
            size: 14,
            color: iconPrimaryColor
          })
        })
      }), (visibleColumns === null || visibleColumns === void 0 ? void 0 : visibleColumns.includes(LIST_VIEW_FOLDERS_COLS_IDS.AMOUNT)) && /*#__PURE__*/_jsx(TableCell, {
        children: /*#__PURE__*/_jsx("label", {
          children: filesDirect
        })
      }), (visibleColumns === null || visibleColumns === void 0 ? void 0 : visibleColumns.includes(LIST_VIEW_FOLDERS_COLS_IDS.LAST_MODIFY)) && /*#__PURE__*/_jsx(TableCell, {
        children: /*#__PURE__*/_jsx(Styled.ModifyAtLabel, {
          title: lastModifyTime,
          children: lastModifyTime
        })
      }), /*#__PURE__*/_jsx(TableCell, {
        children: !isShareboxView && /*#__PURE__*/_jsx(IconButton, {
          onClick: function onClick(event) {
            return handleContextMenuToggle(event, folder);
          },
          size: "sm",
          color: "basic",
          children: function children(props) {
            return /*#__PURE__*/_jsx(More, _objectSpread({}, props));
          }
        })
      })]
    })
  });
};
export default FoldersSectionTableRow;