From 20859dc3263ab189a8662ea077fcfccf6fd2602e Mon Sep 17 00:00:00 2001 From: Timofey Boyko <55255132+TimofeyBoyko@users.noreply.github.com> Date: Fri, 9 Jun 2023 15:42:41 +0300 Subject: [PATCH] Web:Client:Profile: fix fromUrl --- packages/client/src/Shell.jsx | 2 - .../src/components/Article/Body/index.js | 8 +-- .../src/pages/Profile/Section/Header/index.js | 72 +++++++++++-------- .../client/src/store/ProfileActionsStore.js | 11 +-- 4 files changed, 49 insertions(+), 44 deletions(-) diff --git a/packages/client/src/Shell.jsx b/packages/client/src/Shell.jsx index b471ff1eb8..0b6333f00f 100644 --- a/packages/client/src/Shell.jsx +++ b/packages/client/src/Shell.jsx @@ -28,8 +28,6 @@ import MainBar from "./components/MainBar"; import { Portal } from "@docspace/components"; import indexedDbHelper from "@docspace/common/utils/indexedDBHelper"; import { IndexedDBStores } from "@docspace/common/constants"; -import { isMobile as isMobileUtils } from "@docspace/components/utils/device"; -import queryString from "query-string"; const Shell = ({ items = [], page = "home", ...rest }) => { const { diff --git a/packages/client/src/components/Article/Body/index.js b/packages/client/src/components/Article/Body/index.js index 33e8fa20b8..f57400464c 100644 --- a/packages/client/src/components/Article/Body/index.js +++ b/packages/client/src/components/Article/Body/index.js @@ -210,12 +210,8 @@ const ArticleBodyContent = (props) => { return setActiveItemId("settings"); if (location.pathname.includes("profile")) { - if (isVisitor) { - if (activeItemId) return; - return setActiveItemId(rootFolderId || roomsFolderId); - } - - if (activeItemId !== "accounts") return setActiveItemId("accounts"); + if (activeItemId) return; + return setActiveItemId(rootFolderId || roomsFolderId); } if (location.pathname.includes("/products/files/#preview")) { diff --git a/packages/client/src/pages/Profile/Section/Header/index.js b/packages/client/src/pages/Profile/Section/Header/index.js index 0f9e65b33a..9aeb07a2f9 100644 --- a/packages/client/src/pages/Profile/Section/Header/index.js +++ b/packages/client/src/pages/Profile/Section/Header/index.js @@ -19,6 +19,8 @@ import { combineUrl } from "@docspace/common/utils"; import config from "PACKAGE_FILE"; import { StyledHeader } from "./StyledHeader"; +import RoomsFilter from "@docspace/common/api/rooms/filter"; +import { RoomSearchArea } from "@docspace/common/constants"; const Header = (props) => { const { @@ -39,6 +41,7 @@ const Header = (props) => { setChangeAvatarVisible, isProfileLoaded, + profileClicked, } = props; const navigate = useNavigate(); @@ -89,8 +92,7 @@ const Header = (props) => { }; const onClickBack = () => { - console.log(location.state); - if (location?.state?.fromUrl) { + if (location?.state?.fromUrl && profileClicked) { return navigate(location?.state?.fromUrl); } @@ -98,11 +100,14 @@ const Header = (props) => { return navigate("/portal-settings/customization/general"); } - const url = filter.toUrlParams(); - const backUrl = `/accounts/filter?/${url}`; + const roomsFilter = RoomsFilter.getDefault(); + + roomsFilter.searchArea = RoomSearchArea.Active; + const urlParams = roomsFilter.toUrlParams(); + const backUrl = `/rooms/shared/filter?${urlParams}`; navigate(backUrl); - setFilter(filter); + // setFilter(filter); }; if (!isProfileLoaded) return ; @@ -156,41 +161,46 @@ const Header = (props) => { ); }; -export default inject(({ auth, peopleStore, clientLoadingStore }) => { - const { isAdmin } = auth; +export default inject( + ({ auth, peopleStore, clientLoadingStore, profileActionsStore }) => { + const { isAdmin } = auth; - const { isVisitor, isCollaborator } = auth.userStore.user; + const { isVisitor, isCollaborator } = auth.userStore.user; - const { targetUserStore, filterStore } = peopleStore; + const { targetUserStore, filterStore } = peopleStore; - const { filter, setFilterParams } = filterStore; + const { filter, setFilterParams } = filterStore; - const { targetUser, isMe } = targetUserStore; + const { targetUser, isMe } = targetUserStore; - const { isProfileLoaded } = clientLoadingStore; + const { isProfileLoaded } = clientLoadingStore; - const { - setChangeEmailVisible, - setChangePasswordVisible, - setChangeAvatarVisible, - } = targetUserStore; + const { profileClicked } = profileActionsStore; - return { - isAdmin, - isVisitor, - isCollaborator, - filter, + const { + setChangeEmailVisible, + setChangePasswordVisible, + setChangeAvatarVisible, + } = targetUserStore; - setFilter: setFilterParams, + return { + isAdmin, + isVisitor, + isCollaborator, + filter, - profile: targetUser, - isMe, - setChangeEmailVisible, - setChangePasswordVisible, - setChangeAvatarVisible, + setFilter: setFilterParams, - isProfileLoaded, - }; -})( + profile: targetUser, + isMe, + setChangeEmailVisible, + setChangePasswordVisible, + setChangeAvatarVisible, + + isProfileLoaded, + profileClicked, + }; + } +)( observer(withTranslation(["Profile", "Common", "PeopleTranslations"])(Header)) ); diff --git a/packages/client/src/store/ProfileActionsStore.js b/packages/client/src/store/ProfileActionsStore.js index 1ecabcbcc8..922550eb41 100644 --- a/packages/client/src/store/ProfileActionsStore.js +++ b/packages/client/src/store/ProfileActionsStore.js @@ -38,6 +38,7 @@ class ProfileActionsStore { isAboutDialogVisible = false; isDebugDialogVisible = false; isShowLiveChat = false; + profileClicked = false; constructor( authStore, @@ -94,6 +95,8 @@ class ProfileActionsStore { onProfileClick = () => { const { isAdmin, isOwner } = this.authStore.userStore.user; const { isRoomAdmin } = this.authStore; + + this.profileClicked = true; const prefix = window.DocSpace.location.pathname.includes("portal-settings") ? "/portal-settings" : ""; @@ -103,11 +106,9 @@ class ProfileActionsStore { this.treeFoldersStore.setSelectedNode(["accounts"]); } - const state = {}; - - if (prefix) { - state.fromUrl = window.DocSpace.location.pathname; - } + const state = { + fromUrl: `${window.DocSpace.location.pathname}${window.DocSpace.location.search}`, + }; window.DocSpace.navigate(`${prefix}${PROFILE_SELF_URL}`, { state }); };