Skip to content

Commit

Permalink
Merge pull request #449 from ONLYOFFICE/bugfix/folder-tree-selection
Browse files Browse the repository at this point in the history
Bugfix/folder tree selection
  • Loading branch information
gopienkonikita authored Nov 3, 2021
2 parents a15cca7 + 2fd09a6 commit 5eaaa6c
Showing 1 changed file with 70 additions and 59 deletions.
129 changes: 70 additions & 59 deletions products/ASC.Files/Client/src/components/panels/SharingPanel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class SharingPanelComponent extends React.Component {
accessOptions: [],
filesOwnerId: null,
showEmbeddingContent: false,
isLoading: false,
};

this.ref = React.createRef();
Expand Down Expand Up @@ -92,27 +93,8 @@ class SharingPanelComponent extends React.Component {
};

onSaveClick = () => {
const {
baseShareData,
isNotifyUsers,
message,
shareDataItems,
filesOwnerId,
} = this.state;
const {
selection,
setIsLoading,
isPrivacy,
replaceFileStream,
t,
uploadPanelVisible,
updateUploadedItem,
uploadSelection,
isDesktop,
setEncryptionAccess,
setShareFiles,
onSuccess,
} = this.props;
const { baseShareData, shareDataItems, filesOwnerId } = this.state;
const { selection } = this.props;

let folderIds = [];
let fileIds = [];
Expand Down Expand Up @@ -163,8 +145,28 @@ class SharingPanelComponent extends React.Component {
const ownerId =
filesOwnerId !== owner.sharedTo.id ? owner.sharedTo.id : null;

setIsLoading(true);
this.setShareInfo(folderIds, fileIds, share, externalAccess, ownerId);
};

setShareInfo = (folderIds, fileIds, share, externalAccess, ownerId) => {
const { isNotifyUsers, message } = this.state;

const {
selection,
isPrivacy,
replaceFileStream,
t,
uploadPanelVisible,
updateUploadedItem,
uploadSelection,
isDesktop,
setEncryptionAccess,
setShareFiles,
onSuccess,
} = this.props;

this.onClose();

setShareFiles(
folderIds,
fileIds,
Expand Down Expand Up @@ -210,9 +212,9 @@ class SharingPanelComponent extends React.Component {
return Promise.resolve();
})
.then(() => onSuccess && onSuccess())
.catch((err) => toastr.error(err))
.finally(() => setIsLoading(false));
.catch((err) => toastr.error(err));
};

onNotifyUsersChange = () =>
this.setState({ isNotifyUsers: !this.state.isNotifyUsers });

Expand Down Expand Up @@ -264,45 +266,58 @@ class SharingPanelComponent extends React.Component {
};

getShareData = () => {
const returnValue = this.getData();
const folderId = returnValue[0];
const fileId = returnValue[1];

if (folderId.length !== 0 || fileId.length !== 0) {
this.setState(
{
isLoading: true,
},
function () {
this.getShareUsers(folderId, fileId);
}
);
}
};

getShareUsers = (folderId, fileId) => {
const {
getAccessOption,
getExternalAccessOption,
selection,
setIsLoading,
getShareUsers,
} = this.props;

const returnValue = this.getData();
const folderId = returnValue[0];
const fileId = returnValue[1];

if (folderId.length !== 0 || fileId.length !== 0) {
!isMobile && setIsLoading(true);
getShareUsers(folderId, fileId)
.then((shareDataItems) => {
const baseShareData = JSON.parse(JSON.stringify(shareDataItems));
const accessOptions = getAccessOption(selection);

const externalAccessOptions = getExternalAccessOption(selection);
const filesOwner = shareDataItems.find((x) => x.isOwner);
const filesOwnerId = filesOwner ? filesOwner.sharedTo.id : null;

this.setState({
baseShareData,
shareDataItems,
accessOptions,
externalAccessOptions,
//showPanel: true,
filesOwnerId,
});
})
getShareUsers(folderId, fileId)
.then((shareDataItems) => {
const baseShareData = JSON.parse(JSON.stringify(shareDataItems));
const accessOptions = getAccessOption(selection);

const externalAccessOptions = getExternalAccessOption(selection);
const filesOwner = shareDataItems.find((x) => x.isOwner);
const filesOwnerId = filesOwner ? filesOwner.sharedTo.id : null;

this.setState({
baseShareData,
shareDataItems,
accessOptions,
externalAccessOptions,
//showPanel: true,
filesOwnerId,
});
})

.catch((err) => {
toastr.error(err);
this.onClose();
.catch((err) => {
toastr.error(err);
this.onClose();
})
.finally(() =>
this.setState({
isLoading: false,
})
.finally(() => !isMobile && setIsLoading(false));
}
);
};

getInternalLink = () => {
Expand Down Expand Up @@ -414,7 +429,6 @@ class SharingPanelComponent extends React.Component {
selection,
groupsCaption,
canShareOwnerChange,
isLoading,
uploadPanelVisible,
documentTitle,
sharingPanelVisible,
Expand All @@ -434,6 +448,7 @@ class SharingPanelComponent extends React.Component {
accessOptions,
externalAccessOptions,
showEmbeddingContent,
isLoading,
} = this.state;

const visible = sharingPanelVisible;
Expand Down Expand Up @@ -707,10 +722,8 @@ const SharingPanel = inject(
setFolder,
getShareUsers,
setShareFiles,
setIsLoading,
getFileInfo,
getFolderInfo,
isLoading,
setBufferSelection,
} = filesStore;
const { isPrivacyFolder } = treeFoldersStore;
Expand All @@ -732,12 +745,10 @@ const SharingPanel = inject(
: selection.length
? selection
: [bufferSelection],
isLoading,
isPrivacy: isPrivacyFolder,
selectedUploadFile,
canShareOwnerChange,

setIsLoading,
setSharingPanelVisible,
sharingPanelVisible,
selectUploadedFile,
Expand Down

0 comments on commit 5eaaa6c

Please sign in to comment.