Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions front/AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Repository Guidelines

## Project Structure & Module Organization
- `lib/` holds Phoenix contexts, controllers, and services; shared helpers sit in `test/support`.
- `assets/` hosts the Preact/TypeScript UI alongside the build scripts (`build.js`, `package.json`).
- `config/` tracks environment settings, while runtime secrets are read from sibling files in `env/`.
- `test/` mirrors `lib/` with ExUnit suites, Wallaby browser specs in `test/browser`, and fixtures under `test/fixture`.
- `priv/` serves runtime assets, and `workflow_templates/` supplies seeded YAML pipelines consumed by the UI.

## Build, Test, and Development Commands
- First-time setup: `mix deps.get` and `npm install --prefix assets`.
- `make dev.server` (Docker) launches Phoenix with Redis, RabbitMQ, and demo data preloaded.
- `mix phx.server` runs on the host once services are already up via `docker compose up -d`.
- `mix test` runs backend suites; `make test.js` or `npm test --prefix assets` covers frontend logic.
- Keep `mix credo --strict`, `mix format`, and `npm run lint` clean before pushing.
- Bundle production assets with `mix assets.deploy`.

## Coding Style & Naming Conventions
- Format Elixir with `mix format`; favor pipe-first flows and 2-space indentation.
- Credo (`config/.credo.exs`) runs in strict mode—fix findings instead of disabling checks.
- Modules follow `Front.Foo` naming and live in `snake_case` paths; tests are co-located as `*_test.exs`.
- TypeScript components use PascalCase filenames; reusable helpers belong under `assets/js/` and tests under `*.spec.ts`.

## Testing Guidelines
- Keep unit tests close to their modules and name `describe` blocks after the function under test.
- Wallaby browser specs need the Docker stack running; execute with `mix test test/browser`.
- Generate coverage with `mix coveralls.html` and `npm run coverage`.
- Update fixtures in `test/fixture` when workflow, API, or UI contracts change.

## Commit & Pull Request Guidelines
- Commits follow `type(scope): message (#issue)` (e.g., `fix(front): adjust mermaid rendering (#621)`).
- Each commit should bundle code, schema, and tests for a single concern.
- PRs summarize impact, list manual checks, link tracking items, and add UI screenshots when relevant.
- Verify CI (mix, JS lint, tests) is green before requesting review and call out any external dependencies.

## Environment & Services
- Shared defaults live in `env/`; do not commit developer-specific overrides.
- Use Docker (via `make dev.server` or `docker compose up`) to run RabbitMQ, Redis, and API stubs before starting Phoenix.
- Validate YAML pipelines with `scripts/check-templates.sh <path>` prior to committing.
- Maintain security suppressions in `security-ignore-policy.rego` with a short inline rationale.
33 changes: 33 additions & 0 deletions front/assets/js/people/add_to_project.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,23 @@ export var AddToProject = {
if(addPeopleToProjectBtn){
addPeopleToProjectBtn.onclick = () => {
modal.style.display = "block";
this.setModalCopy("user")
this.initProjectNonMembersFilter("user")
}
}

if(addGroupsToProjectBtn){
addGroupsToProjectBtn.onclick = () => {
modal.style.display = "block";
this.setModalCopy("group")
this.initProjectNonMembersFilter("group")
}
}

if(addServiceAccountsToProjectBtn){
addServiceAccountsToProjectBtn.onclick = () => {
modal.style.display = "block";
this.setModalCopy("service_account")
this.initProjectNonMembersFilter("service_account")
}
}
Expand All @@ -59,6 +62,36 @@ export var AddToProject = {
}
},

setModalCopy(type) {
const modal = document.getElementById("modal_overlay");
const container = modal?.querySelector(".popup");
if(!container) return;

const suffix = type === "service_account"
? "Service_account"
: type.charAt(0).toUpperCase() + type.slice(1);

const title = container.dataset[`title${suffix}`];
const subjectPlural = container.dataset[`subjectPlural${suffix}`];
const placeholder = container.dataset[`placeholder${suffix}`];

const titleEl = container.querySelector("[data-modal-title]");
if(titleEl && title){
titleEl.textContent = title;
}

if(subjectPlural){
container.querySelectorAll("[data-modal-subject-plural]").forEach((el) => {
el.textContent = subjectPlural;
});
}

const searchInput = container.querySelector("[data-modal-search]");
if(searchInput && placeholder){
searchInput.placeholder = placeholder;
}
},

initRoleSelectionListeners() {
const roleDivs = document.getElementsByName("role_div")
if(roleDivs){
Expand Down
2 changes: 1 addition & 1 deletion front/lib/front/rbac/role_management.ex
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ defmodule Front.RBAC.RoleManagement do
InternalApi.RBAC.SubjectType.value(:USER)
end

subject = RBAC.Subject.new(subject_id: subject_id, type: subject_type)
subject = RBAC.Subject.new(subject_id: subject_id, subject_type: subject_type)

req =
RBAC.AssignRoleRequest.new(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,39 @@
</style>

<div class="overlay" id="modal_overlay" style="display: none;">
<div class="bg-white popup w-40 br3 pa3 tl" style="min-width: 500px;">
<h3 class="mb0">Add New Users</h3>
<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>
<div
class="bg-white popup w-40 br3 pa3 tl"
style="min-width: 500px;"
data-title-user="Add New Users"
data-title-group="Add New Groups"
data-title-service_account="Add New Service Accounts"
data-subject-plural-user="users"
data-subject-plural-group="groups"
data-subject-plural-service_account="service accounts"
data-placeholder-user="<%= if Front.ce?(), do: "Search users to add to project", else: "Search users and groups to add to project" %>"
data-placeholder-group="Search groups to add to project"
data-placeholder-service_account="Search service accounts to add to project"
>
<h3 class="mb0" data-modal-title>Add New Users</h3>
<p class="measure-wide mb0" data-modal-description>
Ensure that
<span data-modal-subject-plural>users</span>
are part of your organization before trying to add them to the project. Manage
<span data-modal-subject-plural>users</span>
on the
<%= link "organization/people", to: people_path(@conn, :organization) %>
page.
</p>

<div class="flex items-center mv3 justify-between">
<div class="project-jumpto w-100 filters-group flex">
<input type="hidden">
<input
type="text"
class="form-control w-100 mr2"
data-modal-search
placeholder="<%= if Front.ce?(), do: "Search users to add to project", else: "Search users and groups to add to project" %>"
class="form-control w-100 mr2" >
>
<div class="jumpto-results"></div>
</div>
</div>
Expand Down