Web: Files: added file operations to contextMenu, refactoring
This commit is contained in:
parent
547852e678
commit
72bc996a1a
@ -36,11 +36,12 @@ import {
|
|||||||
setDragItem,
|
setDragItem,
|
||||||
setMediaViewerData,
|
setMediaViewerData,
|
||||||
setProgressBarData,
|
setProgressBarData,
|
||||||
clearProgressData
|
clearProgressData,
|
||||||
|
setSelection
|
||||||
} from '../../../../../store/files/actions';
|
} from '../../../../../store/files/actions';
|
||||||
import { isFileSelected, getFileIcon, getFolderIcon, getFolderType, loopTreeFolders, isImage, isSound, isVideo } from '../../../../../store/files/selectors';
|
import { isFileSelected, getFileIcon, getFolderIcon, getFolderType, loopTreeFolders, isImage, isSound, isVideo } from '../../../../../store/files/selectors';
|
||||||
import store from "../../../../../store/store";
|
import store from "../../../../../store/store";
|
||||||
import { SharingPanel } from "../../../../panels";
|
import { SharingPanel, OperationsPanel } from "../../../../panels";
|
||||||
//import { getFilterByLocation } from "../../../../../helpers/converters";
|
//import { getFilterByLocation } from "../../../../../helpers/converters";
|
||||||
//import config from "../../../../../../package.json";
|
//import config from "../../../../../../package.json";
|
||||||
|
|
||||||
@ -85,7 +86,8 @@ class SectionBodyContent extends React.Component {
|
|||||||
this.state = {
|
this.state = {
|
||||||
editingId: null,
|
editingId: null,
|
||||||
showSharingPanel: false,
|
showSharingPanel: false,
|
||||||
currentItem: null
|
showMoveToPanel: false,
|
||||||
|
showCopyPanel: false
|
||||||
};
|
};
|
||||||
|
|
||||||
this.tooltipRef = React.createRef();
|
this.tooltipRef = React.createRef();
|
||||||
@ -143,6 +145,7 @@ class SectionBodyContent extends React.Component {
|
|||||||
} */
|
} */
|
||||||
|
|
||||||
shouldComponentUpdate(nextProps, nextState) {
|
shouldComponentUpdate(nextProps, nextState) {
|
||||||
|
const { showMoveToPanel, showCopyPanel } = this.state;
|
||||||
if (this.state.showSharingPanel !== nextState.showSharingPanel) {
|
if (this.state.showSharingPanel !== nextState.showSharingPanel) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -155,11 +158,15 @@ class SectionBodyContent extends React.Component {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(showMoveToPanel !== nextState.showMoveToPanel || showCopyPanel !== nextState.showCopyPanel) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
onClickRename = (item) => {
|
onClickRename = () => {
|
||||||
const { id, fileExst } = item;
|
const { id, fileExst } = this.props.selection[0];
|
||||||
|
|
||||||
this.setState({ editingId: id }, () => {
|
this.setState({ editingId: id }, () => {
|
||||||
this.props.setAction(
|
this.props.setAction(
|
||||||
@ -199,7 +206,8 @@ class SectionBodyContent extends React.Component {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
onClickDelete = (item) => {
|
onClickDelete = () => {
|
||||||
|
const item = this.props.selection[0];
|
||||||
item.fileExst
|
item.fileExst
|
||||||
? this.onDeleteFile(item.id, item.folderId)
|
? this.onDeleteFile(item.id, item.folderId)
|
||||||
: this.onDeleteFolder(item.id, item.parentId);
|
: this.onDeleteFolder(item.id, item.parentId);
|
||||||
@ -264,19 +272,11 @@ class SectionBodyContent extends React.Component {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
onClickShare = item => {
|
onClickShare = () => this.setState({showSharingPanel: !this.state.showSharingPanel});
|
||||||
let currentItem = item;
|
|
||||||
if (this.state.showSharingPanel) {
|
|
||||||
currentItem = null;
|
|
||||||
}
|
|
||||||
this.setState({
|
|
||||||
currentItem,
|
|
||||||
showSharingPanel: !this.state.showSharingPanel,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
onClickLinkForPortal = item => {
|
onClickLinkForPortal = () => {
|
||||||
const { settings } = this.props;
|
const { settings, selection } = this.props;
|
||||||
|
const item = selection[0];
|
||||||
const isFile = !!item.fileExst;
|
const isFile = !!item.fileExst;
|
||||||
const { t } = this.props;
|
const { t } = this.props;
|
||||||
|
|
||||||
@ -291,8 +291,8 @@ class SectionBodyContent extends React.Component {
|
|||||||
toastr.success(t("LinkCopySuccess"));
|
toastr.success(t("LinkCopySuccess"));
|
||||||
}
|
}
|
||||||
|
|
||||||
onClickDownload = item => {
|
onClickDownload = () => {
|
||||||
return window.open(item.viewUrl, "_blank");
|
return window.open(this.props.selection[0].viewUrl, "_blank");
|
||||||
}
|
}
|
||||||
|
|
||||||
onClickLinkEdit = e => {
|
onClickLinkEdit = e => {
|
||||||
@ -327,6 +327,20 @@ class SectionBodyContent extends React.Component {
|
|||||||
.finally(() => onLoading(false));
|
.finally(() => onLoading(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onMoveAction = () => this.setState({ showMoveToPanel: !this.state.showMoveToPanel });
|
||||||
|
onCopyAction = () => this.setState({ showCopyPanel: !this.state.showCopyPanel });
|
||||||
|
onDuplicate = () => {
|
||||||
|
const { selection, selectedFolderId, setProgressBarData, t } = this.props;
|
||||||
|
const folderIds = [];
|
||||||
|
const fileIds = [];
|
||||||
|
selection[0].fileExst ? fileIds.push(selection[0].id) : folderIds.push(selection[0].id);
|
||||||
|
const conflictResolveType = 2; //Skip = 0, Overwrite = 1, Duplicate = 2
|
||||||
|
const deleteAfter = false;
|
||||||
|
|
||||||
|
setProgressBarData({ visible: true, percent: 0, label: t("CopyOperation")});
|
||||||
|
this.copyTo(selectedFolderId, folderIds, fileIds, conflictResolveType, deleteAfter);
|
||||||
|
}
|
||||||
|
|
||||||
getFilesContextOptions = (item, viewer) => {
|
getFilesContextOptions = (item, viewer) => {
|
||||||
const { t } = this.props;
|
const { t } = this.props;
|
||||||
|
|
||||||
@ -364,7 +378,7 @@ class SectionBodyContent extends React.Component {
|
|||||||
{
|
{
|
||||||
key: "sharing-settings",
|
key: "sharing-settings",
|
||||||
label: t("SharingSettings"),
|
label: t("SharingSettings"),
|
||||||
onClick: this.onClickShare.bind(this, item),
|
onClick: this.onClickShare,
|
||||||
disabled: isSharable
|
disabled: isSharable
|
||||||
},
|
},
|
||||||
isFile
|
isFile
|
||||||
@ -377,7 +391,7 @@ class SectionBodyContent extends React.Component {
|
|||||||
{
|
{
|
||||||
key: "link-for-portal-users",
|
key: "link-for-portal-users",
|
||||||
label: t("LinkForPortalUsers"),
|
label: t("LinkForPortalUsers"),
|
||||||
onClick: this.onClickLinkForPortal.bind(this, item),
|
onClick: this.onClickLinkForPortal,
|
||||||
disabled: false
|
disabled: false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -407,7 +421,7 @@ class SectionBodyContent extends React.Component {
|
|||||||
? {
|
? {
|
||||||
key: "view",
|
key: "view",
|
||||||
label: t("View"),
|
label: t("View"),
|
||||||
onClick: this.onMediaFileClick.bind(this, item.id),
|
onClick: this.onMediaFileClick,
|
||||||
disabled: false
|
disabled: false
|
||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
@ -415,20 +429,38 @@ class SectionBodyContent extends React.Component {
|
|||||||
? {
|
? {
|
||||||
key: "download",
|
key: "download",
|
||||||
label: t("Download"),
|
label: t("Download"),
|
||||||
onClick: this.onClickDownload.bind(this, item),
|
onClick: this.onClickDownload,
|
||||||
disabled: false
|
disabled: false
|
||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
|
{
|
||||||
|
key: "move",
|
||||||
|
label: t("MoveTo"),
|
||||||
|
onClick: this.onMoveAction,
|
||||||
|
disabled: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "copy",
|
||||||
|
label: t("Copy"),
|
||||||
|
onClick: this.onCopyAction,
|
||||||
|
disabled: false
|
||||||
|
},
|
||||||
|
isFile && {
|
||||||
|
key: "duplicate",
|
||||||
|
label: t("Duplicate"),
|
||||||
|
onClick: this.onDuplicate,
|
||||||
|
disabled: false
|
||||||
|
},
|
||||||
{
|
{
|
||||||
key: "rename",
|
key: "rename",
|
||||||
label: t("Rename"),
|
label: t("Rename"),
|
||||||
onClick: this.onClickRename.bind(this, item),
|
onClick: this.onClickRename,
|
||||||
disabled: false
|
disabled: false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "delete",
|
key: "delete",
|
||||||
label: t("Delete"),
|
label: t("Delete"),
|
||||||
onClick: this.onClickDelete.bind(this, item),
|
onClick: this.onClickDelete,
|
||||||
disabled: false
|
disabled: false
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
@ -729,7 +761,8 @@ class SectionBodyContent extends React.Component {
|
|||||||
this.props.setMediaViewerData(item);
|
this.props.setMediaViewerData(item);
|
||||||
}
|
}
|
||||||
onMediaFileClick = (id) => {
|
onMediaFileClick = (id) => {
|
||||||
const item = { visible: true, id };
|
const itemId = typeof(id) !== "object" ? id : this.props.selection[0].id;
|
||||||
|
const item = { visible: true, id: itemId };
|
||||||
this.props.setMediaViewerData(item);
|
this.props.setMediaViewerData(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -996,6 +1029,8 @@ class SectionBodyContent extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onSelectItem = item => this.props.setSelection([item]);
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
files,
|
files,
|
||||||
@ -1014,10 +1049,12 @@ class SectionBodyContent extends React.Component {
|
|||||||
mediaViewerVisible,
|
mediaViewerVisible,
|
||||||
currentMediaFileId,
|
currentMediaFileId,
|
||||||
viewAs,
|
viewAs,
|
||||||
t
|
t,
|
||||||
|
loopFilesOperations
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
const { editingId, showSharingPanel, currentItem } = this.state;
|
const { editingId, showSharingPanel, showMoveToPanel, showCopyPanel } = this.state;
|
||||||
|
const operationsPanelProps = { onLoading, isLoading, loopFilesOperations };
|
||||||
|
|
||||||
let items = [...folders, ...files];
|
let items = [...folders, ...files];
|
||||||
|
|
||||||
@ -1059,6 +1096,23 @@ class SectionBodyContent extends React.Component {
|
|||||||
this.renderEmptyFilterContainer()
|
this.renderEmptyFilterContainer()
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
|
{showMoveToPanel && (
|
||||||
|
<OperationsPanel
|
||||||
|
{...operationsPanelProps}
|
||||||
|
isCopy={false}
|
||||||
|
visible={showMoveToPanel}
|
||||||
|
onClose={this.onMoveAction}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{showCopyPanel && (
|
||||||
|
<OperationsPanel
|
||||||
|
{...operationsPanelProps}
|
||||||
|
isCopy={true}
|
||||||
|
visible={showCopyPanel}
|
||||||
|
onClose={this.onCopyAction}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<CustomTooltip ref={this.tooltipRef}>{tooltipLabel}</CustomTooltip>
|
<CustomTooltip ref={this.tooltipRef}>{tooltipLabel}</CustomTooltip>
|
||||||
|
|
||||||
{viewAs === "tile"
|
{viewAs === "tile"
|
||||||
@ -1176,6 +1230,7 @@ class SectionBodyContent extends React.Component {
|
|||||||
{...checkedProps}
|
{...checkedProps}
|
||||||
{...contextOptionsProps}
|
{...contextOptionsProps}
|
||||||
needForUpdate={this.needForUpdate}
|
needForUpdate={this.needForUpdate}
|
||||||
|
onSelectItem={this.onSelectItem.bind(this, item)}
|
||||||
>
|
>
|
||||||
<FilesRowContent
|
<FilesRowContent
|
||||||
item={item}
|
item={item}
|
||||||
@ -1211,7 +1266,6 @@ class SectionBodyContent extends React.Component {
|
|||||||
{showSharingPanel && (
|
{showSharingPanel && (
|
||||||
<SharingPanel
|
<SharingPanel
|
||||||
onLoading={onLoading}
|
onLoading={onLoading}
|
||||||
selectedItems={currentItem}
|
|
||||||
onClose={this.onClickShare}
|
onClose={this.onClickShare}
|
||||||
visible={showSharingPanel}
|
visible={showSharingPanel}
|
||||||
/>
|
/>
|
||||||
@ -1283,6 +1337,7 @@ export default connect(
|
|||||||
setDragging,
|
setDragging,
|
||||||
setDragItem,
|
setDragItem,
|
||||||
setMediaViewerData,
|
setMediaViewerData,
|
||||||
setProgressBarData
|
setProgressBarData,
|
||||||
|
setSelection
|
||||||
}
|
}
|
||||||
)(withRouter(withTranslation()(SectionBodyContent)));
|
)(withRouter(withTranslation()(SectionBodyContent)));
|
||||||
|
@ -524,7 +524,6 @@ class SectionHeaderContent extends React.Component {
|
|||||||
{showSharingPanel && (
|
{showSharingPanel && (
|
||||||
<SharingPanel
|
<SharingPanel
|
||||||
onLoading={onLoading}
|
onLoading={onLoading}
|
||||||
selectedItems={selection}
|
|
||||||
onClose={this.onOpenSharingPanel}
|
onClose={this.onOpenSharingPanel}
|
||||||
visible={showSharingPanel}
|
visible={showSharingPanel}
|
||||||
/>
|
/>
|
||||||
|
@ -257,7 +257,7 @@ class PureHome extends React.Component {
|
|||||||
let foldersCount = data.current.foldersCount;
|
let foldersCount = data.current.foldersCount;
|
||||||
loopTreeFolders(path, newTreeFolders, folders, foldersCount);
|
loopTreeFolders(path, newTreeFolders, folders, foldersCount);
|
||||||
|
|
||||||
if (!isCopy) {
|
if (!isCopy || destFolderId === currentFolderId) {
|
||||||
fetchFiles(currentFolderId, filter, store.dispatch)
|
fetchFiles(currentFolderId, filter, store.dispatch)
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
if (!isRecycleBinFolder) {
|
if (!isRecycleBinFolder) {
|
||||||
|
@ -103,19 +103,11 @@ class SharingPanelComponent extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!selectedItems.length) {
|
for (let item of selectedItems) {
|
||||||
if (selectedItems.fileExst) {
|
if (item.fileExst) {
|
||||||
fileIds.push(selectedItems.id);
|
fileIds.push(item.id);
|
||||||
} else {
|
} else {
|
||||||
folderIds.push(selectedItems.id);
|
folderIds.push(item.id);
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (let item of selectedItems) {
|
|
||||||
if (item.fileExst) {
|
|
||||||
fileIds.push(item.id);
|
|
||||||
} else {
|
|
||||||
folderIds.push(item.id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -387,7 +379,7 @@ class SharingPanelComponent extends React.Component {
|
|||||||
arrayItems = this.removeDuplicateShareData(arrayItems);
|
arrayItems = this.removeDuplicateShareData(arrayItems);
|
||||||
const baseShareData = JSON.parse(JSON.stringify(arrayItems));
|
const baseShareData = JSON.parse(JSON.stringify(arrayItems));
|
||||||
|
|
||||||
const accessOptions = !this.props.selectedItems.length ? getAccessOption([this.props.selectedItems]) : getAccessOption(this.props.selectedItems);
|
const accessOptions = getAccessOption(this.props.selectedItems);
|
||||||
|
|
||||||
this.setState(
|
this.setState(
|
||||||
{ baseShareData, shareDataItems: arrayItems, accessOptions },
|
{ baseShareData, shareDataItems: arrayItems, accessOptions },
|
||||||
@ -409,20 +401,12 @@ class SharingPanelComponent extends React.Component {
|
|||||||
const folderId = [];
|
const folderId = [];
|
||||||
const fileId = [];
|
const fileId = [];
|
||||||
|
|
||||||
if (!selectedItems.length) {
|
for (let item of selectedItems) {
|
||||||
if (selectedItems.fileExst) {
|
if (item.access === 1 || item.access === 0) {
|
||||||
fileId.push(selectedItems.id);
|
if (item.fileExst) {
|
||||||
} else {
|
fileId.push(item.id);
|
||||||
folderId.push(selectedItems.id);
|
} else {
|
||||||
}
|
folderId.push(item.id);
|
||||||
} else {
|
|
||||||
for (let item of selectedItems) {
|
|
||||||
if (item.access === 1 || item.access === 0) {
|
|
||||||
if (item.fileExst) {
|
|
||||||
fileId.push(item.id);
|
|
||||||
} else {
|
|
||||||
folderId.push(item.id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -705,7 +689,10 @@ const SharingPanel = (props) => (
|
|||||||
);
|
);
|
||||||
|
|
||||||
const mapStateToProps = (state) => {
|
const mapStateToProps = (state) => {
|
||||||
return { isMyId: state.auth.user.id };
|
return {
|
||||||
|
isMyId: state.auth.user.id,
|
||||||
|
selectedItems: state.files.selection
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export default connect(mapStateToProps)(withRouter(SharingPanel));
|
export default connect(mapStateToProps)(withRouter(SharingPanel));
|
||||||
|
@ -29,9 +29,7 @@ const SharingRow = (props) => {
|
|||||||
onShowEmbeddingPanel,
|
onShowEmbeddingPanel,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const linkVisible =
|
const linkVisible = selection && selection.length === 1 && item.shareLink;
|
||||||
(selection && selection.length === 1 && item.shareLink) ||
|
|
||||||
(!selection.length && item.shareLink);
|
|
||||||
|
|
||||||
const onCopyInternalLink = () => {
|
const onCopyInternalLink = () => {
|
||||||
const internalLink = selection.webUrl ? selection.webUrl : selection[0].webUrl;
|
const internalLink = selection.webUrl ? selection.webUrl : selection[0].webUrl;
|
||||||
|
Loading…
Reference in New Issue
Block a user