diff --git a/frontend-modern/src/components/Settings/NodeModal.tsx b/frontend-modern/src/components/Settings/NodeModal.tsx index b40dbcd39..956862771 100644 --- a/frontend-modern/src/components/Settings/NodeModal.tsx +++ b/frontend-modern/src/components/Settings/NodeModal.tsx @@ -44,10 +44,10 @@ export const NodeModal: Component = (props) => { monitorGarbageJobs: false }); - // Reset form when node type changes (prevents cross-contamination between PVE and PBS) + // Reset form when modal opens for adding new node (prevents contamination) createEffect(() => { - // When adding a new node (no editingNode) or type mismatch, ensure clean form - if (!props.editingNode || (props.editingNode && props.editingNode.type !== props.nodeType)) { + if (props.isOpen && !props.editingNode) { + // Clear form completely when opening modal for new node setFormData({ name: '', host: '', @@ -70,6 +70,7 @@ export const NodeModal: Component = (props) => { monitorPruneJobs: true, monitorGarbageJobs: false }); + setTestResult(null); // Also clear any test results } }); diff --git a/manual-test-pbs.md b/manual-test-pbs.md new file mode 100644 index 000000000..2bcaa7ae8 --- /dev/null +++ b/manual-test-pbs.md @@ -0,0 +1,33 @@ +# Manual Test Steps for PBS Form Fix + +## Test Procedure + +1. Open http://192.168.0.123:7655 in browser +2. Navigate to Settings → Nodes tab +3. Click "Add PVE Node" + - Enter name: test-pve + - Enter host: https://192.168.1.100:8006 + - Enter token: root@pam!pvetoken + - Click Cancel (don't save) +4. Click "Add PBS Node" + - CHECK: Form should be completely empty (no PVE data) + - If form has any PVE data = FAIL +5. Add a real PBS node: + - Name: test-pbs + - Host: https://192.168.1.200:8007 + - Token: root@pam!pbstoken + - Token value: xxxxx + - Click Add Node +6. Edit the PBS node (click edit icon) + - CHECK: Form should show PBS data (test-pbs, https://192.168.1.200:8007, etc) + - If form is empty or shows wrong data = FAIL +7. Cancel and add a PVE node +8. Edit the PVE node + - CHECK: Form should show PVE data, not PBS data + - If form shows PBS data = FAIL + +## Expected Results +- [ ] PBS form never shows PVE data +- [ ] PVE form never shows PBS data +- [ ] Editing PBS node shows PBS data +- [ ] Editing PVE node shows PVE data \ No newline at end of file diff --git a/test-pbs-cli.sh b/test-pbs-cli.sh new file mode 100644 index 000000000..62b7f0d89 --- /dev/null +++ b/test-pbs-cli.sh @@ -0,0 +1,89 @@ +#!/bin/bash + +echo "=== PBS Form Contamination Test ===" +echo "" +echo "This test verifies the PBS form fix by:" +echo "1. Opening Pulse UI in Firefox" +echo "2. You manually test according to the steps" +echo "" + +# Open the manual test instructions +echo "Opening test instructions and Pulse UI..." + +# Create HTML test page with instructions +cat > /tmp/pbs-test.html << 'EOF' + + + + PBS Form Test + + + +

PBS Form Contamination Test

+ +
+

Test Steps:

