-
Notifications
You must be signed in to change notification settings - Fork 15
refactors to generalize icon warnings to make usage flexible #2837
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: experiment-design-refresh
Are you sure you want to change the base?
refactors to generalize icon warnings to make usage flexible #2837
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR refactors the warning icon system for feature flags to make it more flexible and extensible. It fixes issue #2832 by enabling warnings to display on the root page and provides a framework for easily adding new warning types in the future.
Changes:
- Replaced boolean
showWarningproperty with an array-basedwarningMessageKeyssystem that accepts translation keys - Moved translation handling from templates into the
CommonWarningIconComponentwhich now formats multiple warnings as a bulleted list - Refactored selectors to return arrays of translation keys instead of boolean flags, making the system extensible for future warning types
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
frontend/projects/upgrade/src/assets/i18n/en.json |
Renamed translation key from feature-flags.global-status-warning-tooltip.text to feature-flags.warning.no-enabled-inclusions.text for better organization |
frontend/projects/upgrade/src/app/shared-standalone-component-lib/components/common-warning-icon/common-warning-icon.component.ts |
Added translation handling, formatting logic for multiple warnings, and lifecycle hooks to handle translation key arrays |
frontend/projects/upgrade/src/app/shared-standalone-component-lib/components/common-warning-icon/common-warning-icon.component.html |
Updated to bind to internally formatted warning message instead of accepting external string |
frontend/projects/upgrade/src/app/shared-standalone-component-lib/components/common-status-indicator-chip/common-status-indicator-chip.component.ts |
Changed input from warningMessage string to warningMessageKeys array and updated documentation |
frontend/projects/upgrade/src/app/shared-standalone-component-lib/components/common-status-indicator-chip/common-status-indicator-chip.component.html |
Updated to pass warning message keys array and check array length instead of string truthiness |
frontend/projects/upgrade/src/app/shared-standalone-component-lib/components/common-section-card-title-header/common-section-card-title-header.component.ts |
Changed input property to accept translation key arrays and updated documentation examples |
frontend/projects/upgrade/src/app/shared-standalone-component-lib/components/common-section-card-title-header/common-section-card-title-header.component.html |
Removed translation pipe usage and updated to pass translation key arrays directly |
frontend/projects/upgrade/src/app/features/dashboard/feature-flags/pages/feature-flag-root-page/feature-flag-root-page-content/feature-flag-root-section-card/feature-flag-root-section-card-table/feature-flag-root-section-card-table.component.ts |
Renamed observable from warningStatusForAllFlags$ to warningKeysForAllFlags$ |
frontend/projects/upgrade/src/app/features/dashboard/feature-flags/pages/feature-flag-root-page/feature-flag-root-page-content/feature-flag-root-section-card/feature-flag-root-section-card-table/feature-flag-root-section-card-table.component.html |
Updated to use warning keys array with fallback to empty array |
frontend/projects/upgrade/src/app/features/dashboard/feature-flags/pages/feature-flag-details-page/feature-flag-details-page-content/feature-flag-overview-details-section-card/feature-flag-overview-details-section-card.component.ts |
Renamed observable from shouldShowWarningForSelectedFlag$ to warningKeysForSelectedFlag$ |
frontend/projects/upgrade/src/app/features/dashboard/feature-flags/pages/feature-flag-details-page/feature-flag-details-page-content/feature-flag-overview-details-section-card/feature-flag-overview-details-section-card.component.html |
Simplified template to directly bind warning keys observable without conditional translation |
frontend/projects/upgrade/src/app/core/feature-flags/store/feature-flags.selectors.ts |
Refactored to use extensible helper functions that return arrays of translation keys instead of boolean values |
frontend/projects/upgrade/src/app/core/feature-flags/feature-flags.service.ts |
Updated property names to reflect new warning keys approach |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
frontend/projects/upgrade/src/app/core/feature-flags/store/feature-flags.selectors.ts
Show resolved
Hide resolved
| export const selectWarningKeysForSelectedFlag = createSelector(selectSelectedFeatureFlag, (flag: FeatureFlag) => | ||
| getWarningKeysForFlag(flag) | ||
| ); |
Copilot
AI
Jan 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The selector doesn't handle the case where 'flag' is null or undefined. If selectSelectedFeatureFlag returns undefined, getWarningKeysForFlag will be called with undefined, and hasNoEnabledInclusionsWarning will fail on the optional chaining checks. While optional chaining prevents errors, it would be more robust to add an early return check at the beginning of getWarningKeysForFlag to handle null/undefined flags explicitly.
| const getWarningKeysForFlag = (flag: FeatureFlag): string[] => { | ||
| const warnings: string[] = []; | ||
|
|
||
| // Selector for the selected feature flag | ||
| export const selectShouldShowWarningForSelectedFlag = createSelector(selectSelectedFeatureFlag, (flag: FeatureFlag) => | ||
| shouldShowWarningForFlag(flag) | ||
| // Check each warning type (in future more types can be added here) | ||
| if (hasNoEnabledInclusionsWarning(flag)) { | ||
| warnings.push('feature-flags.warning.no-enabled-inclusions.text'); | ||
| } | ||
|
|
||
| return warnings; | ||
| }; |
Copilot
AI
Jan 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The getWarningKeysForFlag helper function should have a null/undefined guard at the beginning to handle cases where flag is not provided. Add an early return: 'if (!flag) return [];' at the start of the function to make the code more robust and explicit about handling missing flags.
|
hold up on this one until #2840 is merged, as it may have some useful tooltip functions i can borrow. |
…fix/doswalt/2832-refactor-warning-icon-message-usage
…or-warning-icon-message-usage
| } | ||
| const translatedMessages = this.warningMessageKeys.map((key) => this.translateService.instant(key)); | ||
| this.formattedWarningMessage = '• ' + translatedMessages.join('\n• '); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor UX suggestion: When there’s only one warning, showing it as plain text (no bullet) feels cleaner. I think bullets make more sense once there are multiple warnings.
this fixes the issue in #2832, it will now show up on the root page; it required a bit more of a fixup due as it was a little inflexible and confusingly worded in some places (showWarning looks like a general thing, but it only shows one specific warning, etc).
Will make implementing for experiments straightforward, and adding future errors types should be really simple, just add a selector helper function to check in the
getWarningKeysForFlagfunction , and a message key in en.json.