Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: display members(admin) and profile only for collect group policy #36672

Merged
merged 3 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 6 additions & 0 deletions src/libs/PolicyUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ function isExpensifyGuideTeam(email: string): boolean {
*/
const isPolicyAdmin = (policy: OnyxEntry<Policy> | EmptyObject): boolean => policy?.role === CONST.POLICY.ROLE.ADMIN;

const isCollectPolicy = (policy: OnyxEntry<Policy> | EmptyObject): boolean => policy?.type === CONST.POLICY.TYPE.TEAM;

const isFreePolicy = (policy: OnyxEntry<Policy> | EmptyObject): boolean => policy?.type === CONST.POLICY.TYPE.FREE;
Copy link
Member

@rushatgabhane rushatgabhane Feb 17, 2024

Choose a reason for hiding this comment

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

There is a policy type Personal also. Should we show the protect items for policy type personal?

Asked here - https://expensify.slack.com/archives/C01GTK53T8Q/p1708141365502539

App/src/CONST.ts

Lines 1333 to 1334 in f8080a2

FREE: 'free',
PERSONAL: 'personal',

Copy link
Member

Choose a reason for hiding this comment

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

got confirmation here. the current logic looks good


const isPolicyMember = (policyID: string, policies: OnyxCollection<Policy>): boolean => Object.values(policies ?? {}).some((policy) => policy?.id === policyID);

/**
Expand Down Expand Up @@ -258,6 +262,8 @@ export {
isExpensifyTeam,
isExpensifyGuideTeam,
isInstantSubmitEnabled,
isCollectPolicy,
isFreePolicy,
isPolicyAdmin,
isSubmitAndClose,
getMemberAccountIDsForWorkspace,
Expand Down
17 changes: 15 additions & 2 deletions src/pages/workspace/WorkspaceInitialPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,10 @@ function WorkspaceInitialPage({policyDraft, policy: policyProp, policyMembers, r
const hasGeneralSettingsError = !isEmptyObject(policy?.errorFields?.generalSettings ?? {}) || !isEmptyObject(policy?.errorFields?.avatar ?? {});

const shouldShowProtectedItems = PolicyUtils.isPolicyAdmin(policy);
const isCollectPolicy = PolicyUtils.isCollectPolicy(policy);
mountiny marked this conversation as resolved.
Show resolved Hide resolved
const isFreePolicy = PolicyUtils.isFreePolicy(policy);

const protectedMenuItems: WorkspaceMenuItem[] = [
const protectedFreePolicyMenuItems: WorkspaceMenuItem[] = [
{
translationKey: 'workspace.common.card',
icon: Expensicons.ExpensifyCard,
Expand Down Expand Up @@ -148,6 +150,16 @@ function WorkspaceInitialPage({policyDraft, policy: policyProp, policyMembers, r
},
];

const protectedCollectPolicyMenuItems: WorkspaceMenuItem[] = [
{
translationKey: 'workspace.common.members',
icon: Expensicons.Users,
action: singleExecution(waitForNavigate(() => Navigation.navigate(ROUTES.WORKSPACE_MEMBERS.getRoute(policyID)))),
brickRoadIndicator: hasMembersError ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined,
routeName: SCREENS.WORKSPACE.MEMBERS,
},
];

const menuItems: WorkspaceMenuItem[] = [
{
translationKey: 'workspace.common.profile',
Expand All @@ -156,7 +168,8 @@ function WorkspaceInitialPage({policyDraft, policy: policyProp, policyMembers, r
brickRoadIndicator: hasGeneralSettingsError ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined,
routeName: SCREENS.WORKSPACE.PROFILE,
},
...(shouldShowProtectedItems ? protectedMenuItems : []),
...(isCollectPolicy && shouldShowProtectedItems ? protectedCollectPolicyMenuItems : []),
...(isFreePolicy && shouldShowProtectedItems ? protectedFreePolicyMenuItems : []),
];

const prevPolicy = usePrevious(policy);
Expand Down
Loading