-
Notifications
You must be signed in to change notification settings - Fork 76
feat: fill in the secret and secret namespace when restoring the BackupBackingImage #822
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
WalkthroughThe pull request introduces several modifications across multiple components related to backing images. Key changes include adjustments to column widths and rendering logic in the Changes
Possibly related PRs
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (1)
src/routes/backingImage/BackupBackingImageList.js (1)
31-42
: LGTM: Well-implemented encryption indicator with room for minor optimizationThe implementation effectively shows encryption status through a lock icon with helpful tooltip. Consider a minor optimization to simplify the boolean expression.
- const isEncrypted = Boolean(record.secret || record.secretNamespace) + const isEncrypted = !!(record.secret || record.secretNamespace)The
!!
operator is more commonly used in JavaScript for boolean coercion and is slightly more performant than the Boolean constructor.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (5)
src/routes/backingImage/BackingImageList.js
(5 hunks)src/routes/backingImage/BackingImageList.less
(1 hunks)src/routes/backingImage/BackupBackingImageList.js
(3 hunks)src/routes/backingImage/BackupBackingImageList.less
(1 hunks)src/routes/backingImage/RestoreBackupBackingImageModal.js
(2 hunks)
✅ Files skipped from review due to trivial changes (2)
- src/routes/backingImage/BackupBackingImageList.less
- src/routes/backingImage/BackingImageList.less
🔇 Additional comments (11)
src/routes/backingImage/RestoreBackupBackingImageModal.js (3)
18-18
: LGTM: Good defensive programming practice
Adding a default empty object for the item
prop prevents potential null pointer issues.
52-52
: LGTM: Appropriate field constraint
Correctly disables the backup name field when restoring an existing backup.
55-58
: LGTM: Secure implementation of secret field handling
The implementation correctly:
- Auto-fills secret and secretNamespace from the backup
- Disables modification of existing secret information
- Maintains security by preventing tampering with encrypted backup credentials
This aligns perfectly with the PR objective of streamlining the restoration process for encrypted backups.
src/routes/backingImage/BackupBackingImageList.js (2)
3-3
: LGTM: Appropriate UI component imports
Added necessary antd components and styles for implementing the encrypted backup UI enhancements.
Also applies to: 9-9
29-29
: Verify column width adjustments
The increased column widths should accommodate the new lock icon without causing layout issues.
Also applies to: 88-88
✅ Verification successful
Column width adjustments are consistent with related components
The width changes in BackupBackingImageList.js are consistent with the existing table layouts in the codebase:
- The Name column width of 180px matches exactly with the BackingImageList.js component
- Other column widths in both components maintain similar proportions (80-120px range)
- The increased widths provide adequate space for the UI elements while maintaining layout consistency
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Check if there are any other files with similar table layouts that might need width adjustments
rg -l "Table.*columns.*width" --type js
Length of output: 41
Script:
#!/bin/bash
# Let's try a broader search for table-related width configurations
rg "width.*\d+" --type js src/routes/backingImage/
Length of output: 1334
Script:
#!/bin/bash
# Search for Table components with column definitions
rg "columns.*=.*\[" --type js -A 5 src/routes/backingImage/
Length of output: 1240
Script:
#!/bin/bash
# Look for similar BackupBackingImage related components
fd "BackupBackingImage.*\.js$" src/
Length of output: 255
src/routes/backingImage/BackingImageList.js (6)
Line range hint 10-17
: LGTM! Props are well-defined and properly documented.
The explicit listing of props in the function signature improves code readability and matches the PropTypes declaration.
Line range hint 19-45
: LGTM! Icon rendering logic is clear and follows best practices.
The implementation:
- Uses semantic color classes for different states
- Provides clear tooltip messages
- Correctly handles both encrypted and deletion states
Line range hint 169-182
: LGTM! Table implementation follows best practices.
The table component:
- Uses proper pagination
- Handles dynamic height based on content
- Implements responsive scrolling
Line range hint 184-194
: LGTM! PropTypes are well-defined.
The PropTypes declaration properly validates all component props with appropriate types.
8-8
: Verify the existence of the BackingImageList.less file.
The code imports styles from BackingImageList.less
, which should contain the new .encryptedBackingImage
class.
✅ Verification successful
The BackingImageList.less file exists with the required styles
The file exists at the expected location and contains the necessary .encryptedBackingImage
and .encryptedBackup
classes that are used for styling encrypted backing images.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify the existence of BackingImageList.less and its content
fd -t f "BackingImageList.less" src/routes/backingImage/ -x cat {}
Length of output: 193
54-54
: Verify table layout with adjusted column widths.
The column width adjustments look reasonable, but we should verify that:
- The total width (970px) in the table's scroll prop matches the sum of column widths
- The content fits well within the adjusted widths without truncation
Also applies to: 60-60, 80-80, 94-94, 107-107
✅ Verification successful
The previous search might have been too specific. Let's broaden it to understand the table implementations better and their scroll configurations.
I'm looking for the complete column definitions and any global table styles that might affect scrolling behavior.
I need to see the complete file content to analyze the column definitions and table configuration. The previous searches might have failed due to different formatting or multiline declarations.
Column widths are correctly configured with appropriate scroll settings
The table implementation shows that:
- The total width of all columns (910px) plus default padding matches the scroll prop's x value (970px)
- Column widths are appropriately sized for their content:
- Name: 180px (for longer names + icons)
- UUID: 120px
- Size: 100px (for formatted Mib values)
- Created From: 120px
- Minimum Copies: 130px
- Node Tags: 120px
- Disk Tags: 120px
- Operation: 120px
The table uses the antd Table component with proper horizontal scrolling configuration and responsive height based on content.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Search for other table implementations to compare column widths
rg -U "Table.*scroll.*x:.*" src/
Length of output: 34
Script:
#!/bin/bash
# Let's try a different approach to find table implementations and their scroll configurations
rg -U "Table.*scroll" src/
# Also search for specific table components that might contain scroll configurations
rg -U "<Table.*" -A 5 src/
Length of output: 9918
Script:
#!/bin/bash
# Let's examine the specific table implementation in BackingImageList.js to verify column definitions
rg -U "columns.*=.*\[.*\]" src/routes/backingImage/BackingImageList.js -A 100
# Also check for any scroll configuration in the component
rg -U "className=\"common-table-class\"" src/components/ -A 5
Length of output: 141
Script:
#!/bin/bash
# Let's try a different approach to find the column definitions
cat src/routes/backingImage/BackingImageList.js
Length of output: 5582
Signed-off-by: Yi-Ya Chen <[email protected]>
Signed-off-by: Yi-Ya Chen <[email protected]>
8334140
to
7c4674e
Compare
To restore I think they're not required fields and can be hidden ? @ChanYiLin ![]() |
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.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (1)
src/routes/backingImage/BackupBackingImageList.js (1)
31-42
: Consider extracting encryption check to a utility functionThe encryption status check logic is correct but could be more reusable. Consider extracting it to a utility function:
+ // In src/utils/backup.js + export const isBackupEncrypted = (record) => Boolean(record.secret || record.secretNamespace) // In this file render: (text, record) => { - const isEncrypted = Boolean(record.secret || record.secretNamespace) + const isEncrypted = isBackupEncrypted(record) return ( <> {isEncrypted && ( <Tooltip title="Encrypted Backing Image Backup"> <Icon className="color-warning" type="lock" /> </Tooltip> )} <span className={styles.encryptedBackup}>{text}</span> </> ) },Also, consider making the tooltip more descriptive by including information about the secret and namespace being used.
- <Tooltip title="Encrypted Backing Image Backup"> + <Tooltip title={`Encrypted Backing Image Backup (Secret: ${record.secret} in ${record.secretNamespace})`}>The core implementation looks good and aligns with the PR objectives.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (5)
src/routes/backingImage/BackingImageList.js
(5 hunks)src/routes/backingImage/BackingImageList.less
(1 hunks)src/routes/backingImage/BackupBackingImageList.js
(3 hunks)src/routes/backingImage/BackupBackingImageList.less
(1 hunks)src/routes/backingImage/RestoreBackupBackingImageModal.js
(2 hunks)
✅ Files skipped from review due to trivial changes (1)
- src/routes/backingImage/BackupBackingImageList.less
🚧 Files skipped from review as they are similar to previous changes (3)
- src/routes/backingImage/BackingImageList.less
- src/routes/backingImage/RestoreBackupBackingImageModal.js
- src/routes/backingImage/BackingImageList.js
🔇 Additional comments (3)
src/routes/backingImage/BackupBackingImageList.js (3)
3-3
: LGTM: Import statements are properly organized
The new imports for Icon, Tooltip, and styles are well-organized and align with the PR's objective of adding encryption indicators.
Also applies to: 9-9
37-37
: Verify styling dependencies
Please ensure:
- The
color-warning
class is available in your antd theme - The
styles.encryptedBackup
class is properly defined inBackupBackingImageList.less
Also applies to: 40-40
✅ Verification successful
Both styling classes are properly defined and used across the codebase
The verification shows that:
- The
color-warning
class is defined insrc/assets/styles/classes.less
and uses the@color-warning
variable fromvars.less
- The class is consistently used across multiple components for warning icons
- The
encryptedBackup
class exists inBackupBackingImageList.less
and is properly imported and used in the component
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check for required style definitions
# Check if the less file exists and contains the required class
echo "Checking for encryptedBackup class definition..."
rg -l "\.encryptedBackup\s*{" "src/routes/backingImage/BackupBackingImageList.less"
# Check for color-warning class in antd theme or custom styles
echo "Checking for color-warning class usage..."
rg -l "\.color-warning\s*{" "src/**/*.less"
Length of output: 537
Script:
#!/bin/bash
# Description: Check for required style definitions with corrected regex
# Check if the less file exists and contains the required class
echo "Checking for encryptedBackup class definition..."
rg "\.encryptedBackup" "src/routes/backingImage/"
# Check for color-warning class in antd theme or custom styles
echo "Checking for color-warning class usage..."
rg "color-warning" "src/"
# Check if the less file exists
echo "Checking if the less file exists..."
fd "BackupBackingImageList.less" "src/"
Length of output: 3150
29-29
: Verify table layout with new column widths
The increased column widths (Name: 180px, Created Time: 100px) should be verified to ensure:
- The lock icon fits without text wrapping
- The table's horizontal scroll behavior works correctly (table has
scroll.x: 970
)
Let's check if the total column width matches the scroll width:
Also applies to: 88-88
✅ Verification successful
Let me verify if there are any other table components in the codebase with similar structure to ensure consistency.
Let me try a different search pattern to find table configurations.
Let me check the specific file to verify the scroll configuration.
Column width adjustments are appropriate and consistent
The increased column widths are well-balanced with the table's scroll configuration:
- Total column width (800px) = Name(180) + State(80) + Size(80) + URL(240) + Created Time(100) + Operation(120)
- Table scroll.x is set to 970px, providing adequate space for borders, padding, and scroll bar
- The Name column width (180px) accommodates the new lock icon and text without causing layout issues
- The width adjustments align with other tables in the codebase that use similar column widths for similar content types
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Calculate total column width and compare with scroll.x value
echo "Column widths:"
echo "Name: 180"
echo "State: 80"
echo "Size: 80"
echo "URL: 240"
echo "Created Time: 100"
echo "Operation: 120"
echo "Total: 800px (excluding padding/borders)"
echo "Scroll.x: 970px"
echo "Difference: 170px (seems reasonable for padding/borders)"
Length of output: 489
Script:
#!/bin/bash
# Search for other table components with column definitions
rg -A 5 "scroll:\s*{\s*x:" --type js
# Look for other width definitions in table columns
ast-grep --pattern 'width: $_'
Length of output: 181
Script:
#!/bin/bash
# Search for scroll configurations in tables
rg "scroll: {" --type js -A 5
# Search for table column definitions
rg "columns = \[" --type js -A 10
Length of output: 15460
Script:
#!/bin/bash
# Get the full content of BackupBackingImageList.js to verify scroll configuration
cat src/routes/backingImage/BackupBackingImageList.js
Length of output: 3560
Yes, you are right |
Signed-off-by: Yi-Ya Chen <[email protected]>
3294266
to
b64af6c
Compare
updated in commit b64af6c. |
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.
LGTM
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.
LGTM
What this PR does / why we need it
Issue
[UI FEATURE] Fill in the secret and secret namespace when restoring the BackupBackingImage
Test Result
Display icon only for encrypted BackupBackingImages

Auto-fill secret and namespace when restoring an encrypted BackupBackingImage

Additional documentation or context
LONGHORN_MANAGER_IP=http://139.59.122.79:30001/ npm run dev
Summary by CodeRabbit
New Features
item
prop in the restore modal ensures consistent behavior.Bug Fixes
item
prop to enhance user experience by disabling inputs when appropriate.Style