From fd50db234119e3855f42b2c9976beb0b174b4560 Mon Sep 17 00:00:00 2001 From: roo hutton Date: Mon, 1 Jul 2024 09:30:19 +0100 Subject: [PATCH] [web] Pending invite prevents Viewer being changed to Editor (#19214) * only count editor invites when disabling editor in dropdown GitOrigin-RevId: 400215d4817c0146da4f8397fe2007699da0e92b --- .../restricted-link-sharing/share-modal-body.tsx | 7 ++++++- .../frontend/js/shared/context/types/project-context.tsx | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/services/web/frontend/js/features/share-project-modal/components/restricted-link-sharing/share-modal-body.tsx b/services/web/frontend/js/features/share-project-modal/components/restricted-link-sharing/share-modal-body.tsx index a6c04f90a0..bc7bcfaac0 100644 --- a/services/web/frontend/js/features/share-project-modal/components/restricted-link-sharing/share-modal-body.tsx +++ b/services/web/frontend/js/features/share-project-modal/components/restricted-link-sharing/share-modal-body.tsx @@ -26,9 +26,13 @@ export default function ShareModalBody() { return true } + const editorInvites = invites.filter( + invite => invite.privileges === 'readAndWrite' + ).length + return ( members.filter(member => member.privileges === 'readAndWrite').length + - invites.length < + editorInvites < (features.collaborators ?? 1) ) }, [members, invites, features, isProjectOwner]) @@ -41,6 +45,7 @@ export default function ShareModalBody() { if (features.collaborators === -1) { return false } + return ( members.filter(member => member.privileges === 'readAndWrite').length > (features.collaborators ?? 1) diff --git a/services/web/frontend/js/shared/context/types/project-context.tsx b/services/web/frontend/js/shared/context/types/project-context.tsx index de8e73d543..60e50c6517 100644 --- a/services/web/frontend/js/shared/context/types/project-context.tsx +++ b/services/web/frontend/js/shared/context/types/project-context.tsx @@ -14,7 +14,7 @@ export type ProjectContextValue = { rootDocId?: string compiler: string members: ProjectContextMember[] - invites: { _id: UserId }[] + invites: ProjectContextMember[] features: { collaborators?: number compileGroup?: 'alpha' | 'standard' | 'priority'