Skip to content

Commit

Permalink
Account for pending site transfers in Settings > People list
Browse files Browse the repository at this point in the history
  • Loading branch information
zoldar committed Nov 25, 2024
1 parent c6b5a0c commit 51fcf7f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/plausible/teams/adapter/read/sites.ex
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,19 @@ defmodule Plausible.Teams.Adapter.Read.Sites do
)
|> Repo.all()

%{memberships: memberships, invitations: invitations}
site_transfers =
from(
st in Teams.SiteTransfer,
where: st.site_id == ^site.id,
select: %Plausible.Auth.Invitation{
invitation_id: st.transfer_id,
email: st.email,
role: :owner
}
)
|> Repo.all()

%{memberships: memberships, invitations: site_transfers ++ invitations}
else
site
|> Repo.preload([:invitations, memberships: :user])
Expand Down
13 changes: 13 additions & 0 deletions test/plausible_web/controllers/site_controller_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,19 @@ defmodule PlausibleWeb.SiteControllerTest do
assert text_of_element(resp, "#invitation-#{i2.invitation_id}") ==
"[email protected] Viewer"
end

test "lists pending site transfer", %{conn: conn, user: user} do
site = new_site(owner: user)
new_owner = new_user()

st = invite_transfer(site, new_owner, inviter: user)

conn = get(conn, "/#{site.domain}/settings/people")
resp = html_response(conn, 200)

assert text_of_element(resp, "#invitation-#{st.invitation_id}") ==
"#{new_owner.email} Owner"
end
end

describe "GET /:domain/settings/goals" do
Expand Down

0 comments on commit 51fcf7f

Please sign in to comment.