-
Notifications
You must be signed in to change notification settings - Fork 268
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
[JENKINS-73900] Un-inline JS in ModuleLocation/config.jelly
and fix validation logic
#319
Conversation
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.
Let me know if you get stuck or any of the dots do not connect. I could also provide a patch myself if this all is too confusing :P
src/main/resources/hudson/scm/SubversionSCM/ModuleLocation/config.jelly
Outdated
Show resolved
Hide resolved
src/main/resources/hudson/scm/SubversionSCM/ModuleLocation/config.jelly
Outdated
Show resolved
Hide resolved
if (revPropField) { | ||
revPropField.dispatchEvent(new Event('change')); | ||
} |
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 do we need to dispatch the event here? Is that supposed to retrigger the validation for excludedRevprop
field when we change either remote
or credentialsId
? Is that how it worked before your change?
I don't like it personally, I'd prefer to have it triggered only when excludedRevprop
loses focus. But disregard my comment if it worked like this before, who am I to judge :)
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.
Yes, that is the way it was "supposed" to work before. Although it wasn't working correctly.
if (self===document.getElementById('svn.remote.loc')){
r=findNextFormItem(self,'excludedRevprop');
r.onchange(r);
}
I think it makes sense as we should validate the excluded revProp whenever remote or credentials changes as well as when excluded revProp itself changes
var remoteLocationElement = document.querySelector("input[name='_.remote']"); | ||
var credentialsIdElement = document.querySelector("select[name='_.credentialsId'][filldependson='remote']"); | ||
var selectedOption = credentialsIdElement.options[credentialsIdElement.selectedIndex].value; |
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 expect this will fall apart if we try to define a second location in the configuration, because you selectors will return arrays of elements. Could you check how it behaves in that case?
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.
Nevermind, disregard "arrays of elements", you're using querySelector
, not querySelectorAll
. Either way I'm concerned whether this is going to work when we try to define multiple locations.
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 see what you're saying.
In this case, each time you add a module, the checkUrl and checkCredentials is correctly called for the corresponding module, however, the validation for the excludedRevprop only works on the module that was added first.
We can discuss this on the call this morning
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.
Sorted it out on a call. excludeRevProp
validation previously has referenced credentialsId and remote URL or the first module that was defined. While this behavior seems wrong it is preserved here.
src/main/resources/hudson/scm/SubversionSCM/excludedRevprop-validation.js
Outdated
Show resolved
Hide resolved
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.
Nice work taking this through to completion!
JENKINS-73900
This pull request addresses two main improvements for the Subversion plugin:
Testing done
Original validation logic improvement: Loom Video
With CSP restrictions enabled: Loom Video
Submitter checklist