mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-27 18:18:55 +00:00
Add feature flags for TODOs and Flows (#2542)
Why: * Some sections of the UI were still displaying `TODO` and needed to be hidden for beta release, so a feature flag was created. Also, the 'Flows' are not ready to be utilized in the UI at this time, so a feature flag was created to hide any mention of 'Flows'.
This commit is contained in:
@@ -113,10 +113,20 @@ defmodule Domain.Config do
|
||||
end
|
||||
end
|
||||
|
||||
## Feature flag helpers
|
||||
|
||||
def sign_up_enabled? do
|
||||
compile_config!(Definitions, :feature_sign_up_enabled)
|
||||
end
|
||||
|
||||
def flow_activities_enabled? do
|
||||
compile_config!(Definitions, :feature_flow_activities_enabled)
|
||||
end
|
||||
|
||||
def todos_enabled? do
|
||||
compile_config!(Definitions, :feature_todos_enabled)
|
||||
end
|
||||
|
||||
## Test helpers
|
||||
|
||||
if Mix.env() != :test do
|
||||
|
||||
@@ -613,4 +613,14 @@ defmodule Domain.Config.Definitions do
|
||||
Boolean flag to turn Sign-ups on/off.
|
||||
"""
|
||||
defconfig(:feature_sign_up_enabled, :boolean, default: true)
|
||||
|
||||
@doc """
|
||||
Boolean flag to turn UI flow activities on/off.
|
||||
"""
|
||||
defconfig(:feature_flow_activities_enabled, :boolean, default: false)
|
||||
|
||||
@doc """
|
||||
Boolean flag to turn UI TODOs on/off.
|
||||
"""
|
||||
defconfig(:feature_todos_enabled, :boolean, default: false)
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
defmodule Web.Clients.Show do
|
||||
use Web, :live_view
|
||||
import Web.Policies.Components
|
||||
alias Domain.{Clients, Flows}
|
||||
alias Domain.{Clients, Flows, Config}
|
||||
|
||||
def mount(%{"id" => id}, _session, socket) do
|
||||
with {:ok, client} <- Clients.fetch_client_by_id(id, socket.assigns.subject, preload: :actor),
|
||||
@@ -9,7 +9,17 @@ defmodule Web.Clients.Show do
|
||||
Flows.list_flows_for(client, socket.assigns.subject,
|
||||
preload: [gateway: [:group], policy: [:resource, :actor_group]]
|
||||
) do
|
||||
{:ok, assign(socket, client: client, flows: flows)}
|
||||
socket =
|
||||
assign(
|
||||
socket,
|
||||
client: client,
|
||||
flows: flows,
|
||||
todos_enabled?: Config.todos_enabled?(),
|
||||
flow_activities_enabled?: Config.flow_activities_enabled?()
|
||||
)
|
||||
|
||||
{:ok, socket,
|
||||
temporary_assigns: [flows: [], todos_enabled?: nil, flow_activities_enabled?: nil]}
|
||||
else
|
||||
{:error, _reason} -> raise Web.LiveErrors.NotFoundError
|
||||
end
|
||||
@@ -66,7 +76,7 @@ defmodule Web.Clients.Show do
|
||||
<.relative_datetime datetime={@client.last_seen_at} />
|
||||
</:value>
|
||||
</.vertical_table_row>
|
||||
<.vertical_table_row>
|
||||
<.vertical_table_row :if={@todos_enabled?}>
|
||||
<:label>Transfer</:label>
|
||||
<:value>TODO</:value>
|
||||
</.vertical_table_row>
|
||||
@@ -118,7 +128,7 @@ defmodule Web.Clients.Show do
|
||||
</.link>
|
||||
(<%= flow.gateway_remote_ip %>)
|
||||
</:col>
|
||||
<:col :let={flow} label="ACTIVITY">
|
||||
<:col :let={flow} :if={@flow_activities_enabled?} label="ACTIVITY">
|
||||
<.link
|
||||
navigate={~p"/#{@account}/flows/#{flow.id}"}
|
||||
class="font-medium text-blue-600 dark:text-blue-500 hover:underline"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
defmodule Web.Gateways.Show do
|
||||
use Web, :live_view
|
||||
import Web.Policies.Components
|
||||
alias Domain.{Gateways, Flows}
|
||||
alias Domain.{Gateways, Flows, Config}
|
||||
|
||||
def mount(%{"id" => id}, _session, socket) do
|
||||
with {:ok, gateway} <-
|
||||
@@ -11,7 +11,17 @@ defmodule Web.Gateways.Show do
|
||||
preload: [client: [:actor], policy: [:resource, :actor_group]]
|
||||
) do
|
||||
:ok = Gateways.subscribe_for_gateways_presence_in_group(gateway.group)
|
||||
{:ok, assign(socket, gateway: gateway, flows: flows)}
|
||||
|
||||
socket =
|
||||
assign(
|
||||
socket,
|
||||
gateway: gateway,
|
||||
flows: flows,
|
||||
todos_enabled?: Config.todos_enabled?(),
|
||||
flow_activities_enabled?: Config.flow_activities_enabled?()
|
||||
)
|
||||
|
||||
{:ok, socket}
|
||||
else
|
||||
{:error, _reason} -> raise Web.LiveErrors.NotFoundError
|
||||
end
|
||||
@@ -52,7 +62,7 @@ defmodule Web.Gateways.Show do
|
||||
<:label>Instance Name</:label>
|
||||
<:value><%= @gateway.name_suffix %></:value>
|
||||
</.vertical_table_row>
|
||||
<.vertical_table_row>
|
||||
<.vertical_table_row :if={@todos_enabled?}>
|
||||
<:label>Connectivity</:label>
|
||||
<:value>TODO: Peer to Peer</:value>
|
||||
</.vertical_table_row>
|
||||
@@ -143,7 +153,7 @@ defmodule Web.Gateways.Show do
|
||||
</.link>
|
||||
(<%= flow.client_remote_ip %>)
|
||||
</:col>
|
||||
<:col :let={flow} label="ACTIVITY">
|
||||
<:col :let={flow} :if={@flow_activities_enabled?} label="ACTIVITY">
|
||||
<.link
|
||||
navigate={~p"/#{@account}/flows/#{flow.id}"}
|
||||
class="font-medium text-blue-600 dark:text-blue-500 hover:underline"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
defmodule Web.Policies.Show do
|
||||
use Web, :live_view
|
||||
import Web.Policies.Components
|
||||
alias Domain.{Policies, Flows}
|
||||
alias Domain.{Policies, Flows, Config}
|
||||
|
||||
def mount(%{"id" => id}, _session, socket) do
|
||||
with {:ok, policy} <-
|
||||
@@ -12,7 +12,15 @@ defmodule Web.Policies.Show do
|
||||
Flows.list_flows_for(policy, socket.assigns.subject,
|
||||
preload: [client: [:actor], gateway: [:group]]
|
||||
) do
|
||||
{:ok, assign(socket, policy: policy, flows: flows, page_title: "Policy")}
|
||||
socket =
|
||||
assign(socket,
|
||||
policy: policy,
|
||||
flows: flows,
|
||||
page_title: "Policy",
|
||||
flow_activities_enabled?: Config.flow_activities_enabled?()
|
||||
)
|
||||
|
||||
{:ok, socket}
|
||||
else
|
||||
_other -> raise Web.LiveErrors.NotFoundError
|
||||
end
|
||||
@@ -120,7 +128,7 @@ defmodule Web.Policies.Show do
|
||||
</.link>
|
||||
(<%= flow.gateway_remote_ip %>)
|
||||
</:col>
|
||||
<:col :let={flow} label="ACTIVITY">
|
||||
<:col :let={flow} :if={@flow_activities_enabled?} label="ACTIVITY">
|
||||
<.link navigate={~p"/#{@account}/flows/#{flow.id}"} class={link_style()}>
|
||||
Show
|
||||
</.link>
|
||||
|
||||
@@ -1,11 +1,19 @@
|
||||
defmodule Web.Relays.Show do
|
||||
use Web, :live_view
|
||||
alias Domain.Relays
|
||||
alias Domain.{Relays, Config}
|
||||
|
||||
def mount(%{"id" => id}, _session, socket) do
|
||||
with {:ok, relay} <-
|
||||
Relays.fetch_relay_by_id(id, socket.assigns.subject, preload: :group) do
|
||||
:ok = Relays.subscribe_for_relays_presence_in_group(relay.group)
|
||||
|
||||
socket =
|
||||
assign(
|
||||
socket,
|
||||
relay: relay,
|
||||
todos_enabled?: Config.todos_enabled?()
|
||||
)
|
||||
|
||||
{:ok, assign(socket, relay: relay)}
|
||||
else
|
||||
{:error, _reason} -> raise Web.LiveErrors.NotFoundError
|
||||
@@ -87,7 +95,7 @@ defmodule Web.Relays.Show do
|
||||
<%= @relay.last_seen_user_agent %>
|
||||
</:value>
|
||||
</.vertical_table_row>
|
||||
<.vertical_table_row>
|
||||
<.vertical_table_row :if={@todos_enabled?}>
|
||||
<:label>Deployment Method</:label>
|
||||
<:value>TODO: Docker</:value>
|
||||
</.vertical_table_row>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
defmodule Web.Resources.Show do
|
||||
use Web, :live_view
|
||||
import Web.Policies.Components
|
||||
alias Domain.{Resources, Flows}
|
||||
alias Domain.{Resources, Flows, Config}
|
||||
|
||||
def mount(%{"id" => id}, _session, socket) do
|
||||
with {:ok, resource} <-
|
||||
@@ -12,7 +12,15 @@ defmodule Web.Resources.Show do
|
||||
Flows.list_flows_for(resource, socket.assigns.subject,
|
||||
preload: [client: [:actor], gateway: [:group], policy: [:resource, :actor_group]]
|
||||
) do
|
||||
{:ok, assign(socket, resource: resource, flows: flows)}
|
||||
socket =
|
||||
assign(
|
||||
socket,
|
||||
resource: resource,
|
||||
flows: flows,
|
||||
todos_enabled?: Config.todos_enabled?()
|
||||
)
|
||||
|
||||
{:ok, socket}
|
||||
else
|
||||
{:error, _reason} -> raise Web.LiveErrors.NotFoundError
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user