Hide "Rotate password" button for Observer role in Recovery Lock modal#45649
Hide "Rotate password" button for Observer role in Recovery Lock modal#45649sharon-fdm wants to merge 2 commits into
Conversation
#42249) Instead of showing a disabled "Rotate password" button with a tooltip for Observers, hide the button entirely when `canRotatePassword` is false. This is consistent with how ManagedAccountModal handles the same prop.
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.
Tip: disable this comment in your organization's Code Review settings.
There was a problem hiding this comment.
Pull request overview
This PR updates the Host details “Recovery Lock password” modal UI to fully hide the “Rotate password” action for users who lack permission (e.g., Observer role), aligning the behavior with existing patterns used in similar modals.
Changes:
- Hide the rotate action by returning
nullwhencanRotatePasswordis false (instead of rendering a disabled/tooltip UI). - Remove the now-unused
TooltipWrapperimport. - Remove the SCSS styling that only applied to the previously-disabled rotate UI state.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| frontend/pages/hosts/details/HostDetailsPage/modals/RecoveryLockPasswordModal/RecoveryLockPasswordModal.tsx | Hide rotate button when canRotatePassword is false; remove tooltip-based disabled rendering and unused import. |
| frontend/pages/hosts/details/HostDetailsPage/modals/RecoveryLockPasswordModal/_styles.scss | Remove styles for the removed disabled rotate button UI state. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const renderRotateButton = () => { | ||
| if (canRotatePassword) { | ||
| return ( | ||
| <Button | ||
| variant="inverse" | ||
| onClick={onRotatePassword} | ||
| disabled={isRotating} | ||
| className={`${baseClass}__rotate-button`} | ||
| > | ||
| <Icon name="refresh" /> | ||
| {isRotating ? "Rotating..." : "Rotate password"} | ||
| </Button> | ||
| ); | ||
| if (!canRotatePassword) { | ||
| return null; | ||
| } | ||
|
|
||
| return ( | ||
| <span className={`${baseClass}__rotate-button--disabled`}> | ||
| <TooltipWrapper | ||
| underline={false} | ||
| showArrow | ||
| position="bottom" | ||
| tipContent="Only users with the maintainer role and above can rotate password." | ||
| > | ||
| <span className={`${baseClass}__rotate-button-content`}> | ||
| <Icon name="refresh" /> | ||
| Rotate password | ||
| </span> | ||
| </TooltipWrapper> | ||
| </span> | ||
| <Button | ||
| variant="inverse" | ||
| onClick={onRotatePassword} | ||
| disabled={isRotating} | ||
| className={`${baseClass}__rotate-button`} | ||
| > | ||
| <Icon name="refresh" /> | ||
| {isRotating ? "Rotating..." : "Rotate password"} | ||
| </Button> |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughRecoveryLockPasswordModal is refactored to hide the "Rotate password" button entirely when the user lacks rotation permission, rather than displaying it as disabled with a tooltip. The TooltipWrapper import is removed, the renderRotateButton method now returns null when canRotatePassword is false, and the corresponding &__rotate-button--disabled SCSS styling block is deleted. The button remains visible and functional only when rotation is permitted. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #45649 +/- ##
=======================================
Coverage 66.74% 66.75%
=======================================
Files 2744 2744
Lines 219316 219316
Branches 10794 10794
=======================================
+ Hits 146393 146411 +18
+ Misses 59698 59679 -19
- Partials 13225 13226 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Closes #42249
Supersedes #42247 (stale draft with merge conflicts)
Summary
canRotatePasswordis false), instead of showing a disabled span with a tooltipTooltipWrapperimport and orphaned SCSS styles for the disabled stateManagedAccountModalwhich already hides the button for observersChanges
RecoveryLockPasswordModal.tsx: Returnnullwhen!canRotatePasswordinstead of rendering disabled tooltip_styles.scss: Remove__rotate-button--disabledstylesRecoveryLockPasswordModal.tests.tsxwith two tests covering button visibility based on roleHow I tested
ManagedAccountModal.tests.tsxpattern) that verify:canRotatePassword={false}(Observer role)canRotatePassword={true}(Admin/Maintainer role)Test plan
Summary by CodeRabbit
Bug Fixes
Tests