Skip to content

Commit

Permalink
fix(portal): don't confirm group selections if there aren't changes (#…
Browse files Browse the repository at this point in the history
…4946)

- Fixes #4937 (not worth adding complexity to the live table for this,
so just added as a note in the bottom)
- Don't show confirmation dialog if no changes have been made

<img width="912" alt="Screenshot 2024-05-09 at 11 03 00 PM"
src="https://github.com/firezone/firezone/assets/167144/47f1a76c-5f2a-4815-b0ff-7f1e68c785bf">
  • Loading branch information
jamilbk committed May 10, 2024
1 parent 8b3df2d commit e03340b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
12 changes: 10 additions & 2 deletions elixir/apps/web/lib/web/live/actors/groups.ex
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,10 @@ defmodule Web.Actors.EditGroups do
</div>
</:col>
</.live_table>
<div class="flex justify-end">
<div class="flex justify-between items-center">
<p class="px-4 text-sm text-gray-500">
Note: Users will always belong to the <strong>Everyone</strong> group.
</p>
<.button class="m-4" data-confirm={confirm_message(@added, @removed)} phx-click="submit">
Save
</.button>
Expand Down Expand Up @@ -222,7 +225,12 @@ defmodule Web.Actors.EditGroups do
remove = if removed_names != [], do: "remove #{Enum.join(removed_names, ", ")}"
change = [add, remove] |> Enum.reject(&is_nil/1) |> Enum.join(" and ")

"Are you sure you want to #{change}?"
if change == "" do
# Don't show confirmation message if no changes were made
nil
else
"Are you sure you want to #{change}?"
end
end

defp remove_non_editable_memberships(memberships, editable_groups) do
Expand Down
7 changes: 6 additions & 1 deletion elixir/apps/web/lib/web/live/groups/edit_actors.ex
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,11 @@ defmodule Web.Groups.EditActors do
remove = if removed_names != [], do: "remove #{Enum.join(removed_names, ", ")}"
change = [add, remove] |> Enum.reject(&is_nil/1) |> Enum.join(" and ")

"Are you sure you want to #{change}?"
if change == "" do
# Don't show confirmation message if no changes were made
nil
else
"Are you sure you want to #{change}?"
end
end
end

0 comments on commit e03340b

Please sign in to comment.