Skip to content

Commit 594a620

Browse files
committed
update custom bounty styling on org pages
1 parent 6831275 commit 594a620

File tree

7 files changed

+85
-32
lines changed

7 files changed

+85
-32
lines changed

lib/algora/bounties/bounties.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,9 +1327,9 @@ defmodule Algora.Bounties do
13271327

13281328
from(b in Bounty)
13291329
|> join(:inner, [b], bb in subquery(base_bounties), on: b.id == bb.id)
1330-
|> join(:inner, [b], t in assoc(b, :ticket), as: :t)
1330+
|> join(:left, [b], t in assoc(b, :ticket), as: :t)
13311331
|> join(:inner, [b], o in assoc(b, :owner), as: :o)
1332-
|> join(:inner, [t: t], r in assoc(t, :repository), as: :r)
1332+
|> join(:left, [t: t], r in assoc(t, :repository), as: :r)
13331333
|> join(:left, [r: r], ro in assoc(r, :user), as: :ro)
13341334
|> where([b], not is_nil(b.amount))
13351335
|> where([b], b.status != :cancelled)

lib/algora/bounties/schemas/bounty.ex

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,18 @@ defmodule Algora.Bounties.Bounty do
7070
"https://github.com/#{login}/#{name}/issues/#{number}"
7171
end
7272

73+
def url(%{id: id, owner: owner, repository: %{name: nil}}) do
74+
"/#{owner.handle}/bounties/#{id}"
75+
end
76+
7377
def url(%{ticket: %{url: url}}) do
7478
url
7579
end
7680

81+
def path(%{repository: %{name: nil}}) do
82+
nil
83+
end
84+
7785
def path(%{repository: %{name: name}, ticket: %{number: number}}) do
7886
"#{name}##{number}"
7987
end

lib/algora_web/components/bounties.ex

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,32 @@ defmodule AlgoraWeb.Components.Bounties do
55
import AlgoraWeb.CoreComponents
66

77
alias Algora.Accounts.User
8+
alias Algora.Bounties.Bounty
89

910
def bounties(assigns) do
1011
~H"""
1112
<div class="relative -mx-2 -mt-2 overflow-auto scrollbar-thin">
1213
<ul class="divide-y divide-border">
1314
<%= for bounty <- @bounties do %>
14-
<.link href={bounty.ticket.url} class="block whitespace-nowrap hover:bg-muted/50">
15+
<.link href={Bounty.url(bounty)} class="block whitespace-nowrap hover:bg-muted/50">
1516
<li class="flex items-center py-2 px-3">
1617
<div class="flex-shrink-0 mr-3">
1718
<.avatar class="h-8 w-8">
18-
<.avatar_image src={bounty.repository.owner.avatar_url} />
19+
<.avatar_image src={bounty.repository.owner.avatar_url || bounty.owner.avatar_url} />
1920
<.avatar_fallback>
20-
{Algora.Util.initials(User.handle(bounty.repository.owner))}
21+
{Algora.Util.initials(User.handle(bounty.repository.owner || bounty.owner))}
2122
</.avatar_fallback>
2223
</.avatar>
2324
</div>
2425
2526
<div class="flex-grow min-w-0 mr-4">
2627
<div class="flex items-center text-sm">
27-
<span class="font-semibold mr-1">{bounty.repository.owner.name}</span>
28-
<span class="text-muted-foreground mr-2">#{bounty.ticket.number}</span>
28+
<span class="font-semibold mr-1">
29+
{bounty.repository.owner.name || bounty.owner.name}
30+
</span>
31+
<span :if={bounty.ticket.number} class="text-muted-foreground mr-2">
32+
#{bounty.ticket.number}
33+
</span>
2934
<span class="font-display whitespace-nowrap text-sm font-semibold tabular-nums text-success mr-2">
3035
{Money.to_string!(bounty.amount)}
3136
</span>

lib/algora_web/live/bounty_live.ex

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,9 @@ defmodule AlgoraWeb.BountyLive do
318318
def render(assigns) do
319319
~H"""
320320
<div class={classes(["xl:flex p-4", if(!@current_user, do: "pb-16 xl:pb-24")])}>
321+
<div :if={@current_user && @current_user.is_admin}>
322+
Autopay disabled: {@bounty.autopay_disabled}
323+
</div>
321324
<.scroll_area class="xl:h-[calc(100svh-96px)] flex-1 pr-6">
322325
<div class="space-y-4">
323326
<.card>
@@ -330,24 +333,38 @@ defmodule AlgoraWeb.BountyLive do
330333
{Util.initials(User.handle(@host))}
331334
</.avatar_fallback>
332335
</.avatar>
333-
<div>
334-
<.link
335-
href={@ticket.url}
336-
target="_blank"
337-
rel="noopener"
338-
class="block text-xl sm:text-3xl font-semibold text-foreground/90 hover:underline"
339-
>
340-
{@ticket.title}
341-
</.link>
342-
<.link
343-
href={@ticket.url}
344-
target="_blank"
345-
rel="noopener"
346-
class="block text-base font-display sm:text-xl font-medium text-muted-foreground hover:underline"
347-
>
348-
{@host.provider_login}<span :if={@ticket.repository}>/{@ticket.repository.name}#{@ticket.number}</span>
349-
</.link>
350-
</div>
336+
<%= if @ticket.url do %>
337+
<div>
338+
<.link
339+
href={@ticket.url}
340+
target="_blank"
341+
rel="noopener"
342+
class="block text-xl sm:text-3xl font-semibold text-foreground/90 hover:underline"
343+
>
344+
{@ticket.title}
345+
</.link>
346+
<.link
347+
href={@ticket.url}
348+
target="_blank"
349+
rel="noopener"
350+
class="block text-base font-display sm:text-xl font-medium text-muted-foreground hover:underline"
351+
>
352+
{@host.provider_login}<span :if={@ticket.repository}>/{@ticket.repository.name}#{@ticket.number}</span>
353+
</.link>
354+
</div>
355+
<% else %>
356+
<div>
357+
<div class="block text-xl sm:text-3xl font-semibold text-foreground/90 hover:underline">
358+
{@ticket.title}
359+
</div>
360+
<div
361+
href={@ticket.url}
362+
class="block text-base font-display sm:text-xl font-medium text-muted-foreground hover:underline"
363+
>
364+
{@host.name}
365+
</div>
366+
</div>
367+
<% end %>
351368
</div>
352369
<div class="flex flex-col gap-4">
353370
<div class="font-display tabular-nums text-5xl text-success-400 font-bold">

