-
Notifications
You must be signed in to change notification settings - Fork 230
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
Bug 1400775 - Disable the Create button when Configuration File field didn't pass the validation check #974
Conversation
I noticed a typo here in the view: <osc-file-input
if="dockercfg-file-input"
model="newSecret.data.dockerConfig"
drop-zone-id="docker-config"
help-text="Upload a .dockercfg or .docker/config.json file"
show-values="false"
required="true"></osc-file-input>
|
Indeed it should.. will update right away |
@@ -292,7 +292,7 @@ | |||
<div class="buttons gutter-top-bottom"> | |||
<button class="btn btn-lg btn-primary" | |||
type="button" | |||
ng-disabled="secretForm.$invalid || secretForm.$pristine" | |||
ng-disabled="secretForm.$invalid || secretForm.$pristine || invalidConfigFormat" |
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.
We should be calling $setValidity
in the controller to mark the field invalid, and then just check $invalid
here as before. For instance, give the input name="dockerConfig"
, then in the controller (untested)
var updateEditorMode = _.debounce(function(){
try {
JSON.parse($scope.newSecret.data.dockerConfig);
$scope.$apply(function() {
$scope.secretForm.dockerConfig.$setValidity('validJSON', true);
});
} catch (e) {
$scope.$apply(function() {
$scope.secretForm.dockerConfig.$setValidity('validJSON', false);
});
}
}, 300, {
'leading': true
});
Use $scope.$apply
because the function is debounced.
In the view, show the error with
<div class="has-warning" ng-if="secertForm.dockerConfig.$error.validJSON">
<span class="help-block">
Configuration file should be valid JSON.
</span>
</div>
… didn't pass the validation check
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.
@jhadvig approving per our discussion since we're using osc-file-input
, which means we can't name in input.
I think we can add validation to osc-file-input
in a follow-on.
[merge] |
Evaluated for origin web console merge up to 1793f9b |
Origin Web Console Merge Results: SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_requests_origin_web_console/794/) (Base Commit: 6aabd72) |
@spadgett PTAL