Skip to content

Commit 6a405b2

Browse files
committed
fix: remove file_select_component changes that belong to PR #3157
1 parent 58521a5 commit 6a405b2

2 files changed

Lines changed: 3 additions & 47 deletions

File tree

lib/livebook_web/live/file_select_component.ex

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ defmodule LivebookWeb.FileSelectComponent do
523523
send_event(socket.assigns.target, {:mount_file_system, file_system})
524524
send_event(socket.assigns.target, {:set_file, file, %{exists: true}})
525525

526-
{:noreply, socket}
526+
{:noreply, assign(socket, loading: true)}
527527
end
528528

529529
def handle_event("set_path", %{"path" => path}, socket) do
@@ -544,7 +544,7 @@ defmodule LivebookWeb.FileSelectComponent do
544544
end
545545

546546
send_event(socket.assigns.target, {:set_file, file, info})
547-
{:noreply, socket}
547+
{:noreply, assign(socket, loading: socket.assigns.file.path != path)}
548548
end
549549

550550
def handle_event("clear_error", %{}, socket) do
@@ -640,13 +640,8 @@ defmodule LivebookWeb.FileSelectComponent do
640640
current_file_infos = assigns[:file_infos] || []
641641
{dir, prefix} = dir_and_prefix(assigns.file)
642642

643-
dir_changed? = dir != assigns.current_dir
644-
645-
# Only show loading when changing directories (which requires listing files)
646-
socket = if dir_changed?, do: assign(socket, :loading, true), else: socket
647-
648643
{file_infos, socket} =
649-
if dir_changed? or force_reload? do
644+
if dir != assigns.current_dir or force_reload? do
650645
case get_file_infos(dir, assigns.extnames, assigns.running_files) do
651646
{:ok, file_infos} ->
652647
{file_infos, assign(socket, :current_dir, dir)}

test/livebook_web/live/file_select_component_test.exs

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -23,45 +23,6 @@ defmodule LivebookWeb.FileSelectComponentTest do
2323
refute render_component(FileSelectComponent, attrs(file: file)) =~ ".."
2424
end
2525

26-
test "shows loading when changing directories" do
27-
file = FileSystem.File.local(notebooks_path() <> "/")
28-
29-
# Initial render in one directory
30-
html = render_component(FileSelectComponent, attrs(file: file))
31-
32-
# Loading should not be shown after initial render
33-
refute html =~ ~s(role="status")
34-
35-
# Simulate changing to a different directory via send_update with a new file
36-
new_file = FileSystem.File.local(p("/"))
37-
38-
html = render_component(FileSelectComponent, attrs(file: new_file))
39-
40-
# After changing directory, loading should be reset to false after listing
41-
refute html =~ ~s(role="status")
42-
end
43-
44-
test "does not show loading when only running_files changes" do
45-
file = FileSystem.File.local(notebooks_path() <> "/")
46-
running_file = FileSystem.File.local(notebooks_path() <> "/basic.livemd")
47-
48-
# Initial render with no running files
49-
html = render_component(FileSelectComponent, attrs(file: file, running_files: []))
50-
51-
refute html =~ ~s(role="status")
52-
# Verify basic.livemd is shown but not marked as running
53-
assert html =~ "basic.livemd"
54-
refute html =~ "play-circle-line"
55-
56-
# Update with running_files changed
57-
html = render_component(FileSelectComponent, attrs(file: file, running_files: [running_file]))
58-
59-
# Loading should not be shown when only running_files changes
60-
refute html =~ ~s(role="status")
61-
# Verify basic.livemd is now marked as running
62-
assert html =~ "play-circle-line"
63-
end
64-
6526
defp attrs(attrs) do
6627
Keyword.merge(
6728
[

0 commit comments

Comments
 (0)