update liveview
This commit is contained in:
		| @@ -16,10 +16,12 @@ defmodule MemexWeb.Components.Topbar do | ||||
|     <nav role="navigation" class="mb-8 px-8 py-4 w-full bg-primary-900 text-primary-400"> | ||||
|       <div class="flex flex-col sm:flex-row justify-between items-center"> | ||||
|         <div class="mb-4 sm:mb-0 sm:mr-8 flex flex-row justify-start items-center space-x-2"> | ||||
|           <%= live_redirect("memex", | ||||
|             to: Routes.live_path(Endpoint, HomeLive), | ||||
|             class: "mx-2 my-1 leading-5 text-xl text-primary-400 hover:underline" | ||||
|           ) %> | ||||
|           <.link | ||||
|             navigate={Routes.live_path(Endpoint, HomeLive)} | ||||
|             class="mx-2 my-1 leading-5 text-xl text-primary-400 hover:underline" | ||||
|           > | ||||
|             <%= gettext("memex") %> | ||||
|           </.link> | ||||
|  | ||||
|           <%= if @title_content do %> | ||||
|             <span class="mx-2 my-1"> | ||||
| @@ -35,75 +37,93 @@ defmodule MemexWeb.Components.Topbar do | ||||
|           text-lg text-primary-400 text-ellipsis"> | ||||
|           <%= if @current_user do %> | ||||
|             <li class="mx-2 my-1"> | ||||
|               <%= live_redirect(gettext("Notes"), | ||||
|                 to: Routes.note_index_path(Endpoint, :index), | ||||
|                 class: "text-primary-400 text-primary-400 hover:underline truncate" | ||||
|               ) %> | ||||
|               <.link | ||||
|                 navigate={Routes.note_index_path(Endpoint, :index)} | ||||
|                 class="text-primary-400 text-primary-400 hover:underline truncate" | ||||
|               > | ||||
|                 <%= gettext("Notes") %> | ||||
|               </.link> | ||||
|             </li> | ||||
|  | ||||
|             <li class="mx-2 my-1"> | ||||
|               <%= live_redirect(gettext("Contexts"), | ||||
|                 to: Routes.context_index_path(Endpoint, :index), | ||||
|                 class: "text-primary-400 text-primary-400 hover:underline truncate" | ||||
|               ) %> | ||||
|               <.link | ||||
|                 navigate={Routes.context_index_path(Endpoint, :index)} | ||||
|                 class="text-primary-400 text-primary-400 hover:underline truncate" | ||||
|               > | ||||
|                 <%= gettext("Contexts") %> | ||||
|               </.link> | ||||
|             </li> | ||||
|  | ||||
|             <li class="mx-2 my-1"> | ||||
|               <%= live_redirect(gettext("Pipelines"), | ||||
|                 to: Routes.pipeline_index_path(Endpoint, :index), | ||||
|                 class: "text-primary-400 text-primary-400 hover:underline truncate" | ||||
|               ) %> | ||||
|               <.link | ||||
|                 navigate={Routes.pipeline_index_path(Endpoint, :index)} | ||||
|                 class="text-primary-400 text-primary-400 hover:underline truncate" | ||||
|               > | ||||
|                 <%= gettext("Pipelines") %> | ||||
|               </.link> | ||||
|             </li> | ||||
|  | ||||
|             <li class="mx-2 my-1 border-left border border-primary-400"></li> | ||||
|  | ||||
|             <%= if @current_user.role == :admin do %> | ||||
|               <li class="mx-2 my-1"> | ||||
|                 <%= live_redirect(gettext("Invites"), | ||||
|                   to: Routes.invite_index_path(Endpoint, :index), | ||||
|                   class: "text-primary-400 text-primary-400 hover:underline" | ||||
|                 ) %> | ||||
|                 <.link | ||||
|                   navigate={Routes.invite_index_path(Endpoint, :index)} | ||||
|                   class="text-primary-400 text-primary-400 hover:underline" | ||||
|                 > | ||||
|                   <%= gettext("Invites") %> | ||||
|                 </.link> | ||||
|               </li> | ||||
|             <% end %> | ||||
|  | ||||
|             <li class="mx-2 my-1"> | ||||
|               <%= live_redirect(@current_user.email, | ||||
|                 to: Routes.user_settings_path(Endpoint, :edit), | ||||
|                 class: "text-primary-400 text-primary-400 hover:underline truncate" | ||||
|               ) %> | ||||
|               <.link | ||||
|                 navigate={Routes.user_settings_path(Endpoint, :edit)} | ||||
|                 class="text-primary-400 text-primary-400 hover:underline truncate" | ||||
|               > | ||||
|                 <%= @current_user.email %> | ||||
|               </.link> | ||||
|             </li> | ||||
|  | ||||
|             <li class="mx-2 my-1"> | ||||
|               <%= link to: Routes.user_session_path(Endpoint, :delete), | ||||
|                    method: :delete, | ||||
|                    data: [confirm: dgettext("prompts", "Are you sure you want to log out?")] do %> | ||||
|               <.link | ||||
|                 href={Routes.user_session_path(Endpoint, :delete)} | ||||
|                 method="delete" | ||||
|                 data-confirm={dgettext("prompts", "Are you sure you want to log out?")} | ||||
|               > | ||||
|                 <i class="fas fa-sign-out-alt"></i> | ||||
|               <% end %> | ||||
|               </.link> | ||||
|             </li> | ||||
|  | ||||
|             <%= if @current_user.role == :admin and function_exported?(Routes, :live_dashboard_path, 2) do %> | ||||
|               <li class="mx-2 my-1"> | ||||
|                 <%= live_redirect to: Routes.live_dashboard_path(Endpoint, :home), | ||||
|                   class: "text-primary-400 text-primary-400 hover:underline" do %> | ||||
|                 <.link | ||||
|                   navigate={Routes.live_dashboard_path(Endpoint, :home)} | ||||
|                   class="text-primary-400 text-primary-400 hover:underline" | ||||
|                 > | ||||
|                   <i class="fas fa-gauge"></i> | ||||
|                 <% end %> | ||||
|                 </.link> | ||||
|               </li> | ||||
|             <% end %> | ||||
|           <% else %> | ||||
|             <%= if Accounts.allow_registration?() do %> | ||||
|               <li class="mx-2 my-1"> | ||||
|                 <%= live_redirect(dgettext("actions", "Register"), | ||||
|                   to: Routes.user_registration_path(Endpoint, :new), | ||||
|                   class: "text-primary-400 text-primary-400 hover:underline truncate" | ||||
|                 ) %> | ||||
|                 <.link | ||||
|                   navigate={Routes.user_registration_path(Endpoint, :new)} | ||||
|                   class="text-primary-400 text-primary-400 hover:underline truncate" | ||||
|                 > | ||||
|                   <%= dgettext("actions", "Register") %> | ||||
|                 </.link> | ||||
|               </li> | ||||
|             <% end %> | ||||
|  | ||||
|             <li class="mx-2 my-1"> | ||||
|               <%= live_redirect(dgettext("actions", "Log in"), | ||||
|                 to: Routes.user_session_path(Endpoint, :new), | ||||
|                 class: "text-primary-400 text-primary-400 hover:underline truncate" | ||||
|               ) %> | ||||
|               <.link | ||||
|                 navigate={Routes.user_session_path(Endpoint, :new)} | ||||
|                 class="text-primary-400 text-primary-400 hover:underline truncate" | ||||
|               > | ||||
|                 <%= dgettext("actions", "Log in") %> | ||||
|               </.link> | ||||
|             </li> | ||||
|           <% end %> | ||||
|         </ul> | ||||
|   | ||||
| @@ -33,7 +33,7 @@ defmodule MemexWeb.ContextLive.FormComponent do | ||||
|         {:noreply, | ||||
|          socket | ||||
|          |> put_flash(:info, "Context updated successfully") | ||||
|          |> push_redirect(to: socket.assigns.return_to)} | ||||
|          |> push_navigate(to: socket.assigns.return_to)} | ||||
|  | ||||
|       {:error, %Ecto.Changeset{} = changeset} -> | ||||
|         {:noreply, assign(socket, :changeset, changeset)} | ||||
| @@ -46,7 +46,7 @@ defmodule MemexWeb.ContextLive.FormComponent do | ||||
|         {:noreply, | ||||
|          socket | ||||
|          |> put_flash(:info, "Context created successfully") | ||||
|          |> push_redirect(to: socket.assigns.return_to)} | ||||
|          |> push_navigate(to: socket.assigns.return_to)} | ||||
|  | ||||
|       {:error, %Ecto.Changeset{} = changeset} -> | ||||
|         {:noreply, assign(socket, changeset: changeset)} | ||||
|   | ||||
| @@ -2,7 +2,7 @@ | ||||
|   <h2><%= @title %></h2> | ||||
|  | ||||
|   <.form | ||||
|     let={f} | ||||
|     :let={f} | ||||
|     for={@changeset} | ||||
|     id="context-form" | ||||
|     phx-target={@myself} | ||||
|   | ||||
| @@ -34,18 +34,24 @@ | ||||
|  | ||||
|         <td> | ||||
|           <span> | ||||
|             <%= live_redirect("Show", to: Routes.context_show_path(@socket, :show, context)) %> | ||||
|             <.link navigate={Routes.context_show_path(@socket, :show, context)}> | ||||
|               <%= dgettext("actions", "Show") %> | ||||
|             </.link> | ||||
|           </span> | ||||
|           <span> | ||||
|             <%= live_patch("Edit", to: Routes.context_index_path(@socket, :edit, context)) %> | ||||
|             <.link patch={Routes.context_index_path(@socket, :edit, context)}> | ||||
|               <%= dgettext("actions", "Edit") %> | ||||
|             </.link> | ||||
|           </span> | ||||
|           <span> | ||||
|             <%= link("Delete", | ||||
|               to: "#", | ||||
|               phx_click: "delete", | ||||
|               phx_value_id: context.id, | ||||
|               data: [confirm: "Are you sure?"] | ||||
|             ) %> | ||||
|             <.link | ||||
|               href="#" | ||||
|               phx-click="delete" | ||||
|               phx-value-id={context.id} | ||||
|               data-confirm={dgettext("prompts", "Are you sure?")} | ||||
|             > | ||||
|               <%= dgettext("actions", "Delete") %> | ||||
|             </.link> | ||||
|           </span> | ||||
|         </td> | ||||
|       </tr> | ||||
| @@ -53,4 +59,8 @@ | ||||
|   </tbody> | ||||
| </table> | ||||
|  | ||||
| <span><%= live_patch("New Context", to: Routes.context_index_path(@socket, :new)) %></span> | ||||
| <span> | ||||
|   <.link patch={Routes.context_index_path(@socket, :new)}> | ||||
|     <%= dgettext("actions", "New Context") %> | ||||
|   </.link> | ||||
| </span> | ||||
|   | ||||
| @@ -36,6 +36,13 @@ | ||||
| </ul> | ||||
|  | ||||
| <span> | ||||
|   <%= live_patch("Edit", to: Routes.context_show_path(@socket, :edit, @context), class: "button") %> | ||||
|   <.link patch={Routes.context_show_path(@socket, :edit, @context)} class="button"> | ||||
|     <%= dgettext("actions", "Edit") %> | ||||
|   </.link> | ||||
| </span> | ||||
| | | ||||
| <span> | ||||
|   <.link navigate={Routes.context_index_path(@socket, :index)}> | ||||
|     <%= dgettext("actions", "Back") %> | ||||
|   </.link> | ||||
| </span> | ||||
| | <span><%= live_redirect("Back", to: Routes.context_index_path(@socket, :index)) %></span> | ||||
|   | ||||
| @@ -88,10 +88,12 @@ | ||||
|       </b> | ||||
|       <p> | ||||
|         <%= if @admins |> Enum.empty?() do %> | ||||
|           <%= link(dgettext("prompts", "Register to setup %{name}", name: "Cannery"), | ||||
|             class: "hover:underline", | ||||
|             to: Routes.user_registration_path(CanneryWeb.Endpoint, :new) | ||||
|           ) %> | ||||
|           <.link | ||||
|             href={Routes.user_registration_path(MemexWeb.Endpoint, :new)} | ||||
|             class="hover:underline" | ||||
|           > | ||||
|             <%= dgettext("prompts", "Register to setup %{name}", name: "memex") %> | ||||
|           </.link> | ||||
|         <% else %> | ||||
|           <div class="flex flex-wrap justify-center space-x-2"> | ||||
|             <%= for admin <- @admins do %> | ||||
| @@ -107,7 +109,7 @@ | ||||
|     <li class="flex flex-row justify-center space-x-2"> | ||||
|       <b>Registration:</b> | ||||
|       <p> | ||||
|         <%= Application.get_env(:cannery, CanneryWeb.Endpoint)[:registration] | ||||
|         <%= Application.get_env(:memex, MemexWeb.Endpoint)[:registration] | ||||
|         |> case do | ||||
|           "public" -> gettext("Public Signups") | ||||
|           _ -> gettext("Invite Only") | ||||
| @@ -117,13 +119,15 @@ | ||||
|  | ||||
|     <li class="flex flex-row justify-center items-center space-x-2"> | ||||
|       <b>Version:</b> | ||||
|       <%= link class: "flex flex-row justify-center items-center space-x-2 hover:underline", | ||||
|             to: "https://gitea.bubbletea.dev/shibao/memex/src/branch/stable/CHANGELOG.md", | ||||
|             target: "_blank", | ||||
|             rel: "noopener noreferrer" do %> | ||||
|       <.link | ||||
|         href="https://gitea.bubbletea.dev/shibao/memex/src/branch/stable/CHANGELOG.md" | ||||
|         class="flex flex-row justify-center items-center space-x-2 hover:underline" | ||||
|         target="_blank" | ||||
|         rel="noopener noreferrer" | ||||
|       > | ||||
|         <p>0.1.0</p> | ||||
|         <i class="fas fa-md fa-info-circle"></i> | ||||
|       <% end %> | ||||
|       </.link> | ||||
|     </li> | ||||
|   </ul> | ||||
|  | ||||
| @@ -135,31 +139,37 @@ | ||||
|     </h2> | ||||
|  | ||||
|     <li class="flex flex-col justify-center space-x-2"> | ||||
|       <%= link class: "flex flex-row justify-center items-center space-x-2 hover:underline", | ||||
|             to: "https://gitea.bubbletea.dev/shibao/memex", | ||||
|             target: "_blank", | ||||
|             rel: "noopener noreferrer" do %> | ||||
|       <.link | ||||
|         href="https://gitea.bubbletea.dev/shibao/memex" | ||||
|         class="flex flex-row justify-center items-center space-x-2 hover:underline" | ||||
|         target="_blank" | ||||
|         rel="noopener noreferrer" | ||||
|       > | ||||
|         <p><%= gettext("View the source code") %></p> | ||||
|         <i class="fas fa-md fa-code"></i> | ||||
|       <% end %> | ||||
|       </.link> | ||||
|     </li> | ||||
|     <li class="flex flex-col justify-center space-x-2"> | ||||
|       <%= link class: "flex flex-row justify-center items-center space-x-2 hover:underline", | ||||
|           to: "https://weblate.bubbletea.dev/engage/memex", | ||||
|           target: "_blank", | ||||
|           rel: "noopener noreferrer" do %> | ||||
|       <.link | ||||
|         href="https://weblate.bubbletea.dev/engage/memex" | ||||
|         class="flex flex-row justify-center items-center space-x-2 hover:underline" | ||||
|         target="_blank" | ||||
|         rel="noopener noreferrer" | ||||
|       > | ||||
|         <p><%= gettext("Help translate") %></p> | ||||
|         <i class="fas fa-md fa-language"></i> | ||||
|       <% end %> | ||||
|       </.link> | ||||
|     </li> | ||||
|     <li class="flex flex-col justify-center space-x-2"> | ||||
|       <%= link class: "flex flex-row justify-center items-center space-x-2 hover:underline", | ||||
|           to: "https://gitea.bubbletea.dev/shibao/memex/issues/new", | ||||
|           target: "_blank", | ||||
|           rel: "noopener noreferrer" do %> | ||||
|       <.link | ||||
|         href="https://gitea.bubbletea.dev/shibao/memex/issues/new" | ||||
|         class="flex flex-row justify-center items-center space-x-2 hover:underline" | ||||
|         target="_blank" | ||||
|         rel="noopener noreferrer" | ||||
|       > | ||||
|         <p><%= gettext("Report bugs or request features") %></p> | ||||
|         <i class="fas fa-md fa-spider"></i> | ||||
|       <% end %> | ||||
|       </.link> | ||||
|     </li> | ||||
|   </ul> | ||||
| </div> | ||||
|   | ||||
| @@ -2,7 +2,7 @@ defmodule MemexWeb.InitAssigns do | ||||
|   @moduledoc """ | ||||
|   Ensures common `assigns` are applied to all LiveViews attaching this hook. | ||||
|   """ | ||||
|   import Phoenix.LiveView | ||||
|   import Phoenix.Component | ||||
|   alias Memex.Accounts | ||||
|  | ||||
|   def on_mount(:default, _params, %{"locale" => locale, "user_token" => user_token}, socket) do | ||||
|   | ||||
| @@ -41,7 +41,7 @@ defmodule MemexWeb.InviteLive.FormComponent do | ||||
|           prompt = | ||||
|             dgettext("prompts", "%{invite_name} updated successfully", invite_name: invite_name) | ||||
|  | ||||
|           socket |> put_flash(:info, prompt) |> push_redirect(to: return_to) | ||||
|           socket |> put_flash(:info, prompt) |> push_navigate(to: return_to) | ||||
|  | ||||
|         {:error, %Changeset{} = changeset} -> | ||||
|           socket |> assign(:changeset, changeset) | ||||
| @@ -61,7 +61,7 @@ defmodule MemexWeb.InviteLive.FormComponent do | ||||
|           prompt = | ||||
|             dgettext("prompts", "%{invite_name} created successfully", invite_name: invite_name) | ||||
|  | ||||
|           socket |> put_flash(:info, prompt) |> push_redirect(to: return_to) | ||||
|           socket |> put_flash(:info, prompt) |> push_navigate(to: return_to) | ||||
|  | ||||
|         {:error, %Changeset{} = changeset} -> | ||||
|           socket |> assign(changeset: changeset) | ||||
|   | ||||
| @@ -3,7 +3,7 @@ | ||||
|     <%= @title %> | ||||
|   </h2> | ||||
|   <.form | ||||
|     let={f} | ||||
|     :let={f} | ||||
|     for={@changeset} | ||||
|     id="invite-form" | ||||
|     class="flex flex-col space-y-4 sm:space-y-0 sm:grid sm:grid-cols-3 sm:gap-4 justify-center items-center" | ||||
|   | ||||
| @@ -17,7 +17,7 @@ defmodule MemexWeb.InviteLive.Index do | ||||
|       else | ||||
|         prompt = dgettext("errors", "You are not authorized to view this page") | ||||
|         return_to = Routes.live_path(Endpoint, HomeLive) | ||||
|         socket |> put_flash(:error, prompt) |> push_redirect(to: return_to) | ||||
|         socket |> put_flash(:error, prompt) |> push_navigate(to: return_to) | ||||
|       end | ||||
|  | ||||
|     {:ok, socket} | ||||
|   | ||||
| @@ -8,15 +8,13 @@ | ||||
|       <%= gettext("No invites 😔") %> | ||||
|     </h1> | ||||
|  | ||||
|     <%= live_patch(dgettext("actions", "Invite someone new!"), | ||||
|       to: Routes.invite_index_path(Endpoint, :new), | ||||
|       class: "btn btn-primary" | ||||
|     ) %> | ||||
|     <.link patch={Routes.invite_index_path(Endpoint, :new)} class="btn btn-primary"> | ||||
|       <%= dgettext("actions", "Invite someone new!") %> | ||||
|     </.link> | ||||
|   <% else %> | ||||
|     <%= live_patch(dgettext("actions", "Create Invite"), | ||||
|       to: Routes.invite_index_path(Endpoint, :new), | ||||
|       class: "btn btn-primary" | ||||
|     ) %> | ||||
|     <.link patch={Routes.invite_index_path(Endpoint, :new)} class="btn btn-primary"> | ||||
|       <%= dgettext("actions", "Create Invite") %> | ||||
|     </.link> | ||||
|   <% end %> | ||||
|  | ||||
|   <div class="w-full flex flex-row flex-wrap justify-center items-center"> | ||||
| @@ -33,25 +31,28 @@ | ||||
|             </button> | ||||
|           </form> | ||||
|         </:code_actions> | ||||
|         <%= live_patch to: Routes.invite_index_path(Endpoint, :edit, invite), | ||||
|                    class: "text-primary-400 link", | ||||
|                    data: [qa: "edit-#{invite.id}"] do %> | ||||
|         <.link | ||||
|           patch={Routes.invite_index_path(Endpoint, :edit, invite)} | ||||
|           class="text-primary-400 link" | ||||
|           data-qa={"edit-#{invite.id}"} | ||||
|         > | ||||
|           <i class="fa-fw fa-lg fas fa-edit"></i> | ||||
|         <% end %> | ||||
|         </.link> | ||||
|  | ||||
|         <%= link to: "#", | ||||
|              class: "text-primary-400 link", | ||||
|              phx_click: "delete_invite", | ||||
|              phx_value_id: invite.id, | ||||
|              data: [ | ||||
|                confirm: | ||||
|                  dgettext("prompts", "Are you sure you want to delete the invite for %{invite_name}?", | ||||
|                    invite_name: invite.name | ||||
|                  ), | ||||
|                qa: "delete-#{invite.id}" | ||||
|              ] do %> | ||||
|         <.link | ||||
|           href="#" | ||||
|           class="text-primary-400 link" | ||||
|           phx-click="delete_invite" | ||||
|           phx-value-id={invite.id} | ||||
|           data-confirm={ | ||||
|             dgettext("prompts", "Are you sure you want to delete the invite for %{invite_name}?", | ||||
|               invite_name: invite.name | ||||
|             ) | ||||
|           } | ||||
|           data-qa={"delete-#{invite.id}"} | ||||
|         > | ||||
|           <i class="fa-fw fa-lg fas fa-trash"></i> | ||||
|         <% end %> | ||||
|         </.link> | ||||
|  | ||||
|         <%= if invite.disabled_at |> is_nil() do %> | ||||
|           <a href="#" class="btn btn-primary" phx-click="disable_invite" phx-value-id={invite.id}> | ||||
| @@ -92,20 +93,21 @@ | ||||
|     <div class="w-full flex flex-row flex-wrap justify-center items-center"> | ||||
|       <%= for admin <- @admins do %> | ||||
|         <.user_card user={admin}> | ||||
|           <%= link to: "#", | ||||
|                class: "text-primary-400 link", | ||||
|                phx_click: "delete_user", | ||||
|                phx_value_id: admin.id, | ||||
|                data: [ | ||||
|                  confirm: | ||||
|                    dgettext( | ||||
|                      "prompts", | ||||
|                      "Are you sure you want to delete %{email}? This action is permanent!", | ||||
|                      email: admin.email | ||||
|                    ) | ||||
|                ] do %> | ||||
|           <.link | ||||
|             href="#" | ||||
|             class="text-primary-400 link" | ||||
|             phx-click="delete_user" | ||||
|             phx-value-id={admin.id} | ||||
|             data-confirm={ | ||||
|               dgettext( | ||||
|                 "prompts", | ||||
|                 "Are you sure you want to delete %{email}? This action is permanent!", | ||||
|                 email: admin.email | ||||
|               ) | ||||
|             } | ||||
|           > | ||||
|             <i class="fa-fw fa-lg fas fa-trash"></i> | ||||
|           <% end %> | ||||
|           </.link> | ||||
|         </.user_card> | ||||
|       <% end %> | ||||
|     </div> | ||||
| @@ -121,20 +123,21 @@ | ||||
|     <div class="w-full flex flex-row flex-wrap justify-center items-center"> | ||||
|       <%= for user <- @users do %> | ||||
|         <.user_card user={user}> | ||||
|           <%= link to: "#", | ||||
|                class: "text-primary-400 link", | ||||
|                phx_click: "delete_user", | ||||
|                phx_value_id: user.id, | ||||
|                data: [ | ||||
|                  confirm: | ||||
|                    dgettext( | ||||
|                      "prompts", | ||||
|                      "Are you sure you want to delete %{email}? This action is permanent!", | ||||
|                      email: user.email | ||||
|                    ) | ||||
|                ] do %> | ||||
|           <.link | ||||
|             href="#" | ||||
|             class="text-primary-400 link" | ||||
|             phx-click="delete_user" | ||||
|             phx-value-id={user.id} | ||||
|             data-confirm={ | ||||
|               dgettext( | ||||
|                 "prompts", | ||||
|                 "Are you sure you want to delete %{email}? This action is permanent!", | ||||
|                 email: user.email | ||||
|               ) | ||||
|             } | ||||
|           > | ||||
|             <i class="fa-fw fa-lg fas fa-trash"></i> | ||||
|           <% end %> | ||||
|           </.link> | ||||
|         </.user_card> | ||||
|       <% end %> | ||||
|     </div> | ||||
|   | ||||
| @@ -3,7 +3,7 @@ defmodule MemexWeb.LiveHelpers do | ||||
|   Contains resuable methods for all liveviews | ||||
|   """ | ||||
|  | ||||
|   import Phoenix.LiveView.Helpers | ||||
|   import Phoenix.Component | ||||
|   alias Phoenix.LiveView.JS | ||||
|  | ||||
|   @doc """ | ||||
| @@ -27,17 +27,17 @@ defmodule MemexWeb.LiveHelpers do | ||||
|   """ | ||||
|   def modal(assigns) do | ||||
|     ~H""" | ||||
|     <%= live_patch to: @return_to, | ||||
|       id: "modal-bg", | ||||
|       class: | ||||
|         "fade-in fixed z-10 left-0 top-0 | ||||
|     <.link | ||||
|       patch={@return_to} | ||||
|       id="modal-bg" | ||||
|       class="fade-in fixed z-10 left-0 top-0 | ||||
|          w-screen h-screen overflow-hidden | ||||
|          p-8 flex flex-col justify-center items-center cursor-auto", | ||||
|       style: "background-color: rgba(0,0,0,0.4);", | ||||
|       phx_remove: hide_modal() | ||||
|     do %> | ||||
|          p-8 flex flex-col justify-center items-center cursor-auto" | ||||
|       style="background-color: rgba(0,0,0,0.4);" | ||||
|       phx-remove={hide_modal()} | ||||
|     > | ||||
|       <span class="hidden"></span> | ||||
|     <% end %> | ||||
|     </.link> | ||||
|  | ||||
|     <div | ||||
|       id="modal" | ||||
| @@ -52,15 +52,16 @@ defmodule MemexWeb.LiveHelpers do | ||||
|         px-8 py-4 sm:py-8 flex flex-col justify-start items-stretch | ||||
|         bg-primary-800 text-primary-400 border-primary-900 border-2 rounded-lg" | ||||
|       > | ||||
|         <%= live_patch to: @return_to, | ||||
|                    id: "close", | ||||
|                    class: | ||||
|                      "absolute top-8 right-10 | ||||
|         <.link | ||||
|           patch={@return_to} | ||||
|           id="close" | ||||
|           class="absolute top-8 right-10 | ||||
|                       text-gray-500 hover:text-gray-800 | ||||
|                       transition-all duration-500 ease-in-out", | ||||
|                    phx_remove: hide_modal() do %> | ||||
|                       transition-all duration-500 ease-in-out" | ||||
|           phx-remove={hide_modal()} | ||||
|         > | ||||
|           <i class="fa-fw fa-lg fas fa-times"></i> | ||||
|         <% end %> | ||||
|         </.link> | ||||
|  | ||||
|         <div class="overflow-x-hidden overflow-y-visible p-8 flex flex-col space-y-4 justify-start items-stretch"> | ||||
|           <%= render_slot(@inner_block) %> | ||||
|   | ||||
| @@ -33,7 +33,7 @@ defmodule MemexWeb.NoteLive.FormComponent do | ||||
|         {:noreply, | ||||
|          socket | ||||
|          |> put_flash(:info, "Note updated successfully") | ||||
|          |> push_redirect(to: socket.assigns.return_to)} | ||||
|          |> push_navigate(to: socket.assigns.return_to)} | ||||
|  | ||||
|       {:error, %Ecto.Changeset{} = changeset} -> | ||||
|         {:noreply, assign(socket, :changeset, changeset)} | ||||
| @@ -46,7 +46,7 @@ defmodule MemexWeb.NoteLive.FormComponent do | ||||
|         {:noreply, | ||||
|          socket | ||||
|          |> put_flash(:info, "Note created successfully") | ||||
|          |> push_redirect(to: socket.assigns.return_to)} | ||||
|          |> push_navigate(to: socket.assigns.return_to)} | ||||
|  | ||||
|       {:error, %Ecto.Changeset{} = changeset} -> | ||||
|         {:noreply, assign(socket, changeset: changeset)} | ||||
|   | ||||
| @@ -2,7 +2,7 @@ | ||||
|   <h2><%= @title %></h2> | ||||
|  | ||||
|   <.form | ||||
|     let={f} | ||||
|     :let={f} | ||||
|     for={@changeset} | ||||
|     id="note-form" | ||||
|     phx-target={@myself} | ||||
|   | ||||
| @@ -34,16 +34,24 @@ | ||||
|  | ||||
|         <td> | ||||
|           <span> | ||||
|             <%= live_redirect("Show", to: Routes.note_show_path(@socket, :show, note)) %> | ||||
|             <.link navigate={Routes.note_show_path(@socket, :show, note)}> | ||||
|               <%= dgettext("actions", "Show") %> | ||||
|             </.link> | ||||
|           </span> | ||||
|           <span><%= live_patch("Edit", to: Routes.note_index_path(@socket, :edit, note)) %></span> | ||||
|           <span> | ||||
|             <%= link("Delete", | ||||
|               to: "#", | ||||
|               phx_click: "delete", | ||||
|               phx_value_id: note.id, | ||||
|               data: [confirm: "Are you sure?"] | ||||
|             ) %> | ||||
|             <.link patch={Routes.note_index_path(@socket, :edit, note)}> | ||||
|               <%= dgettext("actions", "Edit") %> | ||||
|             </.link> | ||||
|           </span> | ||||
|           <span> | ||||
|             <.link | ||||
|               href="#" | ||||
|               phx-click="delete" | ||||
|               phx-value-id={note.id} | ||||
|               data-confirm={dgettext("prompts", "Are you sure?")} | ||||
|             > | ||||
|               <%= dgettext("actions", "Delete") %> | ||||
|             </.link> | ||||
|           </span> | ||||
|         </td> | ||||
|       </tr> | ||||
| @@ -51,4 +59,8 @@ | ||||
|   </tbody> | ||||
| </table> | ||||
|  | ||||
| <span><%= live_patch("New Note", to: Routes.note_index_path(@socket, :new)) %></span> | ||||
| <span> | ||||
|   <.link patch={Routes.note_index_path(@socket, :new)}> | ||||
|     <%= dgettext("actions", "New Note") %> | ||||
|   </.link> | ||||
| </span> | ||||
|   | ||||
| @@ -36,6 +36,13 @@ | ||||
| </ul> | ||||
|  | ||||
| <span> | ||||
|   <%= live_patch("Edit", to: Routes.note_show_path(@socket, :edit, @note), class: "button") %> | ||||
|   <.link patch={Routes.note_show_path(@socket, :edit, @note)} class="button"> | ||||
|     <%= dgettext("actions", "Edit") %> | ||||
|   </.link> | ||||
| </span> | ||||
| | | ||||
| <span> | ||||
|   <.link patch={Routes.note_index_path(@socket, :index)}> | ||||
|     <%= dgettext("actions", "Back") %> | ||||
|   </.link> | ||||
| </span> | ||||
| | <span><%= live_redirect("Back", to: Routes.note_index_path(@socket, :index)) %></span> | ||||
|   | ||||
| @@ -33,7 +33,7 @@ defmodule MemexWeb.PipelineLive.FormComponent do | ||||
|         {:noreply, | ||||
|          socket | ||||
|          |> put_flash(:info, "Pipeline updated successfully") | ||||
|          |> push_redirect(to: socket.assigns.return_to)} | ||||
|          |> push_navigate(to: socket.assigns.return_to)} | ||||
|  | ||||
|       {:error, %Ecto.Changeset{} = changeset} -> | ||||
|         {:noreply, assign(socket, :changeset, changeset)} | ||||
| @@ -46,7 +46,7 @@ defmodule MemexWeb.PipelineLive.FormComponent do | ||||
|         {:noreply, | ||||
|          socket | ||||
|          |> put_flash(:info, "Pipeline created successfully") | ||||
|          |> push_redirect(to: socket.assigns.return_to)} | ||||
|          |> push_navigate(to: socket.assigns.return_to)} | ||||
|  | ||||
|       {:error, %Ecto.Changeset{} = changeset} -> | ||||
|         {:noreply, assign(socket, changeset: changeset)} | ||||
|   | ||||
| @@ -2,7 +2,7 @@ | ||||
|   <h2><%= @title %></h2> | ||||
|  | ||||
|   <.form | ||||
|     let={f} | ||||
|     :let={f} | ||||
|     for={@changeset} | ||||
|     id="pipeline-form" | ||||
|     phx-target={@myself} | ||||
|   | ||||
| @@ -32,18 +32,24 @@ | ||||
|  | ||||
|         <td> | ||||
|           <span> | ||||
|             <%= live_redirect("Show", to: Routes.pipeline_show_path(@socket, :show, pipeline)) %> | ||||
|             <.link navigate={Routes.pipeline_show_path(@socket, :show, pipeline)}> | ||||
|               <%= dgettext("actions", "Show") %> | ||||
|             </.link> | ||||
|           </span> | ||||
|           <span> | ||||
|             <%= live_patch("Edit", to: Routes.pipeline_index_path(@socket, :edit, pipeline)) %> | ||||
|             <.link patch={Routes.pipeline_index_path(@socket, :edit, pipeline)}> | ||||
|               <%= dgettext("actions", "Edit") %> | ||||
|             </.link> | ||||
|           </span> | ||||
|           <span> | ||||
|             <%= link("Delete", | ||||
|               to: "#", | ||||
|               phx_click: "delete", | ||||
|               phx_value_id: pipeline.id, | ||||
|               data: [confirm: "Are you sure?"] | ||||
|             ) %> | ||||
|             <.link | ||||
|               href="#" | ||||
|               phx-click="delete" | ||||
|               phx-value-id={pipeline.id} | ||||
|               data-confirm={dgettext("prompts", "Are you sure?")} | ||||
|             > | ||||
|               <%= dgettext("actions", "Delete") %> | ||||
|             </.link> | ||||
|           </span> | ||||
|         </td> | ||||
|       </tr> | ||||
| @@ -51,4 +57,8 @@ | ||||
|   </tbody> | ||||
| </table> | ||||
|  | ||||
| <span><%= live_patch("New Pipeline", to: Routes.pipeline_index_path(@socket, :new)) %></span> | ||||
| <span> | ||||
|   <.link patch={Routes.pipeline_index_path(@socket, :new)}> | ||||
|     <%= dgettext("actions", "New Pipeline") %> | ||||
|   </.link> | ||||
| </span> | ||||
|   | ||||
| @@ -31,6 +31,13 @@ | ||||
| </ul> | ||||
|  | ||||
| <span> | ||||
|   <%= live_patch("Edit", to: Routes.pipeline_show_path(@socket, :edit, @pipeline), class: "button") %> | ||||
|   <.link patch={Routes.pipeline_show_path(@socket, :edit, @pipeline)} class="button"> | ||||
|     <%= dgettext("actions", "Edit") %> | ||||
|   </.link> | ||||
| </span> | ||||
| | | ||||
| <span> | ||||
|   <.link patch={Routes.pipeline_index_path(@socket, :index)}> | ||||
|     <%= dgettext("actions", "Back") %> | ||||
|   </.link> | ||||
| </span> | ||||
| | <span><%= live_redirect("Back", to: Routes.pipeline_index_path(@socket, :index)) %></span> | ||||
|   | ||||
| @@ -5,8 +5,9 @@ | ||||
|     <meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||||
|     <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||||
|     <%= csrf_meta_tag() %> | ||||
|     <%= if(assigns |> Map.has_key?(:page_title), do: @page_title, else: "memex") | ||||
|     |> live_title_tag(suffix: " | memex") %> | ||||
|     <.live_title suffix={" | #{gettext("memex")}"}> | ||||
|       <%= assigns[:page_title] || gettext("memex") %> | ||||
|     </.live_title> | ||||
|     <link phx-track-static rel="stylesheet" href={Routes.static_path(@conn, "/css/app.css")} /> | ||||
|     <script | ||||
|       defer | ||||
|   | ||||
| @@ -4,7 +4,7 @@ | ||||
|   </h1> | ||||
|  | ||||
|   <.form | ||||
|     let={f} | ||||
|     :let={f} | ||||
|     for={:user} | ||||
|     action={Routes.user_confirmation_path(@conn, :create)} | ||||
|     class="flex flex-col space-y-4 sm:space-y-0 sm:grid sm:grid-cols-3 sm:gap-4 justify-center items-center" | ||||
| @@ -21,14 +21,12 @@ | ||||
|  | ||||
|   <div class="flex flex-row justify-center items-center space-x-4"> | ||||
|     <%= if Accounts.allow_registration?() do %> | ||||
|       <%= link(dgettext("actions", "Register"), | ||||
|         to: Routes.user_registration_path(@conn, :new), | ||||
|         class: "btn btn-primary" | ||||
|       ) %> | ||||
|       <.link href={Routes.user_registration_path(@conn, :new)} class="btn btn-primary"> | ||||
|         <%= dgettext("actions", "Register") %> | ||||
|       </.link> | ||||
|     <% end %> | ||||
|     <%= link(dgettext("actions", "Log in"), | ||||
|       to: Routes.user_session_path(@conn, :new), | ||||
|       class: "btn btn-primary" | ||||
|     ) %> | ||||
|     <.link href={Routes.user_session_path(@conn, :new)} class="btn btn-primary"> | ||||
|       <%= dgettext("actions", "Log in") %> | ||||
|     </.link> | ||||
|   </div> | ||||
| </div> | ||||
|   | ||||
| @@ -4,7 +4,7 @@ | ||||
|   </h1> | ||||
|  | ||||
|   <.form | ||||
|     let={f} | ||||
|     :let={f} | ||||
|     for={@changeset} | ||||
|     action={Routes.user_registration_path(@conn, :create)} | ||||
|     class="flex flex-col space-y-4 sm:space-y-0 sm:grid sm:grid-cols-3 sm:gap-4 justify-center items-center" | ||||
| @@ -44,13 +44,11 @@ | ||||
|   <hr class="hr" /> | ||||
|  | ||||
|   <div class="flex flex-row justify-center items-center space-x-4"> | ||||
|     <%= link(dgettext("actions", "Log in"), | ||||
|       to: Routes.user_session_path(@conn, :new), | ||||
|       class: "btn btn-primary" | ||||
|     ) %> | ||||
|     <%= link(dgettext("actions", "Forgot your password?"), | ||||
|       to: Routes.user_reset_password_path(@conn, :new), | ||||
|       class: "btn btn-primary" | ||||
|     ) %> | ||||
|     <.link href={Routes.user_session_path(@conn, :new)} class="btn btn-primary"> | ||||
|       <%= dgettext("actions", "Log in") %> | ||||
|     </.link> | ||||
|     <.link href={Routes.user_reset_password_path(@conn, :new)} class="btn btn-primary"> | ||||
|       <%= dgettext("actions", "Forgot your password?") %> | ||||
|     </.link> | ||||
|   </div> | ||||
| </div> | ||||
|   | ||||
| @@ -4,7 +4,7 @@ | ||||
|   </h1> | ||||
|  | ||||
|   <.form | ||||
|     let={f} | ||||
|     :let={f} | ||||
|     for={@changeset} | ||||
|     action={Routes.user_reset_password_path(@conn, :update, @token)} | ||||
|     class="flex flex-col space-y-4 sm:space-y-0 sm:grid sm:grid-cols-3 sm:gap-4 justify-center items-center" | ||||
| @@ -39,14 +39,12 @@ | ||||
|  | ||||
|   <div class="flex flex-row justify-center items-center space-x-4"> | ||||
|     <%= if Accounts.allow_registration?() do %> | ||||
|       <%= link(dgettext("actions", "Register"), | ||||
|         to: Routes.user_registration_path(@conn, :new), | ||||
|         class: "btn btn-primary" | ||||
|       ) %> | ||||
|       <.link href={Routes.user_registration_path(@conn, :new)} class="btn btn-primary"> | ||||
|         <%= dgettext("actions", "Register") %> | ||||
|       </.link> | ||||
|     <% end %> | ||||
|     <%= link(dgettext("actions", "Log in"), | ||||
|       to: Routes.user_session_path(@conn, :new), | ||||
|       class: "btn btn-primary" | ||||
|     ) %> | ||||
|     <.link href={Routes.user_session_path(@conn, :new)} class="btn btn-primary"> | ||||
|       <%= dgettext("actions", "Log in") %> | ||||
|     </.link> | ||||
|   </div> | ||||
| </div> | ||||
|   | ||||
| @@ -4,7 +4,7 @@ | ||||
|   </h1> | ||||
|  | ||||
|   <.form | ||||
|     let={f} | ||||
|     :let={f} | ||||
|     for={:user} | ||||
|     action={Routes.user_reset_password_path(@conn, :create)} | ||||
|     class="flex flex-col space-y-4 sm:space-y-0 sm:grid sm:grid-cols-3 sm:gap-4 justify-center items-center" | ||||
| @@ -21,14 +21,12 @@ | ||||
|  | ||||
|   <div class="flex flex-row justify-center items-center space-x-4"> | ||||
|     <%= if Accounts.allow_registration?() do %> | ||||
|       <%= link(dgettext("actions", "Register"), | ||||
|         to: Routes.user_registration_path(@conn, :new), | ||||
|         class: "btn btn-primary" | ||||
|       ) %> | ||||
|       <.link href={Routes.user_registration_path(@conn, :new)} class="btn btn-primary"> | ||||
|         <%= dgettext("actions", "Register") %> | ||||
|       </.link> | ||||
|     <% end %> | ||||
|     <%= link(dgettext("actions", "Log in"), | ||||
|       to: Routes.user_session_path(@conn, :new), | ||||
|       class: "btn btn-primary" | ||||
|     ) %> | ||||
|     <.link href={Routes.user_session_path(@conn, :new)} class="btn btn-primary"> | ||||
|       <%= dgettext("actions", "Log in") %> | ||||
|     </.link> | ||||
|   </div> | ||||
| </div> | ||||
|   | ||||
| @@ -4,7 +4,7 @@ | ||||
|   </h1> | ||||
|  | ||||
|   <.form | ||||
|     let={f} | ||||
|     :let={f} | ||||
|     for={@conn} | ||||
|     action={Routes.user_session_path(@conn, :create)} | ||||
|     as="user" | ||||
| @@ -36,14 +36,12 @@ | ||||
|  | ||||
|   <div class="flex flex-row justify-center items-center space-x-4"> | ||||
|     <%= if Accounts.allow_registration?() do %> | ||||
|       <%= link(dgettext("actions", "Register"), | ||||
|         to: Routes.user_registration_path(@conn, :new), | ||||
|         class: "btn btn-primary" | ||||
|       ) %> | ||||
|       <.link href={Routes.user_registration_path(@conn, :new)} class="btn btn-primary"> | ||||
|         <%= dgettext("actions", "Register") %> | ||||
|       </.link> | ||||
|     <% end %> | ||||
|     <%= link(dgettext("actions", "Forgot your password?"), | ||||
|       to: Routes.user_reset_password_path(@conn, :new), | ||||
|       class: "btn btn-primary" | ||||
|     ) %> | ||||
|     <.link href={Routes.user_reset_password_path(@conn, :new)} class="btn btn-primary"> | ||||
|       <%= dgettext("actions", "Forgot your password?") %> | ||||
|     </.link> | ||||
|   </div> | ||||
| </div> | ||||
|   | ||||
| @@ -6,7 +6,7 @@ | ||||
|   <hr class="hr" /> | ||||
|  | ||||
|   <.form | ||||
|     let={f} | ||||
|     :let={f} | ||||
|     for={@email_changeset} | ||||
|     action={Routes.user_settings_path(@conn, :update)} | ||||
|     class="flex flex-col space-y-4 sm:space-y-0 sm:grid sm:grid-cols-3 sm:gap-4 justify-center items-center" | ||||
| @@ -49,7 +49,7 @@ | ||||
|   <hr class="hr" /> | ||||
|  | ||||
|   <.form | ||||
|     let={f} | ||||
|     :let={f} | ||||
|     for={@password_changeset} | ||||
|     action={Routes.user_settings_path(@conn, :update)} | ||||
|     class="flex flex-col space-y-4 sm:space-y-0 sm:grid sm:grid-cols-3 sm:gap-4 justify-center items-center" | ||||
| @@ -104,7 +104,7 @@ | ||||
|   <hr class="hr" /> | ||||
|  | ||||
|   <.form | ||||
|     let={f} | ||||
|     :let={f} | ||||
|     for={@locale_changeset} | ||||
|     action={Routes.user_settings_path(@conn, :update)} | ||||
|     class="flex flex-col space-y-4 justify-center items-center" | ||||
| @@ -136,10 +136,12 @@ | ||||
|  | ||||
|   <hr class="hr" /> | ||||
|  | ||||
|   <%= link(dgettext("actions", "Delete User"), | ||||
|     to: Routes.user_settings_path(@conn, :delete, @current_user), | ||||
|     method: :delete, | ||||
|     class: "btn btn-alert", | ||||
|     data: [confirm: dgettext("prompts", "Are you sure you want to delete your account?")] | ||||
|   ) %> | ||||
|   <.link | ||||
|     href={Routes.user_settings_path(@conn, :delete, @current_user)} | ||||
|     method={:delete} | ||||
|     class="btn btn-alert" | ||||
|     data-confirm={dgettext("prompts", "Are you sure you want to delete your account?")} | ||||
|   > | ||||
|     <%= dgettext("actions", "Delete User") %> | ||||
|   </.link> | ||||
| </div> | ||||
|   | ||||
| @@ -4,7 +4,7 @@ defmodule MemexWeb.ErrorHelpers do | ||||
|   """ | ||||
|  | ||||
|   use Phoenix.HTML | ||||
|   import Phoenix.LiveView.Helpers | ||||
|   import Phoenix.Component | ||||
|   alias Ecto.Changeset | ||||
|   alias Phoenix.{HTML.Form, LiveView.Rendered} | ||||
|  | ||||
|   | ||||
| @@ -5,7 +5,7 @@ defmodule MemexWeb.ViewHelpers do | ||||
|   :view` | ||||
|   """ | ||||
|  | ||||
|   import Phoenix.LiveView.Helpers | ||||
|   import Phoenix.Component | ||||
|  | ||||
|   @doc """ | ||||
|   Returns a <time> element that renders the naivedatetime in the user's local | ||||
| @@ -20,11 +20,15 @@ defmodule MemexWeb.ViewHelpers do | ||||
|     } | ||||
|  | ||||
|     ~H""" | ||||
|     <time datetime={@datetime} x-data={"{ | ||||
|     <time | ||||
|       datetime={@datetime} | ||||
|       x-data={"{ | ||||
|         date: | ||||
|           Intl.DateTimeFormat([], {dateStyle: 'short', timeStyle: 'long'}) | ||||
|             .format(new Date(\"#{@datetime}\")) | ||||
|       }"} x-text="date"> | ||||
|       }"} | ||||
|       x-text="date" | ||||
|     > | ||||
|       <%= @datetime %> | ||||
|     </time> | ||||
|     """ | ||||
| @@ -41,10 +45,14 @@ defmodule MemexWeb.ViewHelpers do | ||||
|     assigns = %{date: date |> Date.to_iso8601(:extended)} | ||||
|  | ||||
|     ~H""" | ||||
|     <time datetime={@date} x-data={"{ | ||||
|     <time | ||||
|       datetime={@date} | ||||
|       x-data={"{ | ||||
|         date: | ||||
|           Intl.DateTimeFormat([], {timeZone: 'Etc/UTC', dateStyle: 'short'}).format(new Date(\"#{@date}\")) | ||||
|       }"} x-text="date"> | ||||
|       }"} | ||||
|       x-text="date" | ||||
|     > | ||||
|       <%= @date %> | ||||
|     </time> | ||||
|     """ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user