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

Disable credential / repository form when embedded ansible is unavailable #3840

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,12 @@ ManageIQ.angular.app.controller('ansibleCredentialsFormController', ['$window',
}

function setManagerResource(response) {
vm.credentialModel.manager_resource = { "href": response.resources[0].href };
if (response.resources.length > 0) {
vm.credentialModel.manager_resource = { "href": response.resources[0].href };
} else {
vm.credentialModel.manager_resource = null;
miqService.miqFlash('error', __('Embedded Ansible service is not available.'));
}
}

init();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ ManageIQ.angular.app.controller('repositoryFormController', ['repositoryId', 'mi

var getManagerResource = function(response) {
if (!response.resources.length) {
vm.repositoryModel.manager_resource = null;
miqService.miqFlash('error', __('Embedded Ansible Provider not found.'));
} else {
vm.repositoryModel.manager_resource = {'href': response.resources[0].href};
Expand Down
26 changes: 14 additions & 12 deletions app/views/ansible_credential/_credential_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,27 @@
%label.col-md-2.control-label
= _('Name')
.col-md-8
%input.form-control{:type => "text",
:name => "name",
"id" => "name",
'ng-model' => "vm.credentialModel.name",
:maxlength => ViewHelper::MAX_NAME_LEN,
:required => true,
"auto-focus" => ""}
%input.form-control{:type => "text",
:name => "name",
"id" => "name",
'ng-model' => "vm.credentialModel.name",
:maxlength => ViewHelper::MAX_NAME_LEN,
:required => true,
'ng-disabled' => 'vm.credentialModel.manager_resource === null',
"auto-focus" => ""}
%span.help-block{"ng-show" => "angularForm.name.$error.required"}
= _("Required")
.form-group
%label.col-md-2.control-label
= _('Credential type')
- if @id == 'new' # we don't allow changing auth. type when editing a resource
.col-md-8
%select{'ng-model' => 'vm.credentialModel.type',
'ng-options' => 'cred.value as cred.label for cred in vm.select_options',
'id' => 'type',
'required' => 'true',
'pf-select' => 'true'}
%select{'ng-model' => 'vm.credentialModel.type',
'ng-options' => 'cred.value as cred.label for cred in vm.select_options',
'id' => 'type',
'ng-disabled' => 'vm.credentialModel.manager_resource === null',
'required' => 'true',
'pf-select' => 'true'}
- else
.col-md-8
{{ vm.credential_options[vm.credentialModel.type].label }}
Expand Down
47 changes: 26 additions & 21 deletions app/views/ansible_repository/_repository_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,24 @@
%label.col-md-2.control-label
= _('Name')
.col-md-8
%input.form-control{:type => "text",
:name => "name",
"id" => "name",
'ng-model' => "vm.repositoryModel.name",
:maxlength => ViewHelper::MAX_NAME_LEN,
:required => ""}
%input.form-control{:type => "text",
:name => "name",
"id" => "name",
'ng-model' => "vm.repositoryModel.name",
'ng-disabled' => 'vm.repositoryModel.manager_resource === null',
:maxlength => ViewHelper::MAX_NAME_LEN,
:required => ""}
%span.help-block{"ng-show" => "angularForm.name.$error.required"}
= _("Required")
.form-group
%label.col-md-2.control-label
= _('Description')
.col-md-8
%input.form-control{:type => "text",
:name => "description",
"id" => "description",
'ng-model' => "vm.repositoryModel.description"}
%input.form-control{:type => "text",
:name => "description",
"id" => "description",
'ng-disabled' => 'vm.repositoryModel.manager_resource === null',
'ng-model' => "vm.repositoryModel.description"}
.form-group
%label.col-md-2.control-label
= _('SCM type')
Expand All @@ -49,6 +51,7 @@
:id => "scm_url",
'ng-model' => "vm.repositoryModel.scm_url",
:required => "",
'ng-disabled' => 'vm.repositoryModel.manager_resource === null',
'url-validation' => true}
%span.help-block{"ng-show" => "angularForm.scm_url.$error.required"}
= _("Required")
Expand All @@ -58,33 +61,35 @@
%label.col-md-2.control-label
= _('SCM credentials')
.col-md-8
%select{'name' => 'authentication_id',
'ng-model' => 'vm.repositoryModel.authentication_id',
'ng-options' => 'scm_credential.value as scm_credential.name for scm_credential in vm.scm_credentials',
'pf-select' => true}
%select{'name' => 'authentication_id',
'ng-model' => 'vm.repositoryModel.authentication_id',
'ng-options' => 'scm_credential.value as scm_credential.name for scm_credential in vm.scm_credentials',
'ng-disabled' => 'vm.repositoryModel.manager_resource === null',
'pf-select' => true}
.form-group
%label.col-md-2.control-label
= _('SCM Branch')
.col-md-8
%input.form-control{:type => "text",
:name => "scm_branch",
"id" => "scm_branch",
'ng-model' => "vm.repositoryModel.scm_branch"}
%input.form-control{:type => "text",
:name => "scm_branch",
"id" => "scm_branch",
'ng-disabled' => 'vm.repositoryModel.manager_resource === null',
'ng-model' => "vm.repositoryModel.scm_branch"}
.form-group
%label.col-md-2.control-label
= _('SCM Update Options')
.col-md-8
%div
%label
= check_box_tag("clean", "1", false, 'ng-model' => "vm.repositoryModel.scm_clean")
= check_box_tag("clean", "1", false, 'ng-model' => "vm.repositoryModel.scm_clean", 'ng-disabled' => 'vm.repositoryModel.manager_resource === null')
= _('Clean')
%div
%label
= check_box_tag("scm_delete_on_update", "1", false, 'ng-model' => 'vm.repositoryModel.scm_delete_on_update')
= check_box_tag("scm_delete_on_update", "1", false, 'ng-model' => 'vm.repositoryModel.scm_delete_on_update', 'ng-disabled' => 'vm.repositoryModel.manager_resource === null')
= _('Delete on Update')
%div
%label
= check_box_tag("scm_update_on_launch", "1", false, 'ng-model' => 'vm.repositoryModel.scm_update_on_launch')
= check_box_tag("scm_update_on_launch", "1", false, 'ng-model' => 'vm.repositoryModel.scm_update_on_launch', 'ng-disabled' => 'vm.repositoryModel.manager_resource === null')
= _('Update on Launch')
= render :partial => 'layouts/angular/generic_form_buttons'
:javascript
Expand Down