improve templates

This commit is contained in:
2023-02-04 11:29:06 -05:00
parent 1726a1b72e
commit eb75937587
38 changed files with 745 additions and 764 deletions

View File

@ -30,46 +30,47 @@
pipelines={@pipelines}
>
<:actions :let={pipeline}>
<%= if is_owner?(pipeline, @current_user) do %>
<.link
patch={Routes.pipeline_index_path(@socket, :edit, pipeline.slug)}
data-qa={"pipeline-edit-#{pipeline.id}"}
>
<%= dgettext("actions", "edit") %>
</.link>
<% end %>
<%= if is_owner_or_admin?(pipeline, @current_user) do %>
<.link
href="#"
phx-click="delete"
phx-value-id={pipeline.id}
data-confirm={dgettext("prompts", "are you sure?")}
data-qa={"delete-pipeline-#{pipeline.id}"}
>
<%= dgettext("actions", "delete") %>
</.link>
<% end %>
<.link
:if={is_owner?(pipeline, @current_user)}
patch={Routes.pipeline_index_path(@socket, :edit, pipeline.slug)}
data-qa={"pipeline-edit-#{pipeline.id}"}
>
<%= dgettext("actions", "edit") %>
</.link>
<.link
:if={is_owner_or_admin?(pipeline, @current_user)}
href="#"
phx-click="delete"
phx-value-id={pipeline.id}
data-confirm={dgettext("prompts", "are you sure?")}
data-qa={"delete-pipeline-#{pipeline.id}"}
>
<%= dgettext("actions", "delete") %>
</.link>
</:actions>
</.live_component>
<% end %>
<%= if @current_user do %>
<.link patch={Routes.pipeline_index_path(@socket, :new)} class="self-end btn btn-primary">
<%= dgettext("actions", "new pipeline") %>
</.link>
<% end %>
<.link
:if={@current_user}
patch={Routes.pipeline_index_path(@socket, :new)}
class="self-end btn btn-primary"
>
<%= dgettext("actions", "new pipeline") %>
</.link>
</div>
<%= if @live_action in [:new, :edit] do %>
<.modal return_to={Routes.pipeline_index_path(@socket, :index)}>
<.live_component
module={MemexWeb.PipelineLive.FormComponent}
id={@pipeline.id || :new}
current_user={@current_user}
title={@page_title}
action={@live_action}
pipeline={@pipeline}
return_to={Routes.pipeline_index_path(@socket, :index)}
/>
</.modal>
<% end %>
<.modal
:if={@live_action in [:new, :edit]}
return_to={Routes.pipeline_index_path(@socket, :index)}
>
<.live_component
module={MemexWeb.PipelineLive.FormComponent}
id={@pipeline.id || :new}
current_user={@current_user}
title={@page_title}
action={@live_action}
pipeline={@pipeline}
return_to={Routes.pipeline_index_path(@socket, :index)}
/>
</.modal>

View File

@ -4,23 +4,24 @@
</h1>
<div class="flex flex-wrap space-x-1">
<%= for tag <- @pipeline.tags do %>
<.link navigate={Routes.pipeline_index_path(Endpoint, :search, tag)} class="link">
<%= tag %>
</.link>
<% end %>
<.link
:for={tag <- @pipeline.tags}
navigate={Routes.pipeline_index_path(Endpoint, :search, tag)}
class="link"
>
<%= tag %>
</.link>
</div>
<%= if @pipeline.description do %>
<textarea
id="show-pipeline-description"
class="input input-primary h-32 min-h-32"
phx-hook="MaintainAttrs"
phx-update="ignore"
readonly
phx-no-format
><%= @pipeline.description %></textarea>
<% end %>
<textarea
:if={@pipeline.description}
id="show-pipeline-description"
class="input input-primary h-32 min-h-32"
phx-hook="MaintainAttrs"
phx-update="ignore"
readonly
phx-no-format
><%= @pipeline.description %></textarea>
<p class="self-end">
<%= gettext("Visibility: %{visibility}", visibility: @pipeline.visibility) %>
@ -30,25 +31,23 @@
<.link class="btn btn-primary" navigate={Routes.pipeline_index_path(@socket, :index)}>
<%= dgettext("actions", "back") %>
</.link>
<%= if is_owner?(@pipeline, @current_user) do %>
<.link
class="btn btn-primary"
patch={Routes.pipeline_show_path(@socket, :edit, @pipeline.slug)}
>
<%= dgettext("actions", "edit") %>
</.link>
<% end %>
<%= if is_owner_or_admin?(@pipeline, @current_user) do %>
<button
type="button"
class="btn btn-primary"
phx-click="delete"
data-confirm={dgettext("prompts", "are you sure?")}
data-qa={"delete-pipeline-#{@pipeline.id}"}
>
<%= dgettext("actions", "delete") %>
</button>
<% end %>
<.link
:if={is_owner?(@pipeline, @current_user)}
class="btn btn-primary"
patch={Routes.pipeline_show_path(@socket, :edit, @pipeline.slug)}
>
<%= dgettext("actions", "edit") %>
</.link>
<button
:if={is_owner_or_admin?(@pipeline, @current_user)}
type="button"
class="btn btn-primary"
phx-click="delete"
data-confirm={dgettext("prompts", "are you sure?")}
data-qa={"delete-pipeline-#{@pipeline.id}"}
>
<%= dgettext("actions", "delete") %>
</button>
</div>
<hr class="hr" />
@ -126,15 +125,14 @@
<% end %>
<% end %>
<%= if is_owner?(@pipeline, @current_user) do %>
<.link
class="self-end btn btn-primary"
patch={Routes.pipeline_show_path(@socket, :add_step, @pipeline.slug)}
data-qa={"add-step-#{@pipeline.id}"}
>
<%= dgettext("actions", "add step") %>
</.link>
<% end %>
<.link
:if={is_owner?(@pipeline, @current_user)}
class="self-end btn btn-primary"
patch={Routes.pipeline_show_path(@socket, :add_step, @pipeline.slug)}
data-qa={"add-step-#{@pipeline.id}"}
>
<%= dgettext("actions", "add step") %>
</.link>
</div>
<%= case @live_action do %>
@ -150,20 +148,7 @@
return_to={Routes.pipeline_show_path(@socket, :show, @pipeline.slug)}
/>
</.modal>
<% :add_step -> %>
<.modal return_to={Routes.pipeline_show_path(@socket, :show, @pipeline.slug)}>
<.live_component
module={MemexWeb.StepLive.FormComponent}
id={@pipeline.id || :new}
current_user={@current_user}
title={@page_title}
action={@live_action}
pipeline={@pipeline}
step={@step}
return_to={Routes.pipeline_show_path(@socket, :show, @pipeline.slug)}
/>
</.modal>
<% :edit_step -> %>
<% action when action in [:add_step, :edit_step] -> %>
<.modal return_to={Routes.pipeline_show_path(@socket, :show, @pipeline.slug)}>
<.live_component
module={MemexWeb.StepLive.FormComponent}