From 1e995cfca34d10f09b1f08e8892747aea79ff329 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonatan=20K=C5=82osko?= Date: Wed, 22 Mar 2023 17:37:44 +0100 Subject: [PATCH] Allow unstarring notebooks directly from the cards (#1818) --- lib/livebook_web/live/home_live.ex | 25 +++++++++++++++++-- .../live/notebook_cards_component.ex | 2 +- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/lib/livebook_web/live/home_live.ex b/lib/livebook_web/live/home_live.ex index 46d3b518f..7afca84c8 100644 --- a/lib/livebook_web/live/home_live.ex +++ b/lib/livebook_web/live/home_live.ex @@ -116,8 +116,23 @@ defmodule LivebookWeb.HomeLive do sessions={@sessions} added_at_label="Starred" > - <:card_icon> - <.remix_icon icon="star-fill" class="text-yellow-600" /> + <:card_icon :let={{_info, idx}}> + + + <% end %> @@ -262,6 +277,12 @@ defmodule LivebookWeb.HomeLive do {:noreply, create_session(socket)} end + def handle_event("unstar_notebook", %{"idx" => idx}, socket) do + %{file: file} = Enum.fetch!(socket.assigns.starred_notebooks, idx) + Livebook.NotebookManager.remove_starred_notebook(file) + {:noreply, socket} + end + def handle_event("bulk_action", %{"action" => "disconnect"} = params, socket) do socket = assign(socket, selected_session_ids: params["session_ids"]) {:noreply, push_patch(socket, to: ~p"/home/sessions/edit_sessions/disconnect")} diff --git a/lib/livebook_web/live/notebook_cards_component.ex b/lib/livebook_web/live/notebook_cards_component.ex index b46fb8c35..07be8107f 100644 --- a/lib/livebook_web/live/notebook_cards_component.ex +++ b/lib/livebook_web/live/notebook_cards_component.ex @@ -18,7 +18,7 @@ defmodule LivebookWeb.NotebookCardsComponent do <%= info.name %> - <%= @card_icon && render_slot(@card_icon) %> + <%= @card_icon && render_slot(@card_icon, {info, idx}) %>
<%= @added_at_label %> <%= format_date_relatively(info.added_at) %>