From e59be1982915dfe3854786e5f77cfd3ac4b8a4e3 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Thu, 11 Apr 2024 11:38:54 +0700 Subject: [PATCH 1/2] Refactor layout of WorkspaceListRow --- src/pages/workspace/WorkspacesListRow.tsx | 197 ++++++++++------------ 1 file changed, 93 insertions(+), 104 deletions(-) diff --git a/src/pages/workspace/WorkspacesListRow.tsx b/src/pages/workspace/WorkspacesListRow.tsx index 54717b032ebe..1a6ef8c20577 100644 --- a/src/pages/workspace/WorkspacesListRow.tsx +++ b/src/pages/workspace/WorkspacesListRow.tsx @@ -21,6 +21,7 @@ import type {AnchorPosition} from '@styles/index'; import variables from '@styles/variables'; import CONST from '@src/CONST'; import type IconAsset from '@src/types/utils/IconAsset'; +import useWindowDimensions from '@hooks/useWindowDimensions'; type WorkspacesListRowProps = WithCurrentUserPersonalDetailsProps & { /** Name of the workspace */ @@ -108,6 +109,7 @@ function WorkspacesListRow({ const {translate} = useLocalize(); const [threeDotsMenuPosition, setThreeDotsMenuPosition] = useState({horizontal: 0, vertical: 0}); const threeDotsMenuContainerRef = useRef(null); + const {isSmallScreenWidth} = useWindowDimensions(); const ownerDetails = ownerAccountID && PersonalDetailsUtils.getPersonalDetailsByIDs([ownerAccountID], currentUserPersonalDetails.accountID)[0]; @@ -136,124 +138,111 @@ function WorkspacesListRow({ const isDeleted = style && Array.isArray(style) ? style.includes(styles.offlineFeedback.deleted) : false; return ( - - - - - {title} - - {isNarrow && - (!isJoinRequestPending ? ( + + + + + + {title} + + + + {!!ownerDetails && ( <> - - + + + {PersonalDetailsUtils.getDisplayNameOrDefault(ownerDetails)} + + + {ownerDetails.login} + + - ) : ( + )} + + + + + + {userFriendlyWorkspaceType} + + + {translate('workspace.common.plan')} + + + + + + {isJoinRequestPending && ( + - ))} - - - {!!ownerDetails && ( + + )} + {!isJoinRequestPending && ( <> - - - - {PersonalDetailsUtils.getDisplayNameOrDefault(ownerDetails)} - - - {ownerDetails.login} - + + + + + { + if (isSmallScreenWidth) { + return; + } + threeDotsMenuContainerRef.current?.measureInWindow((x, y, width, height) => { + setThreeDotsMenuPosition({ + horizontal: x + width, + vertical: y + height, + }); + }); + }} + menuItems={menuItems} + anchorPosition={threeDotsMenuPosition} + anchorAlignment={{horizontal: CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.RIGHT, vertical: CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.TOP}} + shouldOverlay + disabled={shouldDisableThreeDotsMenu} + /> )} - - - - - {userFriendlyWorkspaceType} - - - {translate('workspace.common.plan')} - - - - {isJoinRequestPending && !isNarrow && ( - - - - )} - - {isWide && !isJoinRequestPending && ( - <> - - - - - { - threeDotsMenuContainerRef.current?.measureInWindow((x, y, width, height) => { - setThreeDotsMenuPosition({ - horizontal: x + width, - vertical: y + height, - }); - }); - }} - menuItems={menuItems} - anchorPosition={threeDotsMenuPosition} - anchorAlignment={{horizontal: CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.RIGHT, vertical: CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.TOP}} - iconStyles={[styles.mr2]} - shouldOverlay - disabled={shouldDisableThreeDotsMenu} - /> - - - )} ); } From 789607a1deee28fd1e2a68485c8427c0a1c90acd Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Thu, 11 Apr 2024 11:55:38 +0700 Subject: [PATCH 2/2] fix lint --- src/pages/workspace/WorkspacesListRow.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/WorkspacesListRow.tsx b/src/pages/workspace/WorkspacesListRow.tsx index 1a6ef8c20577..e9963e5469c2 100644 --- a/src/pages/workspace/WorkspacesListRow.tsx +++ b/src/pages/workspace/WorkspacesListRow.tsx @@ -15,13 +15,13 @@ import withCurrentUserPersonalDetails from '@components/withCurrentUserPersonalD import useLocalize from '@hooks/useLocalize'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; +import useWindowDimensions from '@hooks/useWindowDimensions'; import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils'; import type {AvatarSource} from '@libs/UserUtils'; import type {AnchorPosition} from '@styles/index'; import variables from '@styles/variables'; import CONST from '@src/CONST'; import type IconAsset from '@src/types/utils/IconAsset'; -import useWindowDimensions from '@hooks/useWindowDimensions'; type WorkspacesListRowProps = WithCurrentUserPersonalDetailsProps & { /** Name of the workspace */