Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/folder tree selection #449

Merged
merged 4 commits into from
Nov 3, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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