Skip to content

Add a new cookie policy/category manager#521

Merged
microstudi merged 69 commits into
mainfrom
feature/add_new_cookie_policy
Mar 24, 2026
Merged

Add a new cookie policy/category manager#521
microstudi merged 69 commits into
mainfrom
feature/add_new_cookie_policy

Conversation

@ElviaBth

@ElviaBth ElviaBth commented Feb 20, 2026

Copy link
Copy Markdown
Contributor

🎩 What? Why?
Add a new cookie policy/category manager.

📌 Related Issues
Link your PR to an issue
Related to #?
Fixes #520

📷 Screenshots
image
menu

image

admin categories view

image

admin category items view

image modal items

♥️ Thank you!

@ElviaBth ElviaBth changed the title add cookie_manager to the menu Add a new cookie policy/category manager Feb 20, 2026
@codecov

codecov Bot commented Feb 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.66667% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.09%. Comparing base (5e17a61) to head (bafa1eb).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...m/decidim_awesome/admin/cookie_items_controller.rb 92.85% 5 Missing ⚠️
...ecidim/decidim_awesome/admin/update_cookie_item.rb 89.47% 2 Missing ⚠️
...idim_awesome/admin/cookie_categories_controller.rb 96.15% 2 Missing ⚠️
...decidim_awesome/admin/create_cookie_item_preset.rb 96.15% 1 Missing ⚠️
...m/decidim_awesome/admin/destroy_cookie_category.rb 93.75% 1 Missing ⚠️
...cidim/decidim_awesome/admin/destroy_cookie_item.rb 94.73% 1 Missing ⚠️
...im/decidim_awesome/admin/update_cookie_category.rb 95.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #521      +/-   ##
==========================================
+ Coverage   94.60%   97.09%   +2.49%     
==========================================
  Files         183      196      +13     
  Lines        4948     5335     +387     
==========================================
+ Hits         4681     5180     +499     
+ Misses        267      155     -112     

☔ View full report in Codecov by Sentry.
📢 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.

@ElviaBth ElviaBth marked this pull request as ready for review March 2, 2026 15:28
@ElviaBth ElviaBth requested a review from microstudi March 2, 2026 15:28
@microstudi microstudi requested a review from Copilot March 2, 2026 15:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an admin-facing “Cookie Management” feature to Decidim Awesome to configure cookie consent categories and items via UI (backed by AwesomeConfig), and uses a custom data consent cell to render configured categories on the public side.

Changes:

  • Add admin CRUD for cookie categories and cookie items, stored under AwesomeConfig[:cookie_management].
  • Add a custom DataConsentCell + view to render configured cookie categories/items (with visibility rules).
  • Register new admin menu entry, feature flag, routes, and translations; add specs for the new behavior.

Reviewed changes

Copilot reviewed 43 out of 43 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
spec/system/public/voting_cards_spec.rb Adds extra synchronization assertions around voting UI.
spec/forms/admin/cookie_item_form_spec.rb New validation coverage for cookie item form.
spec/forms/admin/cookie_category_form_spec.rb New validation coverage for cookie category form, including visibility states.
spec/controllers/admin/cookie_items_controller_spec.rb New controller specs for cookie items CRUD.
spec/controllers/admin/cookie_categories_controller_spec.rb New controller specs for cookie categories CRUD.
spec/commands/admin/update_cookie_item_spec.rb New command spec for updating a cookie item.
spec/commands/admin/update_cookie_category_spec.rb New command spec for updating a cookie category.
spec/commands/admin/destroy_cookie_item_spec.rb New command spec for deleting/resetting a cookie item.
spec/commands/admin/destroy_cookie_category_spec.rb New command spec for deleting/resetting a cookie category.
spec/commands/admin/create_cookie_item_spec.rb New command spec for creating a cookie item (including duplicate checks).
spec/commands/admin/create_cookie_category_spec.rb New command spec for creating a cookie category (including duplicate checks).
spec/cells/data_consent_cell_spec.rb New cell spec for rendering configured categories/items.
lib/decidim/decidim_awesome/test/initializer.rb Enables :cookie_management in test initializer config list.
lib/decidim/decidim_awesome/menu.rb Adds admin menu entry for cookie management and adjusts menu positions.
lib/decidim/decidim_awesome/has_cookie_categories.rb Introduces default-category helpers, normalization, visibility logic, and reset/modified checks.
lib/decidim/decidim_awesome/engine.rb Requires cookie category helpers and registers a new icon.
lib/decidim/decidim_awesome/awesome.rb Adds config_accessor :cookie_management.
lib/decidim/decidim_awesome/admin_engine.rb Adds routes for cookie categories and nested cookie items.
config/locales/en.yml Adds admin UI strings and attribute labels for cookie management.
app/views/layouts/decidim/_application.html.erb Switches data consent cell to the custom one when feature enabled.
app/views/decidim/decidim_awesome/admin/cookie_items/new.html.erb New item creation UI.
app/views/decidim/decidim_awesome/admin/cookie_items/index.html.erb New items list UI with actions/reset logic.
app/views/decidim/decidim_awesome/admin/cookie_items/edit.html.erb New item edit UI.
app/views/decidim/decidim_awesome/admin/cookie_items/_form.html.erb Form partial for cookie items.
app/views/decidim/decidim_awesome/admin/cookie_categories/new.html.erb New category creation UI.
app/views/decidim/decidim_awesome/admin/cookie_categories/index.html.erb New categories list UI with actions/reset logic.
app/views/decidim/decidim_awesome/admin/cookie_categories/edit.html.erb New category edit UI.
app/views/decidim/decidim_awesome/admin/cookie_categories/_form.html.erb Form partial for cookie categories.
app/overrides/decidim/meetings/layouts/live_event/replace_data_consent.html.erb.deface Replaces the consent cell in meetings live event layout when enabled.
app/forms/decidim/decidim_awesome/admin/cookie_item_form.rb New admin form object for cookie items.
app/forms/decidim/decidim_awesome/admin/cookie_category_form.rb New admin form object for cookie categories.
app/controllers/decidim/decidim_awesome/admin/cookie_items_controller.rb New controller for managing cookie items.
app/controllers/decidim/decidim_awesome/admin/cookie_categories_controller.rb New controller for managing cookie categories.
app/controllers/concerns/decidim/decidim_awesome/admin/cookie_management_helpers.rb Shared config access + helpers for cookie management controllers.
app/controllers/concerns/decidim/decidim_awesome/admin/cookie_breadcrumb_helper.rb Adds breadcrumb helper for the new admin pages.
app/commands/decidim/decidim_awesome/admin/update_cookie_item.rb Command to update an item in config.
app/commands/decidim/decidim_awesome/admin/update_cookie_category.rb Command to update a category in config.
app/commands/decidim/decidim_awesome/admin/destroy_cookie_item.rb Command to delete/reset an item.
app/commands/decidim/decidim_awesome/admin/destroy_cookie_category.rb Command to delete/reset a category.
app/commands/decidim/decidim_awesome/admin/create_cookie_item.rb Command to create an item.
app/commands/decidim/decidim_awesome/admin/create_cookie_category.rb Command to create a category.
app/cells/decidim/decidim_awesome/data_consent_cell.rb Custom consent cell that reads categories from AwesomeConfig.
app/cells/decidim/decidim_awesome/data_consent/category.erb Custom consent category rendering including items table.
Comments suppressed due to low confidence (2)

