Skip to content
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

Merged
merged 1 commit into from
Dec 2, 2016

Conversation

jhadvig
Copy link
Member

@jhadvig jhadvig commented Dec 2, 2016

@spadgett PTAL

@spadgett
Copy link
Member

spadgett commented Dec 2, 2016

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>

if should be id, correct?

@jhadvig
Copy link
Member Author

jhadvig commented Dec 2, 2016

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"
Copy link
Member

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>

Copy link
Member

@spadgett spadgett left a 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.

@spadgett
Copy link
Member

spadgett commented Dec 2, 2016

[merge]

@openshift-bot
Copy link

Evaluated for origin web console merge up to 1793f9b

@openshift-bot
Copy link

openshift-bot commented Dec 2, 2016

Origin Web Console Merge Results: SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_requests_origin_web_console/794/) (Base Commit: 6aabd72)

@openshift-bot openshift-bot merged commit 4aaf5da into openshift:master Dec 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants