From c5ba2d73d0937ee60fba891efb92ce076b17e2fd Mon Sep 17 00:00:00 2001 From: Sean Hatfield Date: Mon, 17 Jun 2024 14:26:44 -0700 Subject: [PATCH] [STYLE] Document picker UI improvements (#1700) * rework document picker ui * refactor tooltips to use react-tooltip lib with custom elements --------- Co-authored-by: timothycarambat --- .../Documents/Directory/FileRow/index.jsx | 65 ++++++++--------- .../Documents/Directory/index.jsx | 2 - .../WorkspaceFileRow/index.jsx | 72 +++++++++---------- .../Documents/WorkspaceDirectory/index.jsx | 4 -- 4 files changed, 60 insertions(+), 83 deletions(-) diff --git a/frontend/src/components/Modals/ManageWorkspace/Documents/Directory/FileRow/index.jsx b/frontend/src/components/Modals/ManageWorkspace/Documents/Directory/FileRow/index.jsx index e679896f..1b8cb81e 100644 --- a/frontend/src/components/Modals/ManageWorkspace/Documents/Directory/FileRow/index.jsx +++ b/frontend/src/components/Modals/ManageWorkspace/Documents/Directory/FileRow/index.jsx @@ -1,26 +1,13 @@ -import { useState } from "react"; +import React from "react"; import { formatDate, getFileExtension, middleTruncate, } from "@/utils/directories"; import { File } from "@phosphor-icons/react"; -import debounce from "lodash.debounce"; +import { Tooltip } from "react-tooltip"; export default function FileRow({ item, selected, toggleSelection }) { - const [showTooltip, setShowTooltip] = useState(false); - - const handleShowTooltip = () => { - setShowTooltip(true); - }; - - const handleHideTooltip = () => { - setShowTooltip(false); - }; - - const handleMouseEnter = debounce(handleShowTooltip, 500); - const handleMouseLeave = debounce(handleHideTooltip, 500); - return ( toggleSelection(item)} @@ -28,7 +15,10 @@ export default function FileRow({ item, selected, toggleSelection }) { selected ? "selected" : "" }`} > -
+
-
-

- {middleTruncate(item.title, 17)} -

- {showTooltip && ( -
- {item.title} -
- )} -
+

+ {middleTruncate(item.title, 60)} +

-

- {formatDate(item?.published)} -

-

- {getFileExtension(item.url)} -

-
+
{item?.cached && (

Cached

)}
+ +
+

{item.title}

+
+

+ Date: {formatDate(item?.published)} +

+

+ Type: {getFileExtension(item.url).toUpperCase()} +

+
+
+
); } diff --git a/frontend/src/components/Modals/ManageWorkspace/Documents/Directory/index.jsx b/frontend/src/components/Modals/ManageWorkspace/Documents/Directory/index.jsx index 10d3ca87..c8d942d0 100644 --- a/frontend/src/components/Modals/ManageWorkspace/Documents/Directory/index.jsx +++ b/frontend/src/components/Modals/ManageWorkspace/Documents/Directory/index.jsx @@ -203,8 +203,6 @@ function Directory({

Name

-

Date

-

Kind

diff --git a/frontend/src/components/Modals/ManageWorkspace/Documents/WorkspaceDirectory/WorkspaceFileRow/index.jsx b/frontend/src/components/Modals/ManageWorkspace/Documents/WorkspaceDirectory/WorkspaceFileRow/index.jsx index f4732542..727331ad 100644 --- a/frontend/src/components/Modals/ManageWorkspace/Documents/WorkspaceDirectory/WorkspaceFileRow/index.jsx +++ b/frontend/src/components/Modals/ManageWorkspace/Documents/WorkspaceDirectory/WorkspaceFileRow/index.jsx @@ -6,9 +6,8 @@ import { } from "@/utils/directories"; import { ArrowUUpLeft, File, PushPin } from "@phosphor-icons/react"; import Workspace from "@/models/workspace"; -import debounce from "lodash.debounce"; -import { Tooltip } from "react-tooltip"; import showToast from "@/utils/toast"; +import { Tooltip } from "react-tooltip"; export default function WorkspaceFileRow({ item, @@ -20,8 +19,6 @@ export default function WorkspaceFileRow({ hasChanges, movedItems, }) { - const [showTooltip, setShowTooltip] = useState(false); - const onRemoveClick = async () => { setLoading(true); @@ -40,62 +37,57 @@ export default function WorkspaceFileRow({ setLoading(false); }; - const handleShowTooltip = () => { - setShowTooltip(true); - }; - - const handleHideTooltip = () => { - setShowTooltip(false); - }; - const isMovedItem = movedItems?.some((movedItem) => movedItem.id === item.id); - const handleMouseEnter = debounce(handleShowTooltip, 500); - const handleMouseLeave = debounce(handleHideTooltip, 500); return (
-
+
-
-

- {middleTruncate(item.title, 17)} -

- {showTooltip && ( -
- {item.title} -
- )} -
+

+ {middleTruncate(item.title, 60)} +

-

- {formatDate(item?.published)} -

-

- {getFileExtension(item.url)} -

-
+
{hasChanges ? (
) : (
)}
+ +
+

{item.title}

+
+

+ Date: {formatDate(item?.published)} +

+

+ Type: {getFileExtension(item.url).toUpperCase()} +

+
+
+
); } diff --git a/frontend/src/components/Modals/ManageWorkspace/Documents/WorkspaceDirectory/index.jsx b/frontend/src/components/Modals/ManageWorkspace/Documents/WorkspaceDirectory/index.jsx index 5617a020..fa32bf9f 100644 --- a/frontend/src/components/Modals/ManageWorkspace/Documents/WorkspaceDirectory/index.jsx +++ b/frontend/src/components/Modals/ManageWorkspace/Documents/WorkspaceDirectory/index.jsx @@ -31,8 +31,6 @@ function WorkspaceDirectory({

Name

-

Date

-

Kind

@@ -61,8 +59,6 @@ function WorkspaceDirectory({ >

Name

-

Date

-

Kind