From 9c7a3157c308d2053bdb78c2029c8d908eb3e61d Mon Sep 17 00:00:00 2001 From: gopienkonikita Date: Tue, 18 Jul 2023 12:53:03 +0300 Subject: [PATCH] Web: Files: Leave-room: fixed translations, fixed bugs --- packages/client/public/locales/en/Files.json | 12 +-- .../sub-components/SetRoomParams.js | 2 +- .../dialogs/LeaveRoomDialog/index.js | 83 +++++++++++++------ .../panels/ChangeRoomOwnerPanel/index.js | 8 +- .../client/src/store/ContextOptionsStore.js | 2 +- 5 files changed, 70 insertions(+), 37 deletions(-) diff --git a/packages/client/public/locales/en/Files.json b/packages/client/public/locales/en/Files.json index 12f85ced20..de9ea1b4a7 100644 --- a/packages/client/public/locales/en/Files.json +++ b/packages/client/public/locales/en/Files.json @@ -120,12 +120,12 @@ "TableSettingsTitle": "Manage displayed columns", "DocumentEdited": "Cannot perform the action because the document is being edited.", "LeaveTheRoom": "Leave the room", - "LeaveRoomDescription": "You are about to leave the room in which you are the owner. You must first transfer the owner's rights to another user.", - "ChangeOfRoomOwner": "Change of room Owner", - "AssignAnOwner": "Assign an Owner", + "LeaveRoomDescription": "You are the owner of this room. Before you leave the room, you must transfer the owner's role to another user.", + "ChangeTheRoomOwner": "Change the Room Owner", + "AssignOwner": "Assign Owner", "WantLeaveRoom": "Do you really want to leave this room?", "RoomOwner": "Room owner", - "YouLeftTheRoom": "You left the room", - "YouLeftTheRoomOwner": "You left the room and appointed its new owner.", - "YouHaveAppointedNewOwner": "You have appointed a new owner." + "YouLeftTheRoom": "You have left the room", + "LeftAndAppointNewOwner": "You have left the room and appointed a new owner", + "AppointNewOwner": "You have appointed a new owner." } diff --git a/packages/client/src/components/dialogs/CreateEditRoomDialog/sub-components/SetRoomParams.js b/packages/client/src/components/dialogs/CreateEditRoomDialog/sub-components/SetRoomParams.js index df32846bf9..4c3b32cab5 100644 --- a/packages/client/src/components/dialogs/CreateEditRoomDialog/sub-components/SetRoomParams.js +++ b/packages/client/src/components/dialogs/CreateEditRoomDialog/sub-components/SetRoomParams.js @@ -105,7 +105,7 @@ const SetRoomParams = ({ ); }; - const isMe = userId === roomParams.roomOwner.id; + const isMe = userId === roomParams?.roomOwner?.id; const canOwnerChange = isAdmin || isMe; return ( diff --git a/packages/client/src/components/dialogs/LeaveRoomDialog/index.js b/packages/client/src/components/dialogs/LeaveRoomDialog/index.js index a293010e13..cb2b310905 100644 --- a/packages/client/src/components/dialogs/LeaveRoomDialog/index.js +++ b/packages/client/src/components/dialogs/LeaveRoomDialog/index.js @@ -1,4 +1,5 @@ import React, { useEffect, useState } from "react"; +import { useNavigate } from "react-router-dom"; import ModalDialog from "@docspace/components/modal-dialog"; import Button from "@docspace/components/button"; import Text from "@docspace/components/text"; @@ -6,6 +7,7 @@ import { withTranslation } from "react-i18next"; import { inject, observer } from "mobx-react"; import { ShareAccessRights } from "@docspace/common/constants"; import toastr from "@docspace/components/toast/toastr"; +import RoomsFilter from "@docspace/common/api/rooms/filter"; const LeaveRoomDialog = (props) => { const { @@ -20,8 +22,12 @@ const LeaveRoomDialog = (props) => { userId, removeFiles, isAdmin, + setSelected, + isRoot, } = props; + const navigate = useNavigate(); + const [isLoading, setIsLoading] = useState(false); useEffect(() => { @@ -47,12 +53,21 @@ const LeaveRoomDialog = (props) => { invitations: [{ id: userId, access: ShareAccessRights.None }], }) .then(() => { - if (!isAdmin) removeFiles(null, [roomId]); + if (!isAdmin) { + if (isRoot) { + const filter = RoomsFilter.getDefault(); + navigate(`rooms/shared/filter?${filter.toUrlParams()}`); + } else { + removeFiles(null, [roomId]); + } + } + toastr.success(t("Files:YouLeftTheRoom")); }) .finally(() => { onClose(); setIsLoading(false); + setSelected("none"); }); } }; @@ -74,7 +89,7 @@ const LeaveRoomDialog = (props) => {