Skip to content

Commit ae73078

Browse files
fix: Service accounts showing up as users (#638)
## 📝 Description Fixes a bug where service accounts were showing up in people section on `/people` page on CE installations. Fixes a bug where when adding service account to a project modal was showing "Add New Users". ## ✅ Checklist - [x] I have tested this change - [ ] This change requires documentation update
1 parent 3ae2a00 commit ae73078

File tree

4 files changed

+100
-5
lines changed

4 files changed

+100
-5
lines changed

front/AGENTS.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Repository Guidelines
2+
3+
## Project Structure & Module Organization
4+
- `lib/` holds Phoenix contexts, controllers, and services; shared helpers sit in `test/support`.
5+
- `assets/` hosts the Preact/TypeScript UI alongside the build scripts (`build.js`, `package.json`).
6+
- `config/` tracks environment settings, while runtime secrets are read from sibling files in `env/`.
7+
- `test/` mirrors `lib/` with ExUnit suites, Wallaby browser specs in `test/browser`, and fixtures under `test/fixture`.
8+
- `priv/` serves runtime assets, and `workflow_templates/` supplies seeded YAML pipelines consumed by the UI.
9+
10+
## Build, Test, and Development Commands
11+
- First-time setup: `mix deps.get` and `npm install --prefix assets`.
12+
- `make dev.server` (Docker) launches Phoenix with Redis, RabbitMQ, and demo data preloaded.
13+
- `mix phx.server` runs on the host once services are already up via `docker compose up -d`.
14+
- `mix test` runs backend suites; `make test.js` or `npm test --prefix assets` covers frontend logic.
15+
- Keep `mix credo --strict`, `mix format`, and `npm run lint` clean before pushing.
16+
- Bundle production assets with `mix assets.deploy`.
17+
18+
## Coding Style & Naming Conventions
19+
- Format Elixir with `mix format`; favor pipe-first flows and 2-space indentation.
20+
- Credo (`config/.credo.exs`) runs in strict mode—fix findings instead of disabling checks.
21+
- Modules follow `Front.Foo` naming and live in `snake_case` paths; tests are co-located as `*_test.exs`.
22+
- TypeScript components use PascalCase filenames; reusable helpers belong under `assets/js/` and tests under `*.spec.ts`.
23+
24+
## Testing Guidelines
25+
- Keep unit tests close to their modules and name `describe` blocks after the function under test.
26+
- Wallaby browser specs need the Docker stack running; execute with `mix test test/browser`.
27+
- Generate coverage with `mix coveralls.html` and `npm run coverage`.
28+
- Update fixtures in `test/fixture` when workflow, API, or UI contracts change.
29+
30+
## Commit & Pull Request Guidelines
31+
- Commits follow `type(scope): message (#issue)` (e.g., `fix(front): adjust mermaid rendering (#621)`).
32+
- Each commit should bundle code, schema, and tests for a single concern.
33+
- PRs summarize impact, list manual checks, link tracking items, and add UI screenshots when relevant.
34+
- Verify CI (mix, JS lint, tests) is green before requesting review and call out any external dependencies.
35+
36+
## Environment & Services
37+
- Shared defaults live in `env/`; do not commit developer-specific overrides.
38+
- Use Docker (via `make dev.server` or `docker compose up`) to run RabbitMQ, Redis, and API stubs before starting Phoenix.
39+
- Validate YAML pipelines with `scripts/check-templates.sh <path>` prior to committing.
40+
- Maintain security suppressions in `security-ignore-policy.rego` with a short inline rationale.

front/assets/js/people/add_to_project.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,23 @@ export var AddToProject = {
2727
if(addPeopleToProjectBtn){
2828
addPeopleToProjectBtn.onclick = () => {
2929
modal.style.display = "block";
30+
this.setModalCopy("user")
3031
this.initProjectNonMembersFilter("user")
3132
}
3233
}
3334

3435
if(addGroupsToProjectBtn){
3536
addGroupsToProjectBtn.onclick = () => {
3637
modal.style.display = "block";
38+
this.setModalCopy("group")
3739
this.initProjectNonMembersFilter("group")
3840
}
3941
}
4042

4143
if(addServiceAccountsToProjectBtn){
4244
addServiceAccountsToProjectBtn.onclick = () => {
4345
modal.style.display = "block";
46+
this.setModalCopy("service_account")
4447
this.initProjectNonMembersFilter("service_account")
4548
}
4649
}
@@ -59,6 +62,36 @@ export var AddToProject = {
5962
}
6063
},
6164

65+
setModalCopy(type) {
66+
const modal = document.getElementById("modal_overlay");
67+
const container = modal?.querySelector(".popup");
68+
if(!container) return;
69+
70+
const suffix = type === "service_account"
71+
? "Service_account"
72+
: type.charAt(0).toUpperCase() + type.slice(1);
73+
74+
const title = container.dataset[`title${suffix}`];
75+
const subjectPlural = container.dataset[`subjectPlural${suffix}`];
76+
const placeholder = container.dataset[`placeholder${suffix}`];
77+
78+
const titleEl = container.querySelector("[data-modal-title]");
79+
if(titleEl && title){
80+
titleEl.textContent = title;
81+
}
82+
83+
if(subjectPlural){
84+
container.querySelectorAll("[data-modal-subject-plural]").forEach((el) => {
85+
el.textContent = subjectPlural;
86+
});
87+
}
88+
89+
const searchInput = container.querySelector("[data-modal-search]");
90+
if(searchInput && placeholder){
91+
searchInput.placeholder = placeholder;
92+
}
93+
},
94+
6295
initRoleSelectionListeners() {
6396
const roleDivs = document.getElementsByName("role_div")
6497
if(roleDivs){

front/lib/front/rbac/role_management.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ defmodule Front.RBAC.RoleManagement do
212212
InternalApi.RBAC.SubjectType.value(:USER)
213213
end
214214

215-
subject = RBAC.Subject.new(subject_id: subject_id, type: subject_type)
215+
subject = RBAC.Subject.new(subject_id: subject_id, subject_type: subject_type)
216216

217217
req =
218218
RBAC.AssignRoleRequest.new(

front/lib/front_web/templates/people/add_to_project/_popup_window.html.eex

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,17 +93,39 @@
9393
</style>
9494

9595
<div class="overlay" id="modal_overlay" style="display: none;">
96-
<div class="bg-white popup w-40 br3 pa3 tl" style="min-width: 500px;">
97-
<h3 class="mb0">Add New Users</h3>
98-
<p class="measure-wide mb0">Ensure that the user is a part of your organization before trying to add them to the project. Go to <%= link "organization/people", to: people_path(@conn, :organization) %> to invite users to the organization.</p>
96+
<div
97+
class="bg-white popup w-40 br3 pa3 tl"
98+
style="min-width: 500px;"
99+
data-title-user="Add New Users"
100+
data-title-group="Add New Groups"
101+
data-title-service_account="Add New Service Accounts"
102+
data-subject-plural-user="users"
103+
data-subject-plural-group="groups"
104+
data-subject-plural-service_account="service accounts"
105+
data-placeholder-user="<%= if Front.ce?(), do: "Search users to add to project", else: "Search users and groups to add to project" %>"
106+
data-placeholder-group="Search groups to add to project"
107+
data-placeholder-service_account="Search service accounts to add to project"
108+
>
109+
<h3 class="mb0" data-modal-title>Add New Users</h3>
110+
<p class="measure-wide mb0" data-modal-description>
111+
Ensure that
112+
<span data-modal-subject-plural>users</span>
113+
are part of your organization before trying to add them to the project. Manage
114+
<span data-modal-subject-plural>users</span>
115+
on the
116+
<%= link "organization/people", to: people_path(@conn, :organization) %>
117+
page.
118+
</p>
99119

100120
<div class="flex items-center mv3 justify-between">
101121
<div class="project-jumpto w-100 filters-group flex">
102122
<input type="hidden">
103123
<input
104124
type="text"
125+
class="form-control w-100 mr2"
126+
data-modal-search
105127
placeholder="<%= if Front.ce?(), do: "Search users to add to project", else: "Search users and groups to add to project" %>"
106-
class="form-control w-100 mr2" >
128+
>
107129
<div class="jumpto-results"></div>
108130
</div>
109131
</div>

0 commit comments

Comments
 (0)