mirror of
https://github.com/livebook-dev/livebook.git
synced 2024-09-20 18:15:56 +08:00
Add debug button to app session page (#1940)
This commit is contained in:
parent
3cf7a2f7cb
commit
826fcf2344
|
@ -118,6 +118,12 @@ defmodule LivebookWeb.AppSessionLive do
|
||||||
<span>View source</span>
|
<span>View source</span>
|
||||||
</.link>
|
</.link>
|
||||||
</.menu_item>
|
</.menu_item>
|
||||||
|
<.menu_item :if={@livebook_authenticated?}>
|
||||||
|
<.link patch={~p"/sessions/#{@session.id}"} role="menuitem">
|
||||||
|
<.remix_icon icon="terminal-line" />
|
||||||
|
<span>Debug</span>
|
||||||
|
</.link>
|
||||||
|
</.menu_item>
|
||||||
</.menu>
|
</.menu>
|
||||||
</div>
|
</div>
|
||||||
<div data-el-js-view-iframes phx-update="ignore" id="js-view-iframes"></div>
|
<div data-el-js-view-iframes phx-update="ignore" id="js-view-iframes"></div>
|
||||||
|
|
|
@ -28,19 +28,29 @@ defmodule LivebookWeb.AppAuthHook do
|
||||||
# send it in mount connect params via the socket. Then on the
|
# send it in mount connect params via the socket. Then on the
|
||||||
# server we use that token to authenticate.
|
# server we use that token to authenticate.
|
||||||
#
|
#
|
||||||
# This module defines a hook that sets the `:app_authenticated?`
|
# This module defines a hook that sets the following assigns:
|
||||||
# assign to reflect the current authentication state and also
|
#
|
||||||
# `:app_settings`. For public apps (or in case the user has full
|
# * `:app_authenticated?` - reflects the current authentication.
|
||||||
# access) it is set to `true` on both dead and live render.
|
# For public apps (or in case the user has full access) it is
|
||||||
|
# set to `true` on both dead and live render
|
||||||
|
#
|
||||||
|
# * `:livebook_authenticated?` - if the user has full Livebook
|
||||||
|
# access
|
||||||
|
#
|
||||||
|
# * `:app_settings` - the current app settings
|
||||||
|
#
|
||||||
|
|
||||||
def on_mount(:default, %{"slug" => slug}, session, socket) do
|
def on_mount(:default, %{"slug" => slug}, session, socket) do
|
||||||
|
livebook_authenticated? = livebook_authenticated?(session, socket)
|
||||||
|
|
||||||
|
socket = assign(socket, livebook_authenticated?: livebook_authenticated?)
|
||||||
|
|
||||||
case Livebook.Apps.fetch_settings(slug) do
|
case Livebook.Apps.fetch_settings(slug) do
|
||||||
{:ok, %{access_type: :public} = app_settings} ->
|
{:ok, %{access_type: :public} = app_settings} ->
|
||||||
{:cont, assign(socket, app_authenticated?: true, app_settings: app_settings)}
|
{:cont, assign(socket, app_authenticated?: true, app_settings: app_settings)}
|
||||||
|
|
||||||
{:ok, %{access_type: :protected} = app_settings} ->
|
{:ok, %{access_type: :protected} = app_settings} ->
|
||||||
app_authenticated? =
|
app_authenticated? = livebook_authenticated? or has_valid_token?(socket, app_settings)
|
||||||
livebook_authenticated?(session, socket) or has_valid_token?(socket, app_settings)
|
|
||||||
|
|
||||||
{:cont,
|
{:cont,
|
||||||
assign(socket, app_authenticated?: app_authenticated?, app_settings: app_settings)}
|
assign(socket, app_authenticated?: app_authenticated?, app_settings: app_settings)}
|
||||||
|
|
Loading…
Reference in a new issue