mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-11-10 06:01:44 +08:00
Fix smart cell editor initialization (#2017)
This commit is contained in:
parent
02cc289f7c
commit
9541eb91c8
4 changed files with 12 additions and 7 deletions
|
|
@ -1821,9 +1821,13 @@ defmodule LivebookWeb.SessionLive do
|
||||||
defp after_operation(
|
defp after_operation(
|
||||||
socket,
|
socket,
|
||||||
_prev_socket,
|
_prev_socket,
|
||||||
{:smart_cell_started, _client_id, _cell_id, _delta, _chunks, _js_view, _editor}
|
{:smart_cell_started, _client_id, cell_id, _delta, _chunks, _js_view, _editor}
|
||||||
) do
|
) do
|
||||||
prune_cell_sources(socket)
|
{:ok, cell, _section} = Notebook.fetch_cell_and_section(socket.private.data.notebook, cell_id)
|
||||||
|
|
||||||
|
socket
|
||||||
|
|> push_cell_editor_payloads(socket.private.data, [cell], [:secondary])
|
||||||
|
|> prune_cell_sources()
|
||||||
end
|
end
|
||||||
|
|
||||||
defp after_operation(socket, _prev_socket, {:erase_outputs, _client_id}) do
|
defp after_operation(socket, _prev_socket, {:erase_outputs, _client_id}) do
|
||||||
|
|
@ -2060,9 +2064,10 @@ defmodule LivebookWeb.SessionLive do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
defp push_cell_editor_payloads(socket, data, cells) do
|
defp push_cell_editor_payloads(socket, data, cells, tags \\ :all) do
|
||||||
for cell <- cells,
|
for cell <- cells,
|
||||||
{tag, payload} <- cell_editor_init_payloads(cell, data.cell_infos[cell.id]),
|
{tag, payload} <- cell_editor_init_payloads(cell, data.cell_infos[cell.id]),
|
||||||
|
tags == :all or tag in tags,
|
||||||
reduce: socket do
|
reduce: socket do
|
||||||
socket ->
|
socket ->
|
||||||
push_event(socket, "cell_editor_init:#{cell.id}:#{tag}", payload)
|
push_event(socket, "cell_editor_init:#{cell.id}:#{tag}", payload)
|
||||||
|
|
@ -2106,7 +2111,7 @@ defmodule LivebookWeb.SessionLive do
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
] ++
|
] ++
|
||||||
if cell.editor do
|
if cell.editor && cell_info.status == :started do
|
||||||
[
|
[
|
||||||
secondary: %{
|
secondary: %{
|
||||||
source: cell.editor.source,
|
source: cell.editor.source,
|
||||||
|
|
|
||||||
|
|
@ -156,7 +156,7 @@ defmodule LivebookWeb.SessionLive.SecretsListComponent do
|
||||||
*****
|
*****
|
||||||
</span>
|
</span>
|
||||||
<.link
|
<.link
|
||||||
id="edit-secret-button"
|
id={"#{@id}-edit-button"}
|
||||||
navigate={~p"/hub/#{@secret.hub_id}/secrets/edit/#{@secret.name}"}
|
navigate={~p"/hub/#{@secret.hub_id}/secrets/edit/#{@secret.name}"}
|
||||||
class="hover:text-gray-900"
|
class="hover:text-gray-900"
|
||||||
role="button"
|
role="button"
|
||||||
|
|
|
||||||
|
|
@ -121,7 +121,7 @@ defmodule LivebookWeb.Integration.SessionLiveTest do
|
||||||
# clicks the button to edit a secret
|
# clicks the button to edit a secret
|
||||||
view
|
view
|
||||||
|> with_target("#secrets_list")
|
|> with_target("#secrets_list")
|
||||||
|> element("#hub-#{id}-secret-#{secret_name}-detail #edit-secret-button")
|
|> element("#hub-#{id}-secret-#{secret_name}-edit-button")
|
||||||
|> render_click()
|
|> render_click()
|
||||||
|
|
||||||
# redirects to hub page and loads the modal with
|
# redirects to hub page and loads the modal with
|
||||||
|
|
|
||||||
|
|
@ -1322,7 +1322,7 @@ defmodule LivebookWeb.SessionLiveTest do
|
||||||
# clicks the button to edit a secret
|
# clicks the button to edit a secret
|
||||||
view
|
view
|
||||||
|> with_target("#secrets_list")
|
|> with_target("#secrets_list")
|
||||||
|> element("#hub-#{hub.id}-secret-#{secret_name}-detail #edit-secret-button")
|
|> element("#hub-#{hub.id}-secret-#{secret_name}-edit-button")
|
||||||
|> render_click()
|
|> render_click()
|
||||||
|
|
||||||
# redirects to hub page and loads the modal with
|
# redirects to hub page and loads the modal with
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue