Skip to content

Commit

Permalink
Merge branch 'main' into rjt/ui-polish-3
Browse files Browse the repository at this point in the history
  • Loading branch information
rjt-rockx authored Aug 12, 2023
2 parents 7d8ebcd + 038e330 commit 4f326f5
Show file tree
Hide file tree
Showing 27 changed files with 129 additions and 54 deletions.
19 changes: 19 additions & 0 deletions lib/banchan/commissions/commissions.ex
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ defmodule Banchan.Commissions do
* `page` - The page number to return. Defaults to 1.
* `page_size` - The number of items to return per page. Defaults to 24.
* `exclude_member` - Exclude commissions where the current user is a
member of the studio.
* `order_by` - Sort order, and in some cases, filters. Defaults to
`:recently_updated`. Supports the following values:
* `:recently_updated` - List by most recently updated commissions (with
Expand All @@ -102,6 +104,7 @@ defmodule Banchan.Commissions do
opts \\ []
) do
main_dashboard_query(user)
|> dashboard_exclude_member(opts)
|> dashboard_query_filter(filter)
|> dashboard_order_by(opts)
|> Repo.paginate(
Expand Down Expand Up @@ -153,6 +156,22 @@ defmodule Banchan.Commissions do
end
end

defp dashboard_exclude_member(q, opts) do
if Keyword.get(opts, :exclude_member, false) do
q
|> join(
:left,
[current_user: u, studio: s],
current_member in assoc(s, :artists),
on: current_member.id == u.id,
as: :current_member
)
|> where([current_member: current_member], is_nil(current_member.id))
else
q
end
end

defp dashboard_order_by(q, opts) do
case Keyword.fetch(opts, :order_by) do
{:ok, :recently_updated} ->
Expand Down
4 changes: 2 additions & 2 deletions lib/banchan/reports/reports.ex
Original file line number Diff line number Diff line change
Expand Up @@ -250,13 +250,13 @@ defmodule Banchan.Reports do
@doc """
File a bug on GitHub
"""
def report_bug(%User{} = actor, title, body, actor_url_fn) do
def report_bug(%User{} = actor, title, body, bug?, actor_url_fn) do
%{access_token: Application.fetch_env!(:banchan, :github_access_token)}
|> Tentacat.Client.new()
|> Tentacat.Issues.create("BanchanArt", "banchan", %{
title: title,
body: "reported by [@#{actor.handle}](#{actor_url_fn.(actor)}):\n\n#{body}",
labels: ["bug", "from-site"]
labels: ["feedback", "from-site" | if(bug? == "true", do: ["bug"], else: [])]
})
|> case do
{201, %{"html_url" => url}, _} ->
Expand Down
2 changes: 1 addition & 1 deletion lib/banchan_web/components/flash.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ defmodule BanchanWeb.Components.Flash do

def render(assigns) do
~F"""
<div class="flash-container">
<div class="fixed bottom-auto z-20 w-auto w-3/5 translate-y-0 toast toast-center top-20 flash-container">
{#if live_flash(@flashes, :success)}
<div
class="p-2 alert alert-success hover:cursor-pointer"
Expand Down
2 changes: 1 addition & 1 deletion lib/banchan_web/components/form/checkbox.ex
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ defmodule BanchanWeb.Components.Form.Checkbox do
<div class="flex flex-row items-center gap-1 px-2 label-text">
<#slot>{@label}</#slot>
{#if @info}
<div class="tooltip" data-tip={@info}>
<div class="tooltip tooltip-right" data-tip={@info}>
<Icon
name="info"
size="4"
Expand Down
2 changes: 1 addition & 1 deletion lib/banchan_web/components/form/date_time_local_input.ex
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ defmodule BanchanWeb.Components.Form.DateTimeLocalInput do
<span class="flex flex-row items-center gap-1 label-text">
{@label || Phoenix.Naming.humanize(@name)}
{#if @info}
<div class="tooltip" data-tip={@info}>
<div class="tooltip tooltip-right" data-tip={@info}>
<Icon
name="info"
size="4"
Expand Down
2 changes: 1 addition & 1 deletion lib/banchan_web/components/form/email_input.ex
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ defmodule BanchanWeb.Components.Form.EmailInput do
<span class="flex flex-row items-center gap-1 label-text">
{@label || Phoenix.Naming.humanize(@name)}
{#if @info}
<div class="tooltip" data-tip={@info}>
<div class="tooltip tooltip-right" data-tip={@info}>
<Icon
name="info"
size="4"
Expand Down
2 changes: 1 addition & 1 deletion lib/banchan_web/components/form/multiple_select.ex
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ defmodule BanchanWeb.Components.Form.MultipleSelect do
<span class="flex flex-row items-center gap-1 label-text">
{@label || Phoenix.Naming.humanize(@name)}
{#if @info}
<div class="tooltip" data-tip={@info}>
<div class="tooltip tooltip-right" data-tip={@info}>
<Icon
name="info"
size="4"
Expand Down
2 changes: 1 addition & 1 deletion lib/banchan_web/components/form/number_input.ex
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ defmodule BanchanWeb.Components.Form.NumberInput do
<span class="flex flex-row items-center gap-1 label-text">
{@label || Phoenix.Naming.humanize(@name)}
{#if @info}
<div class="tooltip" data-tip={@info}>
<div class="tooltip tooltip-right" data-tip={@info}>
<Icon
name="info"
size="4"
Expand Down
2 changes: 1 addition & 1 deletion lib/banchan_web/components/form/quill_input/quill_input.ex
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ defmodule BanchanWeb.Components.Form.QuillInput do
<span class="flex flex-row items-center gap-1 label-text">
{@label || Phoenix.Naming.humanize(@name)}
{#if @info}
<div class="tooltip" data-tip={@info}>
<div class="tooltip tooltip-right" data-tip={@info}>
<Icon
name="info"
size="4"
Expand Down
2 changes: 1 addition & 1 deletion lib/banchan_web/components/form/select.ex
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ defmodule BanchanWeb.Components.Form.Select do
<span class="flex flex-row items-center gap-1 label-text">
{@label || Phoenix.Naming.humanize(@name)}
{#if @info}
<div class="tooltip" data-tip={@info}>
<div class="tooltip tooltip-right" data-tip={@info}>
<Icon
name="info"
size="4"
Expand Down
2 changes: 1 addition & 1 deletion lib/banchan_web/components/form/tags_input/tags_input.ex
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ defmodule BanchanWeb.Components.Form.TagsInput do
<span class="flex flex-row items-center gap-1 label-text">
{@label || Phoenix.Naming.humanize(@name)}
{#if @info}
<div class="tooltip" data-tip={@info}>
<div class="tooltip tooltip-right" data-tip={@info}>
<Icon
name="info"
size="4"
Expand Down
2 changes: 1 addition & 1 deletion lib/banchan_web/components/form/text_input.ex
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ defmodule BanchanWeb.Components.Form.TextInput do
<span class="flex flex-row items-center gap-1 label-text">
{@label || Phoenix.Naming.humanize(@name)}
{#if @info}
<div class="tooltip" data-tip={@info}>
<div class="tooltip tooltip-right" data-tip={@info}>
<Icon
name="info"
size="4"
Expand Down
2 changes: 1 addition & 1 deletion lib/banchan_web/components/form/textarea.ex
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ defmodule BanchanWeb.Components.Form.TextArea do
<span class="flex flex-row items-center gap-1 label-text">
{@label || Phoenix.Naming.humanize(@name)}
{#if @info}
<div class="tooltip" data-tip={@info}>
<div class="tooltip tooltip-right" data-tip={@info}>
<Icon
name="info"
size="4"
Expand Down
10 changes: 8 additions & 2 deletions lib/banchan_web/components/layout.ex
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ defmodule BanchanWeb.Components.Layout do
<div>
<span class="opacity-100 footer-title text-primary">Co-op</span>
<LiveRedirect to={Routes.static_about_us_path(Endpoint, :show)} class="link link-hover">About Us</LiveRedirect>
<LiveRedirect to={Routes.static_contact_path(Endpoint, :show)} class="link link-hover">Contact</LiveRedirect>
<LiveRedirect to={Routes.static_membership_path(Endpoint, :show)} class="link link-hover">Membership</LiveRedirect>
<LiveRedirect to={Routes.report_bug_new_path(Endpoint, :new)}>Report Bug</LiveRedirect>
<LiveRedirect to={Routes.static_contact_path(Endpoint, :show)} class="link link-hover">Contact</LiveRedirect>
<LiveRedirect to={Routes.report_bug_new_path(Endpoint, :new)}>Feedback</LiveRedirect>
</div>
<div>
<span class="opacity-100 footer-title text-primary">Legal</span>
Expand Down Expand Up @@ -130,6 +130,12 @@ defmodule BanchanWeb.Components.Layout do
target="_blank"
rel="noopener noreferrer"
><i class="text-xl fab fa-discord" /></a>
<a
href="https://github.com/BanchanArt/banchan"
aria-label="Banchan Art on Github (opens in new tab)"
target="_blank"
rel="noopener noreferrer"
><i class="text-xl fab fa-github" /></a>
</div>
</div>
</footer>
Expand Down
1 change: 1 addition & 0 deletions lib/banchan_web/components/layouts/root.sface
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1">
<meta name="banchan-git-rev" content={Application.get_env(:banchan, :git_rev)}>
<meta name="robots" content="noai">
<.live_title prefix="Banchan Art |">
{assigns[:page_title] || "The Co-operative Commissions Platform"}
</.live_title>
Expand Down
2 changes: 1 addition & 1 deletion lib/banchan_web/components/notifications.ex
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ defmodule BanchanWeb.Components.Notifications do
</button>
</div>
{#if @open}
<div class="absolute right-0 z-30 p-2 origin-top translate-x-px translate-y-px border divide-y-2 border-base-content border-opacity-10 menu rounded-box bg-base-100 w-80 divide-neutral-content divide-opacity-10 text-base-content">
<div class="absolute right-0 z-30 p-2 origin-top translate-x-px translate-y-px border divide-y-2 border-base-content border-opacity-10 menu rounded-box bg-base-100 divide-neutral-content divide-opacity-10 text-base-content">
{#if !@notifications || Enum.empty?(@notifications.entries)}
<div class="px-8 m-2">No notifications</div>
{#else}
Expand Down
14 changes: 7 additions & 7 deletions lib/banchan_web/components/user_handle.ex
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ defmodule BanchanWeb.Components.UserHandle do
<span class={"inline-flex items-center gap-1", @class}>
<strong title={@user.name} class="font-semibold hover:underline">{@user.handle}</strong>
{#if :admin in @user.roles}
<div class="tooltip" data-tip="Admin">
<div class="tooltip tooltip-right" data-tip="Admin">
<Icon name="shield-check" size="4" class="text-error">
</Icon>
</div>
{#elseif :mod in @user.roles}
<div class="tooltip" data-tip="Moderator">
<div class="tooltip tooltip-right" data-tip="Moderator">
<Icon name="gavel" size="4" class="text-warning">
</Icon>
</div>
{#elseif :system in @user.roles}
<div class="tooltip" data-tip="System">
<div class="tooltip tooltip-right" data-tip="System">
<Icon name="bot" size="4" class="text-primary">
</Icon>
</div>
Expand All @@ -44,25 +44,25 @@ defmodule BanchanWeb.Components.UserHandle do
{@user.handle}
</strong>
{#if :admin in @user.roles}
<div class="tooltip" data-tip="Admin">
<div class="tooltip tooltip-right" data-tip="Admin">
<Icon name="shield-check" size="4" class="text-error">
</Icon>
</div>
{#elseif :mod in @user.roles}
<div class="tooltip" data-tip="Moderator">
<div class="tooltip tooltip-right" data-tip="Moderator">
<Icon name="gavel" size="4" class="text-warning">
</Icon>
</div>
{#elseif :system in @user.roles}
<div class="tooltip" data-tip="System">
<div class="tooltip tooltip-right" data-tip="System">
<Icon name="bot" size="4" class="text-primary">
</Icon>
</div>
{/if}
</span>
{#else}
<strong title="User deactivated their account" class="font-semibold">
<div class="tooltip" data-tip="Deactivated">
<div class="tooltip tooltip-right" data-tip="Deactivated">
<Icon name="circle-slash" size="4" class="text-primary">
</Icon>
</div>
Expand Down
11 changes: 7 additions & 4 deletions lib/banchan_web/endpoint.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ defmodule BanchanWeb.Endpoint do
use Sentry.PlugCapture
use Phoenix.Endpoint, otp_app: :banchan

alias BanchanWeb.CacheBodyReader

# The session will be stored in the cookie and signed,
# this means its contents can be read but not tampered with.
# Set :encryption_salt if you would also like to encrypt it.
Expand All @@ -25,7 +23,9 @@ defmodule BanchanWeb.Endpoint do
at: "/",
from: :banchan,
gzip: false,
only: BanchanWeb.static_paths()
only: BanchanWeb.static_paths(),
# Fuck AI
headers: [{"x-robots-tag", "noai"}]

# Code reloading can be explicitly enabled under the
# :code_reloader configuration of your endpoint.
Expand All @@ -46,7 +46,7 @@ defmodule BanchanWeb.Endpoint do
plug Plug.Parsers,
parsers: [:urlencoded, :multipart, :json],
pass: ["*/*"],
body_reader: {CacheBodyReader, :read_body, []},
body_reader: {BanchanWeb.CacheBodyReader, :read_body, []},
json_decoder: Phoenix.json_library()

# Adds contextual information to errors captured by Sentry, should be under Plug.Parsers
Expand All @@ -56,5 +56,8 @@ defmodule BanchanWeb.Endpoint do
plug Plug.Head
plug Plug.Session, @session_options

# Reject AI as much as possible
plug BanchanWeb.FuckAiPlug

plug BanchanWeb.Router
end
15 changes: 8 additions & 7 deletions lib/banchan_web/live/commission_live/index.ex
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,6 @@ defmodule BanchanWeb.CommissionLive do
|> assign(status_options: @status_options)
|> assign(filter_open: Map.get(socket.assigns, :filter_open, false))

socket =
socket
|> assign(
:results,
list_comms(socket)
)

socket =
case params do
%{"commission_id" => commission_id} ->
Expand Down Expand Up @@ -124,6 +117,13 @@ defmodule BanchanWeb.CommissionLive do
end
)

socket =
socket
|> assign(
:results,
list_comms(socket)
)

socket =
Context.put(socket,
commission: socket.assigns.commission,
Expand Down Expand Up @@ -335,6 +335,7 @@ defmodule BanchanWeb.CommissionLive do
Commissions.list_commissions(
socket.assigns.current_user,
Ecto.Changeset.apply_changes(socket.assigns.filter),
exclude_member: is_nil(socket.assigns.studio),
page: page,
page_size: 10,
order_by: socket.assigns.order_by
Expand Down
19 changes: 13 additions & 6 deletions lib/banchan_web/live/report_bug_live/new.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,24 @@ defmodule BanchanWeb.ReportBugLive.New do
alias Surface.Components.Form

alias BanchanWeb.Components.{Button, Layout}
alias BanchanWeb.Components.Form.{QuillInput, Submit, TextInput}
alias BanchanWeb.Components.Form.{Checkbox, QuillInput, Submit, TextInput}

@impl true
def handle_params(_params, _uri, socket) do
{:noreply, assign(socket, report_url: nil)}
end

@impl true
def handle_event("submit", %{"bug_report" => %{"title" => title, "body" => body}}, socket) do
def handle_event(
"submit",
%{"bug_report" => %{"title" => title, "body" => body, "bug?" => bug?}},
socket
) do
case Reports.report_bug(
socket.assigns.current_user,
title,
body,
bug?,
&Routes.denizen_show_url(Endpoint, :show, &1.handle)
) do
{:ok, url} ->
Expand All @@ -48,13 +53,14 @@ defmodule BanchanWeb.ReportBugLive.New do
<div class="w-full bg-base-200">
<div class="w-full max-w-lg p-10 mx-auto rounded-xl md:my-10 bg-base-200">
{#if @report_url}
<p>Thanks for your bug report! You can view the issue and sign up for updates <a href={@report_url} class="link link-primary">here</a>.</p>
<p>Thanks for your feedback! You can view the issue and sign up for updates <a href={@report_url} class="link link-primary">here</a>.</p>
<Button label="Report Another" click="reset" />
{#else}
<Form class="flex flex-col gap-4" for={%{}} as={:bug_report} submit="submit">
<h1 class="text-2xl">Submit a bug report</h1>
<p>Use this form to submit bug reports for Banchan Art. Please include as much context as you can.</p>
<p><span class="text-error">NOTE: This report will be <span class="font-bold">publicly visible</span> on GitHub. Do NOT include anything personal or confidential</span></p>
<h1 class="text-2xl">Submit feedback</h1>
<p>To submit feedback for Banchan Art, you may use this form or <a href="https://github.com/BanchanArt/banchan/issues/new/choose" class="link">Github</a>. Please include as much context as you can.</p>
<p>You may view existing issues using our <a href="https://github.com/BanchanArt/banchan/issues" class="link">Github issues page.</a></p>
<p><span class="text-error">NOTE: This feedback will be <span class="font-bold">publicly visible</span> on GitHub. Do NOT include any personal or confidential information.</span></p>
<p>If you need support for something that shouldn't be public, please contact us at <a href="mailto:[email protected]" class="link">[email protected]</a>.</p>
<TextInput name={:title} label="Title" opts={required: true, maxlength: "256", minlength: "10"} />
<QuillInput
Expand All @@ -63,6 +69,7 @@ defmodule BanchanWeb.ReportBugLive.New do
label="Body"
opts={required: true, maxlength: "2000", minlength: "30"}
/>
<Checkbox name={:bug?} label="Bug Report" opts={"aria-label": "Bug Report"} />
<Submit />
</Form>
{/if}
Expand Down
Loading

0 comments on commit 4f326f5

Please sign in to comment.