Merge branch 'develop' of github.com:ONLYOFFICE/DocSpace into develop

This commit is contained in:
Alexey Bannov 2022-11-16 17:41:30 +03:00
commit 83d84be867
8 changed files with 101 additions and 28 deletions

View File

@ -124,7 +124,6 @@ const ArticleMainButtonContent = (props) => {
); );
const onCreateRoom = React.useCallback(() => { const onCreateRoom = React.useCallback(() => {
console.log("click");
const event = new Event(Events.ROOM_CREATE); const event = new Event(Events.ROOM_CREATE);
window.dispatchEvent(event); window.dispatchEvent(event);
}, []); }, []);

View File

@ -23,6 +23,10 @@ const CreateRoomEvent = ({
currrentFolderId, currrentFolderId,
updateCurrentFolder, updateCurrentFolder,
withPaging,
addFile,
setCreateRoomDialogVisible,
}) => { }) => {
const { t } = useTranslation(["CreateEditRoomDialog", "Common", "Files"]); const { t } = useTranslation(["CreateEditRoomDialog", "Common", "Files"]);
const [fetchedTags, setFetchedTags] = useState([]); const [fetchedTags, setFetchedTags] = useState([]);
@ -50,7 +54,7 @@ const CreateRoomEvent = ({
setIsLoading(true); setIsLoading(true);
// create room // create room
const room = let room =
isThirdparty && storageFolderId isThirdparty && storageFolderId
? await createRoomInThirdpary(storageFolderId, createRoomData) ? await createRoomInThirdpary(storageFolderId, createRoomData)
: await createRoom(createRoomData); : await createRoom(createRoomData);
@ -64,7 +68,7 @@ const CreateRoomEvent = ({
await createTag(createTagsData[i]); await createTag(createTagsData[i]);
// add new tags to room // add new tags to room
await addTagsToRoom(room.id, addTagsData); room = await addTagsToRoom(room.id, addTagsData);
// calculate and upload logo to room // calculate and upload logo to room
if (roomParams.icon.uploadedFile) if (roomParams.icon.uploadedFile)
@ -73,19 +77,26 @@ const CreateRoomEvent = ({
const img = new Image(); const img = new Image();
img.onload = async () => { img.onload = async () => {
const { x, y, zoom } = roomParams.icon; const { x, y, zoom } = roomParams.icon;
await addLogoToRoom(room.id, { room = await addLogoToRoom(room.id, {
tmpFile: response.data, tmpFile: response.data,
...calculateRoomLogoParams(img, x, y, zoom), ...calculateRoomLogoParams(img, x, y, zoom),
}); });
!withPaging && addFile(room, true);
URL.revokeObjectURL(img.src); URL.revokeObjectURL(img.src);
}; };
img.src = url; img.src = url;
}); });
else !withPaging && addFile(room, true);
} catch (err) { } catch (err) {
toastr.error(err); toastr.error(err);
console.log(err); console.log(err);
} finally { } finally {
await updateCurrentFolder(null, currrentFolderId); if (withPaging) {
await updateCurrentFolder(null, currrentFolderId);
}
setIsLoading(false); setIsLoading(false);
onClose(); onClose();
} }
@ -96,6 +107,12 @@ const CreateRoomEvent = ({
setFetchedTags(tags); setFetchedTags(tags);
}, []); }, []);
useEffect(() => {
setCreateRoomDialogVisible(true);
return () => setCreateRoomDialogVisible(false);
}, []);
return ( return (
<CreateRoomDialog <CreateRoomDialog
t={t} t={t}
@ -113,6 +130,7 @@ const CreateRoomEvent = ({
export default inject( export default inject(
({ ({
auth,
filesStore, filesStore,
tagsStore, tagsStore,
filesActionsStore, filesActionsStore,
@ -127,18 +145,20 @@ export default inject(
calculateRoomLogoParams, calculateRoomLogoParams,
uploadRoomLogo, uploadRoomLogo,
addLogoToRoom, addLogoToRoom,
addFile,
} = filesStore; } = filesStore;
const { createTag, fetchTags } = tagsStore; const { createTag, fetchTags } = tagsStore;
const { id: currrentFolderId } = selectedFolderStore; const { id: currrentFolderId } = selectedFolderStore;
const { updateCurrentFolder } = filesActionsStore; const { updateCurrentFolder } = filesActionsStore;
const { connectDialogVisible } = dialogsStore; const { connectDialogVisible, setCreateRoomDialogVisible } = dialogsStore;
const { const {
deleteThirdParty, deleteThirdParty,
fetchThirdPartyProviders, fetchThirdPartyProviders,
} = settingsStore.thirdPartyStore; } = settingsStore.thirdPartyStore;
const { withPaging } = auth.settingsStore;
return { return {
createRoom, createRoom,
@ -155,6 +175,10 @@ export default inject(
connectDialogVisible, connectDialogVisible,
currrentFolderId, currrentFolderId,
updateCurrentFolder, updateCurrentFolder,
withPaging,
addFile,
setCreateRoomDialogVisible,
}; };
} }
)(observer(CreateRoomEvent)); )(observer(CreateRoomEvent));

View File

@ -26,6 +26,9 @@ const EditRoomEvent = ({
currentFolderId, currentFolderId,
updateCurrentFolder, updateCurrentFolder,
setCreateRoomDialogVisible,
withPaging,
}) => { }) => {
const { t } = useTranslation(["CreateEditRoomDialog", "Common", "Files"]); const { t } = useTranslation(["CreateEditRoomDialog", "Common", "Files"]);
@ -72,14 +75,14 @@ const EditRoomEvent = ({
try { try {
setIsLoading(true); setIsLoading(true);
const room = await editRoom(item.id, editRoomParams); let room = await editRoom(item.id, editRoomParams);
for (let i = 0; i < newTags.length; i++) await createTag(newTags[i]); for (let i = 0; i < newTags.length; i++) await createTag(newTags[i]);
await addTagsToRoom(room.id, tags); room = await addTagsToRoom(room.id, tags);
await removeTagsFromRoom(room.id, removedTags); room = await removeTagsFromRoom(room.id, removedTags);
if (!!item.logo.original && !roomParams.icon.uploadedFile) if (!!item.logo.original && !roomParams.icon.uploadedFile)
await removeLogoFromRoom(room.id); room = await removeLogoFromRoom(room.id);
if (roomParams.icon.uploadedFile) { if (roomParams.icon.uploadedFile) {
await setFolder({ await setFolder({
@ -91,19 +94,24 @@ const EditRoomEvent = ({
const img = new Image(); const img = new Image();
img.onload = async () => { img.onload = async () => {
const { x, y, zoom } = roomParams.icon; const { x, y, zoom } = roomParams.icon;
await addLogoToRoom(room.id, { room = await addLogoToRoom(room.id, {
tmpFile: response.data, tmpFile: response.data,
...calculateRoomLogoParams(img, x, y, zoom), ...calculateRoomLogoParams(img, x, y, zoom),
}); });
!withPaging && setFolder(room);
URL.revokeObjectURL(img.src); URL.revokeObjectURL(img.src);
}; };
img.src = url; img.src = url;
}); });
} } else !withPaging && setFolder(room);
} catch (err) { } catch (err) {
console.log(err); console.log(err);
} finally { } finally {
await updateCurrentFolder(null, currentFolderId); if (withPaging) {
await updateCurrentFolder(null, currentFolderId);
}
setIsLoading(false); setIsLoading(false);
onClose(); onClose();
} }
@ -129,6 +137,12 @@ const EditRoomEvent = ({
setFetchedTags(tags); setFetchedTags(tags);
}, []); }, []);
useEffect(() => {
setCreateRoomDialogVisible(true);
return () => setCreateRoomDialogVisible(false);
}, []);
return ( return (
<EditRoomDialog <EditRoomDialog
t={t} t={t}
@ -145,10 +159,12 @@ const EditRoomEvent = ({
export default inject( export default inject(
({ ({
auth,
filesStore, filesStore,
tagsStore, tagsStore,
filesActionsStore, filesActionsStore,
selectedFolderStore, selectedFolderStore,
dialogsStore,
settingsStore, settingsStore,
}) => { }) => {
const { const {
@ -166,6 +182,8 @@ export default inject(
const { id: currentFolderId } = selectedFolderStore; const { id: currentFolderId } = selectedFolderStore;
const { updateCurrentFolder } = filesActionsStore; const { updateCurrentFolder } = filesActionsStore;
const { getThirdPartyIcon } = settingsStore.thirdPartyStore; const { getThirdPartyIcon } = settingsStore.thirdPartyStore;
const { setCreateRoomDialogVisible } = dialogsStore;
const { withPaging } = auth.settingsStore;
return { return {
editRoom, editRoom,
@ -185,6 +203,9 @@ export default inject(
currentFolderId, currentFolderId,
updateCurrentFolder, updateCurrentFolder,
withPaging,
setCreateRoomDialogVisible,
}; };
} }
)(observer(EditRoomEvent)); )(observer(EditRoomEvent));

View File

@ -45,6 +45,13 @@ const StyledDropDown = styled(DropDown)`
font-weight: 400; font-weight: 400;
font-size: 13px; font-size: 13px;
line-height: 20px; line-height: 20px;
display: block;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
&:hover { &:hover {
background: ${(props) => background: ${(props) =>
props.theme.createEditRoomDialog.dropdown.item.hoverBackground}; props.theme.createEditRoomDialog.dropdown.item.hoverBackground};

View File

@ -609,6 +609,7 @@ class SectionHeaderContent extends React.Component {
isEmptyPage, isEmptyPage,
canCreateFiles, canCreateFiles,
} = this.props; } = this.props;
const menuItems = this.getMenuItems(); const menuItems = this.getMenuItems();
const isLoading = !title || !tReady; const isLoading = !title || !tReady;
const headerMenu = getHeaderMenu(t); const headerMenu = getHeaderMenu(t);
@ -636,7 +637,7 @@ class SectionHeaderContent extends React.Component {
sectionWidth={context.sectionWidth} sectionWidth={context.sectionWidth}
showText={showText} showText={showText}
isRootFolder={isRootFolder} isRootFolder={isRootFolder}
canCreate={canCreate && canCreateFiles} canCreate={canCreate && (canCreateFiles || isRoomsFolder)}
title={title} title={title}
isDesktop={isDesktop} isDesktop={isDesktop}
isTabletView={isTabletView} isTabletView={isTabletView}

View File

@ -56,6 +56,7 @@ class DialogsStore {
restoreAllArchive = false; restoreAllArchive = false;
isConnectDialogReconnect = false; isConnectDialogReconnect = false;
saveAfterReconnectOAuth = false; saveAfterReconnectOAuth = false;
createRoomDialogVisible = false;
constructor( constructor(
authStore, authStore,
@ -306,6 +307,10 @@ class DialogsStore {
this.inviteUsersWarningDialogVisible = inviteUsersWarningDialogVisible; this.inviteUsersWarningDialogVisible = inviteUsersWarningDialogVisible;
}; };
setCreateRoomDialogVisible = (createRoomDialogVisible) => {
this.createRoomDialogVisible = createRoomDialogVisible;
};
get someDialogIsOpen() { get someDialogIsOpen() {
return ( return (
this.sharingPanelVisible || this.sharingPanelVisible ||
@ -329,7 +334,8 @@ class DialogsStore {
this.invitePanelOptions.visible || this.invitePanelOptions.visible ||
this.archiveDialogVisible || this.archiveDialogVisible ||
this.restoreAllPanelVisible || this.restoreAllPanelVisible ||
this.inviteUsersWarningDialogVisible this.inviteUsersWarningDialogVisible ||
this.createRoomDialogVisible
); );
} }

View File

@ -900,7 +900,7 @@ class FilesStore {
runInAction(() => { runInAction(() => {
this.setFolders(data.folders); this.setFolders(data.folders);
this.setFiles(data.files); this.setFiles([]);
}); });
if (clearFilter) { if (clearFilter) {
@ -1733,9 +1733,15 @@ class FilesStore {
}; };
addFile = (item, isFolder) => { addFile = (item, isFolder) => {
const filter = this.filter.clone(); const { isRoomsFolder, isArchiveFolder } = this.treeFoldersStore;
const isRooms = isRoomsFolder || isArchiveFolder;
const filter = isRooms ? this.roomsFilter.clone() : this.filter.clone();
filter.total += 1; filter.total += 1;
this.setFilter(filter);
if (isRooms) this.setRoomsFilter(filter);
else this.setFilter(filter);
isFolder ? this.folders.unshift(item) : this.files.unshift(item); isFolder ? this.folders.unshift(item) : this.files.unshift(item);
@ -2652,18 +2658,8 @@ class FilesStore {
const { isRoomsFolder, isArchiveFolder } = this.treeFoldersStore; const { isRoomsFolder, isArchiveFolder } = this.treeFoldersStore;
const isRooms = isRoomsFolder || isArchiveFolder; const isRooms = isRoomsFolder || isArchiveFolder;
// const filterTotal = isRoom ? this.roomsFilterTotal : this.filterTotal;
const filterTotal = isRooms ? this.roomsFilter.total : this.filter.total; const filterTotal = isRooms ? this.roomsFilter.total : this.filter.total;
// console.log("hasMoreFiles isRooms", isRooms);
// console.log("hasMoreFiles filesList", this.filesList.length);
// console.log("hasMoreFiles this.filterTotal", this.filterTotal);
// console.log("hasMoreFiles this.roomsFilterTotal", this.roomsFilterTotal);
// console.log("hasMoreFiles filterTotal", filterTotal);
// console.log("hasMoreFiles", this.filesList.length < filterTotal);
// console.log("----------------------------");
if (this.isLoading) return false; if (this.isLoading) return false;
return this.filesList.length < filterTotal; return this.filesList.length < filterTotal;
} }

View File

@ -408,11 +408,17 @@ public class PortalController : ControllerBase
} }
} }
[AllowNotPayment]
[HttpPost("suspend")] [HttpPost("suspend")]
public void SendSuspendInstructions() public void SendSuspendInstructions()
{ {
_permissionContext.DemandPermissions(SecutiryConstants.EditPortalSettings); _permissionContext.DemandPermissions(SecutiryConstants.EditPortalSettings);
if (_securityContext.CurrentAccount.ID != Tenant.OwnerId)
{
throw new Exception(Resource.ErrorAccessDenied);
}
var owner = _userManager.GetUsers(Tenant.OwnerId); var owner = _userManager.GetUsers(Tenant.OwnerId);
var suspendUrl = _commonLinkUtility.GetConfirmationEmailUrl(owner.Email, ConfirmType.PortalSuspend); var suspendUrl = _commonLinkUtility.GetConfirmationEmailUrl(owner.Email, ConfirmType.PortalSuspend);
var continueUrl = _commonLinkUtility.GetConfirmationEmailUrl(owner.Email, ConfirmType.PortalContinue); var continueUrl = _commonLinkUtility.GetConfirmationEmailUrl(owner.Email, ConfirmType.PortalContinue);
@ -422,10 +428,17 @@ public class PortalController : ControllerBase
_messageService.Send(MessageAction.OwnerSentPortalDeactivationInstructions, _messageTarget.Create(owner.Id), owner.DisplayUserName(false, _displayUserSettingsHelper)); _messageService.Send(MessageAction.OwnerSentPortalDeactivationInstructions, _messageTarget.Create(owner.Id), owner.DisplayUserName(false, _displayUserSettingsHelper));
} }
[AllowNotPayment]
[HttpPost("delete")] [HttpPost("delete")]
public void SendDeleteInstructions() public void SendDeleteInstructions()
{ {
_permissionContext.DemandPermissions(SecutiryConstants.EditPortalSettings); _permissionContext.DemandPermissions(SecutiryConstants.EditPortalSettings);
if (_securityContext.CurrentAccount.ID != Tenant.OwnerId)
{
throw new Exception(Resource.ErrorAccessDenied);
}
var owner = _userManager.GetUsers(Tenant.OwnerId); var owner = _userManager.GetUsers(Tenant.OwnerId);
var showAutoRenewText = !_coreBaseSettings.Standalone && var showAutoRenewText = !_coreBaseSettings.Standalone &&
@ -455,10 +468,16 @@ public class PortalController : ControllerBase
_messageService.Send(MessageAction.PortalDeactivated); _messageService.Send(MessageAction.PortalDeactivated);
} }
[AllowNotPayment]
[HttpDelete("delete")] [HttpDelete("delete")]
[Authorize(AuthenticationSchemes = "confirm", Roles = "PortalRemove")] [Authorize(AuthenticationSchemes = "confirm", Roles = "PortalRemove")]
public async Task<object> DeletePortal() public async Task<object> DeletePortal()
{ {
if (_securityContext.CurrentAccount.ID != Tenant.OwnerId)
{
throw new Exception(Resource.ErrorAccessDenied);
}
_tenantManager.RemoveTenant(Tenant.Id); _tenantManager.RemoveTenant(Tenant.Id);
if (!string.IsNullOrEmpty(_apiSystemHelper.ApiCacheUrl)) if (!string.IsNullOrEmpty(_apiSystemHelper.ApiCacheUrl))