-
Notifications
You must be signed in to change notification settings - Fork 14k
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
fix: SSH Tunnel creation with dynamic form #24196
Conversation
Codecov Report
@@ Coverage Diff @@
## master #24196 +/- ##
==========================================
+ Coverage 69.03% 69.07% +0.04%
==========================================
Files 1901 1906 +5
Lines 74002 74123 +121
Branches 8116 8158 +42
==========================================
+ Hits 51086 51204 +118
+ Misses 20805 20797 -8
- Partials 2111 2122 +11
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
const errors = await getValidation(dbToUpdate, true); | ||
if ((validationErrors && !isEmpty(validationErrors)) || errors) { | ||
// only do validation for non ssh tunnel connections | ||
console.log(dbToUpdate); |
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.
leftover
a27ed0a
to
fdde2f8
Compare
const errors = await getValidation(dbToUpdate, true); | ||
if ((validationErrors && !isEmpty(validationErrors)) || errors) { | ||
// only do validation for non ssh tunnel connections | ||
if (!dbToUpdate?.ssh_tunnel) { |
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.
@hughhhh why can't we run the validation for SSH tunnel connections, assuming the user has provided that info?
I think the logic should be: if the user has enabled SSH, we don't perform any validation until SSH credentials are entered.
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.
for the initial implementation, we were okay with doing validation on just connect. Right now users are not able to connect at all via dynamic forms.
I'm open to this fix but that's going to take longer to implement vs. fixing the issue at hand.
Let me know what you think
changeMethods, | ||
db, | ||
}: FieldPropTypes) => | ||
true ? ( |
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.
Why the ternary operator here if the condition is always true?
@@ -753,6 +753,11 @@ export function useDatabaseValidation() { | |||
.catch(e => { | |||
if (typeof e.json === 'function') { | |||
return e.json().then(({ errors = [] }: JsonObject) => { | |||
if (database?.parameters?.ssh) { |
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.
I don't think this belongs here... if we don't want to show validation errors for some reason, then we shouldn't be running the validation API calls.
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.
Awesome!
(cherry picked from commit 226c7f8)
🏷️ preset:2023.27 |
(cherry picked from commit 226c7f8)
(cherry picked from commit 226c7f8)
(cherry picked from commit 226c7f8)
(cherry picked from commit 226c7f8)
SUMMARY
Fixing issue with SSH tunnel creation with dynamic forms. Main issue was the ssh toggle would lose state, and validate_parameters endpoints would fail immediately since no tunnel is created on every
onBlur
eventTo fix it I refactored the toggle state to the reducer, and stop validation on any ssh tunnel requests to connect to a DB
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION