ETQ super-admin, je peux publier un bandeau d'en-tête sur le site depuis le manager#13237
Merged
colinux merged 4 commits intoJun 15, 2026
Merged
Conversation
Member
|
[ j'ai commencé à reprendre la PR pour signer les commits et rajouter 2-3 petits trucs ] |
colinux
force-pushed
the
feature/banner-system
branch
from
June 8, 2026 12:47
30be4d9 to
0e7b282
Compare
Member
|
Donc j'ai amendé la PR avec ces modifications :
|
colinux
approved these changes
Jun 9, 2026
colinux
enabled auto-merge
June 9, 2026 09:37
colinux
force-pushed
the
feature/banner-system
branch
from
June 10, 2026 09:03
8ed25ad to
9beac6e
Compare
Replace BANNER_MESSAGE, ADMINISTRATION_BANNER_MESSAGE, and USAGER_BANNER_MESSAGE environment variables with database-backed banners editable at /manager/banners by super admins. Five banner types: global, instructeurs-only, usagers-only, login page (/users/sign_in + /users/sign_up), and manager login (/super_admins/sign_in). Each uses DSFR NoticeComponent with a custom .banner-notice CSS class (pastel orange via DSFR vars). Banners are published by filling content and unpublished by clearing it. Redis-cached per target with 1-minute TTL and after_commit invalidation. Sanitization restricted to safe inline tags. Admin /manager/banners rebuilt with self-contained design (bn-* classes in manager_banners.scss), card grid, Heroicons SVG via ManagerBannerIconsHelper, status badges. Cards have green border when active, red when inactive. NoticeComponent extended with extra_class_names, coexisting with the existing data_attributes parameter. Ported cross-repo from demat-social@2.5.93 (commits 2e17d846b8, 34f88f5001, 906582d58e, e35069fb97, 845bd9a53e), squashed. CLAUDE.md hunk dropped (file not present in this repo). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…tenance Restore the two fixes from the polish commit (845bd9a53e) that were lost when this partial was recreated in ERB during the cross-repo port (the upstream chore: port layout to herb commit had migrated it from HAML to ERB after the BDD-backed banners commit). - Use nav_bar_profile (context) instead of instructeur_signed_in? (role) so that a user with both an instructeur record and a user/admin record sees usagers_only when browsing in usager/admin context, not just instructeurs_only. - Pass extra_class_names: 'banner-notice' so the custom orange pastel styling (banner_notice.scss) is actually applied. Without it, public pages render banners in DSFR blue (fr-notice--info) instead of the warning-variable orange intended. Runtime-validated on /, /users/sign_in, /admin/procedures (admin nav), /procedures (instructeur nav), /dossiers (user nav) with the same multi-role user. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The manager banners page shipped a dedicated 516-line stylesheet (manager_banners.scss). Because app/assets/stylesheets is bundled through `require_tree`, that file ended up in application.css — the bundle loaded on every public page — so all front-end visitors downloaded ~27 KB of manager-only styling they never use. Rebuild the page with Administrate's existing classes (main-content, field-unit, flash-*, button) so no extra stylesheet is needed. Remove the custom manager_banners.scss, its import, the icons helper and Banner::TARGET_ICONS.
Gate Manager::BannersController#update behind RequiresFreshSuperAdminOtp, like the dossier transfer and user email overwrite actions: the super admin must enter a fresh TOTP code to change a banner. Each inline banner form renders Manager::OtpAttemptInputComponent; the component now accepts an `id` so the five forms don't share a DOM id (the submitted param stays `otp_attempt`).
colinux
force-pushed
the
feature/banner-system
branch
from
June 15, 2026 12:46
9beac6e to
99000c0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces the three
BANNER_MESSAGE/ADMINISTRATION_BANNER_MESSAGE/USAGER_BANNER_MESSAGEenv-variable banners with a database-backed system editable at/manager/bannersby super admins.Five banner targets, each rendered via DSFR
NoticeComponentwith a custom.banner-noticeclass (pastel orange via DSFR--background-contrast-warning/--text-default-warningvariables):globalinstructeurs_onlynav_bar_profile == :instructeurusagers_onlylogin_page/users/sign_in+/users/sign_up(rendered inside the fieldset, below the subtitle)manager_login/super_admins/sign_in(rendered inside the form container, belowEspace Manager)Banners are published by filling content and unpublished by clearing it. Redis-cached per target with 1-minute TTL and
after_commitinvalidation. Sanitization restricted to[a strong em b i br u abbr sub sup]inline whitelist (verified againstjavascript:,onerror,onclick,<script>,<iframe>,<style>injection vectors).Admin UI
/manager/bannersrebuilt with a self-containedbn-*design (516 lines SCSS): card grid, Heroicons SVG viaManagerBannerIconsHelper, status badges Active/Inactive, modern typography, gray background extending through main-content padding, guide encart documenting allowed HTML tags with a full test message.Commits
feat(banners): add database-backed banners with admin UI(model, controller, view, helper, 3 migrations, 2 SCSS files, 3 doc files, layout integrations on_pre_maintenance,super_admins/sessions/new,users/sessions/new,users/registrations/new, plusNoticeComponentextension withextra_class_names).fix(banners): use nav_bar_profile and banner-notice class in pre_maintenance— uses navigation context (nav_bar_profile) instead of role check (instructeur_signed_in?) so a user with multiple roles seesusagers_onlywhen browsing user/admin context (not justinstructeurs_only), and applies thebanner-noticestyling class. Both fixes were lost when the partial was recreated in ERB during the cross-repo port (the upstreamchore: port layout to herbcommit had migrated it from HAML to ERB after the BDD-backed banners commit).Test plan
Runtime-validated locally (puma + browser MCP + psql) — 9 pages × 5 banner targets = 45 visibility checks, all PASS.
Cold state: all 5 banners empty → no notice on any page
Admin UI
/manager/banners: cards rendered with Heroicons + badges, guide encart with allowed tags + full example, form submit posts PATCH, flash notice 'Bannière mise à jour', badge toggles ACTIVE/INACTIVE, stats counterN/5 activesaccurateActivation via admin form → banner visible on front (orange pastel
.banner-noticeclass)Deactivation by emptying textarea → banner disappears on front
Targeting matrix runtime (all 45 combinations verified via browser MCP):
/anon/auth:guestG + U/users/sign_in:guestG + U + L(L inside fieldset)/users/sign_up:guestG + U + L(L inside fieldset)/super_admins/sign_in:superadminG + U + M(M inside container)/admin/procedures:guestG + U/procedures:instructeurG + I/dossiers:guestG + U/faq:guestG + USanitization XSS: 6 attack vectors (
javascript:href,onerror,onclick,<script>,<iframe>,<style>) all neutralized; 10 whitelist tags all preserved withhrefhttps andtitleattrs intactCache after_commit:
update!→Rails.cache.delete(\"banner/{target}\")(validated viarails runner4 scenarios T1→T4 on MemoryStore)Edge cases: empty string, NULL, whitespace-only content all treated as inactive (Rails
String#present?blank-aware); 5000 chars rendered without truncationRoute surface restricted to
GET /manager/banners+PATCH /manager/banners/:id(no:show,:create,:destroy,:new)Authorization: unauth GET → 302 sign_in; unauth PATCH → 422 CSRF; PATCH from logged super_admin → success
Logs: no errors, no
NoMethodError, noStatementInvalidduring full test passNotes
20260602100001..03are after the latest upstream migration20260521105001, will run ondb:migrate.Banner.cached_for(target)rescuesActiveRecord::StatementInvalidso the partial does not break during the window between code deploy and migration completion.NoticeComponentextended with optionalextra_class_names:parameter merged viaclass_namesinto the existingoptionshelper; backward-compatible with all existing call sites (state, data_attributes).🤖 Generated with Claude Code