Skip to content

Commit

Permalink
Replace actors type filter with actors status one
Browse files Browse the repository at this point in the history
I feels more useful while it doesn't suffer from issues like leaking "API Client" actor types
  • Loading branch information
AndrewDryga committed Mar 26, 2024
1 parent 1f11064 commit 78cd706
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
18 changes: 18 additions & 0 deletions elixir/apps/domain/lib/domain/actors/actor/query.ex
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,16 @@ defmodule Domain.Actors.Actor.Query do
values: &Domain.Auth.all_providers!/1,
fun: &filter_by_identity_provider_id/2
},
%Domain.Repo.Filter{
name: :status,
title: "Status",
type: :string,
values: [
{"Enabled", "enabled"},
{"Disabled", "disabled"}
],
fun: &filter_by_status/2
},
%Domain.Repo.Filter{
name: :type,
title: "Type",
Expand Down Expand Up @@ -189,6 +199,14 @@ defmodule Domain.Actors.Actor.Query do
}
]

def filter_by_status(queryable, "enabled") do
{queryable, dynamic([actors: actors], is_nil(actors.disabled_at))}
end

def filter_by_status(queryable, "disabled") do
{queryable, dynamic([actors: actors], not is_nil(actors.disabled_at))}
end

def filter_by_type(queryable, type) do
{queryable, dynamic([actors: actors], actors.type == ^type)}
end
Expand Down
2 changes: 2 additions & 0 deletions elixir/apps/web/lib/web/live/actors/index.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ defmodule Web.Actors.Index do
|> assign(page_title: "Actors")
|> assign_live_table("actors",
query_module: Actors.Actor.Query,
# TODO[bmanifold]: Enable this filter once we start collapsing them
hide_filters: [:type],
sortable_fields: [
{:actors, :name}
],
Expand Down
2 changes: 1 addition & 1 deletion elixir/apps/web/lib/web/live/groups/edit_actors.ex
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ defmodule Web.Groups.EditActors do
sortable_fields: [
{:actors, :name}
],
hide_filters: [:type, :provider_id],
hide_filters: [:type, :provider_id, :status],
callback: &handle_actors_update!/2
)

Expand Down
2 changes: 1 addition & 1 deletion elixir/apps/web/lib/web/live/groups/show.ex
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ defmodule Web.Groups.Show do
sortable_fields: [
{:actors, :name}
],
hide_filters: [:type, :provider_id],
hide_filters: [:type, :status, :provider_id],
callback: &handle_actors_update!/2
)
|> assign_live_table("policies",
Expand Down

0 comments on commit 78cd706

Please sign in to comment.