From d9bed070ec2fc3e28efc64595009e36eb204c2bd Mon Sep 17 00:00:00 2001 From: Dmitry Popov Date: Wed, 2 Oct 2024 16:47:29 +0400 Subject: [PATCH] fix(ACL): Fix allowing to save map/access list with empty owner set --- CHANGELOG.md | 94 +++---------------- lib/wanderer_app/api/access_list.ex | 3 - lib/wanderer_app/api/map.ex | 1 - .../components/core_components.ex | 2 +- .../live/access_lists/access_lists_live.ex | 60 ++++++------ .../access_lists/access_lists_live.html.heex | 22 ++--- lib/wanderer_app_web/live/maps/maps_live.ex | 18 ---- .../live/maps/maps_live.html.heex | 18 ++-- 8 files changed, 53 insertions(+), 165 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff635c0b..822c1121 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) - - - diff --git a/lib/wanderer_app/api/access_list.ex b/lib/wanderer_app/api/access_list.ex index b5ba3be0..588f2b15 100644 --- a/lib/wanderer_app/api/access_list.ex +++ b/lib/wanderer_app/api/access_list.ex @@ -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 diff --git a/lib/wanderer_app/api/map.ex b/lib/wanderer_app/api/map.ex index 6833c244..4ff84ac3 100644 --- a/lib/wanderer_app/api/map.ex +++ b/lib/wanderer_app/api/map.ex @@ -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 diff --git a/lib/wanderer_app_web/components/core_components.ex b/lib/wanderer_app_web/components/core_components.ex index 9eedf6cb..8a08131c 100644 --- a/lib/wanderer_app_web/components/core_components.ex +++ b/lib/wanderer_app_web/components/core_components.ex @@ -602,11 +602,11 @@ defmodule WandererAppWeb.CoreComponents do <%= render_slot(col, @row_item.(row)) %> diff --git a/lib/wanderer_app_web/live/access_lists/access_lists_live.ex b/lib/wanderer_app_web/live/access_lists/access_lists_live.ex index 9e42f010..4b019390 100755 --- a/lib/wanderer_app_web/live/access_lists/access_lists_live.ex +++ b/lib/wanderer_app_web/live/access_lists/access_lists_live.ex @@ -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 diff --git a/lib/wanderer_app_web/live/access_lists/access_lists_live.html.heex b/lib/wanderer_app_web/live/access_lists/access_lists_live.html.heex index 1f202c74..70a8d314 100644 --- a/lib/wanderer_app_web/live/access_lists/access_lists_live.html.heex +++ b/lib/wanderer_app_web/live/access_lists/access_lists_live.html.heex @@ -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}> -
- <.avatar url={member_icon_url(option.eve_id)} label={option.label} /> -  <%= option.label %> -
- - + 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)} + />