Fix smart cell editor initialization (#2017)

This commit is contained in:
Jonatan Kłosko 2023-06-28 22:39:24 +02:00 committed by GitHub
parent 02cc289f7c
commit 9541eb91c8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 7 deletions

View file

@ -1821,9 +1821,13 @@ defmodule LivebookWeb.SessionLive do
defp after_operation(
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
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
defp after_operation(socket, _prev_socket, {:erase_outputs, _client_id}) do
@ -2060,9 +2064,10 @@ defmodule LivebookWeb.SessionLive do
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,
{tag, payload} <- cell_editor_init_payloads(cell, data.cell_infos[cell.id]),
tags == :all or tag in tags,
reduce: socket do
socket ->
push_event(socket, "cell_editor_init:#{cell.id}:#{tag}", payload)
@ -2106,7 +2111,7 @@ defmodule LivebookWeb.SessionLive do
end
}
] ++
if cell.editor do
if cell.editor && cell_info.status == :started do
[
secondary: %{
source: cell.editor.source,

View file

@ -156,7 +156,7 @@ defmodule LivebookWeb.SessionLive.SecretsListComponent do
*****
</span>
<.link
id="edit-secret-button"
id={"#{@id}-edit-button"}
navigate={~p"/hub/#{@secret.hub_id}/secrets/edit/#{@secret.name}"}
class="hover:text-gray-900"
role="button"

View file

@ -121,7 +121,7 @@ defmodule LivebookWeb.Integration.SessionLiveTest do
# clicks the button to edit a secret
view
|> with_target("#secrets_list")
|> element("#hub-#{id}-secret-#{secret_name}-detail #edit-secret-button")
|> element("#hub-#{id}-secret-#{secret_name}-edit-button")
|> render_click()
# redirects to hub page and loads the modal with

View file

@ -1322,7 +1322,7 @@ defmodule LivebookWeb.SessionLiveTest do
# clicks the button to edit a secret
view
|> 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()
# redirects to hub page and loads the modal with