fix(portal): Use href when navigating out of liveview (#8363)

Not a major issue, but LiveView emits a warning for these that cause
monitoring noise.
This commit is contained in:
Jamil
2025-03-05 02:34:32 +00:00
committed by GitHub
parent c3a9bac465
commit 383a67ef09
6 changed files with 23 additions and 11 deletions

View File

@@ -475,7 +475,7 @@ defmodule Web.FormComponents do
@doc """
Base button type to be used directly or by the specialized button types above. e.g. edit_button, delete_button, etc.
If a navigate path is provided, an <a> tag will be used, otherwise a <button> tag will be used.
If a navigate, href, or patch path is provided, an <a> tag will be used, otherwise a <button> tag will be used.
## Examples
@@ -493,6 +493,13 @@ defmodule Web.FormComponents do
otherwise a <button> tag will be used
"""
attr :href, :string,
required: false,
doc: """
The path to redirect to using a full page reload, when set an <a> tag will be used,
otherwise a <button> tag will be used
"""
attr :class, :string, default: "", doc: "Custom classes to be added to the button"
attr :style, :string, default: nil, doc: "The style of the button"
attr :type, :string, default: nil, doc: "The button type"
@@ -503,9 +510,18 @@ defmodule Web.FormComponents do
required: false,
doc: "The icon to be displayed on the button"
attr :rest, :global, include: ~w(disabled form name value navigate)
attr :rest, :global, include: ~w(disabled form name value navigate href)
slot :inner_block, required: true, doc: "The label for the button"
def button(%{href: _} = assigns) do
~H"""
<.link class={button_style(@style) ++ button_size(@size) ++ [@class]} href={@href} {@rest}>
<.icon :if={@icon} name={@icon} class="h-3.5 w-3.5 mr-2" />
{render_slot(@inner_block)}
</.link>
"""
end
def button(%{navigate: _} = assigns) do
~H"""
<.link class={button_style(@style) ++ button_size(@size) ++ [@class]} navigate={@navigate} {@rest}>

View File

@@ -100,7 +100,7 @@ defmodule Web.Settings.IdentityProviders.GoogleWorkspace.Show do
<:action :if={is_nil(@provider.deleted_at)}>
<.button
style="primary"
navigate={
href={
~p"/#{@account.id}/settings/identity_providers/google_workspace/#{@provider}/redirect"
}
icon="hero-arrow-path"

View File

@@ -102,7 +102,7 @@ defmodule Web.Settings.IdentityProviders.JumpCloud.Show do
<:action :if={is_nil(@provider.deleted_at)}>
<.button
style="primary"
navigate={~p"/#{@account.id}/settings/identity_providers/jumpcloud/#{@provider}/redirect"}
href={~p"/#{@account.id}/settings/identity_providers/jumpcloud/#{@provider}/redirect"}
icon="hero-arrow-path"
>
Reconnect

View File

@@ -100,9 +100,7 @@ defmodule Web.Settings.IdentityProviders.MicrosoftEntra.Show do
<:action :if={is_nil(@provider.deleted_at)}>
<.button
style="primary"
navigate={
~p"/#{@account.id}/settings/identity_providers/microsoft_entra/#{@provider}/redirect"
}
href={~p"/#{@account.id}/settings/identity_providers/microsoft_entra/#{@provider}/redirect"}
icon="hero-arrow-path"
>
Reconnect

View File

@@ -100,7 +100,7 @@ defmodule Web.Settings.IdentityProviders.Okta.Show do
<:action :if={is_nil(@provider.deleted_at)}>
<.button
style="primary"
navigate={~p"/#{@account.id}/settings/identity_providers/okta/#{@provider}/redirect"}
href={~p"/#{@account.id}/settings/identity_providers/okta/#{@provider}/redirect"}
icon="hero-arrow-path"
>
Reconnect

View File

@@ -93,9 +93,7 @@ defmodule Web.Settings.IdentityProviders.OpenIDConnect.Show do
<:action :if={is_nil(@provider.deleted_at)}>
<.button
style="primary"
navigate={
~p"/#{@account.id}/settings/identity_providers/openid_connect/#{@provider}/redirect"
}
href={~p"/#{@account.id}/settings/identity_providers/openid_connect/#{@provider}/redirect"}
icon="hero-arrow-path"
>
Reconnect