From 9a47ad57150333c415db13490173a9c054684f46 Mon Sep 17 00:00:00 2001 From: Jay Hodgson Date: Thu, 26 Oct 2023 19:29:39 -0700 Subject: [PATCH] show join team button if the user has an open invitation in a locked team --- .../web/client/presenter/TeamPresenter.java | 7 ++++-- .../presenter/TeamPresenterTest.java | 24 +++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/sagebionetworks/web/client/presenter/TeamPresenter.java b/src/main/java/org/sagebionetworks/web/client/presenter/TeamPresenter.java index d965a6f60e..e5c5d33a47 100644 --- a/src/main/java/org/sagebionetworks/web/client/presenter/TeamPresenter.java +++ b/src/main/java/org/sagebionetworks/web/client/presenter/TeamPresenter.java @@ -247,8 +247,11 @@ public void onSuccess(TeamBundle result) { !teamMembershipStatus.getIsMember() ) ) { - // not a member, is team locked down? - if (!isLockedDown) { + // not a member, show the Join Team button if the team is not locked down, or if the user has an open team invitation + boolean hasOpenInvitation = + teamMembershipStatus != null && + teamMembershipStatus.getHasOpenInvitation(); + if (!isLockedDown || hasOpenInvitation) { // not locked down, add the Join team widget joinTeamWidget.configure( teamId, diff --git a/src/test/java/org/sagebionetworks/web/unitclient/presenter/TeamPresenterTest.java b/src/test/java/org/sagebionetworks/web/unitclient/presenter/TeamPresenterTest.java index 3af84d4c31..33ca2f5804 100644 --- a/src/test/java/org/sagebionetworks/web/unitclient/presenter/TeamPresenterTest.java +++ b/src/test/java/org/sagebionetworks/web/unitclient/presenter/TeamPresenterTest.java @@ -525,4 +525,28 @@ public void testNotMemberOfLockedTeam() { anyBoolean() ); } + + @Test + public void testNotMemberOfLockedTeamHasOpenInvite() { + boolean isAdmin = false; + when(mockTeamBundle.isUserAdmin()).thenReturn(isAdmin); + when(mockTeamMembershipStatus.getIsMember()).thenReturn(false); + when(mockTeamMembershipStatus.getHasOpenInvitation()).thenReturn(true); + when(mockTeam.getCanRequestMembership()).thenReturn(false); + + presenter.refresh(teamId); + + verify(mockJoinWidget) + .configure( + eq(teamId), + anyBoolean(), + eq(mockTeamMembershipStatus), + any(Callback.class), + anyString(), + anyString(), + anyString(), + anyString(), + anyBoolean() + ); + } }