Skip to content

Commit

Permalink
More natural click behaviour for tables (#2889)
Browse files Browse the repository at this point in the history
* natural clicking for projects

* fix tests

* cl
  • Loading branch information
taylordowns2000 authored Feb 5, 2025
1 parent ac0b0d0 commit e926588
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ and this project adheres to

### Changed

- Makes the whole project row in the projects table clickable.
[#2889](https://github.com/OpenFn/lightning/pull/2889)
- Standardizes date formats to YYYY-MM-DD
[#2884](https://github.com/OpenFn/lightning/pull/2884)

Expand Down
13 changes: 6 additions & 7 deletions lib/lightning_web/live/dashboard_live/components.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ defmodule LightningWeb.DashboardLive.Components do
import PetalComponents.Table

alias LightningWeb.Components.Common
alias Phoenix.LiveView.JS

def welcome_banner(assigns) do
~H"""
Expand Down Expand Up @@ -173,15 +174,11 @@ defmodule LightningWeb.DashboardLive.Components do
<.tr
:for={project <- @projects}
id={"projects-table-row-#{project.id}"}
class="hover:bg-gray-100 transition-colors duration-200"
class="hover:bg-gray-100 transition-colors duration-200 cursor-pointer"
phx-click={JS.navigate(~p"/projects/#{project.id}/w")}
>
<.td>
<.link
class="break-words max-w-[15rem] text-gray-800"
href={~p"/projects/#{project.id}/w"}
>
<%= project.name %>
</.link>
<%= project.name %>
</.td>
<.td class="break-words max-w-[25rem]">
<%= project.role
Expand All @@ -195,6 +192,7 @@ defmodule LightningWeb.DashboardLive.Components do
<.link
class="link"
href={~p"/projects/#{project.id}/settings#collaboration"}
onclick="event.stopPropagation()"
>
<%= project.collaborators_count %>
</.link>
Expand All @@ -210,6 +208,7 @@ defmodule LightningWeb.DashboardLive.Components do
<.link
class="table-action"
navigate={~p"/projects/#{project.id}/history"}
onclick="event.stopPropagation()"
>
History
</.link>
Expand Down
4 changes: 2 additions & 2 deletions test/lightning_web/live/dashboard_live_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ defmodule LightningWeb.DashboardLiveTest do

assert has_element?(
view,
"tr#projects-table-row-#{project.id} > td:nth-child(1) > a[href='/projects/#{project.id}/w']",
"tr#projects-table-row-#{project.id}",
project.name
)

Expand Down Expand Up @@ -437,7 +437,7 @@ defmodule LightningWeb.DashboardLiveTest do
|> Floki.parse_document!()
|> Floki.find("#projects-table tr")
|> Enum.map(fn tr ->
Floki.find(tr, "td:nth-child(1) a")
Floki.find(tr, "td:nth-child(1)")
|> Floki.text()
|> String.trim()
end)
Expand Down

0 comments on commit e926588

Please sign in to comment.