Skip to content

Commit 9ec93e4

Browse files
authored
toil(front): properly check service account feature access (#730)
## 📝 Description - Extracted `people_management_permissions?` helper to check only user permissions, allowing the service accounts "Add" button to work independently of the `rbac__project_roles` feature flag. ## ✅ Checklist - [x] I have tested this change - [ ] This change requires documentation update
1 parent 1232098 commit 9ec93e4

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed
Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
<%= if show_people_management_buttons?(@conn, @org_scope?, @permissions) do %>
2-
<div>
3-
<div class="flex-m">
4-
<div>
5-
<button id="add_service_accounts_to_project" class="btn btn-primary flex items-center">
6-
<span class="material-symbols-outlined mr2">smart_toy</span>
7-
Add service accounts
8-
</button>
9-
</div>
1+
<div>
2+
<div class="flex-m">
3+
<div>
4+
<button id="add_service_accounts_to_project" class="btn btn-primary flex items-center">
5+
<span class="material-symbols-outlined mr2">smart_toy</span>
6+
Add service accounts
7+
</button>
108
</div>
119
</div>
12-
<% end %>
10+
</div>

front/lib/front_web/templates/people/members/members_list.html.eex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
<div class="b">Service Accounts</div>
6161
</div>
6262
</div>
63-
<%= if !@org_scope? && show_people_management_buttons?(@conn, @org_scope?, @permissions) do %>
63+
<%= if !@org_scope? && people_management_permissions?(@org_scope?, @permissions) do %>
6464
<%= render "members/_add_service_account_button.html", conn: @conn, org_scope?: @org_scope?, permissions: @permissions %>
6565
<% end %>
6666
</div>

front/lib/front_web/views/people_view.ex

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,12 +162,15 @@ defmodule FrontWeb.PeopleView do
162162
Timex.format!(Timex.from_unix(seconds), "%b %d, %Y, %I:%M%p", :strftime)
163163
end
164164

165+
def people_management_permissions?(org_scope?, permissions) do
166+
(org_scope? && permissions["organization.people.manage"]) ||
167+
(!org_scope? && permissions["project.access.manage"])
168+
end
169+
165170
def show_people_management_buttons?(conn, org_scope?, permissions) do
166171
org_id = conn.assigns[:organization_id]
167172

168-
user_has_permissions? =
169-
(org_scope? && permissions["organization.people.manage"]) ||
170-
(!org_scope? && permissions["project.access.manage"])
173+
user_has_permissions? = people_management_permissions?(org_scope?, permissions)
171174

172175
feature_enabled? =
173176
org_scope? || FeatureProvider.feature_enabled?(:rbac__project_roles, param: org_id) ||

0 commit comments

Comments
 (0)