diff --git a/packages/client/src/store/ProfileActionsStore.js b/packages/client/src/store/ProfileActionsStore.js index 4a46ae15cb..93af480a29 100644 --- a/packages/client/src/store/ProfileActionsStore.js +++ b/packages/client/src/store/ProfileActionsStore.js @@ -1,30 +1,30 @@ // (c) Copyright Ascensio System SIA 2010-2024 -// +// // This program is a free software product. // You can redistribute it and/or modify it under the terms // of the GNU Affero General Public License (AGPL) version 3 as published by the Free Software // Foundation. In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended // to the effect that Ascensio System SIA expressly excludes the warranty of non-infringement of // any third-party rights. -// +// // This program is distributed WITHOUT ANY WARRANTY, without even the implied warranty // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, see // the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html -// +// // You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021. -// +// // The interactive user interfaces in modified source and object code versions of the Program must // display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3. -// +// // Pursuant to Section 7(b) of the License you must retain the original Product logo when // distributing the program. Pursuant to Section 7(e) we decline to grant you any rights under // trademark law for use of our trademarks. -// +// // All the Product's GUI elements, including illustrations and icon sets, as well as technical writing // content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0 // International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode -import CatalogSettingsReactSvgUrl from "PUBLIC_DIR/images/catalog.settings.react.svg?url"; +import CatalogSettingsReactSvgUrl from "PUBLIC_DIR/images/catalog.settings.react.svg?url"; import HotkeysReactSvgUrl from "PUBLIC_DIR/images/hotkeys.react.svg?url"; import ProfileReactSvgUrl from "PUBLIC_DIR/images/profile.react.svg?url"; import PaymentsReactSvgUrl from "PUBLIC_DIR/images/payments.react.svg?url"; @@ -46,6 +46,7 @@ import { LIVE_CHAT_LOCAL_STORAGE_KEY } from "@docspace/shared/constants"; import { toastr } from "@docspace/shared/components/toast"; import { isDesktop, isTablet } from "@docspace/shared/utils"; import TariffBar from "SRC_DIR/components/TariffBar"; +import { openingNewTab } from "@docspace/shared/utils/openingNewTab"; const PROXY_HOMEPAGE_URL = combineUrl(window.DocSpaceConfig?.proxy?.url, "/"); const PROFILE_SELF_URL = combineUrl(PROXY_HOMEPAGE_URL, "/profile"); @@ -57,7 +58,7 @@ const PAYMENTS_URL = combineUrl( ); //const VIDEO_GUIDES_URL = "https://onlyoffice.com/"; - +let profilePrefix; const SPACES_URL = combineUrl(PROXY_HOMEPAGE_URL, "/management"); class ProfileActionsStore { authStore = null; @@ -131,14 +132,14 @@ class ProfileActionsStore { return "manager"; }; - onProfileClick = () => { + onProfileClick = (obj) => { const { isAdmin, isOwner } = this.userStore.user; const { isRoomAdmin } = this.authStore; + const profileUrl = `${profilePrefix}${PROFILE_SELF_URL}`; + if (openingNewTab(profileUrl, obj.originalEvent)) return; + this.profileClicked = true; - const prefix = window.DocSpace.location.pathname.includes("portal-settings") - ? "/portal-settings" - : ""; if ((isAdmin || isOwner || isRoomAdmin) && !prefix) { this.selectedFolderStore.setSelectedFolder(null); @@ -148,10 +149,12 @@ class ProfileActionsStore { fromUrl: `${window.DocSpace.location.pathname}${window.DocSpace.location.search}`, }; - window.DocSpace.navigate(`${prefix}${PROFILE_SELF_URL}`, { state }); + window.DocSpace.navigate(profileUrl, { state }); }; - onSettingsClick = (settingsUrl) => { + onSettingsClick = (settingsUrl, obj) => { + if (openingNewTab(settingsUrl, obj.originalEvent)) return; + this.selectedFolderStore.setSelectedFolder(null); window.DocSpace.navigate(settingsUrl); }; @@ -161,7 +164,9 @@ class ProfileActionsStore { window.open(SPACES_URL, "_blank"); }; - onPaymentsClick = () => { + onPaymentsClick = (obj) => { + if (openingNewTab(PAYMENTS_URL, obj.originalEvent)) return; + this.selectedFolderStore.setSelectedFolder(null); window.DocSpace.navigate(PAYMENTS_URL); }; @@ -257,7 +262,8 @@ class ProfileActionsStore { key: "user-menu-settings", icon: CatalogSettingsReactSvgUrl, label: t("Common:Settings"), - onClick: () => this.onSettingsClick(settingsUrl), + onClick: (obj) => this.onSettingsClick(settingsUrl, obj), + url: settingsUrl, } : null; @@ -348,12 +354,19 @@ class ProfileActionsStore { const helpCenterEnabled = this.settingsStore.additionalResourcesData?.helpCenterEnabled; + profilePrefix = window.DocSpace.location.pathname.includes( + "portal-settings", + ) + ? "/portal-settings" + : ""; + const actions = [ { key: "user-menu-profile", icon: ProfileReactSvgUrl, label: t("Common:Profile"), - onClick: this.onProfileClick, + onClick: (obj) => this.onProfileClick(obj), + url: `${profilePrefix}${PROFILE_SELF_URL}`, }, settings, management, @@ -362,8 +375,9 @@ class ProfileActionsStore { key: "user-menu-payments", icon: PaymentsReactSvgUrl, label: t("Common:PaymentsTitle"), - onClick: this.onPaymentsClick, + onClick: (obj) => this.onPaymentsClick(obj), additionalElement: , + url: PAYMENTS_URL, }, { isSeparator: true, diff --git a/packages/shared/components/article/Article.types.ts b/packages/shared/components/article/Article.types.ts index 8bc9198eea..b8423d97d1 100644 --- a/packages/shared/components/article/Article.types.ts +++ b/packages/shared/components/article/Article.types.ts @@ -53,7 +53,7 @@ export interface ArticleProfileProps { user?: TUser; showText: boolean; getActions?: (t: TTranslation) => ContextMenuModel[]; - onProfileClick?: () => void; + onProfileClick?: (obj: { originalEvent: React.MouseEvent }) => void; currentDeviceType: DeviceType; } diff --git a/packages/shared/components/article/sub-components/Profile.tsx b/packages/shared/components/article/sub-components/Profile.tsx index 8d163a286f..68dc580f48 100644 --- a/packages/shared/components/article/sub-components/Profile.tsx +++ b/packages/shared/components/article/sub-components/Profile.tsx @@ -81,10 +81,14 @@ const ArticleProfile = (props: ArticleProfileProps) => { if (isTabletView && !showText) { toggle(e, !isOpen, menuRef); } else { - onProfileClick?.(); + onProfileClick?.({ originalEvent: e }); } }; + const onNameClick = (e: React.MouseEvent) => { + onProfileClick?.({ originalEvent: e }); + }; + const onHide = () => { setIsOpen(false); }; @@ -139,7 +143,7 @@ const ArticleProfile = (props: ArticleProfileProps) => { {(!isTabletView || showText) && ( <> - + {firstTerm}   diff --git a/packages/shared/components/avatar/Avatar.tsx b/packages/shared/components/avatar/Avatar.tsx index 01bb9bf6a3..2ba3daba5f 100644 --- a/packages/shared/components/avatar/Avatar.tsx +++ b/packages/shared/components/avatar/Avatar.tsx @@ -163,6 +163,7 @@ const AvatarPure = ({ data-testid="avatar" className={className} onClick={onClick} + onMouseDown={onClick} > { - if (e.ctrlKey || e.metaKey || e.button === 1) { + if (e?.ctrlKey || e?.metaKey || e?.button === 1) { const path = combineUrl(window.DocSpaceConfig?.proxy?.url, url); window.open(path, "_blank");