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

Show guest roles for other members in Site CRM #4928

Merged
merged 1 commit into from
Dec 19, 2024
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
10 changes: 7 additions & 3 deletions lib/plausible/site/admin.ex
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ defmodule Plausible.SiteAdmin do
from(r in query,
as: :site,
inner_join: o in assoc(r, :owner),
preload: [owner: o, team: [team_memberships: :user]],
inner_join: t in assoc(r, :team),
preload: [owner: o, team: t, guest_memberships: [team_membership: :user]],
or_where: ilike(r.domain, ^search_term),
or_where: ilike(o.email, ^search_term),
or_where: ilike(o.name, ^search_term),
Expand Down Expand Up @@ -193,8 +194,8 @@ defmodule Plausible.SiteAdmin do
end

defp get_other_members(site) do
site.team.team_memberships
|> Enum.map(fn m -> m.user.email <> "(#{to_string(m.role)})" end)
site.guest_memberships
|> Enum.map(fn m -> m.team_membership.user.email <> "(#{member_role(m.role)})" end)
|> Enum.join(", ")
end

Expand All @@ -208,4 +209,7 @@ defmodule Plausible.SiteAdmin do

def create_changeset(schema, attrs), do: Plausible.Site.crm_changeset(schema, attrs)
def update_changeset(schema, attrs), do: Plausible.Site.crm_changeset(schema, attrs)

defp member_role(:editor), do: :admin
defp member_role(other), do: other
end
Loading