config/locales/en.yml:563

  • The strings cookie_items.*.cannot_edit_mandatory_category / cannot_remove_mandatory_category are phrased as applying to any mandatory category, but the enforcement checks default_category? && mandatory. Either clarify the text to match the actual restriction (default mandatory categories) or enforce the restriction for all mandatory categories.
            cannot_edit_mandatory_category: Items from mandatory categories cannot
              be edited
            save: Save
            title: Edit cookie item
          index:
            back_to_categories: Back to categories
            cannot_edit_mandatory_category: Items from mandatory categories cannot
              be edited
            cannot_remove_default: Default items cannot be removed
            cannot_remove_mandatory_category: Items from mandatory categories cannot
              be removed

config/locales/en.yml:526

  • The translation key cookie_categories.index.cannot_edit_mandatory says mandatory categories cannot be edited, but the UI logic only disables editing for default mandatory categories (is_default && is_mandatory). Either adjust the copy to match the behavior (e.g. "Mandatory default categories...") or extend the restriction to all mandatory categories for consistency.
            cannot_edit_mandatory: Mandatory categories cannot be edited
            cannot_remove_default: Default categories cannot be removed

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread app/controllers/decidim/decidim_awesome/admin/cookie_items_controller.rb Outdated
Comment thread app/cells/concerns/decidim/decidim_awesome/has_cookie_categories.rb Outdated
Comment thread app/cells/decidim/decidim_awesome/data_consent_cell.rb Outdated
Comment thread app/forms/decidim/decidim_awesome/admin/cookie_item_form.rb
Comment thread spec/cells/data_consent_cell_override_spec.rb Outdated
Comment thread app/cells/concerns/decidim/decidim_awesome/has_cookie_categories.rb Outdated

@microstudi microstudi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't done a profound review but i see that you can improve some parts by trying not to repead code around. Check specially at the "CookieCategory", "CookieItem" classes. It seems to me that they do much more than needed

Comment thread docs/tweaks/ui-theming-navigation.md
Comment thread app/services/decidim/decidim_awesome/cookie_category.rb Outdated
Comment thread app/services/decidim/decidim_awesome/cookie_item.rb Outdated
@microstudi microstudi requested a review from Copilot March 19, 2026 15:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 55 out of 57 changed files in this pull request and generated 16 comments.

Comment thread app/forms/decidim/decidim_awesome/admin/cookie_category_form.rb Outdated
Comment thread app/forms/decidim/decidim_awesome/admin/cookie_category_form.rb
Comment thread app/forms/decidim/decidim_awesome/admin/cookie_item_form.rb Outdated
Comment thread app/forms/decidim/decidim_awesome/admin/cookie_item_form.rb Outdated
Comment thread app/controllers/decidim/decidim_awesome/admin/cookie_items_controller.rb Outdated
Comment thread docs/tweaks/ui-theming-navigation.md Outdated
Comment thread config/locales/en.yml
Comment thread config/locales/en.yml Outdated
Comment thread config/locales/en.yml
Comment thread app/controllers/decidim/decidim_awesome/admin/cookie_categories_controller.rb Outdated

@microstudi microstudi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ElviaBth I've made the latest changes in the code in order to simplificate and solve a couple of bugs.

Now it only requires to add a couple of system tests, please do:

  • Create an admin system test editing/creating/deleting categories and items and adding presets.
  • Create a public system test where we can see that the default cookies are shown if no editions are made and the corresponding overrides if they are.

@microstudi microstudi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! lets gooo!

@microstudi microstudi merged commit dd3d9e3 into main Mar 24, 2026
21 of 23 checks passed
@microstudi microstudi deleted the feature/add_new_cookie_policy branch March 24, 2026 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a new cookie policy/category manager

3 participants