fix: preserve existing comments in bulk update and always show save notification

This commit fixes two UX issues with environment variable bulk updates:

1. Comment Preservation (High Priority Bug):
   - When bulk updating environment variables via Developer view, existing
     manually-entered comments are now preserved when no inline comment is provided
   - Only overwrites existing comments when an inline comment (#comment) is explicitly
     provided in the pasted content
   - Previously: pasting "KEY=value" would erase existing comment to null
   - Now: pasting "KEY=value" preserves existing comment, "KEY=value #new" overwrites it

2. Save Notification (UX Improvement):
   - "Save all Environment variables" button now always shows success notification
   - Previously: only showed notification when changes were detected
   - Now: provides feedback even when no changes were made
   - Consistent with other save operations in the codebase

Changes:
- Modified updateOrCreateVariables() to only update comment field when inline comment
  is provided (null check prevents overwriting existing comments)
- Modified handleBulkSubmit() to always dispatch success notification unless error occurred
- Added comprehensive test coverage for bulk update comment preservation scenarios

Tests:
- Added 4 new feature tests covering comment preservation edge cases
- All 22 existing unit tests for parseEnvFormatToArray pass
- Code formatted with Pint

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Andras Bacsai
2025-12-27 15:24:09 +01:00
co-authored by Claude
parent dfb180601a
commit d640911bb9
2 changed files with 138 additions and 5 deletions
@@ -193,8 +193,8 @@ class All extends Component
}
}
// Only show success message if changes were actually made and no errors occurred
if ($changesMade && ! $errorOccurred) {
// Always show success message unless an error occurred
if (! $errorOccurred) {
$this->dispatch('success', 'Environment variables updated.');
}
}
@@ -294,9 +294,9 @@ class All extends Component
$changed = true;
}
// Always update comment from inline comment (overwrites existing)
// Set to comment if provided, otherwise set to null if no comment
if ($found->comment !== $comment) {
// Only update comment from inline comment if one is provided (overwrites existing)
// If $comment is null, don't touch existing comment field to preserve it
if ($comment !== null && $found->comment !== $comment) {
$found->comment = $comment;
$changed = true;
}