fix: fix tenant/actor session w/ new phx version

This commit is contained in:
Zach Daniel 2022-03-17 10:38:41 -04:00
parent d9fca6a5ba
commit ef0e947cd6
6 changed files with 27 additions and 7 deletions

View file

@ -96,6 +96,7 @@ Hooks.Actor = {
document.cookie = 'actor_paused=true;path=/';
});
this.handleEvent("toggle_authorizing", (payload) => {
console.log(payload);
document.cookie = 'actor_authorizing' + '=' + payload.authorizing + ';path=/';
});
this.handleEvent("toggle_actor_paused", (payload) => {

View file

@ -279,6 +279,7 @@ defmodule AshAdmin.Components.Resource.DataTable do
<div class="flex-1 flex justify-between sm:hidden">
<button
:if={!(keyset?(@data) && is_nil(@params["page"])) && prev_page?(@data)}
phx-target={@myself}
:on-click="prev_page"
class="relative inline-flex items-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-md text-gray-700 bg-white hover:text-gray-500"
>
@ -288,6 +289,7 @@ defmodule AshAdmin.Components.Resource.DataTable do
<button
:if={next_page?(@data)}
:on-click="next_page"
phx-target={@myself}
class="ml-3 relative inline-flex items-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-md text-gray-700 bg-white hover:text-gray-500"
>
Next
@ -302,6 +304,7 @@ defmodule AshAdmin.Components.Resource.DataTable do
<button
:if={!(keyset?(@data) && is_nil(@params["page"])) && prev_page?(@data)}
:on-click="prev_page"
phx-target={@myself}
class="relative inline-flex items-center px-2 py-2 rounded-l-md border border-gray-300 bg-white text-sm font-medium text-gray-500 hover:bg-gray-50"
>
<span class="sr-only">Previous</span>
@ -328,6 +331,7 @@ defmodule AshAdmin.Components.Resource.DataTable do
<button
:if={next_page?(@data)}
:on-click="next_page"
phx-target={@myself}
class="relative inline-flex items-center px-2 py-2 rounded-r-md border border-gray-300 bg-white text-sm font-medium text-gray-500 hover:bg-gray-50"
>
<span class="sr-only">Next</span>
@ -358,6 +362,7 @@ defmodule AshAdmin.Components.Resource.DataTable do
~F"""
<button
:on-click="specific_page"
phx-target={@myself}
phx-value-page={i}
:for={i <- page_nums}
class={

View file

@ -300,6 +300,7 @@ defmodule AshAdmin.Components.Resource.Form do
<button
type="button"
:on-click="remove_form"
phx-target={@myself}
:if={can_remove_related?(inner_form, opts)}
phx-value-path={inner_form.name}
class="flex h-6 w-6 mt-2 border-gray-600 hover:bg-gray-400 rounded-md justify-center items-center"
@ -311,6 +312,7 @@ defmodule AshAdmin.Components.Resource.Form do
<button
type="button"
:on-click="add_form"
phx-target={@myself}
:if={can_add_related?(form, :read_action, argument)}
phx-value-path={form.name <> "[#{argument.name}]"}
phx-value-type={"lookup"}
@ -322,6 +324,7 @@ defmodule AshAdmin.Components.Resource.Form do
<button
type="button"
:on-click="add_form"
phx-target={@myself}
:if={can_add_related?(form, :create_action, argument)}
phx-value-path={form.name <> "[#{argument.name}]"}
phx-value-type={"create"}
@ -332,6 +335,7 @@ defmodule AshAdmin.Components.Resource.Form do
<button
type="button"
:on-click="add_form"
phx-target={@myself}
:if={form.source.form_keys[argument.name][:read_form] && !relationship_set?(form.source.source, relationship.name, argument.name)}
phx-value-path={form.name <> "[#{argument.name}]"}
phx-value-type={"lookup"}
@ -343,6 +347,7 @@ defmodule AshAdmin.Components.Resource.Form do
<div :if={needs_to_load?(opts) && !loaded?(form.source.source, relationship.name)}>
<button
:on-click="load"
phx-target={@myself}
phx-value-path={form.name}
phx-value-relationship={relationship.name}
type="button"
@ -630,6 +635,7 @@ defmodule AshAdmin.Components.Resource.Form do
<button
type="button"
:on-click="remove_form"
phx-target={@myself}
phx-value-path={inner_form.name}
class="flex h-6 w-6 mt-2 border-gray-600 hover:bg-gray-400 rounded-md justify-center items-center"
>
@ -641,6 +647,7 @@ defmodule AshAdmin.Components.Resource.Form do
<button
type="button"
:on-click="add_form"
phx-target={@myself}
:if={can_append_embed?(form.source.source, attribute.name)}
phx-value-pkey={embedded_type_pkey(attribute.type)}
phx-value-path={name || form.name <> "[#{attribute.name}]"}
@ -676,6 +683,7 @@ defmodule AshAdmin.Components.Resource.Form do
<button
type="button"
:on-click="remove_value"
phx-target={@myself}
phx-value-path={form.name}
phx-value-field={attribute.name}
phx-value-index={index}
@ -687,6 +695,7 @@ defmodule AshAdmin.Components.Resource.Form do
<button
type="button"
:on-click="append_value"
phx-target={@myself}
phx-value-path={form.name}
phx-value-field={attribute.name}
class="flex h-6 w-6 mt-2 border-gray-600 hover:bg-gray-400 rounded-md justify-center items-center"
@ -1283,6 +1292,10 @@ defmodule AshAdmin.Components.Resource.Form do
end
def attributes(resource, action, _) do
arguments =
action.arguments
|> Enum.reject(& &1.private?)
attributes =
resource
|> Ash.Resource.Info.attributes()
@ -1290,10 +1303,9 @@ defmodule AshAdmin.Components.Resource.Form do
|> Enum.reject(& &1.private?)
|> Enum.reject(&(&1.name == :autogenerated_id))
|> only_accepted(action)
arguments =
action.arguments
|> Enum.reject(& &1.private?)
|> Enum.reject(fn attribute ->
Enum.any?(arguments, &(&1.name == attribute.name))
end)
attributes
|> Enum.concat(arguments)

View file

@ -89,6 +89,7 @@ defmodule AshAdmin.Components.Resource.Show do
<button
:if={!loaded?(@record, relationship.name)}
:on-click="load"
phx-target={@myself}
phx-value-relationship={relationship.name}
type="button"
class="flex py-2 ml-4 px-4 mt-2 bg-indigo-600 text-white border-gray-600 hover:bg-gray-400 rounded-md justify-center items-center"
@ -98,6 +99,7 @@ defmodule AshAdmin.Components.Resource.Show do
<button
:if={loaded?(@record, relationship.name) && relationship.cardinality == :many}
:on-click="unload"
phx-target={@myself}
phx-value-relationship={relationship.name}
type="button"
class="flex py-2 ml-4 px-4 mt-2 bg-indigo-600 text-white border-gray-600 hover:bg-gray-400 rounded-md justify-center items-center"

View file

@ -10,7 +10,7 @@ defmodule AshAdmin.Components.TopNav.TenantForm do
def render(assigns) do
~F"""
<div id="tenant-hook" class="relative text-white" phx-hook="Tenant" >
<div id="tenant-hook" class="relative text-white" phx-hook="Tenant" phx-target={@myself}>
<form :if={@editing_tenant} :on-submit={@set_tenant}>
<input type="text" name="tenant" value={@tenant} class={"text-black": @editing_tenant}>
<button :on-click="stop_editing_tenant">
@ -34,7 +34,7 @@ defmodule AshAdmin.Components.TopNav.TenantForm do
/>
</svg>
</button>
<a :if={!@editing_tenant} href="#" :on-click="start_editing_tenant">
<a :if={!@editing_tenant} href="#" :on-click="start_editing_tenant" phx-target={@myself}>
{@tenant || "No tenant"}
</a>
</div>

File diff suppressed because one or more lines are too long