mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-10-08 20:46:16 +08:00
Allow unstarring notebooks directly from the cards (#1818)
This commit is contained in:
parent
32987558be
commit
1e995cfca3
2 changed files with 24 additions and 3 deletions
|
@ -116,8 +116,23 @@ defmodule LivebookWeb.HomeLive do
|
||||||
sessions={@sessions}
|
sessions={@sessions}
|
||||||
added_at_label="Starred"
|
added_at_label="Starred"
|
||||||
>
|
>
|
||||||
<:card_icon>
|
<:card_icon :let={{_info, idx}}>
|
||||||
<.remix_icon icon="star-fill" class="text-yellow-600" />
|
<span class="tooltip top" data-tooltip="Unstar">
|
||||||
|
<button
|
||||||
|
aria-label="unstar notebook"
|
||||||
|
phx-click={
|
||||||
|
with_confirm(
|
||||||
|
JS.push("unstar_notebook", value: %{idx: idx}),
|
||||||
|
title: "Unstar notebook",
|
||||||
|
description: "Once you unstar this notebook, you can always star it again.",
|
||||||
|
confirm_text: "Unstar",
|
||||||
|
opt_out_id: "unstar-notebook"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<.remix_icon icon="star-fill" class="text-yellow-600" />
|
||||||
|
</button>
|
||||||
|
</span>
|
||||||
</:card_icon>
|
</:card_icon>
|
||||||
</.live_component>
|
</.live_component>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
@ -262,6 +277,12 @@ defmodule LivebookWeb.HomeLive do
|
||||||
{:noreply, create_session(socket)}
|
{:noreply, create_session(socket)}
|
||||||
end
|
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
|
def handle_event("bulk_action", %{"action" => "disconnect"} = params, socket) do
|
||||||
socket = assign(socket, selected_session_ids: params["session_ids"])
|
socket = assign(socket, selected_session_ids: params["session_ids"])
|
||||||
{:noreply, push_patch(socket, to: ~p"/home/sessions/edit_sessions/disconnect")}
|
{:noreply, push_patch(socket, to: ~p"/home/sessions/edit_sessions/disconnect")}
|
||||||
|
|
|
@ -18,7 +18,7 @@ defmodule LivebookWeb.NotebookCardsComponent do
|
||||||
<%= info.name %>
|
<%= info.name %>
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
<%= @card_icon && render_slot(@card_icon) %>
|
<%= @card_icon && render_slot(@card_icon, {info, idx}) %>
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-1 flex-grow text-gray-600 text-sm">
|
<div class="mt-1 flex-grow text-gray-600 text-sm">
|
||||||
<%= @added_at_label %> <%= format_date_relatively(info.added_at) %>
|
<%= @added_at_label %> <%= format_date_relatively(info.added_at) %>
|
||||||
|
|
Loading…
Add table
Reference in a new issue