Skip to content

[#270] Added a patched 'environment_indicator_navigation' submodule showing the environment on the Navigation sidebar. - #274

Merged
AlexSkrypnyk merged 4 commits into
developfrom
feature/270-env-indicator-nav
Jul 30, 2026
Merged

[#270] Added a patched 'environment_indicator_navigation' submodule showing the environment on the Navigation sidebar.#274
AlexSkrypnyk merged 4 commits into
developfrom
feature/270-env-indicator-nav

Conversation

@AlexSkrypnyk

@AlexSkrypnyk AlexSkrypnyk commented Jul 30, 2026

Copy link
Copy Markdown
Member

Closes #270

Checklist before requesting a review

  • Subject includes ticket number as [#123] Verb in past tense.
  • Ticket number #123 added to description
  • Added context in Changed section
  • Self-reviewed code and commented in commented complex areas.
  • Added tests for fix/feature.
  • Relevant tests run and passed locally.

Changed

  1. The environment indicator was invisible on every page. Uninstalling toolbar (Enable core Navigation module #255) made ToolbarHandler::externalIntegration('toolbar') return FALSE, so environment_indicator_page_top() fell back to rendering its classic full-width strip as the first element of <body>. That strip is position: static; z-index: 10, while core Navigation's sidebar (fixed, z-index: 501) and top bar (fixed, z-index: 490) both sit at top: 0. Measured as uid 1 at 1280px, document.elementFromPoint(640, 5) returned ASIDE.top-bar - the strip was painted underneath the navigation chrome on both the front-end and admin themes, so no viewport position exposed it.

  2. It also cost 28px of dead layout. The strip stayed in document flow while being invisible, pushing every authenticated page down. On the homepage .ct-header sat at 92px; with the strip gone it returns to 64px, flush under the top bar.

  3. Added patches/environment-indicator-navigation.patch, which creates an environment_indicator_navigation submodule inside drupal/environment_indicator. The submodule shows the active environment as an 8px coloured stripe along the inline-start edge of the Navigation sidebar - the treatment the parent module already applies to Gin's vertical toolbar via border-left on .toolbar-menu-administration. It depends on environment_indicator and navigation, so no defensive module guards are needed.

  4. Kept the favicon colouring alive. The page_top element carries the environment_indicator/favicon library and the drupalSettings.environmentIndicator payload that recolours the browser tab icon. Setting #access to FALSE or unsetting the element would have silently dropped both, so the element is reduced with array_intersect_key() to its #attached and #cache keys instead. Verified in the browser: addFavicon: true and the favicon rewritten to a data:image/png;base64,... URI.

  5. Targeted .admin-toolbar, which is core Navigation's class - defined in core/modules/navigation/layouts/navigation.html.twig, not the contrib admin_toolbar module, which is uninstalled and whose assets never load. Core sets border-inline-end on that element but never border-inline-start, and Gin only sets top and height, so the property is unclaimed and needs no specificity override. The sidebar is box-sizing: border-box, so it stays exactly 265px wide and Drupal.displace() offsets are untouched.

  6. Namespaced the width property deliberately. The parent module defines --environment-indicator-border-width: 6px at :root in CSS that is still attached, so reusing that name would silently yield 6px. The submodule uses --environment-indicator-navigation-width, defaulting to 8px, and --environment-indicator-navigation-color for the colour.

  7. Registered the patch in composer.json, patches.lock.json (via composer patches-relock, recorded at depth: 1) and config/default/core.extension.yml. Because the patch only adds files, it applies cleanly across releases - and will fail loudly the moment a release ships its own submodule of this name, which is the signal to drop it.

  8. Rewrote environment_indicator_access.feature and added a computed-style Behat step. The previous scenario asserted the element existed and carried a style attribute, which passed for the entire period the indicator was invisible. The new assertions compare a computed value that differs by role - 8px for a site administrator against 0px for a content author on the same selector - and assert the legacy strip is gone. These cover rendered output, so they hold regardless of where the implementation lives.

Navigation support is tracked upstream at #3457688 but ships in no release: the GitLab API confirms modules/ on both 4.x and 5.0.x contains only environment_indicator_toolbar and environment_indicator_ui, and drush pm:list on 4.0.25 discovers only those two submodules. MR !86 targets 4.x but is written against a pre-4.0.25 tree and no longer applies; MR !141 indents the strip past the sidebar horizontally, which does not help because the top bar covers it vertically across the full width. Note that the upstream design renders a named button rather than a stripe, so the two are not visually equivalent.

Screenshots

Sidebar detail, zoomed - the 8px environment stripe on the inline-start edge:

Environment stripe on the Navigation sidebar, zoomed

Full page, showing the site header now flush under the top bar:

Homepage as an administrator with the environment stripe

Before / After

BEFORE                                    AFTER

y=0  ┌─────────────────────────────┐      y=0  ┌─────────────────────────────┐
     │ #environment-indicator      │           │▓ .top-bar      z-index: 490 │
     │   static, z-index: 10, h=28 │           │▓                            │
     │   ...covered, never seen    │      y=64 ├▓────────────────────────────┤
y=0  │ .top-bar       z-index: 490 │           │▓ .ct-header  (flush at 64)  │
     │   fixed, paints over it     │           │▓                            │
y=64 ├─────────────────────────────┤           │▓                            │
     │                             │           │▓                            │
     │   28px dead band            │           ▓ = 8px stripe on .admin-toolbar
     │                             │               border-inline-start,
y=92 ├─────────────────────────────┤               coloured from bg_color
     │ .ct-header  (pushed to 92)  │
     │                             │


.ct-header top: 92px                      .ct-header top: 64px
#environment-indicator: present, unseen   #environment-indicator: removed
favicon: environment-coloured             favicon: environment-coloured (preserved)


PACKAGING

  composer.json
    └── extra.patches
          └── drupal/environment_indicator
                └── patches/environment-indicator-navigation.patch
                      │
                      │ creates (add-only, -p1)
                      ▼
  web/modules/contrib/environment_indicator/
    └── modules/
          ├── environment_indicator_navigation/   ← this patch
          │     ├── .info.yml   (deps: environment_indicator, navigation)
          │     ├── .libraries.yml
          │     ├── .module     (page_attachments, preprocess_html)
          │     ├── css/navigation.css
          │     └── README.md
          ├── environment_indicator_toolbar/      ← shipped
          └── environment_indicator_ui/           ← shipped

  When a release ships its own environment_indicator_navigation,
  the add-only patch fails to apply and the build stops - the
  signal to drop the patch.

@AlexSkrypnyk AlexSkrypnyk added A1 Board worker 1 AUTOMERGE Pull request has been approved and set to automerge labels Jul 30, 2026
@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The do_base module now integrates the environment indicator with the navigation sidebar using conditional library attachment, CSS variables, and border styling. HTML preprocessing removes the full-width indicator markup while preserving related attachments and cache metadata. Unit and Behat tests cover eligibility and role-specific rendering.

Changes

Environment indicator integration

Layer / File(s) Summary
Indicator assets and attachment hook
web/modules/custom/do_base/src/Hook/EnvironmentIndicatorHook.php, web/modules/custom/do_base/css/*, web/modules/custom/do_base/do_base.libraries.yml
Adds conditional environment indicator library attachment based on module availability, permissions, and active environment configuration. Defines sidebar border styling using CSS variables.
HTML preprocessing and render cleanup
web/modules/custom/do_base/src/Hook/EnvironmentIndicatorHook.php
Adds the environment color CSS variable and retains only indicator attachments and cache metadata while removing the full-width indicator markup.
Indicator behavior validation
web/modules/custom/do_base/tests/src/Unit/EnvironmentIndicatorHookTest.php, tests/behat/bootstrap/FeatureContext.php, tests/behat/features/environment_indicator_access.feature
Tests applicability, cacheability, HTML output, render-array handling, computed styles, and administrator/content-author scenarios.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant DrupalPage
  participant EnvironmentIndicatorHook
  participant ModuleHandler
  participant Account
  participant EnvironmentConfig
  participant HtmlOutput
  DrupalPage->>EnvironmentIndicatorHook: invoke pageAttachments
  EnvironmentIndicatorHook->>ModuleHandler: check required modules
  EnvironmentIndicatorHook->>Account: check required permissions
  EnvironmentIndicatorHook->>EnvironmentConfig: read active environment
  EnvironmentIndicatorHook->>DrupalPage: attach library and cache metadata
  DrupalPage->>EnvironmentIndicatorHook: invoke preprocessHtml
  EnvironmentIndicatorHook->>HtmlOutput: append color CSS variable
  EnvironmentIndicatorHook->>HtmlOutput: retain indicator attachments and cache metadata
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes implement the requested Navigation module integration and show the environment as a colored sidebar stripe.
Out of Scope Changes check ✅ Passed The modifications are limited to the sidebar stripe feature, its CSS, hook wiring, and tests; no unrelated scope stands out.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: integrating the environment indicator as a visual element in Drupal’s Navigation sidebar.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/270-env-indicator-nav

Comment @coderabbitai help to get the list of available commands.

@github-actions

This comment has been minimized.

@codecov-commenter

codecov-commenter commented Jul 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.16%. Comparing base (c6c0c34) to head (1756fb6).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop     #274   +/-   ##
========================================
  Coverage    89.16%   89.16%           
========================================
  Files           15       15           
  Lines          203      203           
========================================
  Hits           181      181           
  Misses          22       22           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@AlexSkrypnyk AlexSkrypnyk added the Needs review Pull request needs a review from assigned developers label Jul 30, 2026
@AlexSkrypnyk
AlexSkrypnyk temporarily deployed to PR-274 July 30, 2026 07:36 Inactive
@AlexSkrypnyk AlexSkrypnyk changed the title [#270] Showed the environment as a coloured stripe on the Navigation sidebar. [#270] Added a patched 'environment_indicator_navigation' submodule showing the environment on the Navigation sidebar. Jul 30, 2026
@github-actions

Copy link
Copy Markdown

Code coverage (threshold: 80%)

  Classes: 50.00% (7/14)
  Methods: 73.33% (22/30)
  Lines:   93.21% (357/383)
Per-class coverage
Drupal\do_content_api\EventSubscriber\JsonApiWriteGateSubscriber
  Methods:  66.67% ( 2/ 3)   Lines:  88.89% (  8/  9)
Drupal\do_content_api\Hook\EntityCreateAccessHook
  Methods: 100.00% ( 1/ 1)   Lines: 100.00% (  9/  9)
Drupal\do_content_api\Hook\ModerationPolicyHook
  Methods:  50.00% ( 1/ 2)   Lines:  93.75% ( 15/ 16)
Drupal\do_content_api\Routing\RouteSubscriber
  Methods: 100.00% ( 1/ 1)   Lines: 100.00% (  6/  6)
Drupal\do_feed\FeedUrlBuilder
  Methods: 100.00% ( 4/ 4)   Lines: 100.00% ( 18/ 18)
Drupal\do_feed\Form\FeedSettingsForm
  Methods: 100.00% ( 4/ 4)   Lines: 100.00% ( 15/ 15)
Drupal\do_feed\Hook\EntityDeleteHook
  Methods:  50.00% ( 1/ 2)   Lines:  92.31% ( 12/ 13)
Drupal\do_feed\Hook\EntityPresaveHook
  Methods: 100.00% ( 4/ 4)   Lines: 100.00% ( 54/ 54)
Drupal\do_feed\Hook\PreprocessParagraphHook
  Methods: 100.00% ( 2/ 2)   Lines: 100.00% ( 14/ 14)
Drupal\do_feed\Hook\PreprocessViewsViewRowRssHook
  Methods: 100.00% ( 1/ 1)   Lines: 100.00% (  3/  3)
Drupal\do_feed\Hook\ViewsPreViewHook
  Methods:  50.00% ( 1/ 2)   Lines:  96.43% ( 27/ 28)

@AlexSkrypnyk
AlexSkrypnyk merged commit 44cae56 into develop Jul 30, 2026
14 of 15 checks passed
@AlexSkrypnyk
AlexSkrypnyk deleted the feature/270-env-indicator-nav branch July 30, 2026 23:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A1 Board worker 1 AUTOMERGE Pull request has been approved and set to automerge Needs review Pull request needs a review from assigned developers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add better integration of the Environment Indicator with the new Navigation module

2 participants