fix(ACL): Fix allowing to save map/access list with empty owner set

This commit is contained in:
Dmitry Popov
2024-10-02 16:47:29 +04:00
parent 240b180857
commit d9bed070ec
8 changed files with 53 additions and 165 deletions
+13 -81
View File
@@ -4,60 +4,37 @@
## [v1.0.22](https://github.com/wanderer-industries/wanderer/compare/v1.0.21...v1.0.22) (2024-09-25)
### Bug Fixes:
### Bug Fixes
* Map: Main map doesn't load back after refreshing/switching pages
## [v1.0.21](https://github.com/wanderer-industries/wanderer/compare/v1.0.20...v1.0.21) (2024-09-24)
### Bug Fixes:
### Bug Fixes
* Map: Main map doesn't load back after refreshing/switching pages
## [v1.0.20](https://github.com/wanderer-industries/wanderer/compare/v1.0.19...v1.0.20) (2024-09-23)
### Bug Fixes:
### Bug Fixes
* core: Small fixes & improvements
## [v1.0.19](https://github.com/wanderer-industries/wanderer/compare/v1.0.18...v1.0.19) (2024-09-23)
### Bug Fixes:
### Bug Fixes
* ACL: Fix adding empty members list
## [v1.0.18](https://github.com/wanderer-industries/wanderer/compare/v1.0.17...v1.0.18) (2024-09-22)
### Bug Fixes:
### Bug Fixes
* ACL: Cant delete ACL list after map deletion #5
## [v1.0.17](https://github.com/wanderer-industries/wanderer/compare/v1.0.16...v1.0.17) (2024-09-21)
## [v1.0.16](https://github.com/wanderer-industries/wanderer/compare/v1.0.15...v1.0.16) (2024-09-21)
### Bug Fixes:
### Bug Fixes
* Map: commented console log
@@ -67,103 +44,58 @@
## [v1.0.15](https://github.com/wanderer-industries/wanderer/compare/v1.0.14...v1.0.15) (2024-09-21)
### Bug Fixes:
### Bug Fixes
* map: Show a proper user notification if map was deleted/archived
## [v1.0.14](https://github.com/wanderer-industries/wanderer/compare/v1.0.13...v1.0.14) (2024-09-21)
## [v1.0.13](https://github.com/wanderer-industries/wanderer/compare/v1.0.12...v1.0.13) (2024-09-21)
### Bug Fixes:
### Bug Fixes
* tracking: Ensure user has at least one character tracked to work with map
## [v1.0.12](https://github.com/wanderer-industries/wanderer/compare/v1.0.11...v1.0.12) (2024-09-20)
### Bug Fixes:
### Bug Fixes
* audit: Hide character for non-character map activities
## [v1.0.11](https://github.com/wanderer-industries/wanderer/compare/v1.0.10...v1.0.11) (2024-09-20)
## [v1.0.10](https://github.com/wanderer-industries/wanderer/compare/v1.0.9...v1.0.10) (2024-09-19)
### Bug Fixes:
### Bug Fixes
* signatures: Fix update signatures error if no character tracked on map
## [v1.0.9](https://github.com/wanderer-industries/wanderer/compare/v1.0.8...v1.0.9) (2024-09-19)
### Bug Fixes:
### Bug Fixes
* core: Fix system add error if it's already added on map
## [v1.0.8](https://github.com/wanderer-industries/wanderer/compare/v1.0.7...v1.0.8) (2024-09-19)
### Bug Fixes:
### Bug Fixes
* docker: Fix DB connection in docker-compose internal network
## [v1.0.7](https://github.com/wanderer-industries/wanderer/compare/v1.0.6...v1.0.7) (2024-09-19)
## [v1.0.6](https://github.com/wanderer-industries/wanderer/compare/v1.0.5...v1.0.6) (2024-09-18)
## [v1.0.5](https://github.com/wanderer-industries/wanderer/compare/v1.0.4...v1.0.5) (2024-09-18)
## [v1.0.4](https://github.com/wanderer-industries/wanderer/compare/v1.0.3...v1.0.4) (2024-09-18)
### Bug Fixes:
### Bug Fixes
* core: skip search results for failed character info request
## [v1.0.3](https://github.com/wanderer-industries/wanderer/compare/v1.0.2...v1.0.3) (2024-09-18)
## [v1.0.2](https://github.com/wanderer-industries/wanderer/compare/v1.0.1...v1.0.2) (2024-09-18)
## [v1.0.1](https://github.com/wanderer-industries/wanderer/compare/v1.0.0...v1.0.1) (2024-09-18)
-3
View File
@@ -43,7 +43,6 @@ defmodule WandererApp.Api.AccessList do
primary?(true)
argument :owner_id, :uuid, allow_nil?: false
argument :owner_id_text_input, :string, allow_nil?: true
change manage_relationship(:owner_id, :owner, on_lookup: :relate, on_no_match: nil)
end
@@ -51,8 +50,6 @@ defmodule WandererApp.Api.AccessList do
update :update do
accept [:name, :description, :owner_id]
primary?(true)
argument :owner_id_text_input, :string, allow_nil?: true
end
update :assign_owner do
-1
View File
@@ -63,7 +63,6 @@ defmodule WandererApp.Api.Map do
primary?(true)
argument :owner_id, :uuid, allow_nil?: false
argument :owner_id_text_input, :string, allow_nil?: true
argument :create_default_acl, :boolean, allow_nil?: true
argument :acls, {:array, :uuid}, allow_nil?: true
argument :acls_text_input, :string, allow_nil?: true
@@ -602,11 +602,11 @@ defmodule WandererAppWeb.CoreComponents do
<tr
:for={row <- @rows}
id={@row_id && @row_id.(row)}
phx-click={@row_click && @row_click.(row)}
class={"hover #{if @row_selected && @row_selected.(row), do: "!bg-slate-600", else: ""} #{if @row_click, do: "cursor-pointer", else: ""}"}
>
<td
:for={{col, _index} <- Enum.with_index(@col)}
phx-click={@row_click && @row_click.(row)}
>
<%= render_slot(col, @row_item.(row)) %>
</td>
@@ -99,40 +99,34 @@ defmodule WandererAppWeb.AccessListsLive do
end
defp apply_action(socket, :add_members, %{"id" => acl_id} = _params) do
{:ok, %{owner: %{id: _character_id}} = access_list} =
socket.assigns.access_lists |> Enum.find(&(&1.id == acl_id)) |> Ash.load(:owner)
with {:ok, %{owner: %{id: _character_id}} = access_list} <- socket.assigns.access_lists |> Enum.find(&(&1.id == acl_id)) |> Ash.load(:owner),
user_character_ids <- socket.assigns.current_user.characters |> Enum.map(& &1.id) do
user_character_ids
|> Enum.each(fn user_character_id ->
:ok = WandererApp.Character.TrackerManager.start_tracking(user_character_id)
end)
user_character_ids = socket.assigns.current_user.characters |> Enum.map(& &1.id)
user_character_ids
|> Enum.each(fn user_character_id ->
:ok = WandererApp.Character.TrackerManager.start_tracking(user_character_id)
end)
socket
|> assign(:active_page, :access_lists)
|> assign(:page_title, "Access Lists - Add Members")
|> assign(:selected_acl_id, acl_id)
|> assign(:user_character_ids, user_character_ids)
|> assign(
member_search_options: socket.assigns.characters |> Enum.map(&map_user_character_info/1)
)
|> assign(:access_list, access_list)
|> assign(
:members,
WandererApp.Api.AccessListMember.read_by_access_list!(%{access_list_id: acl_id})
)
|> assign(
:member_form,
%{} |> to_form()
)
end
@impl true
def handle_event("set-default", %{"id" => id}, socket) do
send_update(LiveSelect.Component, options: socket.assigns.characters, id: id)
{:noreply, socket}
socket
|> assign(:active_page, :access_lists)
|> assign(:page_title, "Access Lists - Add Members")
|> assign(:selected_acl_id, acl_id)
|> assign(:user_character_ids, user_character_ids)
|> assign(
member_search_options: socket.assigns.characters |> Enum.map(&map_user_character_info/1)
)
|> assign(:access_list, access_list)
|> assign(
:members,
WandererApp.Api.AccessListMember.read_by_access_list!(%{access_list_id: acl_id})
)
|> assign(
:member_form,
%{} |> to_form()
)
else
_ ->
socket
end
end
@impl true
@@ -127,23 +127,13 @@
<.form :let={f} for={@form} phx-change="validate" phx-submit={@live_action}>
<.input type="text" field={f[:name]} placeholder="Name" />
<.input type="textarea" field={f[:description]} placeholder="Public description" />
<.live_select
<.input
type="select"
field={f[:owner_id]}
dropdown_extra_class="max-h-64"
available_option_class="w-full"
value_mapper={&map_character/1}
update_min_len={0}
phx-focus="set-default"
options={@characters}
placeholder="Owner"
>
<:option :let={option}>
<div class="flex items-center">
<.avatar url={member_icon_url(option.eve_id)} label={option.label} />
&nbsp;<%= option.label %>
</div>
</:option>
</.live_select>
class="p-dropdown p-component p-inputwrapper mt-8"
placeholder="Select a map owner"
options={Enum.map(@characters, fn character -> {character.label, character.id} end)}
/>
<div class="modal-action">
<.button class="mt-2" type="submit" phx-disable-with="Saving...">
<%= (@live_action == :create && "Create") || "Save" %>
@@ -167,24 +167,6 @@ defmodule WandererAppWeb.MapsLive do
{:noreply, socket}
end
@impl true
def handle_event(
"live_select_change",
%{"id" => "form_owner_id_live_select_component" = id, "text" => text} = _change_event,
socket
) do
options =
if text == "" do
socket.assigns.characters
else
socket.assigns.characters
end
send_update(LiveSelect.Component, options: options, id: id)
{:noreply, socket}
end
@impl true
def handle_event(
"live_select_change",
@@ -137,23 +137,17 @@
<.input type="text" field={f[:name]} placeholder="Name" />
<.input type="text" field={f[:slug]} prefix={@uri} placeholder="map-slug" />
<.input type="textarea" field={f[:description]} placeholder="Public description" />
<.live_select
<.input
type="select"
field={f[:owner_id]}
value_mapper={&map_character/1}
options={@characters}
class="p-dropdown p-component p-inputwrapper mt-8"
placeholder="Select a map owner"
>
<:option :let={option}>
<div class="flex items-center">
<.avatar url={member_icon_url(option.eve_id)} label={option.label} />
&nbsp;<%= option.label %>
</div>
</:option>
</.live_select>
options={Enum.map(@characters, fn character -> {character.label, character.id} end)}
/>
<.input
type="select"
field={f[:scope]}
class="p-dropdown p-component p-inputwrapper"
class="p-dropdown p-component p-inputwrapper mt-8"
placeholder="Select a map scope"
options={Enum.map(@scopes, fn scope -> {scope, scope} end)}
/>