Repository URL to install this package:
|
Version:
3.12.20 ▾
|
var _excluded = ["files"];
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); }
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; }
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); }
import { FileMoveTo, Remove, Rename, Share, EditImage, More, Download, MoreDetails, Tag, NoUrlsFlush, Link, Label, Comment2Left } from '@scaleflex/icons';
import isImage from '@filerobot/utils/lib/isImage';
import { addLabelSubListItemsFn } from './addLabelSubListItemsFn';
import { selectIsUserAuth, selectIsUserPermittedToShare } from '@filerobot/core/lib/slices/user.slice';
import { useSelector } from 'react-redux';
import { IMAGE_EDITOR_MODES, PERMISSIONS, PLUGINS_IDS } from '@filerobot/utils/lib/constants';
import addToItem from './addToItem';
import PropertiesItems from './PropertiesOptions';
import ShareOptions from '../ShareOptions';
import DownloadOptions from '../DownloadOptions';
import { isBackgroundRemoved, isRemoveBackgroundNotSupported } from '../../../utils/removeBackground';
import { fileWindowUpdated, imageEditorOpened, itemRenameOpened, selectFileWindowFor, sharePanelOpened } from '../../../slices/panels.slice';
import { useExplorer } from '../../../hooks';
import { useAkeneoAssetModal, useDeleteItemsModal, useDownloadConsentModal, useMoveItemsModal } from '../../Modals';
import { downloadOneFile, emitExportEvent } from '../../../slices/downloads.slice';
import FileCardOptions from './FileCardOptions';
import { selectIsFavoritesView, selectIsLabelsView, selectIsLabelsViewAvailable, selectIsShareboxView } from '../../../slices/views.slice';
import { activateLabelsView, detachFilesLabels, selectActiveLabelSid } from '../../../slices/labels.slice';
import { unFavoriteFiles } from '../../../thunks/favorites.thunks';
import { TABS_IDS } from '../../FileWindowPanel/tabs/tabs.constants';
import prepareExportedFilesLinks from '../../../utils/prepareExportedFilesLinks';
import { jsx as _jsx } from "react/jsx-runtime";
var moveTo = function moveTo(_ref) {
var filesUuids = _ref.filesUuids,
triggerMoveItemsModal = _ref.triggerMoveItemsModal;
triggerMoveItemsModal({
filesUuids: filesUuids
});
};
var renameFile = function renameFile(_ref2) {
var files = _ref2.files,
dispatch = _ref2.dispatch;
// .id for pre-upload case
dispatch(itemRenameOpened(files[0].uuid || files[0].id));
};
var download = function download(_ref3) {
var files = _ref3.files,
dispatch = _ref3.dispatch,
preventDownloadDefaultBehavior = _ref3.preventDownloadDefaultBehavior,
triggerDownloadConsentModal = _ref3.triggerDownloadConsentModal;
var file = files[0];
if (!preventDownloadDefaultBehavior) {
triggerDownloadConsentModal(function () {
return dispatch(downloadOneFile({
file: file
}));
});
} else {
dispatch(emitExportEvent(prepareExportedFilesLinks([file])));
}
};
// TODO: Uncomment when more options available
// const isVideoActions = (currentSelection) => {
// const hideOption = !isSupportedVideo(currentSelection[0]) || currentSelection[0].info?.playlists
// return hideOption
// }
var editImage = function editImage(_ref4) {
var files = _ref4.files,
dispatch = _ref4.dispatch;
var mode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : IMAGE_EDITOR_MODES.DEFAULT;
var showBackButton = arguments.length > 2 ? arguments[2] : undefined;
var hideSavingOptions = arguments.length > 3 ? arguments[3] : undefined;
dispatch(imageEditorOpened({
file: files[0],
mode: mode,
showBackButton: showBackButton,
hideSavingOptions: hideSavingOptions
}));
};
var deleteFile = function deleteFile(_ref5) {
var filesUuids = _ref5.filesUuids,
filesIdsBeforeUpload = _ref5.filesIdsBeforeUpload,
triggerDeleteItemsModal = _ref5.triggerDeleteItemsModal;
triggerDeleteItemsModal({
filesUuids: filesUuids,
filesIdsBeforeUpload: filesIdsBeforeUpload
});
};
export var hideIfNotActiveLabelView = function hideIfNotActiveLabelView(_ref6) {
var isLabelsViewAvailable = _ref6.isLabelsViewAvailable,
isLabelsView = _ref6.isLabelsView;
return Boolean(isLabelsViewAvailable && !isLabelsView);
};
var editImgHide = function editImgHide(_ref7) {
var checkPluginExistence = _ref7.checkPluginExistence,
files = _ref7.files,
noImgOperationsAndDownload = _ref7.noImgOperationsAndDownload;
return !checkPluginExistence(PLUGINS_IDS.IMAGE_EDITOR) || !isImage(files === null || files === void 0 ? void 0 : files[0]) || noImgOperationsAndDownload;
};
var hideDetailsOption = function hideDetailsOption(_ref8) {
var checkUserPermissions = _ref8.checkUserPermissions;
return !checkUserPermissions([PERMISSIONS.DISPLAY]);
};
var hideDownloadOption = function hideDownloadOption(_ref9) {
var noImgOperationsAndDownload = _ref9.noImgOperationsAndDownload;
return noImgOperationsAndDownload;
};
var hideShareOption = function hideShareOption(_ref10) {
var isShareboxView = _ref10.isShareboxView,
isFastToken = _ref10.isFastToken,
isUserPermittedToShare = _ref10.isUserPermittedToShare;
return isFastToken || isShareboxView || !isUserPermittedToShare;
};
var hideAddToFavoritesOption = function hideAddToFavoritesOption(files) {
var _files$;
return files.length === 1 && (files === null || files === void 0 ? void 0 : (_files$ = files[0]) === null || _files$ === void 0 ? void 0 : _files$.is_favorite) || files.filter(function (file) {
return file;
}).every(function (selectedItem) {
return selectedItem.is_favorite;
});
};
var hideAddToOption = function hideAddToOption(_ref11) {
var isShareboxView = _ref11.isShareboxView,
files = _ref11.files,
isUserAuth = _ref11.isUserAuth,
isFastToken = _ref11.isFastToken;
return !isUserAuth || isShareboxView || isFastToken || hideAddToFavoritesOption(files);
};
var hideLabelsOption = function hideLabelsOption(_ref12) {
var isLabelsView = _ref12.isLabelsView,
checkUserPermissions = _ref12.checkUserPermissions,
isLabelsViewAvailable = _ref12.isLabelsViewAvailable,
isFastToken = _ref12.isFastToken;
return !hideIfNotActiveLabelView({
isLabelsViewAvailable: isLabelsViewAvailable,
isLabelsView: isLabelsView
}) || isFastToken || !checkUserPermissions([PERMISSIONS.LABEL_MANAGE]);
};
var hideEditImageOption = function hideEditImageOption(_ref13) {
var checkUserPermissions = _ref13.checkUserPermissions,
checkPluginExistence = _ref13.checkPluginExistence,
files = _ref13.files,
noImgOperationsAndDownload = _ref13.noImgOperationsAndDownload,
isFastToken = _ref13.isFastToken;
return editImgHide({
checkPluginExistence: checkPluginExistence,
files: files,
noImgOperationsAndDownload: noImgOperationsAndDownload
}) || isFastToken || !checkUserPermissions([PERMISSIONS.UPLOAD, PERMISSIONS.FILE_META]);
};
var hideAkeneoOption = function hideAkeneoOption(_ref14) {
var akeneoConfig = _ref14.akeneoConfig,
files = _ref14.files;
return !(akeneoConfig !== null && akeneoConfig !== void 0 && akeneoConfig.enabled) || files.length > 1;
};
var hideRenameOption = function hideRenameOption(_ref15) {
var checkUserPermissions = _ref15.checkUserPermissions;
return !checkUserPermissions([PERMISSIONS.FILE_RENAME]);
};
var hideMoveToOption = function hideMoveToOption(_ref16) {
var checkUserPermissions = _ref16.checkUserPermissions,
isFavoritesViewMode = _ref16.isFavoritesViewMode;
return !checkUserPermissions([PERMISSIONS.FILE_MOVE]) || isFavoritesViewMode;
};
var hideRemoveFromFavoritesOption = function hideRemoveFromFavoritesOption(_ref17) {
var _files$2;
var files = _ref17.files;
return !((_files$2 = files[0]) !== null && _files$2 !== void 0 && _files$2.is_favorite);
};
var hideRemoveLabel = function hideRemoveLabel(_ref18) {
var isLabelsViewAvailable = _ref18.isLabelsViewAvailable,
isLabelsView = _ref18.isLabelsView,
checkUserPermissions = _ref18.checkUserPermissions;
return !isLabelsViewAvailable || !isLabelsView || !checkUserPermissions([PERMISSIONS.LABEL_MANAGE]);
};
var hideDeleteFileOption = function hideDeleteFileOption(_ref19) {
var checkUserPermissions = _ref19.checkUserPermissions;
return !checkUserPermissions([PERMISSIONS.FILE_DELETE]);
};
var SIZE = 14;
// Note: `content` if not a function it would be passed to i18n function so pass an i18n key
// otherwise it would be shown as it is passed
var PostUploadFileOptions = function PostUploadFileOptions() {
var triggerDeleteItemsModal = useDeleteItemsModal();
var triggerMoveItemsModal = useMoveItemsModal();
var triggerAkeneoAssetModal = useAkeneoAssetModal();
var triggerDownloadConsentModal = useDownloadConsentModal();
var _useExplorer = useExplorer(),
checkUserPermissions = _useExplorer.checkUserPermissions,
checkPluginExistence = _useExplorer.checkPluginExistence,
_useExplorer$opts = _useExplorer.opts,
noImgOperationsAndDownload = _useExplorer$opts.noImgOperationsAndDownload,
showRemoveBackgroundOption = _useExplorer$opts.showRemoveBackgroundOption,
isFastToken = _useExplorer$opts.isFastToken,
preventDownloadDefaultBehavior = _useExplorer$opts.preventDownloadDefaultBehavior,
contextMenuSubTabs = _useExplorer$opts.contextMenuSubTabs,
akeneo = _useExplorer$opts.config.akeneo;
var isUserAuth = useSelector(selectIsUserAuth);
var activeLabelSid = useSelector(selectActiveLabelSid);
var isLabelsView = useSelector(selectIsLabelsView);
var isLabelsViewAvailable = useSelector(selectIsLabelsViewAvailable);
var isFavoritesViewMode = useSelector(selectIsFavoritesView);
var isShareboxView = useSelector(selectIsShareboxView);
var isUserPermittedToShare = useSelector(selectIsUserPermittedToShare);
return [{
content: 'mutualizedDetailsLabel',
onClick: function onClick(_ref20) {
var files = _ref20.files,
dispatch = _ref20.dispatch;
return dispatch(fileWindowUpdated(files[0].uuid || files[0].id));
},
prefix: function prefix(_ref21) {
var iconPrimaryColor = _ref21.iconPrimaryColor;
return /*#__PURE__*/_jsx(MoreDetails, {
color: iconPrimaryColor
});
},
key: 'DETAILS',
hideOption: function hideOption() {
return hideDetailsOptionBeforeUpload({
checkUserPermissions: checkUserPermissions
});
}
}, {
content: 'mutualizedDownloadButton',
onClick: function onClick(_ref22) {
var files = _ref22.files,
dispatch = _ref22.dispatch;
return download({
files: files,
dispatch: dispatch,
triggerDownloadConsentModal: triggerDownloadConsentModal,
preventDownloadDefaultBehavior: preventDownloadDefaultBehavior
});
},
subListItemsFn: function subListItemsFn(_ref23) {
var folders = _ref23.folders,
files = _ref23.files;
return DownloadOptions({
files: files,
folders: folders
});
},
hideOption: function hideOption() {
return hideDownloadOption({
noImgOperationsAndDownload: noImgOperationsAndDownload
});
},
prefix: function prefix(_ref24) {
var iconPrimaryColor = _ref24.iconPrimaryColor;
return /*#__PURE__*/_jsx(Download, {
color: iconPrimaryColor,
size: SIZE
});
},
key: 'DOWNLOAD_FILE'
}, {
content: 'mutualizedShareLabel',
onClick: function onClick(_ref25) {
var filesUuids = _ref25.filesUuids,
dispatch = _ref25.dispatch;
return dispatch(sharePanelOpened(filesUuids));
},
subListItemsFn: ShareOptions,
prefix: function prefix(_ref26) {
var iconPrimaryColor = _ref26.iconPrimaryColor;
return /*#__PURE__*/_jsx(Share, {
color: iconPrimaryColor,
size: SIZE
});
},
key: 'SHARE_FILE',
hideOption: function hideOption() {
return hideShareOption({
isShareboxView: isShareboxView,
isUserPermittedToShare: isUserPermittedToShare,
isFastToken: isFastToken
});
}
}, addToItem({
hideAddToFavoritesOption: hideAddToFavoritesOption,
hideAddToOption: hideAddToOption,
isShareboxView: isShareboxView,
isFastToken: isFastToken,
isUserAuth: isUserAuth
}), {
content: /*#__PURE__*/_jsx("div", {
className: "filerobot-c-horizontal-separator"
}),
disabled: true,
key: 'SEPARATOR_1',
hideOption: function hideOption(_ref27) {
var files = _ref27.files;
return hideDetailsOption({
checkUserPermissions: checkUserPermissions
}) && hideDownloadOption({
noImgOperationsAndDownload: noImgOperationsAndDownload
}) && hideShareOption({
isShareboxView: isShareboxView,
isUserPermittedToShare: isUserPermittedToShare,
isFastToken: isFastToken
}) && hideAddToOption({
isUserAuth: isUserAuth,
isShareboxView: isShareboxView,
files: files
}) || hideLabelsOption({
isLabelsView: isLabelsView,
checkUserPermissions: checkUserPermissions,
isLabelsViewAvailable: isLabelsViewAvailable,
isFastToken: isFastToken
}) && hideEditImageOption({
checkUserPermissions: checkUserPermissions,
checkPluginExistence: checkPluginExistence,
files: files,
noImgOperationsAndDownload: noImgOperationsAndDownload
}) && hideAkeneoOption({
akeneoConfig: akeneo,
files: files
});
}
}, {
content: 'mutualizedLabelsLabel',
onClick: function onClick(_ref28) {
var dispatch = _ref28.dispatch,
toggleContextMenu = _ref28.toggleContextMenu;
toggleContextMenu();
dispatch(activateLabelsView());
},
subListItemsFn: addLabelSubListItemsFn,
prefix: function prefix(_ref29) {
var iconPrimaryColor = _ref29.iconPrimaryColor;
return /*#__PURE__*/_jsx(Label, {
color: iconPrimaryColor,
size: SIZE
});
},
key: 'LABELS',
hideOption: function hideOption() {
return hideLabelsOption({
isLabelsView: isLabelsView,
checkUserPermissions: checkUserPermissions,
isLabelsViewAvailable: isLabelsViewAvailable,
isFastToken: isFastToken
});
},
keepMenuOpened: true
}, {
content: 'mutualizedTagsLabel',
onClick: function onClick(_ref30) {
var currentSelection = _ref30.currentSelection,
toggleItemsCard = _ref30.toggleItemsCard;
return toggleItemsCard(currentSelection, true, 'TAGS');
},
prefix: function prefix(_ref31) {
var iconPrimaryColor = _ref31.iconPrimaryColor;
return /*#__PURE__*/_jsx(Tag, {
color: iconPrimaryColor
});
},
key: 'TAGS',
// TODO: Uncomment when tags logic is ready
// hideOption: ({ showTags }) => !showTags,
hideOption: function hideOption() {
return true;
},
disabled: true,
tooltip: '[WIP]: tags view in manage assets'
}, {
content: 'mutualizedEditImageLabel',
onClick: editImage,
hideOption: function hideOption(_ref32) {
var files = _ref32.files;
return hideEditImageOption({
checkUserPermissions: checkUserPermissions,
checkPluginExistence: checkPluginExistence,
files: files,
noImgOperationsAndDownload: noImgOperationsAndDownload,
isFastToken: isFastToken
});
},
prefix: function prefix(_ref33) {
var iconPrimaryColor = _ref33.iconPrimaryColor;
return /*#__PURE__*/_jsx(EditImage, {
color: iconPrimaryColor,
size: SIZE
});
},
key: 'EDIT_IMG'
}, {
content: 'mutualizedAkeneoLabel',
onClick: triggerAkeneoAssetModal,
hideOption: function hideOption(_ref34) {
var files = _ref34.files;
return hideAkeneoOption({
akeneoConfig: akeneo,
files: files
});
},
prefix: function prefix(_ref35) {
var iconPrimaryColor = _ref35.iconPrimaryColor;
return /*#__PURE__*/_jsx(Link, {
color: iconPrimaryColor,
size: SIZE
});
},
key: 'AKENEO'
}, {
content: /*#__PURE__*/_jsx("div", {
className: "filerobot-c-horizontal-separator"
}),
disabled: true,
hideOption: function hideOption(_ref36) {
var files = _ref36.files;
return (showRemoveBackgroundOption ? isRemoveBackgroundNotSupported(files) || isBackgroundRemoved(files) : true) && !isImage(files === null || files === void 0 ? void 0 : files[0]);
},
key: 'SEPARATOR_2'
}, {
content: 'mutualizedCommentsLabel',
onClick: function onClick(_ref37) {
var dispatch = _ref37.dispatch,
filesUuids = _ref37.filesUuids;
dispatch(fileWindowUpdated({
"for": filesUuids[0],
tabId: TABS_IDS.COMMENTS
}));
},
prefix: function prefix(_ref38) {
var iconPrimaryColor = _ref38.iconPrimaryColor;
return /*#__PURE__*/_jsx(Comment2Left, {
color: iconPrimaryColor,
size: SIZE
});
},
hideOption: function hideOption(_ref39) {
var files = _ref39.files;
return !isUserAuth || !isImage(files[0]) || isFastToken;
},
key: 'COMMENTS'
}, {
content: 'mutualizedMoreActions',
subListItemsFn: function subListItemsFn(passedCommonProps) {
return PropertiesItems(_objectSpread({
tabs: contextMenuSubTabs.fileMore,
subTabs: FileCardOptions
}, passedCommonProps));
},
prefix: function prefix(_ref40) {
var iconPrimaryColor = _ref40.iconPrimaryColor;
return /*#__PURE__*/_jsx(More, {
color: iconPrimaryColor,
size: SIZE
});
},
key: 'FILE_PROPERTIES',
hideOption: function hideOption(_ref41) {
var files = _ref41.files;
return showRemoveBackgroundOption ? isRemoveBackgroundNotSupported(files) || isBackgroundRemoved(files) || isFastToken : true;
}
}, {
content: /*#__PURE__*/_jsx("div", {
className: "filerobot-c-horizontal-separator"
}),
disabled: true,
key: 'SEPARATOR_3',
hideOption: function hideOption() {
return hideRenameOption({
checkUserPermissions: checkUserPermissions
}) && hideMoveToOption({
checkUserPermissions: checkUserPermissions,
isFavoritesViewMode: isFavoritesViewMode
});
}
}, {
content: 'mutualizedRenameButtonLabel',
onClick: renameFile,
keepItemSelected: true,
prefix: function prefix(_ref42) {
var iconPrimaryColor = _ref42.iconPrimaryColor;
return /*#__PURE__*/_jsx(Rename, {
color: iconPrimaryColor,
size: SIZE
});
},
key: 'RENAME_FILE',
hideOption: function hideOption() {
return hideRenameOption({
checkUserPermissions: checkUserPermissions
});
}
}, {
content: 'mutualizedMoveToLabel',
onClick: function onClick(_ref43) {
var filesUuids = _ref43.filesUuids;
return moveTo({
filesUuids: filesUuids,
triggerMoveItemsModal: triggerMoveItemsModal
});
},
prefix: function prefix(_ref44) {
var iconPrimaryColor = _ref44.iconPrimaryColor;
return /*#__PURE__*/_jsx(FileMoveTo, {
color: iconPrimaryColor,
size: SIZE
});
},
key: 'MOVE_FILE',
hideOption: function hideOption() {
return hideMoveToOption({
checkUserPermissions: checkUserPermissions,
isFavoritesViewMode: isFavoritesViewMode
});
},
disabled: false
}, {
content: /*#__PURE__*/_jsx("div", {
className: "filerobot-c-horizontal-separator"
}),
disabled: true,
key: 'SEPARATOR_4',
hideOption: function hideOption(_ref45) {
var files = _ref45.files;
return hideRemoveFromFavoritesOption({
files: files
}) && hideRemoveLabel({
isLabelsViewAvailable: isLabelsViewAvailable,
isLabelsView: isLabelsView,
checkUserPermissions: checkUserPermissions
}) && hideDeleteFileOption({
checkUserPermissions: checkUserPermissions
});
}
}, {
content: 'mutualizedRemoveFromFavoritesLabel',
onClick: function onClick(_ref46) {
var filesUuids = _ref46.filesUuids,
dispatch = _ref46.dispatch;
return dispatch(unFavoriteFiles(filesUuids));
},
prefix: function prefix(_ref47) {
var iconPrimaryColor = _ref47.iconPrimaryColor;
return /*#__PURE__*/_jsx(NoUrlsFlush, {
color: iconPrimaryColor,
size: SIZE
});
},
hideOption: function hideOption(_ref48) {
var files = _ref48.files;
return hideRemoveFromFavoritesOption({
files: files
});
},
key: 'REMOVE_FROM_FAVORITES'
}, {
content: 'mutualizedRemoveLabel',
onClick: function onClick(_ref49) {
var filesUuids = _ref49.filesUuids,
dispatch = _ref49.dispatch,
toggleContextMenu = _ref49.toggleContextMenu,
info = _ref49.info,
i18n = _ref49.i18n;
dispatch(detachFilesLabels({
filesUuids: filesUuids,
labelsSids: [activeLabelSid],
toggleContextMenu: toggleContextMenu
})).then(function () {
info(i18n('labelViewModelLabelsDetachedInfo', {
smart_count: filesUuids.length
}), 'success');
});
},
prefix: function prefix(_ref50) {
var iconPrimaryColor = _ref50.iconPrimaryColor;
return /*#__PURE__*/_jsx(NoUrlsFlush, {
color: iconPrimaryColor,
size: SIZE
});
},
key: 'REMOVE_LABEL',
hideOption: function hideOption() {
return hideRemoveLabel({
isLabelsViewAvailable: isLabelsViewAvailable,
isLabelsView: isLabelsView,
checkUserPermissions: checkUserPermissions
});
}
}, {
content: 'mutualizedDeleteButtonLabel',
// filesIdsBeforeUpload is coming from the customized items prop not passed as common prop.
onClick: function onClick(_ref51) {
var filesUuids = _ref51.filesUuids,
filesIdsBeforeUpload = _ref51.filesIdsBeforeUpload;
return deleteFile({
filesUuids: filesUuids,
filesIdsBeforeUpload: filesIdsBeforeUpload,
triggerDeleteItemsModal: triggerDeleteItemsModal
});
},
prefix: function prefix(_ref52) {
var iconPrimaryColor = _ref52.iconPrimaryColor;
return /*#__PURE__*/_jsx(Remove, {
color: iconPrimaryColor,
size: SIZE
});
},
key: 'DELETE_FILE',
hideOption: function hideOption() {
return hideDeleteFileOption({
checkUserPermissions: checkUserPermissions
});
},
hoverTheme: 'danger' // in case we need to change the item's hover styles from css we could use this prop.
}];
};
var hideDetailsOptionBeforeUpload = function hideDetailsOptionBeforeUpload(_ref53) {
var checkUserPermissions = _ref53.checkUserPermissions,
isFileWindowOpened = _ref53.isFileWindowOpened;
return !checkUserPermissions([PERMISSIONS.DISPLAY]) || isFileWindowOpened;
};
var hideEditImageOptionBeforeUpload = function hideEditImageOptionBeforeUpload(_ref54) {
var _files$3;
var files = _ref54.files,
others = _objectWithoutProperties(_ref54, _excluded);
return ((_files$3 = files[0]) === null || _files$3 === void 0 ? void 0 : _files$3.isRemote) || editImgHide(_objectSpread({
files: files
}, others));
};
export var BeforeUploadFileOptions = function BeforeUploadFileOptions() {
var _useExplorer2 = useExplorer(),
checkUserPermissions = _useExplorer2.checkUserPermissions,
removeUploadFiles = _useExplorer2.removeUploadFiles,
checkPluginExistence = _useExplorer2.checkPluginExistence,
noImgOperationsAndDownload = _useExplorer2.opts.noImgOperationsAndDownload;
var isFileWindowOpened = useSelector(selectFileWindowFor);
var triggerDeleteItemsModal = useDeleteItemsModal();
var handleDeleteBeforeUploadItem = function handleDeleteBeforeUploadItem(filesUuids) {
triggerDeleteItemsModal({
filesUuids: filesUuids,
modalPrimaryButtonColor: 'error-primary',
onConfirm: function onConfirm(_ref55) {
var closeModal = _ref55.closeModal;
removeUploadFiles(filesUuids);
closeModal();
}
});
};
return [{
content: 'mutualizedDetailsLabel',
onClick: function onClick(_ref56) {
var files = _ref56.files,
dispatch = _ref56.dispatch;
return dispatch(fileWindowUpdated(files[0].uuid || files[0].id));
},
prefix: function prefix(_ref57) {
var iconPrimaryColor = _ref57.iconPrimaryColor;
return /*#__PURE__*/_jsx(MoreDetails, {
color: iconPrimaryColor
});
},
key: 'DETAILS',
hideOption: function hideOption() {
return hideDetailsOptionBeforeUpload({
checkUserPermissions: checkUserPermissions,
isFileWindowOpened: isFileWindowOpened
});
}
}, {
content: 'mutualizedEditImageLabel',
onClick: function onClick(props) {
return editImage(props, IMAGE_EDITOR_MODES.DEFAULT, true, true);
},
hideOption: function hideOption(_ref58) {
var files = _ref58.files;
return hideEditImageOptionBeforeUpload({
files: files,
checkPluginExistence: checkPluginExistence,
noImgOperationsAndDownload: noImgOperationsAndDownload
});
},
prefix: function prefix(_ref59) {
var iconPrimaryColor = _ref59.iconPrimaryColor;
return /*#__PURE__*/_jsx(EditImage, {
color: iconPrimaryColor
});
},
key: 'EDIT_IMG'
}, {
content: /*#__PURE__*/_jsx("div", {
className: "filerobot-c-horizontal-separator"
}),
disabled: true,
key: 'SEPARATOR_5',
hideOption: function hideOption(_ref60) {
var files = _ref60.files;
return hideDetailsOptionBeforeUpload({
checkUserPermissions: checkUserPermissions
}) && hideEditImageOptionBeforeUpload({
files: files,
checkPluginExistence: checkPluginExistence,
noImgOperationsAndDownload: noImgOperationsAndDownload
});
}
}, {
content: 'mutualizedRenameButtonLabel',
onClick: renameFile,
keepItemSelected: true,
prefix: function prefix(_ref61) {
var iconPrimaryColor = _ref61.iconPrimaryColor;
return /*#__PURE__*/_jsx(Rename, {
color: iconPrimaryColor
});
},
key: 'RENAME_FILE'
}, {
content: /*#__PURE__*/_jsx("div", {
className: "filerobot-c-horizontal-separator"
}),
disabled: true,
key: 'SEPARATOR_6'
}, {
content: 'mutualizedDeleteButtonLabel',
onClick: function onClick(_ref62) {
var filesUuids = _ref62.filesUuids;
return handleDeleteBeforeUploadItem(filesUuids);
},
prefix: function prefix(_ref63) {
var iconPrimaryColor = _ref63.iconPrimaryColor;
return /*#__PURE__*/_jsx(Remove, {
color: iconPrimaryColor
});
},
key: 'DELETE_FILE'
}];
};
export default PostUploadFileOptions;