memEx/lib/memex_web/live/context_live/show.html.heex

53 lines
1.6 KiB
Plaintext
Raw Normal View History

2022-11-24 12:44:34 -05:00
<div class="mx-auto flex flex-col justify-center items-stretch space-y-4 max-w-3xl">
<h1 class="text-xl">
2022-11-26 14:51:18 -05:00
<%= @context.slug %>
2022-11-24 12:44:34 -05:00
</h1>
<p><%= if @context.tags, do: @context.tags |> Enum.join(", ") %></p>
2022-11-26 16:36:30 -05:00
<.context_content context={@context} />
2022-11-24 12:44:34 -05:00
<p class="self-end">
<%= gettext("Visibility: %{visibility}", visibility: @context.visibility) %>
</p>
<div class="self-end flex space-x-4">
<.link class="btn btn-primary" navigate={Routes.context_index_path(@socket, :index)}>
2022-11-24 12:44:34 -05:00
<%= dgettext("actions", "back") %>
</.link>
<%= if is_owner?(@context, @current_user) do %>
2022-11-26 14:51:18 -05:00
<.link
class="btn btn-primary"
patch={Routes.context_show_path(@socket, :edit, @context.slug)}
>
2022-11-24 12:44:34 -05:00
<%= dgettext("actions", "edit") %>
</.link>
<% end %>
<%= if is_owner_or_admin?(@context, @current_user) do %>
2022-11-24 12:44:34 -05:00
<button
type="button"
class="btn btn-primary"
phx-click="delete"
data-confirm={dgettext("prompts", "are you sure?")}
data-qa={"delete-context-#{@context.id}"}
>
<%= dgettext("actions", "delete") %>
</button>
<% end %>
</div>
</div>
2022-07-25 20:11:08 -04:00
<%= if @live_action in [:edit] do %>
2022-11-26 14:51:18 -05:00
<.modal return_to={Routes.context_show_path(@socket, :show, @context.slug)}>
2022-07-25 20:11:08 -04:00
<.live_component
module={MemexWeb.ContextLive.FormComponent}
id={@context.id}
2022-11-24 12:44:34 -05:00
current_user={@current_user}
2022-07-25 20:11:08 -04:00
title={@page_title}
action={@live_action}
context={@context}
2022-11-26 14:51:18 -05:00
return_to={Routes.context_show_path(@socket, :show, @context.slug)}
2022-07-25 20:11:08 -04:00
/>
</.modal>
<% end %>