Skip to content

Configs refactor#31

Merged
apganapa-adobe merged 7 commits intodevfrom
configs-refactor
Nov 16, 2025
Merged

Configs refactor#31
apganapa-adobe merged 7 commits intodevfrom
configs-refactor

Conversation

@qiyundai
Copy link
Collaborator

@qiyundai qiyundai commented Nov 14, 2025

Refactor Configuration Management to Centralized Assets

Overview

This PR refactors the configuration management system to use centralized, multi-sheet JSON files hosted in the content repository, replacing the previous distributed approach. The changes simplify configuration management and improve maintainability across the event-libs codebase.

Key Changes

1. Dictionary Manager Refactoring ✨

  • Consolidated Dictionary Fetching: Changed from individual placeholders.json fetches per sheet to a single multi-sheet dictionary.json fetch
  • Smart Caching: Implemented static-level caching with promise deduplication to prevent redundant fetches
  • Simplified API:
    • Changed from addSheet({ config, sheet }) to initialize() - one call loads all sheets
    • Updated getValue(key, sheet) to default to 'data' sheet (was 'default')
    • Dictionary now loads from ${domain}${prefix}/event-libs/assets/configs/dictionary.json
  • Domain Resolution: Uses import.meta.url to determine domain dynamically instead of requiring config

2. RSVP Configuration Refactoring 🔧

  • New Config Location: RSVP form configs now load from /event-libs/assets/configs/rsvp/{cloud-type}.json
  • Simplified URL Construction: Added getRsvpConfigUrl() helper that uses import.meta.url for domain resolution
  • Removed Dependencies: Eliminated reliance on rsvp-config-location metadata and SP-specific logic
  • Better Error Handling: Improved error messages when config loading fails

3. Promotional Content Refactoring 🎯

  • Updated Path: Promotional content now loads from /event-libs/assets/configs/promotional-content.json
  • Added getPromotionalContentUrl(): Helper function for consistent URL construction using import.meta.url
  • Enhanced Error Handling: Better error messages and graceful degradation

4. RSVP Button Improvements 🐛

  • Fixed Double Initialization: Added data-rsvp-initialized flag to prevent duplicate event handlers
  • Loading State Fix: Properly stores and restores original button text even when loading state is shown
  • Uses data-rsvp-original-text: Persists original text in dataset for reliable restoration

5. CSS Enhancements 🎨

Added new styles for RSVP buttons:

  • Flexbox layout with gap and centering
  • Disabled state styling (opacity + pointer-events)
  • No-event state styling

6. Code Cleanup 🧹

  • Removed unused imports: Removed decorateEvent import from chrono-box
  • Removed unnecessary calls: Cleaned up decorateEvent calls that weren't needed
  • Simplified form link handling: Improved form container detection and creation logic
  • Removed mailto template logic: Cleaned up host-email template processing

7. Documentation Updates 📚

Updated dictionary-manager-consolidation.md with:

  • New multi-sheet architecture details
  • Updated usage examples
  • Explanation of caching and performance optimizations
  • Documentation of the new initialization pattern

Migration Path

Before:

// Multiple sheet fetches
await dictionaryManager.addSheet({ config, sheet: 'default' });
await dictionaryManager.addSheet({ config, sheet: 'rsvp-fields' });

// Get value
const value = dictionaryManager.getValue('my-key', 'default');

After:

// Single initialization loads all sheets
await dictionaryManager.initialize();

// Get value (default sheet is now 'data')
const value = dictionaryManager.getValue('my-key');
const fieldValue = dictionaryManager.getValue('field-key', 'rsvp-fields');

Testing

  • Updated dictionary-manager.test.js with comprehensive tests for:
    • Multi-sheet loading from single fetch
    • Fetch caching and deduplication
    • Both 'data' and 'rsvp-fields' sheet access
    • Static cache clearing for test isolation

Breaking Changes

⚠️ Content Repository Updates Required:

  • Dictionary files must be moved to /event-libs/assets/configs/dictionary.json (multi-sheet format)
  • RSVP configs must be moved to /event-libs/assets/configs/rsvp/{cloudtype}.json
  • Promotional content must be moved to /event-libs/assets/configs/promotional-content.json

Performance Improvements

  • Reduced Network Calls: One fetch loads all dictionary sheets (was 2+ fetches)
  • Better Caching: Static-level cache with promise deduplication prevents redundant fetches
  • Faster Initialization: Parallel loading eliminated by single-fetch approach

Files Changed

  • event-libs/v1/utils/dictionary-manager.js - Core refactoring
  • event-libs/v1/blocks/events-form/events-form.js - RSVP config updates
  • event-libs/v1/blocks/promotional-content/promotional-content.js - Config path updates
  • event-libs/v1/utils/decorate.js - Dictionary initialization and button handling
  • event-libs/v1/libs-styles.css - New RSVP button styles
  • test/unit/scripts/dictionary-manager.test.js - Updated tests
  • docs/dictionary-manager-consolidation.md - Documentation updates

Stats

  • 8 files changed
  • 377 insertions(+)
  • 154 deletions(-)

Test URLs:

@aem-code-sync
Copy link

aem-code-sync bot commented Nov 14, 2025

Hello, I'm the AEM Code Sync Bot and I will run some actions to deploy your branch and validate page speed.
In case there are problems, just click a checkbox below to rerun the respective action.

  • Re-run PSI checks
  • Re-sync branch
Commits

@aem-code-sync
Copy link

aem-code-sync bot commented Nov 14, 2025

Page Scores Audits Google
📱 /?martech=off PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS PSI
🖥️ /?martech=off PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS PSI

@apganapa-adobe apganapa-adobe merged commit e3234df into dev Nov 16, 2025
6 of 7 checks passed
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.

2 participants