lib/algora_web/live/org/bounties_live.ex

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ defmodule AlgoraWeb.Org.BountiesLive do
99
alias Algora.Bounties
1010
alias Algora.Bounties.Bounty
1111
alias Algora.Github
12+
alias Algora.Markdown
1213
alias Algora.Payments
1314
alias Algora.Repo
1415
alias Algora.Types.USD
@@ -120,7 +121,7 @@ defmodule AlgoraWeb.Org.BountiesLive do
120121
class="group/issue inline-flex flex-col"
121122
href={Bounty.url(bounty)}
122123
>
123-
<div class="flex items-center gap-4">
124+
<div :if={Bounty.path(bounty)} class="flex items-center gap-4">
124125
<div class="truncate">
125126
<p class="truncate text-sm font-medium text-gray-300 group-hover/issue:text-gray-200 group-hover/issue:underline">
126127
{Bounty.path(bounty)}
@@ -130,6 +131,25 @@ defmodule AlgoraWeb.Org.BountiesLive do
130131
<p class="line-clamp-2 break-words text-base font-medium leading-tight text-gray-100 group-hover/issue:text-white group-hover/issue:underline">
131132
{bounty.ticket.title}
132133
</p>
134+
<div :if={is_nil(Bounty.path(bounty)) and bounty.ticket.description}>
135+
<.markdown
136+
id={"bounty-description-#{bounty.id}"}
137+
class="line-clamp-3 transition-all duration-200 [&>p]:m-0"
138+
phx-hook="ExpandableText"
139+
data-expand-id={"expand-#{bounty.id}"}
140+
data-class="line-clamp-3"
141+
value={Phoenix.HTML.raw(Markdown.render(bounty.ticket.description))}
142+
/>
143+
<button
144+
id={"expand-#{bounty.id}"}
145+
type="button"
146+
class="text-xs text-foreground font-bold hidden"
147+
data-content-id={"bounty-description-#{bounty.id}"}
148+
phx-hook="ExpandableTextButton"
149+
>
150+
...read more
151+
</button>
152+
</div>
133153
</.link>
134154
<p class="flex items-center gap-1.5 text-xs text-gray-400">
135155
{Algora.Util.time_ago(bounty.inserted_at)}
@@ -182,7 +202,7 @@ defmodule AlgoraWeb.Org.BountiesLive do
182202
<% end %>
183203
</td>
184204
<td class="[&:has([role=checkbox])]:pr-0 p-4 align-middle">
185-
<div class="flex items-center gap-2">
205+
<div class="flex items-center justify-end gap-2">
186206
<.button
187207
phx-click="edit-bounty-amount"
188208
phx-value-id={bounty.id}

lib/algora_web/live/org/home_live.ex

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,10 @@ defmodule AlgoraWeb.Org.HomeLive do
160160
{bounty.ticket.title}
161161
</.link>
162162
163-
<div class="flex shrink-0 items-center gap-1 whitespace-nowrap text-sm text-muted-foreground">
163+
<div
164+
:if={Bounty.path(bounty)}
165+
class="flex shrink-0 items-center gap-1 whitespace-nowrap text-sm text-muted-foreground"
166+
>
164167
<.icon name="tabler-chevron-right" class="h-4 w-4" />
165168
<.link href={Bounty.url(bounty)} class="hover:underline">
166169
{Bounty.path(bounty)}
@@ -196,7 +199,7 @@ defmodule AlgoraWeb.Org.HomeLive do
196199
{Money.to_string!(transaction.net_amount)}
197200
</div>
198201
199-
<.link
202+
<.maybe_link
200203
href={
201204
if ticket.repository,
202205
do:
@@ -206,7 +209,7 @@ defmodule AlgoraWeb.Org.HomeLive do
206209
class="max-w-[400px] truncate text-sm text-foreground hover:underline"
207210
>
208211
{ticket.title}
209-
</.link>
212+
</.maybe_link>
210213
211214
<div
212215
:if={ticket.repository || ticket.url}

lib/algora_web/live/org/jobs_live.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ defmodule AlgoraWeb.Org.JobsLive do
9292
</div>
9393
9494
<%= if not Enum.empty?(@media) do %>
95-
<div class="max-w-xl mx-auto mt-8 flex flex-row justify-center gap-4">
95+
<div class="max-w-4xl mx-auto mt-8 flex flex-row justify-center gap-4">
9696
<%= for media <- @media |> Enum.take(3) do %>
9797
<div class="w-1/3 aspect-video rounded-lg overflow-hidden">
9898
<%= if Algora.Accounts.youtube_url?(media.url) do %>
@@ -102,7 +102,7 @@ defmodule AlgoraWeb.Org.JobsLive do
102102
/>
103103
<.modal_video_dialog />
104104
<% else %>
105-
<img src={media.url} class="w-full h-full object-cover object-cover" />
105+
<img src={media.url} class="w-full h-full object-cover" />
106106
<% end %>
107107
</div>
108108
<% end %>

0 commit comments

Comments
 (0)