File size: 7,669 Bytes
88211d3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<nav class="relative z-20 py-5">
  <div class="container print:max-w-full">
    <nav class="relative flex items-center justify-between sm:h-10 md:justify-center">
      <div class="flex items-center flex-1 md:absolute md:inset-y-0 md:left-0">
        <a href={home_dest(@conn)}>
          <Layout.logo />
        </a>
      </div>
      <div class="absolute inset-y-0 right-0 flex items-center justify-end">
        <%= cond do %>
          <% @conn.assigns[:current_user] -> %>
            <ul class="flex items-center gap-2 w-full sm:w-auto">
              <li :if={
                ee?() && @conn.assigns[:site] &&
                  Plausible.Auth.super_admin?(@conn.assigns[:current_user])
              }>
                <.styled_link
                  class="text-sm font-medium"
                  href={"/cs/sites/site/#{@conn.assigns.site.id}"}
                  new_tab={true}
                >
                  CS
                </.styled_link>
              </li>
              <li
                :if={
                  ee?() and Plausible.Teams.on_trial?(@conn.assigns[:current_team]) and
                    (not Plausible.Teams.setup?(@conn.assigns[:current_team]) or
                       @conn.assigns[:current_team_role] in Plausible.Billing.allowed_roles())
                }
                class="hidden sm:block"
              >
                <div class="flex items-center p-1 rounded-lg bg-yellow-100 dark:bg-yellow-600/35 overflow-hidden">
                  <span class="px-3 text-sm font-medium text-gray-900 dark:text-gray-100">
                    {trial_notification(@conn.assigns[:current_team])}
                  </span>
                  <.button_link
                    href={Routes.settings_path(@conn, :subscription)}
                    theme="yellow"
                    mt?={false}
                    class="!px-3 !py-2"
                  >
                    Upgrade
                  </.button_link>
                </div>
              </li>
              <li class="w-full sm:w-auto">
                <.dropdown>
                  <:button class="flex items-center gap-2 pl-3 pr-1.5 py-2 rounded-md transition-colors duration-150 hover:bg-gray-100 dark:hover:bg-gray-800">
                    <span class="hidden md:block text-sm font-medium truncate dark:text-gray-100">
                      {@conn.assigns[:current_user].name}
                    </span>
                    <img
                      src={Plausible.Auth.User.profile_img_url(@conn.assigns[:current_user])}
                      class="-my-0.5 w-7 rounded-full"
                    />
                  </:button>
                  <:menu class="max-w-xs">
                    <.dropdown_item>
                      <div class="text-xs text-gray-500 dark:text-gray-400">Signed in as</div>
                      <p class="truncate font-medium text-gray-900 dark:text-gray-100" role="none">
                        {@conn.assigns[:current_user].email}
                      </p>
                    </.dropdown_item>
                    <.team_switcher
                      conn={@conn}
                      teams={@teams}
                      my_team={@my_team}
                      current_team={@current_team}
                    />
                    <.dropdown_divider />
                    <.dropdown_item href={Routes.settings_path(@conn, :index)}>
                      Account settings
                    </.dropdown_item>

                    <div :if={@my_team && @my_team.id == @current_team.id}>
                      <.dropdown_item class="flex" href={Routes.team_setup_path(@conn, :setup)}>
                        <span data-test="create-a-team-cta" class="flex-1">
                          Create a team
                        </span>
                      </.dropdown_item>
                      <.dropdown_divider />
                    </div>

                    <div :if={Plausible.Teams.setup?(@current_team)}>
                      <.dropdown_item
                        class="flex"
                        href={Routes.settings_path(@conn, :team_general)}
                      >
                        <span class="flex-1">
                          Team settings
                        </span>
                      </.dropdown_item>
                      <.dropdown_divider />
                    </div>
                    <.dropdown_item
                      class="!flex justify-between gap-x-12"
                      new_tab
                      href="https://plausible.io/docs"
                    >
                      Help center
                    </.dropdown_item>
                    <.dropdown_item
                      :if={ee?()}
                      class="!flex justify-between gap-x-12"
                      new_tab
                      href="https://plausible.io/contact"
                    >
                      Contact support
                    </.dropdown_item>
                    <.dropdown_item
                      :if={ee?()}
                      class="!flex justify-between gap-x-12"
                      new_tab
                      href={feedback_link(@conn.assigns[:current_user])}
                    >
                      Feature requests
                    </.dropdown_item>
                    <.dropdown_item
                      :if={ce?()}
                      class="!flex justify-between gap-x-12"
                      new_tab
                      href="https://github.com/plausible/analytics"
                    >
                      Github repo
                    </.dropdown_item>
                    <.dropdown_item href="/logout">Log out</.dropdown_item>
                  </:menu>
                </.dropdown>
              </li>
              <%= if @conn.assigns[:current_user] && ee?() do %>
                <li id="changelog-notification" class="relative py-2"></li>
              <% end %>
            </ul>
          <% Keyword.fetch!(Application.get_env(:plausible, :selfhost), :disable_registration) != false -> %>
            <ul class="flex" x-show="!document.cookie.includes('logged_in=true')">
              <li>
                <div class="inline-flex">
                  <a
                    href="/login"
                    class="font-medium text-gray-500 dark:text-gray-200 hover:text-gray-900 dark:hover:text-gray-100 focus:outline-hidden focus:text-gray-900 transition duration-150 ease-in-out"
                  >
                    Login
                  </a>
                </div>
              </li>
            </ul>
          <% true -> %>
            <ul class="flex" x-show="!document.cookie.includes('logged_in=true')">
              <li>
                <div class="inline-flex">
                  <a
                    href="/login"
                    class="font-medium text-gray-500 dark:text-gray-200 hover:text-gray-900 dark:hover:text-gray-100 focus:outline-hidden focus:text-gray-900 transition duration-150 ease-in-out"
                  >
                    Login
                  </a>
                </div>
                <div class="inline-flex ml-6 rounded-sm shadow-sm">
                  <a
                    href="/register"
                    class="inline-flex items-center justify-center px-5 py-2 text-base font-medium text-white bg-indigo-600 border border-transparent leading-6 rounded-md hover:bg-indigo-500 focus:outline-hidden focus:ring transition duration-150 ease-in-out"
                  >
                    Sign up
                  </a>
                </div>
              </li>
            </ul>
        <% end %>
      </div>
    </nav>
  </div>
</nav>