Skip to content

Add the ability to remove yourself as a guest - #6826

Merged
RobertJoonas merged 11 commits into
masterfrom
leave-guest-site
Nov 4, 2026
Merged

RobertJoonas merged 11 commits into
masterfrom
leave-guest-site

Conversation

@RobertJoonas

Copy link
Copy Markdown
Contributor

Changes

Add a new "Guest sites" page into Account Settings, that lists all your guest memberships:

image
  • When the owner team is not set up (that means there's only one owner), the team name is replaced with "Owned by #{user.name}"
  • The sidebar link to this page only shows up if the user has any guest memberships.
  • Without any guest memberships, the page redirects to /settings/preferences (the index of account settings)
  • The only action the user can take on this page is leave a site

Tests

  • Automated tests have been added

Changelog

  • Entry has been added to changelog

Documentation

  • Docs have been updated

Dark mode

  • The UI has been tested both in dark and light mode

@RobertJoonas
RobertJoonas requested a review from a team November 2, 2026 13:42
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Preview environment👷🏼‍♀️🏗️
PR-6826

Comment thread lib/plausible_web/router.ex Resolved
Comment thread lib/plausible_web/views/layout_view.ex Resolved
Comment thread lib/plausible/teams/memberships.ex Resolved
Comment thread lib/plausible/teams/memberships.ex Resolved
Comment thread lib/plausible_web/views/layout_view.ex Resolved

@zoldar zoldar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One thing we could consider is querying for guest membership directly in session retrieval query, as discussed elsewhere. Other than that, LGTM.

end
end

describe "GET /settings/guest-sites" do

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

meganitpick, non-blocking: with connected apps screen, I took the approach of putting these in a separate module. defmodule PlausibleWeb.SettingsController.ConnectedAppsTest do

@RobertJoonas RobertJoonas Nov 4, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good call to avoid increasing the giant file even further. Did the same for guest sites settings. 25ff6c0

def leave_guest_site(conn, %{"site_id" => site_id}) do
user = conn.assigns.current_user

guest_membership =

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'd consider refactoring and adding a clause accepting site_id to Teams.Memberships.remove/2 to avoid this slightly awkward site retrieval 😬

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

case Repo.one(token_query) do
%Auth.UserSession{} = user_session ->
{user_session, has_guest_memberships?} ->
user_session = put_in(user_session.user.has_guest_memberships?, has_guest_memberships?)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not a fan of cramming contextual stuff into virtual fields of a struct, but alternative being passing around even more complex result shape along with retrieved session, I guess that's a lesser evil we can live with for now 🙈

@RobertJoonas
RobertJoonas added this pull request to the merge queue Nov 4, 2026
Merged via the queue into master with commit ac8b09b Nov 4, 2026
24 checks passed
@RobertJoonas
RobertJoonas deleted the leave-guest-site branch November 4, 2026 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants