Skip to content

PP-2668 - #5

Merged
sergak01 merged 5 commits into
developfrom
pp-2668
Jan 22, 2026
Merged

PP-2668#5
sergak01 merged 5 commits into
developfrom
pp-2668

Conversation

@sergak01

Copy link
Copy Markdown
Contributor

🚀 Enhance integrateMiTopBar with Selective Configuration Options

Summary

This PR enhances the integrateMiTopBar configuration option to support both boolean and object-based configuration, allowing users to selectively enable addRootElement and addSharedComponentsScripts features independently. Additionally, fixes a null validation bug that could cause crashes.

Changes

✨ Feature Enhancement

  • Enhanced integrateMiTopBar configuration: Now supports both boolean (true/false) and object-based configuration
    • Boolean mode: true enables both features, false disables (backward compatible)
    • Object mode: Selective enabling via { addRootElement?: boolean, addSharedComponentsScripts?: boolean }
  • Updated plugin implementation: miTopBarPlugin now accepts configuration and conditionally injects HTML elements and scripts
  • Improved type safety: Enhanced TypeScript types and validation logic

🔧 Bug Fix

  • Fixed null validation bug: Added explicit null check to prevent TypeError when integrateMiTopBar is null
    • JavaScript's typeof null === "object" quirk was causing crashes when accessing properties on null values
    • Now gracefully rejects null with proper error message

📚 Documentation

  • Updated README.md: Added comprehensive documentation for new configuration options
    • Configuration options explanation
    • Multiple usage examples (boolean, object, partial integration)
    • Clear descriptions of what each option does

🧪 Testing

  • Comprehensive test coverage: Added 9 new test cases covering:
    • Object configuration validation
    • Invalid type handling (string, number, null)
    • Invalid property types
    • Various valid configuration combinations
    • Edge cases (empty objects, false values)

Technical Details

Files Changed

  • src/plugin.ts - Enhanced validation logic and type definitions
  • src/plugins/mi-topbar-plugin.ts - Updated plugin to accept and use configuration
  • src/index.ts - Pass configuration to plugin
  • tests/unit/plugin/plugin.normalize.spec.ts - Added comprehensive test coverage
  • README.md - Updated documentation

Statistics

  • 5 files changed
  • 520 insertions(+), 165 deletions(-)
  • 4 commits

Commits

  • cbb9a6c - feat(plugin): enhance integrateMiTopBar with selective configuration options
  • e0c3175 - test(plugin): add tests for integrateMiTopBar object configuration
  • fe14999 - docs(readme): update integrateMiTopBar configuration documentation
  • df35e2a - fix(plugin): add null check for integrateMiTopBar validation

Breaking Changes

None - Fully backward compatible. Existing boolean configurations continue to work as before.

Usage Examples

Simple Boolean (Backward Compatible)

integrateMiTopBar: true  // Enables both features

Advanced Object Configuration

integrateMiTopBar: {
  addRootElement: true,              // Add root element for React
  addSharedComponentsScripts: true,  // Add MI scripts and styles
}

Partial Integration

integrateMiTopBar: {
  addRootElement: false,             // Manual root element
  addSharedComponentsScripts: true,  // Add scripts only
}

Testing

  • ✅ All existing tests pass
  • ✅ New test cases added and passing
  • ✅ Validation properly rejects invalid configurations
  • ✅ Null handling verified

Ready for Review

@sergak01 sergak01 self-assigned this Jan 22, 2026
@sergak01
sergak01 merged commit d4d2d35 into develop Jan 22, 2026
2 checks passed
@sergak01
sergak01 deleted the pp-2668 branch January 22, 2026 11:19
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.

1 participant