+
    +
  1. Open Pulse UI (click here)
  2. +
  3. Navigate to Settings → Nodes tab
  4. +
  5. + Click "Add PVE Node"
    + - Enter name: test-pve
    + - Enter host: https://192.168.1.100:8006
    + - Click Cancel (don't save) +
  6. +
  7. + Click "Add PBS Node"
    + ✓ CHECK: Form should be COMPLETELY EMPTY
    + ✗ FAIL if: Form has any data from PVE +
  8. +
  9. + Fill PBS form and save:
    + - Name: test-pbs
    + - Host: https://192.168.1.200:8007
    + - Token: root@pam!pbstoken
    + - Token value: test-token-12345
    + - Click "Add Node" +
  10. +
  11. + Click Edit icon on the PBS node
    + ✓ CHECK: Form should show PBS data (test-pbs, etc)
    + ✗ FAIL if: Form is empty or shows wrong data +
  12. +
+
+ +
+

Expected Results:

+
    +
  • PBS form NEVER shows PVE data ✓
  • +
  • PVE form NEVER shows PBS data ✓
  • +
  • Editing PBS node shows correct PBS data ✓
  • +
  • Editing PVE node shows correct PVE data ✓
  • +
+
+ + +EOF + +# Try to open in browser if available +if command -v firefox &> /dev/null; then + firefox /tmp/pbs-test.html 2>/dev/null & +elif command -v chromium &> /dev/null; then + chromium /tmp/pbs-test.html 2>/dev/null & +else + echo "Please open /tmp/pbs-test.html in a browser" +fi + +echo "" +echo "Manual test page created at: /tmp/pbs-test.html" +echo "Please follow the test steps and report results." +echo "" \ No newline at end of file diff --git a/test-pbs-real.js b/test-pbs-real.js new file mode 100644 index 000000000..dfb1734fb --- /dev/null +++ b/test-pbs-real.js @@ -0,0 +1,45 @@ +// Simple test that actually checks if the currentNodeType is being set +// by looking at the compiled JavaScript + +const fs = require('fs'); + +console.log('Checking if PBS form fix is actually in the code...\n'); + +// Read the built frontend JS +const jsFile = '/opt/pulse/frontend-modern/dist/assets/index-D2Xfq6EC.js'; +const content = fs.readFileSync(jsFile, 'utf8'); + +// Check if our fix is in the compiled code +// We're looking for setCurrentNodeType being called with node.type +const hasOldBuggyCode = content.includes('setEditingNode(node),setShowNodeModal(!0)'); +const hasFixedCode = content.includes('setCurrentNodeType(node.type') || + content.includes('setCurrentNodeType(e.type') || + content.includes('CurrentNodeType(n.type') || + content.includes('CurrentNodeType(t.type'); + +console.log('Checking compiled JavaScript for the fix...'); +console.log('Old buggy pattern found:', hasOldBuggyCode); +console.log('Fixed pattern found:', hasFixedCode); + +if (!hasFixedCode) { + console.log('\n❌ FIX NOT FOUND IN COMPILED CODE!'); + console.log('The fix is not in the production build.'); + console.log('Need to rebuild: cd /opt/pulse/frontend-modern && npm run build'); + process.exit(1); +} else { + console.log('\n✅ Fix appears to be in the code'); + console.log('The production build contains the currentNodeType fix'); +} + +// Also check the source to make sure it's there +const sourceFile = '/opt/pulse/frontend-modern/src/components/Settings/Settings.tsx'; +const source = fs.readFileSync(sourceFile, 'utf8'); + +if (source.includes('setCurrentNodeType(node.type')) { + console.log('✅ Fix confirmed in source code'); +} else { + console.log('❌ Fix NOT in source code!'); + process.exit(1); +} + +console.log('\nThe fix is in place, but still needs manual testing to verify it works.'); \ No newline at end of file diff --git a/verify-pbs-fix.md b/verify-pbs-fix.md new file mode 100644 index 000000000..6f46013a4 --- /dev/null +++ b/verify-pbs-fix.md @@ -0,0 +1,40 @@ +# PBS Form Fix Verification + +## What was broken +1. When editing a PBS node, the form wouldn't populate with PBS data +2. PBS forms could show PVE data if a PVE node was edited first + +## What we fixed +In `/opt/pulse/frontend-modern/src/components/Settings/Settings.tsx`: +- Lines 886 and 1063: Added `setCurrentNodeType(node.type as 'pve' | 'pbs');` +- This ensures when editing any node, we set the correct type + +## How to verify the fix works + +### Test #1: PBS form after PVE +1. Go to Settings → Nodes +2. Click "Add PVE Node" +3. Fill in some data +4. Press Escape to cancel +5. Click "Add PBS Node" +6. **VERIFY**: PBS form should be completely empty + +### Test #2: Edit PBS node +1. Add a PBS node with test data +2. Click the edit icon on that PBS node +3. **VERIFY**: Form should show the PBS node's data + +### Test #3: Edit PVE after PBS +1. Add a PVE node +2. Add a PBS node +3. Edit the PBS node +4. Cancel +5. Edit the PVE node +6. **VERIFY**: PVE form shows PVE data, not PBS data + +## Current Status +- [x] Fix implemented in source code +- [x] Frontend rebuilt with fix +- [x] Backend restarted +- [ ] Manual testing completed +- [ ] User confirmed it works \ No newline at end of file