From a1ca9c3e74683ae7c0dfe899e5b58e22ca4ffb29 Mon Sep 17 00:00:00 2001 From: Elyor Djalilov Date: Thu, 29 Aug 2024 12:04:03 +0500 Subject: [PATCH] Web: Client: InfoPanel: History added function to open file --- .../History/HistoryBlockContent/ItemList.tsx | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/packages/client/src/pages/Home/InfoPanel/Body/views/History/HistoryBlockContent/ItemList.tsx b/packages/client/src/pages/Home/InfoPanel/Body/views/History/HistoryBlockContent/ItemList.tsx index 2f8d30bec0..dcea9ef7c8 100644 --- a/packages/client/src/pages/Home/InfoPanel/Body/views/History/HistoryBlockContent/ItemList.tsx +++ b/packages/client/src/pages/Home/InfoPanel/Body/views/History/HistoryBlockContent/ItemList.tsx @@ -30,9 +30,11 @@ import { Trans, withTranslation } from "react-i18next"; import { inject, observer } from "mobx-react"; import { IconButton } from "@docspace/shared/components/icon-button"; +import { combineUrl } from "@docspace/shared/utils/combineUrl"; import { ReactSVG } from "react-svg"; import { TTranslation } from "@docspace/shared/types"; import { getFileExtension } from "@docspace/shared/utils/common"; +import config from "PACKAGE_FILE"; import { StyledHistoryBlockExpandLink, StyledHistoryBlockFile, @@ -77,6 +79,8 @@ const HistoryItemList = ({ const onExpand = () => setIsExpanded(true); + const isFolder = targetType === "folder"; + const items = [ feed.data, ...feed.related.map((relatedFeeds) => relatedFeeds.data), @@ -85,7 +89,7 @@ const HistoryItemList = ({ ...item, title: nameWithoutExtension!(item.title || item.newTitle), fileExst: getFileExtension(item.title || item.newTitle), - isFolder: targetType === "folder", + isFolder, }; }); @@ -94,6 +98,19 @@ const HistoryItemList = ({ fileExst: getFileExtension(feed.data.oldTitle), }; + const handleOpenFile = (item) => { + return ( + !isFolder && + window.open( + combineUrl( + window.ClientConfig?.proxy?.url, + config.homepage, + `/doceditor?fileId=${item.id}`, + ), + ) + ); + }; + return ( {items.map((item, i) => { @@ -105,7 +122,10 @@ const HistoryItemList = ({ isFolder={item.isFolder} key={`${feed.action.id}_${item.id}`} > -
+
handleOpenFile(item)} + >