Repository navigation
Always show My Personal Sites in the team switcher #6855
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
Open
vinibrsl
wants to merge
4
commits into
master
Choose a base branch
from
team-switcher-personal-sites
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
7217ea9
Match team switcher font weight with other menu links
vinibrsl 323bf9a
Always show My Personal Sites in the team switcher
vinibrsl 45212ed
Sort teams in the team switcher
vinibrsl c5433a9
Show "Create new team" for every team switcher selection
vinibrsl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -164,73 +164,62 @@ defmodule PlausibleWeb.LayoutView do | |
| end | ||
| end | ||
|
|
||
| attr :current_user, :any, required: true | ||
| attr :teams, :list, required: true | ||
| attr :my_team, :any, default: nil | ||
| attr :current_team, :any, default: nil | ||
|
|
||
| def team_switcher(assigns) do | ||
| teams = assigns[:teams] | ||
| personal_team = | ||
| assigns.my_team || %Teams.Team{identifier: "none", name: Teams.default_name()} | ||
|
|
||
| if teams && teams != [] do | ||
| current_team = assigns[:current_team] | ||
| my_team = assigns[:my_team] | ||
| current_included? = current_team && Enum.any?(teams, &(&1.id == current_team.id)) | ||
| current_is_my? = current_team && my_team && current_team.id == my_team.id | ||
| current_team = assigns.current_team || personal_team | ||
|
|
||
| teams = | ||
| if current_team && !current_included? && !current_is_my? do | ||
| [current_team | teams] | ||
| else | ||
| teams | ||
| end | ||
|
|
||
| teams = | ||
| if my_team do | ||
| teams ++ [my_team] | ||
| else | ||
| teams ++ [%Teams.Team{identifier: "none", name: Teams.default_name()}] | ||
| end | ||
| other_teams = | ||
| [personal_team | Enum.sort_by(assigns.teams, &String.downcase(&1.name))] | ||
| |> Enum.reject(&(&1.id == current_team.id)) | ||
|
|
||
| selected_id = current_team && current_team.id | ||
| {pinned_team, other_teams} = Enum.split_with(teams, &(&1.id == selected_id)) | ||
| assigns = | ||
| assigns | ||
| |> assign(:current_team, current_team) | ||
| |> assign(:personal_team, personal_team) | ||
| |> assign(:other_teams, other_teams) | ||
|
|
||
| assigns = | ||
| assigns | ||
| |> assign(:pinned_team, List.first(pinned_team)) | ||
| |> assign(:other_teams, other_teams) | ||
|
|
||
| ~H""" | ||
| <.dropdown_item> | ||
| <div class="text-xs text-gray-500 dark:text-gray-400">Teams</div> | ||
| </.dropdown_item> | ||
| ~H""" | ||
| <.dropdown_item> | ||
| <div class="text-xs text-gray-500 dark:text-gray-400">Teams</div> | ||
| </.dropdown_item> | ||
| <.dropdown_item href={~p"/sites?#{[__team: @current_team.identifier]}"}> | ||
| <div class="flex items-center justify-between gap-2" role="none"> | ||
| <p class="font-semibold truncate min-w-0 text-gray-900 dark:text-gray-100"> | ||
| {Teams.name(@current_team)} | ||
| </p> | ||
| <Heroicons.check class="size-4 shrink-0 stroke-2 text-gray-500 dark:text-gray-400" /> | ||
| </div> | ||
| </.dropdown_item> | ||
| <div class="max-h-[200px] overflow-y-auto"> | ||
| <.dropdown_item | ||
| :if={@pinned_team} | ||
| href={~p"/sites?#{[__team: @pinned_team.identifier]}"} | ||
| :for={team <- @other_teams} | ||
| href={~p"/sites?#{[__team: team.identifier]}"} | ||
| > | ||
| <div class="flex items-center justify-between gap-2" role="none"> | ||
| <p class="font-semibold truncate min-w-0 text-gray-900 dark:text-gray-100"> | ||
| {Teams.name(@pinned_team)} | ||
| </p> | ||
| <Heroicons.check class="size-4 shrink-0 stroke-2 text-gray-500 dark:text-gray-400" /> | ||
| </div> | ||
| </.dropdown_item> | ||
| <div class="max-h-[200px] overflow-y-auto"> | ||
| <.dropdown_item | ||
| :for={team <- @other_teams} | ||
| href={~p"/sites?#{[__team: team.identifier]}"} | ||
| <p | ||
| class="truncate text-gray-900 dark:text-gray-100 pr-4" | ||
| role="none" | ||
| > | ||
| <p | ||
| class="font-medium truncate text-gray-900 dark:text-gray-100 pr-4" | ||
| role="none" | ||
| > | ||
| {Teams.name(team)} | ||
| </p> | ||
| </.dropdown_item> | ||
| {Teams.name(team)} | ||
| </p> | ||
| </.dropdown_item> | ||
| </div> | ||
| <.dropdown_item | ||
| :if={Plausible.Users.type(@current_user) == :standard} | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SSO users can't create teams, so we hide the option. |
||
| href={~p"/team/setup?#{[__team: @personal_team.identifier]}"} | ||
| > | ||
| <div class="flex items-center justify-between gap-2" role="none"> | ||
| <span data-test="create-a-team-cta">Create new team</span> | ||
| <Heroicons.plus class="size-4 shrink-0 stroke-2 text-gray-500 dark:text-gray-400" /> | ||
| </div> | ||
| """ | ||
| else | ||
| ~H"" | ||
| end | ||
| </.dropdown_item> | ||
| """ | ||
| end | ||
|
|
||
| def trial_notification(team) do | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this so we don't show the team switcher during onboarding.