diff --git a/lib/plausible_web/components/generic.ex b/lib/plausible_web/components/generic.ex index 003e04dbc..02d192d1f 100644 --- a/lib/plausible_web/components/generic.ex +++ b/lib/plausible_web/components/generic.ex @@ -2,7 +2,7 @@ defmodule PlausibleWeb.Components.Generic do @moduledoc """ Generic reusable components """ - use Phoenix.Component + use Phoenix.Component, global_prefixes: ~w(x-) @notice_themes %{ yellow: %{ @@ -269,6 +269,28 @@ defmodule PlausibleWeb.Components.Generic do """ end + attr :class, :any, default: "" + + def spinner(assigns) do + ~H""" + + + + + + + """ + end + defp icon_class(link_assigns) do if String.contains?(link_assigns[:class], "text-sm") do ["w-3 h-3"] diff --git a/lib/plausible_web/components/two_factor.ex b/lib/plausible_web/components/two_factor.ex index 862fa9443..2657f3f6b 100644 --- a/lib/plausible_web/components/two_factor.ex +++ b/lib/plausible_web/components/two_factor.ex @@ -34,10 +34,10 @@ defmodule PlausibleWeb.Components.TwoFactor do attr :form_target, :string, required: true attr :onsubmit, :string, default: "" attr :title, :string, required: true - attr :submit_label, :string, default: "Submit" slot :icon, required: true slot :inner_block, required: true + slot :buttons, required: true def modal(assigns) do ~H""" @@ -96,11 +96,8 @@ defmodule PlausibleWeb.Components.TwoFactor do
<%= render_slot(@icon) %>
-
-
- + <%= render_slot(@buttons) %> +
Once disabled, verification codes from the authenticator application and current recovery codes will become invalid. 2FA will have to be setup from the start. @@ -468,14 +475,35 @@ state_param="regenerate2FAOpen" form_data={@conn.params} form_target={Routes.auth_path(@conn, :generate_2fa_recovery_codes)} - onsubmit="var button = document.querySelector('#regenerate-2fa-modal button[type=submit]'); button.disabled = true; button.classList.add('animate-pulse')" + onsubmit="var group = document.querySelector('#buttons'); group.classList.add('submitting');" title="Generate New Recovery Codes?" - submit_label="Generate New Codes" > <:icon> + <:buttons> +
+ <.button + type="submit" + x-on:click="submitted = true" + class="w-52 group-[.submitting]:bg-gray-400 dark:group-[.submitting]:bg-gray-800" + > + + Generate New Codes + + + + +
+ +
If you generate new codes, the old ones will become invalid.
diff --git a/lib/plausible_web/templates/auth/verify_2fa_recovery_code.html.heex b/lib/plausible_web/templates/auth/verify_2fa_recovery_code.html.heex index f8863fd9f..026342f18 100644 --- a/lib/plausible_web/templates/auth/verify_2fa_recovery_code.html.heex +++ b/lib/plausible_web/templates/auth/verify_2fa_recovery_code.html.heex @@ -17,7 +17,7 @@ value: "", autocomplete: "off", class: - "font-medium shadow-sm focus:ring-indigo-500 focus:border-indigo-500 block w-full px-8 border-gray-300 dark:border-gray-500 dark:text-gray-200 dark:bg-gray-900 rounded-md", + "font-medium shadow-sm focus:ring-indigo-500 focus:border-indigo-500 block w-full px-2 border-gray-300 dark:border-gray-500 dark:text-gray-200 dark:bg-gray-900 rounded-md", maxlength: "10", placeholder: "Enter recovery code", required: "required"