Add explanation tooltip when starring is disabled (#1762)

This commit is contained in:
Jonatan Kłosko 2023-03-08 16:15:22 +01:00 committed by GitHub
parent c6df940808
commit d8f9ab1a96
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 49 additions and 38 deletions

View file

@ -433,6 +433,7 @@ defmodule LivebookWeb.CoreComponents do
def menu_item(assigns) do
~H"""
<li class={[
"w-full",
"[&>:first-child]:w-full [&>:first-child]:flex [&>:first-child]:space-x-3 [&>:first-child]:px-5 [&>:first-child]:py-2 [&>:first-child]:items-center [&>:first-child:hover]:bg-gray-100 [&>:first-child:focus]:bg-gray-100 [&>:first-child]:whitespace-nowrap font-medium",
menu_item_class(@variant),
@disabled && "pointer-events-none opacity-50"

View file

@ -170,31 +170,36 @@ defmodule LivebookWeb.HomeLive.SessionListComponent do
<span>Fork</span>
</button>
</.menu_item>
<.menu_item disabled={session.file == nil}>
<%= if notebook_starred?(session, @starred_notebooks) do %>
<button
type="button"
role="menuitem"
phx-click="unstar_notebook"
phx-target={@myself}
phx-value-id={session.id}
>
<.remix_icon icon="star-fill" />
<span>Unstar notebook</span>
</button>
<% else %>
<button
type="button"
role="menuitem"
phx-click="star_notebook"
phx-target={@myself}
phx-value-id={session.id}
>
<.remix_icon icon="star-line" />
<span>Star notebook</span>
</button>
<% end %>
</.menu_item>
<span
class="tooltip left"
data-tooltip={session.file == nil && "Save this notebook before starring it"}
>
<.menu_item disabled={session.file == nil}>
<%= if notebook_starred?(session, @starred_notebooks) do %>
<button
type="button"
role="menuitem"
phx-click="unstar_notebook"
phx-target={@myself}
phx-value-id={session.id}
>
<.remix_icon icon="star-fill" />
<span>Unstar notebook</span>
</button>
<% else %>
<button
type="button"
role="menuitem"
phx-click="star_notebook"
phx-target={@myself}
phx-value-id={session.id}
>
<.remix_icon icon="star-line" />
<span>Star notebook</span>
</button>
<% end %>
</.menu_item>
</span>
<.menu_item>
<a role="menuitem" href={live_dashboard_process_path(session.pid)} target="_blank">
<.remix_icon icon="dashboard-2-line" />

View file

@ -276,19 +276,24 @@ defmodule LivebookWeb.SessionLive do
<span>Fork</span>
</button>
</.menu_item>
<.menu_item disabled={@data_view.file == nil}>
<%= if @data_view.file in @starred_files do %>
<button type="button" role="menuitem" phx-click="unstar_notebook">
<.remix_icon icon="star-fill" />
<span>Unstar notebook</span>
</button>
<% else %>
<button type="button" role="menuitem" phx-click="star_notebook">
<.remix_icon icon="star-line" />
<span>Star notebook</span>
</button>
<% end %>
</.menu_item>
<span
class="tooltip left"
data-tooltip={@data_view.file == nil && "Save this notebook before starring it"}
>
<.menu_item disabled={@data_view.file == nil}>
<%= if @data_view.file in @starred_files do %>
<button type="button" role="menuitem" phx-click="unstar_notebook">
<.remix_icon icon="star-fill" />
<span>Unstar notebook</span>
</button>
<% else %>
<button type="button" role="menuitem" phx-click="star_notebook">
<.remix_icon icon="star-line" />
<span>Star notebook</span>
</button>
<% end %>
</.menu_item>
</span>
<.menu_item>
<a role="menuitem" href={live_dashboard_process_path(@session.pid)} target="_blank">
<.remix_icon icon="dashboard-2-line" />