-
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
Changes from all commits
c94d7ab
d3d8ef7
1895dc4
cc487b9
7fb59bd
a574c02
13bd3cf
2e2de5f
80738a0
1bd302a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
Behaviour.specify("input[name='_.remote']", 'SubversionSCM.RemoteLocation', 0, function(element) { | ||
element.addEventListener('blur', updateHiddenFields); | ||
}); | ||
|
||
Behaviour.specify("select[name='_.credentialsId'][filldependson='remote']", 'SubversionSCM.CredentialsId', 0, function(element) { | ||
element.addEventListener('change', updateHiddenFields); | ||
}); | ||
|
||
function updateHiddenFields() { | ||
|
||
var remoteLocationElement = document.querySelector("input[name='_.remote']"); | ||
var credentialsIdElement = document.querySelector("select[name='_.credentialsId'][filldependson='remote']"); | ||
var selectedOption = credentialsIdElement.options[credentialsIdElement.selectedIndex].value; | ||
|
||
|
||
var remoteHidden = document.querySelector(".svn-remote-location-hidden"); | ||
var credentialsHidden = document.querySelector(".svn-credentials-id-hidden"); | ||
|
||
if (remoteHidden) { | ||
remoteHidden.value = remoteLocationElement.value; | ||
} | ||
|
||
if (credentialsHidden) { | ||
credentialsHidden.value = selectedOption; | ||
} | ||
|
||
var revPropField = document.querySelector("input[name='_.excludedRevprop']"); | ||
if (revPropField) { | ||
revPropField.dispatchEvent(new Event('change')); | ||
} | ||
Comment on lines
+28
to
+30
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 I don't like it personally, I'd prefer to have it triggered only when There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
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 |
||
} |
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
, notquerySelectorAll
. 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.