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

152 lines
4.8 KiB
Plaintext
Raw Permalink Normal View History

2022-11-24 14:31:16 -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
<%= @pipeline.slug %>
2022-11-24 14:31:16 -05:00
</h1>
2022-12-15 22:33:10 -05:00
<div class="flex flex-wrap space-x-1">
2023-04-13 23:29:29 -04:00
<.link :for={tag <- @pipeline.tags} navigate={~p"/pipelines/#{tag}"} class="link">
2023-02-04 11:29:06 -05:00
<%= tag %>
</.link>
2022-12-15 22:33:10 -05:00
</div>
2022-11-24 14:31:16 -05:00
2023-11-04 23:27:00 -04:00
<.pipeline_content pipeline={@pipeline} />
2022-11-24 14:31:16 -05:00
<p class="self-end">
<%= gettext("Visibility: %{visibility}", visibility: @pipeline.visibility) %>
</p>
2022-11-26 21:26:21 -05:00
<div class="pb-4 self-end flex space-x-4">
2023-02-04 11:29:06 -05:00
<.link
2024-02-23 22:18:25 -05:00
:if={Pipelines.owner?(@pipeline, @current_user)}
2023-02-04 11:29:06 -05:00
class="btn btn-primary"
2023-04-13 23:29:29 -04:00
patch={~p"/pipeline/#{@pipeline}/edit"}
2023-02-04 11:29:06 -05:00
>
<%= dgettext("actions", "edit") %>
</.link>
<button
:if={Pipelines.owner_or_admin?(@pipeline, @current_user)}
2023-02-04 11:29:06 -05:00
type="button"
class="btn btn-primary"
phx-click="delete"
data-confirm={dgettext("prompts", "are you sure?")}
aria-label={dgettext("actions", "delete %{pipeline_slug}", pipeline_slug: @pipeline.slug)}
2023-02-04 11:29:06 -05:00
>
<%= dgettext("actions", "delete") %>
</button>
2022-11-24 14:31:16 -05:00
</div>
2022-11-26 21:26:21 -05:00
<hr class="hr" />
<h2 class="pt-2 self-center text-lg">
<%= gettext("steps:") %>
</h2>
<%= if @steps |> Enum.empty?() do %>
<h3 class="self-center text-md text-primary-600">
<%= gettext("no steps") %>
</h3>
<% else %>
<%= for %{id: step_id, position: position, title: title} = step <- @steps do %>
<div class="flex justify-between items-center space-x-4">
<h3 class="text-md">
<%= gettext("%{position}. %{title}", position: position + 1, title: title) %>
</h3>
2024-02-23 22:18:25 -05:00
<%= if Pipelines.owner?(@pipeline, @current_user) do %>
2022-11-26 21:26:21 -05:00
<div class="flex justify-between items-center space-x-4">
<%= if position <= 0 do %>
<i class="fas text-xl fa-chevron-up cursor-not-allowed opacity-25"></i>
<% else %>
<button
type="button"
class="cursor-pointer flex justify-center items-center"
phx-click="reorder_step"
phx-value-direction="up"
phx-value-step-id={step_id}
aria-label={dgettext("actions", "move %{step_title} up", step_title: step.title)}
2022-11-26 21:26:21 -05:00
>
<i class="fas text-xl fa-chevron-up"></i>
</button>
<% end %>
<%= if position >= length(@steps) - 1 do %>
<i class="fas text-xl fa-chevron-down cursor-not-allowed opacity-25"></i>
<% else %>
<button
type="button"
class="cursor-pointer flex justify-center items-center"
phx-click="reorder_step"
phx-value-direction="down"
phx-value-step-id={step_id}
aria-label={
dgettext("actions", "move %{step_title} down", step_title: step.title)
}
2022-11-26 21:26:21 -05:00
>
<i class="fas text-xl fa-chevron-down"></i>
</button>
<% end %>
<.link
class="self-end btn btn-primary"
2023-04-13 23:29:29 -04:00
patch={~p"/pipeline/#{@pipeline}/#{step_id}"}
aria-label={dgettext("actions", "edit %{step_title}", step_title: step.title)}
2022-11-26 21:26:21 -05:00
>
<%= dgettext("actions", "edit") %>
</.link>
<button
type="button"
class="btn btn-primary"
phx-click="delete_step"
phx-value-step-id={step_id}
data-confirm={dgettext("prompts", "are you sure?")}
aria-label={dgettext("actions", "delete %{step_title}", step_title: step.title)}
2022-11-26 21:26:21 -05:00
>
<%= dgettext("actions", "delete") %>
</button>
</div>
<% end %>
</div>
<.step_content step={step} />
<% end %>
<% end %>
2023-02-04 11:29:06 -05:00
<.link
2024-02-23 22:18:25 -05:00
:if={Pipelines.owner?(@pipeline, @current_user)}
2023-02-04 11:29:06 -05:00
class="self-end btn btn-primary"
2023-04-13 23:29:29 -04:00
patch={~p"/pipeline/#{@pipeline}/add_step"}
2023-02-04 11:29:06 -05:00
>
<%= dgettext("actions", "add step") %>
</.link>
2022-11-24 14:31:16 -05:00
</div>
2022-07-25 20:12:11 -04:00
2022-11-26 21:26:21 -05:00
<%= case @live_action do %>
<% :edit -> %>
2023-04-13 23:29:29 -04:00
<.modal return_to={~p"/pipeline/#{@pipeline}"}>
2022-11-26 21:26:21 -05:00
<.live_component
module={MemexWeb.PipelineLive.FormComponent}
id={@pipeline.id}
current_user={@current_user}
title={@page_title}
action={@live_action}
pipeline={@pipeline}
2023-04-13 23:29:29 -04:00
return_to={~p"/pipeline/#{@pipeline}"}
2022-11-26 21:26:21 -05:00
/>
</.modal>
2023-02-04 11:29:06 -05:00
<% action when action in [:add_step, :edit_step] -> %>
2023-04-13 23:29:29 -04:00
<.modal return_to={~p"/pipeline/#{@pipeline}"}>
2022-11-26 21:26:21 -05:00
<.live_component
module={MemexWeb.StepLive.FormComponent}
id={@pipeline.id || :new}
current_user={@current_user}
title={@page_title}
action={@live_action}
pipeline={@pipeline}
step={@step}
2023-04-13 23:29:29 -04:00
return_to={~p"/pipeline/#{@pipeline}"}
2022-11-26 21:26:21 -05:00
/>
</.modal>
<% _ -> %>
2022-07-25 20:12:11 -04:00
<% end %>