Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 72 additions & 4 deletions src/pages/workspace/WorkspaceMembersPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useSearchBackPress from '@hooks/useSearchBackPress';
import useSearchResults from '@hooks/useSearchResults';
import useStyleUtils from '@hooks/useStyleUtils';
import useThemeStyles from '@hooks/useThemeStyles';
import {turnOffMobileSelectionMode} from '@libs/actions/MobileSelectionMode';
import {
Expand All @@ -56,6 +57,7 @@
import {getDisplayNameForParticipant} from '@libs/ReportUtils';
import tokenizedSearch from '@libs/tokenizedSearch';
import {convertPolicyEmployeesToApprovalWorkflows, updateWorkflowDataOnApproverRemoval} from '@libs/WorkflowUtils';
import variables from '@styles/variables';
import {close} from '@userActions/Modal';
import {dismissAddedWithPrimaryLoginMessages} from '@userActions/Policy/Policy';
import CONST from '@src/CONST';
Expand All @@ -80,14 +82,20 @@
return Object.fromEntries(invertedEntries);
}

type MemberOption = Omit<ListItem, 'accountID' | 'login'> & {accountID: number; login: string};
type MemberOption = Omit<ListItem, 'accountID' | 'login'> & {
accountID: number;
login: string;
customField1?: string;
customField2?: string;
};

function WorkspaceMembersPage({personalDetails, route, policy}: WorkspaceMembersPageProps) {
const icons = useMemoizedLazyExpensifyIcons(['Download', 'User', 'UserEye', 'MakeAdmin', 'RemoveMembers', 'Table'] as const);
const policyMemberEmailsToAccountIDs = useMemo(() => getMemberAccountIDsForWorkspace(policy?.employeeList, true), [policy?.employeeList]);
const employeeListDetails = useMemo(() => policy?.employeeList ?? ({} as PolicyEmployeeList), [policy?.employeeList]);
const currentUserPersonalDetails = useCurrentUserPersonalDetails();
const styles = useThemeStyles();
const StyleUtils = useStyleUtils();
const [removeMembersConfirmModalVisible, setRemoveMembersConfirmModalVisible] = useState(false);
const {isOffline} = useNetwork();
const prevIsOffline = usePrevious(isOffline);
Expand Down Expand Up @@ -337,6 +345,7 @@
const policyOwner = policy?.owner;
const currentUserLogin = currentUserPersonalDetails.login;
const invitedPrimaryToSecondaryLogins = useMemo(() => invertObject(policy?.primaryLoginsInvited ?? {}), [policy?.primaryLoginsInvited]);
const isControlPolicyWithWideLayout = !shouldUseNarrowLayout && isControlPolicy(policy);
const data: MemberOption[] = useMemo(() => {
const result: MemberOption[] = [];

Expand Down Expand Up @@ -368,13 +377,41 @@
keyForList: details.login ?? '',
accountID,
login: details.login ?? '',
customField1: policyEmployee.employeeUserID,
customField2: policyEmployee.employeePayrollID,
isDisabledCheckbox: !(isPolicyAdmin && accountID !== policy?.ownerAccountID && accountID !== session?.accountID),
isDisabled: isPendingDeleteOrError,
isInteractive: !details.isOptimisticPersonalDetail,
cursorStyle: details.isOptimisticPersonalDetail ? styles.cursorDefault : {},
text: formatPhoneNumber(getDisplayNameOrDefault(details)),
alternateText: formatPhoneNumber(details?.login ?? ''),
rightElement: (
rightElement: isControlPolicyWithWideLayout ? (
<>
<View style={[styles.flex1, styles.pr3]}>
<Text
numberOfLines={1}
style={[styles.alignSelfStart]}
>
{policyEmployee.employeeUserID}
</Text>
</View>
<View style={[styles.flex1, styles.pr3]}>
<Text
numberOfLines={1}
style={[styles.alignSelfStart]}
>
{policyEmployee.employeePayrollID}
</Text>
</View>
<View style={[StyleUtils.getMinimumWidth(variables.w72)]}>
<MemberRightIcon
role={policyEmployee.role}
owner={policy?.owner}
login={details.login}
/>
Comment on lines +406 to +411

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding minWidth here caused minor style regression.
More details: #79341 (comment)

</View>
</>
) : (
<MemberRightIcon
role={policyEmployee.role}
owner={policy?.owner}
Expand All @@ -396,7 +433,7 @@
});
}
return result;
}, [

Check warning on line 436 in src/pages/workspace/WorkspaceMembersPage.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

React Hook useMemo has an unnecessary dependency: 'FallbackAvatar'. Either exclude it or remove the dependency array. Outer scope values like 'FallbackAvatar' aren't valid dependencies because mutating them doesn't re-render the component
policy?.employeeList,
policy?.ownerAccountID,
policy?.owner,
Expand All @@ -406,6 +443,11 @@
isPolicyAdmin,
session?.accountID,
styles.cursorDefault,
styles.flex1,
styles.pr3,
styles.alignSelfStart,
isControlPolicyWithWideLayout,
StyleUtils,
formatPhoneNumber,
FallbackAvatar,
invitedPrimaryToSecondaryLogins,
Expand Down Expand Up @@ -478,12 +520,38 @@
if (filteredData.length === 0) {
return null;
}

// Show 4 columns only on wide screens for control policies
if (isControlPolicyWithWideLayout) {
const header = (
<View style={[styles.flex1, styles.flexRow, styles.justifyContentBetween, canSelectMultiple && styles.pl3]}>
<View style={[styles.flex1, StyleUtils.getPaddingRight(variables.w52 + variables.w12)]}>
<Text style={[styles.textMicroSupporting, styles.alignSelfStart]}>{translate('common.member')}</Text>
</View>
<View style={[styles.flex1, styles.pr3]}>
<Text style={[styles.textMicroSupporting, styles.alignSelfStart]}>{translate('workspace.common.customField1')}</Text>
</View>
<View style={[styles.flex1, styles.pr3]}>
<Text style={[styles.textMicroSupporting, styles.alignSelfStart]}>{translate('workspace.common.customField2')}</Text>
</View>
<View style={[StyleUtils.getMinimumWidth(variables.w72), styles.pr2]}>
<Text style={[styles.textMicroSupporting, styles.alignSelfEnd]}>{translate('common.role')}</Text>
</View>
</View>
);

if (canSelectMultiple) {
return header;
}
return <View style={[styles.ph9, styles.pv3, styles.pb5]}>{header}</View>;
}

// Fall back to 2-column layout for narrow screens or non-control policies
return (
<CustomListHeader
canSelectMultiple={canSelectMultiple}
leftHeaderText={translate('common.member')}
rightHeaderText={translate('common.role')}
shouldShowRightCaret
/>
);
};
Expand Down Expand Up @@ -751,9 +819,9 @@
shouldShowListEmptyContent={false}
customListHeader={getCustomListHeader()}
listHeaderWrapperStyle={[styles.ph9, styles.pv3, styles.pb5]}
listItemTitleContainerStyles={shouldUseNarrowLayout ? undefined : [styles.pr3]}
showScrollIndicator={false}
addBottomSafeAreaPadding
shouldShowRightCaret
Comment thread
mohammadjafarinejad marked this conversation as resolved.
Resolved
/>
</>
)}
Expand Down
Loading