-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[PM-26031] Drawer Service State Refactoring #16580
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
Conversation
…ith BehaviorSubject - Replace individual drawer properties with unified drawerDetailsSubject - Add reactive Observable getters for drawer state checking - Update all drawer methods to use centralized state management
- Add private _isDrawerOpen property for internal state tracking - Subscribe to drawerDetails$ changes with takeUntilDestroyed cleanup - Implement getter/setter for isDrawerOpen to sync component <-> service - Enable two-way binding while maintaining reactive patterns
…servable patterns - Replace dataService.openDrawer with isDrawerOpen special case getter - Wrap drawer in @if block with drawerDetails$ | async for single subscription - Update isActiveDrawerType() calls to reactive isActiveDrawerType$() | async - Replace direct property access with unified drawerDetails object - Use modern @if control flow syntax for better performance
…bservable patterns - Replace dataService.drawerInvokerId with drawerDetails$ | async in card highlighting - Update app-table-row-scrollable input from isDrawerIsOpenForThisRecord function to openApplication string
…ive observable patterns - Replace dataService.drawerInvokerId with drawerDetails$ | async in card highlighting - Update table component binding from isDrawerIsOpenForThisRecord to openApplication - Use reactive drawer state checking for consistent behavior with all-applications
- Remove unused trackByFunction that's no longer needed in template - Remove getSelectedUrls function that's not used anywhere - Remove isDrawerOpenForTableRow replaced by reactive openApplication binding - Clean up unused ApplicationHealthReportDetail import - Simplifies component interface following reactive pattern migration
…nctions - Remove unused trackByFunction that's no longer needed in template - Remove isDrawerOpenForTableRow replaced by reactive openApplication binding
…s with string comparison - Replace isDrawerIsOpenForThisRecord(row.applicationName) with row.applicationName === openApplication - Use direct string comparison instead of function calls for better performance - Matches updated component input from function to string property - Simplifies template logic following reactive pattern migration
… setter methods - Add toggle logic to check if same drawer type and invoker are already open - Close drawer when clicking same button twice (preserves original UX) - Switch drawer content when clicking different button - Maintains reactive patterns while restoring expected behavior
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #16580 +/- ##
==========================================
- Coverage 38.30% 38.29% -0.01%
==========================================
Files 3404 3404
Lines 97592 97591 -1
Branches 14683 14692 +9
==========================================
- Hits 37380 37373 -7
- Misses 58585 58591 +6
Partials 1627 1627 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Great job! No new security vulnerabilities introduced in this pull request |
- the logic replacing these functions will be in pr16523
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.
Added some comments to improve duplicate subscriptions. You can most likely remove the observable function that checks the drawer type if it's not used outside of the components.
...den_license/bit-common/src/dirt/reports/risk-insights/services/risk-insights-data.service.ts
Outdated
Show resolved
Hide resolved
...den_license/bit-common/src/dirt/reports/risk-insights/services/risk-insights-data.service.ts
Outdated
Show resolved
Hide resolved
...den_license/bit-common/src/dirt/reports/risk-insights/services/risk-insights-data.service.ts
Outdated
Show resolved
Hide resolved
...den_license/bit-common/src/dirt/reports/risk-insights/services/risk-insights-data.service.ts
Outdated
Show resolved
Hide resolved
[ngClass]="{ | ||
'tw-bg-primary-100': dataService.drawerInvokerId === 'allAppsOrgAtRiskMembers', | ||
'tw-bg-primary-100': | ||
(dataService.drawerDetails$ | async)?.invokerId === 'allAppsOrgAtRiskMembers', |
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.
dataService.drawerDetails$ | async)
. Each async usage creates a new subscription. You can create a variable above the card to capture the drawer details in the html.
bitwarden_license/bit-web/src/app/dirt/access-intelligence/critical-applications.component.html
Outdated
Show resolved
Hide resolved
bitwarden_license/bit-web/src/app/dirt/access-intelligence/risk-insights.component.html
Outdated
Show resolved
Hide resolved
</div> | ||
</bit-drawer-body> | ||
</ng-container> | ||
@if (dataService.isActiveDrawerType$(drawerTypes.AppAtRiskMembers) | async) { |
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.
bitwarden_license/bit-web/src/app/dirt/access-intelligence/risk-insights.component.html
Outdated
Show resolved
Hide resolved
…e function per review feedback - Keep original isActiveDrawerType() as boolean function using drawerDetailsSubject.value - Maintain isActiveDrawerType$() as Observable version for reactive templates - Apply same pattern to isDrawerOpenForInvoker() for consistency - Addresses review feedback to preserve existing function signatures
…setter methods per review feedback
…on for drawer state per review feedback
…ription for drawer state per review feedback
…ions per review feedback
apps/browser/src/platform/system-notifications/browser-system-notification.service.ts
Outdated
Show resolved
Hide resolved
…omment removed by prettier
|
🎟️ Tracking
https://bitwarden.atlassian.net/browse/PM-26031
📔 Objective
Jira Description:
The draft pull request includes changes to the drawer state to be more easily consumable. This scope of this ticket is to capture the changes made to the drawer state and usage across components.
Changes in scope:
Create the drawerDetailsSubject in the RiskInsightsDataService and update the usage regarding this state
Update angular components that are using this state
Refactors the Risk Insights drawer state management from individual properties to a unified reactive observable pattern, improving maintainability and performance. Based on patterns established in draft PR #16005.
Changes by File:
Core Service Layer
risk-insights-data.service.ts
:openDrawer
,drawerInvokerId
, etc.) with unifieddrawerDetailsSubject
BehaviorSubjectdrawerDetails$
,isActiveDrawerType$()
,isDrawerOpenForInvoker$()
)DrawerDetails
objectMain Component Integration
risk-insights.component.ts
:isDrawerOpen
to sync component two-way binding with service statedrawerDetails$
withtakeUntilDestroyed()
cleanuprisk-insights.component.html
:@if (dataService.drawerDetails$ | async; as drawerDetails)
patternisActiveDrawerType()
calls to reactiveisActiveDrawerType$() | async
drawerDetails
object throughout template for better performanceApplications Components
all-applications.component.html
&critical-applications.component.html
:dataService.drawerInvokerId
comparisons with(dataService.drawerDetails$ | async)?.invokerId
all-applications.component.ts
&critical-applications.component.ts
:isDrawerOpenForTableRow()
andtrackByFunction()
methodsTable Component
app-table-row-scrollable.component.ts
:isDrawerIsOpenForThisRecord
function toopenApplication
string propertyapp-table-row-scrollable.component.html
:row.applicationName === openApplication
)Eliminates 9 function calls per table row for better rendering performanceKey Benefits
DrawerDetails
interface provides strong typing throughoutTesting Notes
⏰ Reminders before review
🦮 Reviewer guidelines
:+1:
) or similar for great changes:memo:
) or ℹ️ (:information_source:
) for notes or general info:question:
) for questions:thinking:
) or 💭 (:thought_balloon:
) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion:art:
) for suggestions / improvements:x:
) or:warning:
) for more significant problems or concerns needing attention:seedling:
) or ♻️ (:recycle:
) for future improvements or indications of technical debt:pick:
) for minor or nitpick changes