Skip to content

Commit

Permalink
Fixed Bug 51909 - Client.Files. Disabled the Move/Delete options for …
Browse files Browse the repository at this point in the history
…a file open for editing
  • Loading branch information
gopienkonikita committed Dec 21, 2021
1 parent 62ffa58 commit aca7239
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 6 deletions.
2 changes: 1 addition & 1 deletion products/ASC.Files/Client/src/components/Badges.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ const Badges = ({
versionGroup,
title,
fileExst,
isEditing,
} = item;

const isFavorite = fileStatus === 32;
const isEditing = fileStatus === 1;
const isNewWithFav = fileStatus === 34;
const isEditingWithFav = fileStatus === 33;
const showEditBadge = !locked || item.access === 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ class DeleteDialogComponent extends React.Component {

let i = 0;
while (props.selection.length !== i) {
if (!(props.isRootFolder && props.selection[i].providerKey)) {
if (
!(
(props.isRootFolder && props.selection[i].providerKey) ||
props.selection[i].isEditing
)
) {
if (
props.selection[i].access === 0 ||
props.selection[i].access === 1 ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ export default inject(
} = dialogsStore;

const selections = selection.length ? selection : [bufferSelection];
const selectionsWithoutEditing = selections.filter((f) => !f.isEditing);

const provider = selections.find((x) => x.providerKey);

Expand All @@ -172,7 +173,7 @@ export default inject(
operationsFolders,
visible: copyPanelVisible || moveToPanelVisible,
provider,
selection: selections,
selection: selectionsWithoutEditing,

setCopyPanelVisible,
setMoveToPanelVisible,
Expand Down
9 changes: 7 additions & 2 deletions products/ASC.Files/Client/src/store/FilesActionsStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,7 @@ class FilesActionStore {
canConvertSelected,
isThirdPartyRootSelection,
hasSelection,
allFilesIsEditing,
} = this.filesStore;
const { personal } = this.authStore.settingsStore;
const { userAccess } = this.filesStore;
Expand All @@ -699,12 +700,16 @@ class FilesActionStore {
hasSelection &&
isAccessedSelected &&
!isRecentFolder &&
!isFavoritesFolder
!isFavoritesFolder &&
!allFilesIsEditing
);

case "delete":
const deleteCondition =
!isThirdPartyRootSelection && hasSelection && isAccessedSelected;
!isThirdPartyRootSelection &&
hasSelection &&
isAccessedSelected &&
!allFilesIsEditing;

return isCommonFolder ? userAccess && deleteCondition : deleteCondition;
}
Expand Down
15 changes: 14 additions & 1 deletion products/ASC.Files/Client/src/store/FilesStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ class FilesStore {
const canConvert = false; //TODO: fix of added convert check;
const isEncrypted = item.encrypted;
const isDocuSign = false; //TODO: need this prop;
const isEditing = false; //TODO: need this prop;
const isEditing = item.fileStatus === 1;
const isFileOwner = item.createdBy.id === this.userStore.user.id;

const {
Expand Down Expand Up @@ -618,6 +618,7 @@ class FilesStore {
fileOptions = this.removeOptions(fileOptions, [
"finalize-version",
"move-to",
"separator2",
"delete",
]);
if (isThirdPartyFolder) {
Expand Down Expand Up @@ -1269,6 +1270,7 @@ class FilesStore {
: null;

const needConvert = canConvert(fileExst);
const isEditing = item.fileStatus === 1;

const docUrl = combineUrl(
AppServerConfig.proxyURL,
Expand Down Expand Up @@ -1328,6 +1330,7 @@ class FilesStore {
folderUrl,
href,
isThirdPartyFolder,
isEditing,
};
});

Expand Down Expand Up @@ -1535,6 +1538,16 @@ class FilesStore {
return filesList.length <= 0;
}

get allFilesIsEditing() {
const hasFolders = this.selection.find(
(x) => !x.fileExst || !x.contentLength
);
if (!hasFolders) {
return this.selection.every((x) => x.isEditing);
}
return false;
}

getOptions = (selection, externalAccess = false) => {
const {
canWebEdit,
Expand Down

0 comments on commit aca7239

Please sign in to comment.