mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-09-04 12:04:20 +08:00
Add Logout button to Apps page (#2994)
This commit is contained in:
parent
f2af9eda59
commit
75ef15a82c
2 changed files with 22 additions and 4 deletions
|
@ -20,9 +20,20 @@ defmodule LivebookWeb.AppsLive do
|
|||
<div class="h-full flex flex-col overflow-y-auto">
|
||||
<div class="px-4 py-3 flex items-center justify-between">
|
||||
<div class="w-10 h-10">
|
||||
<.link navigate={~p"/"}>
|
||||
<img src={~p"/images/logo.png"} height="40" widthz="40" alt="logo livebook" />
|
||||
</.link>
|
||||
<.menu id="apps-menu" position="bottom-right" md_position="bottom-left">
|
||||
<:toggle>
|
||||
<button class="flex items-center text-gray-900">
|
||||
<img src={~p"/images/logo.png"} height="40" width="40" alt="logo livebook" />
|
||||
<.remix_icon icon="arrow-down-s-line" />
|
||||
</button>
|
||||
</:toggle>
|
||||
<.menu_item :if={Livebook.Config.logout_enabled?() and @current_user.email != nil}>
|
||||
<button phx-click="logout" role="menuitem">
|
||||
<.remix_icon icon="logout-box-line" />
|
||||
<span>Logout</span>
|
||||
</button>
|
||||
</.menu_item>
|
||||
</.menu>
|
||||
</div>
|
||||
<div>
|
||||
<.link navigate={~p"/apps-dashboard"} class="flex items-center text-blue-600">
|
||||
|
|
|
@ -78,7 +78,14 @@ defmodule LivebookWeb.AppAuthHook do
|
|||
|
||||
# Skip auth for non-app-specific routes
|
||||
def on_mount(:default, %{}, _session, socket) do
|
||||
{:cont, socket}
|
||||
if connected?(socket) do
|
||||
LivebookWeb.SessionHelpers.subscribe_to_logout()
|
||||
end
|
||||
|
||||
{:cont,
|
||||
socket
|
||||
|> attach_hook(:logout, :handle_info, &handle_info/2)
|
||||
|> attach_hook(:logout, :handle_event, &handle_event/3)}
|
||||
end
|
||||
|
||||
defp livebook_authorized?(session, socket) do
|
||||
|
|
Loading…
Add table
Reference in a new issue