Skip to content

Commit 6e42fa5

Browse files
committed
fix(front): Feature flag user git provider connection management
1 parent 4108ee5 commit 6e42fa5

File tree

3 files changed

+23
-6
lines changed

3 files changed

+23
-6
lines changed

front/lib/front/feature_hub_provider.ex

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,19 @@ defmodule Front.FeatureHubProvider do
1212
import Front.Utils
1313

1414
@impl FeatureProvider.Provider
15+
def provide_features(nil, _opts \\ []) do
16+
%InternalApi.Feature.ListFeaturesRequest{}
17+
|> FeatureClient.list_features()
18+
|> unwrap(fn response ->
19+
features =
20+
response.features
21+
|> Enum.map(&feature_from_grpc/1)
22+
|> Enum.filter(&FeatureProvider.Feature.visible?/1)
23+
24+
ok(features)
25+
end)
26+
end
27+
1528
def provide_features(org_id, _opts \\ []) do
1629
FeatureClient.list_organization_features(%{org_id: org_id})
1730
|> unwrap(fn response ->

front/lib/front_web/templates/account/show.html.eex

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<%= case {@user.github_scope, @user.github_login} do %>
2828
<% {:NONE, nil} -> %>
2929
<span class="red">Not Connected</span>
30-
<%= if Front.saas?() do %>
30+
<%= if FeatureProvider.feature_enabled?(:user_repos_access) do %>
3131
<div>
3232
<%= link "Grant public access…", to: account_path(@conn, :update_repo_scope, "github", [access_level: :public]), method: :post %>
3333
<%= link "Grant private access…", to: account_path(@conn, :update_repo_scope, "github", [access_level: :private]), method: :post %>
@@ -41,7 +41,7 @@
4141
<span class="red">Not Connected</span>
4242
·
4343
<span><a href="https://github.com/<%= @user.github_login %>" target="_blank">@<%= @user.github_login %></a></span>
44-
<%= if Front.saas?() do %>
44+
<%= if FeatureProvider.feature_enabled?(:user_repos_access) do %>
4545
<div>
4646
<%= link "Grant public access…", to: account_path(@conn, :update_repo_scope, "github", [access_level: :public]), method: :post %>
4747
<%= link "Grant private access…", to: account_path(@conn, :update_repo_scope, "github", [access_level: :private]), method: :post %>
@@ -53,7 +53,7 @@
5353
<span class="gray">email only</span>
5454
·
5555
<span><a href="https://github.com/<%= @user.github_login %>" target="_blank">@<%= @user.github_login %></a></span>
56-
<%= if Front.saas?() do %>
56+
<%= if FeatureProvider.feature_enabled?(:user_repos_access) do %>
5757
<div>
5858
<%= link "Grant public access…", to: account_path(@conn, :update_repo_scope, "github", [access_level: :public]), method: :post %>
5959
<%= link "Grant private access…", to: account_path(@conn, :update_repo_scope, "github", [access_level: :private]), method: :post %>
@@ -65,7 +65,7 @@
6565
<span class="gray">public repositories</span>
6666
·
6767
<span><a href="https://github.com/<%= @user.github_login %>" target="_blank">@<%= @user.github_login %></a></span>
68-
<%= if Front.saas?() do %>
68+
<%= if FeatureProvider.feature_enabled?(:user_repos_access) do %>
6969
<div>
7070
<%= link "Grant private access…", to: account_path(@conn, :update_repo_scope, "github", [access_level: :private]), method: :post %>
7171
</div>
@@ -76,7 +76,7 @@
7676
<span><a href="https://github.com/<%= @user.github_login %>" target="_blank">@<%= @user.github_login %></a></span>
7777
<% end %>
7878
</div>
79-
<%= if not Application.get_env(:front, :hide_bitbucket_me_page) do %>
79+
<%= if not FeatureProvider.feature_enabled?(:bitbucket) do %>
8080
<div class="pa2 bt b--lighter-gray">
8181
<span class="b">Bitbucket</span> ·
8282
<%= case {@user.bitbucket_scope, @user.bitbucket_login} do %>
@@ -98,7 +98,7 @@
9898
<span><a href="https://bitbucket.org/<%= @user.bitbucket_login %>" target="_blank">@<%= @user.bitbucket_login %></a></span>
9999
<% end %>
100100
</div>
101-
<%= if not Application.get_env(:front, :hide_gitlab_me_page) do %>
101+
<%= if not FeatureProvider.feature_enabled?(:gitlab) do %>
102102
<div class="pa2 bt b--lighter-gray">
103103
<span class="b">GitLab</span> ·
104104
<%= case {@user.gitlab_scope, @user.gitlab_login} do %>

helm-chart/templates/configmaps/features.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ data:
3636
enabled: false
3737
bitbucket_user_provider:
3838
enabled: false
39+
user_repos_access:
40+
enabled: true
3941
deployment_targets:
4042
enabled: false
4143
expose_cloud_agent_types:
@@ -152,6 +154,8 @@ data:
152154
enabled: false
153155
bitbucket_user_provider:
154156
enabled: false
157+
user_repos_access:
158+
enabled: true
155159
deployment_targets:
156160
enabled: true
157161
expose_cloud_agent_types:

0 commit comments

Comments
 (0)