✨ Disable the admin-console by default in the devenv frontend (#13061)

* ✨ Disable the admin-console by default in the devenv frontend

The devenv does not run the admin-console service, but the frontend
showed its UI by default. The devenv containers now build the
frontend with PENPOT_DEVENV=true, which prepends disable-admin-console
ahead of the developer's config.js flags. Flags parse in order, so
enable-admin-console in config.js re-enables it; builds outside
devenv are unchanged.

Closes #13060

AI-assisted-by: inkling-2-small-free

* 📚 Require English in all code-facing text

Add a hard rule to AGENTS.md: everything in code must be in
English — identifiers, comments, docstrings, test descriptions,
log hints — with tests not excepted. The only allowed place for
another language is product copy rendered through the i18n
system. Also restated in mem:clojure/design-rules and mem:testing.

AI-assisted-by: inkling-2-small-free
This commit is contained in:
Andrey Antukh 2026-11-16 09:54:23 +01:00 committed by GitHub
parent 77c87d16f1
commit 635f7fc914
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 72 additions and 2 deletions

View File

@ -8,6 +8,7 @@ How to shape a function in this codebase. Each rule came from a review round; do
- **Functions that obtain data start with `get-` or `fetch-`.** A reader must see at a glance that the function reads (`get-file`, `get-snapshot`, `get-file-json`); a bare noun hides it (`file-json` says nothing about reading). New helpers that fetch by id follow this, never a `current-` prefix: the id parameter already says which one it is.
- **`?` marks a predicate, not a data prop.** A var or function that answers a question takes `?` (`export-error?`, `(defn editable? …)`); a map key that names a property does not (`:export-error`, never `:export-error?`), even when its value is a boolean. Existing `?` keys are legacy to remove gradually; do not add a new one.
- **Do not shape production code for tests.** No return values added just to assert them; assert on the observable effect. When preconditions move, move the tests with them.
- **All code-facing text MUST be in English** — identifiers, comments, docstrings, test descriptions. No exceptions; see the hard rule in `AGENTS.md`.
Reference implementation: the http metrics samplers in `app.http` (`sample-worker-metrics` / `sample-connector-metrics` are guard-free; `sample-http-metrics` guards at the boundary).

View File

@ -15,6 +15,7 @@ Compose-based dev environment under `docker/devenv/`, driven by `manage.sh`. Par
- For ws1+, `instance-env-overrides` computes the per-instance overrides (container/volume names, host ports offset `10000·N`, `PENPOT_PUBLIC_URI`, `PENPOT_REDIS_URI`, `PENPOT_TEST_DATABASE_URI`, `PENPOT_TEST_REDIS_URI`) and `instance-compose` injects them as env vars at compose time — never written to disk, recomputed each call so they can't drift. ws0 uses `defaults.env` as-is.
- Per-instance test databases are created by `ensure-instance-test-database` (called from `start-instance`): `CREATE DATABASE` guarded by a `pg_database` existence check, so it is idempotent. Needed because `postgresql_init.sql` only runs on first volume creation. The backend applies migrations itself on first use, so an empty database is enough.
- `backend/scripts/_env`: backend-internal only — secret keys, `PENPOT_FLAGS` (with `enable-backend-worker` gated on `PENPOT_BACKEND_WORKER`), `JAVA_OPTS`, `setup_s3_bucket()`. Never duplicates `defaults.env`.
- Frontend admin-console is off by default in devenv: `docker-compose.main.yml` sets `PENPOT_DEVENV=true`, which makes `app.config` (`goog-define devenv-mode`) prepend `disable-admin-console` ahead of the user `config.js` flags; flags parse in order and user flags win, so `enable-admin-console` in `frontend/resources/public/js/config.js` re-enables it. Outside devenv (prod builds) the default is unset and the admin-console stays on, matching `flags/default`.
- Compose files use pure `${VAR}` substitution; missing var = compose fails.
## Invariants

View File

@ -73,6 +73,8 @@ a test that reproduces it:
- **One Assertion Per Concept** — each test verifies one behavior; split
compound assertions
- **Descriptive Test Names** — names read like specifications
- **English Only** — test names, `testing` strings, comments, and every
code-facing text MUST be in English; see the hard rule in `AGENTS.md`.
## Prefer Real Implementations Over Mocks

View File

@ -28,6 +28,12 @@
- Before `gh pr create` / `gh pr edit` → `mem:workflow/creating-prs` (title format, body structure, AI note)
Don't infer format from the title of a previous commit/issue/PR — the memory
is the source of truth.
- **Everything in code MUST be in English.** Identifiers (functions,
variables, types, namespaces), code comments, docstrings, test
descriptions, log hints — always English, regardless of the language the
author works in. Tests are not an exception. The only place another
language may appear in the codebase is product copy rendered through the
i18n system.
## CRITICAL: Read module memories BEFORE writing any code

View File

@ -101,5 +101,11 @@ services:
- SERENA_UPDATE_VERSION=2.1.0
- SHADOW_SERVER_URL=${SHADOW_SERVER_URL}
# Frontend dev devenv switch: makes the frontend compile with
# PENPOT_DEVENV=true so the admin-console is disabled by default
# (app.config/devenv-mode). `enable-admin-console` in config.js
# re-enables it.
- PENPOT_DEVENV=true
networks:
- default

View File

@ -508,6 +508,14 @@ Some examples of commonly used flags:
The full list of available flags can be found in `common/src/app/common/flags.cljc`.
One flag is off by default in the devenv: the frontend compiles with
`PENPOT_DEVENV=true` in the development containers, which hides all
admin-console UI (links, routes, team menu entries) whether or not you created
a `config.js`. To test the admin-console against a local Nitrate instance,
reactivate it from your `config.js`: `var penpotFlags = "enable-admin-console";`.
Your flags are parsed after the injected default, so your entry wins. Production
builds are unaffected: `PENPOT_DEVENV` only exists in the devenv containers.
After creating or modifying this file, **reload the browser** (no need to restart anything).
### Backend flags via PENPOT_FLAGS

View File

@ -70,7 +70,8 @@
:compiler-options
{:output-feature-set :es2020
:output-wrapper false
:warnings {:fn-deprecated false}}
:warnings {:fn-deprecated false}
:closure-defines {app.config/devenv-mode #shadow/env ["PENPOT_DEVENV" :as :bool :default false]}}
:release
{:closure-defines {goog.DEBUG false

View File

@ -73,10 +73,26 @@
:browser
:webworker))
;; --- Compile-time devenv switch
;;
;; Set to true only by the devenv containers (PENPOT_DEVENV=true in
;; docker-compose.main.yml); production builds leave the default. When true,
;; the frontend disables the admin-console by default; `enable-admin-console`
;; in the user's `config.js` re-enables it (user flags parse after the
;; injected default and the last flag wins).
(goog-define devenv-mode false)
(defn- apply-devenv-defaults
"Prepends the devenv default `disable-admin-console` before the user flags.
User flags are parsed after it, so `enable-admin-console` wins."
[devenv? flags]
(if devenv? (concat [:disable-admin-console] flags) flags))
(defn- parse-flags
[global]
(let [flags (obj/get global "penpotFlags" "")
flags (sequence (map keyword) (str/words flags))]
flags (sequence (map keyword) (str/words flags))
flags (apply-devenv-defaults devenv-mode flags)]
(flags/parse flags/default flags)))
(defn- parse-version

View File

@ -0,0 +1,27 @@
;; This Source Code Form is subject to the terms of the Mozilla Public
;; License, v. 2.0. If a copy of the MPL was not distributed with this
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
;;
;; Copyright (c) KALEIDOS SUBSIDIARY SL
(ns frontend-tests.config-test
(:require
[app.common.flags :as flags]
[app.config :as cf]
[cljs.test :as t :include-macros true]))
(def ^:private apply-devenv-defaults @#'cf/apply-devenv-defaults)
(t/deftest devenv-default-disables-admin-console
(t/testing "in devenv, without user flags, the admin-console is disabled by default"
(t/is (not (contains? (flags/parse flags/default (apply-devenv-defaults true []))
:admin-console))))
(t/testing "in devenv, the user can re-enable it with enable-admin-console"
(t/is (contains? (flags/parse flags/default (apply-devenv-defaults true [:enable-admin-console]))
:admin-console)))
(t/testing "in devenv, the user's disable-admin-console is idempotent"
(t/is (not (contains? (flags/parse flags/default (apply-devenv-defaults true [:disable-admin-console]))
:admin-console))))
(t/testing "outside devenv, no default is injected and the flags defaults apply"
(t/is (contains? (flags/parse flags/default (apply-devenv-defaults false []))
:admin-console))))

View File

@ -8,6 +8,7 @@
[frontend-tests.browser-history-test]
[frontend-tests.code-gen-style-test]
[frontend-tests.composable-tests.comp.sync-test]
[frontend-tests.config-test]
[frontend-tests.copy-as-svg-test]
[frontend-tests.data.auth-test]
[frontend-tests.data.comments-batches-test]
@ -210,6 +211,7 @@
['frontend-tests.basic-shapes-test
'frontend-tests.code-gen-style-test
'frontend-tests.composable-tests.comp.sync-test
'frontend-tests.config-test
'frontend-tests.copy-as-svg-test
'frontend-tests.data.auth-test
'frontend-tests.data.comments-batches-test