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

CRUD for embedded Ansible credentials #641

Merged

Conversation

mzazrivec
Copy link
Contributor

@mzazrivec mzazrivec commented Mar 9, 2017

Implemented:

  • delete (done in async manner via queue worker)
  • edit (not fully working b/c of issue #14459)
  • create (pending pr #14217)

The actual Credential edit / create form is implemented as an angular component.

credentials-01
credentials-02
credentials-03
credentials-04
credentials-05
credentials-06
credentials-07

Pending backend PRs:
ManageIQ/manageiq#14217
ManageIQ/manageiq#14483

Outstanding issues:
ManageIQ/manageiq#14459

@mzazrivec mzazrivec changed the title CRUD for embedded Ansible credentials [WIP] CRUD for embedded Ansible credentials Mar 9, 2017
@mzazrivec mzazrivec force-pushed the crud_for_embedded_ansible_credentials branch 6 times, most recently from b3d5461 to 15bdb7d Compare March 15, 2017 17:43
@mzazrivec mzazrivec force-pushed the crud_for_embedded_ansible_credentials branch 19 times, most recently from fa021e2 to fa3b691 Compare March 23, 2017 18:04
.then(getCredentialOptions)
.catch(miqService.handleFailure);

if (credentialId != 'new') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be if (credentialId !== 'new') {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

.catch(miqService.handleFailure);
}
else {
vm.select_options.push({'label':__('<Choose>'), 'value': ''})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

semicolon missing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

};

vm.cancelClicked = function(angularForm) {
if (credentialId == 'new') {
Copy link
Contributor

@AparnaKarve AparnaKarve Mar 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above, === is recommended.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

function getCredentialOptions(response) {
Object.assign(vm.credential_options, response.data.credential_types.embedded_ansible_credential_types);

for (opt in vm.credential_options) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs to be
for (var opt in vm.credential_options)

(define opt, that is)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

var item = vm.credential_options[vm.credentialModel.type]['attributes'][opt]

// void the password fields first
if (item.hasOwnProperty('type') && item['type'] == 'password') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

===

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

if (warning) {
url += '&flash_warning=true&flash_error=false';
}
else if (error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

else /else if need to be on the same line as the closing brace for if (Per style guide)
Please fix this here and other places

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

// get credential specific options for all supported credential types
API.options('/api/authentications')
.then(getCredentialOptions)
.catch(miqService.handleFailure);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After #783 merge, the .catch will now catch the API failures, but those need to be visible to the user as flash messages.
Created a PR #805 that will display the error message flash.

@mzazrivec mzazrivec force-pushed the crud_for_embedded_ansible_credentials branch from 173deed to 2d4d444 Compare March 24, 2017 21:53
@mzazrivec
Copy link
Contributor Author

I'm aware of the problem with breadcrumb pointing to invalid url and yes, it needs to be fixed.

But that problem is not specific for nor caused by this PR and will be addressed as a bug
in a different PR.

'ng-show' => "vm.afterGet",
"miq-form" => true,
"model" => "vm.credentialModel",
"model-copy" => 'vm.modelCopy',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend using ng-clock here in order to address flickering that is seen sometimes.

ng-cloak => ""
(I just tried it in this form and it seems to have fixed it)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

'</div>',
// select
'<div ng-switch-when="choice" class="col-md-8">',
'<select ng-options="opt as opt for opt in attr.choices" class="form-control pf-select" ng-model="vm.model[name]" />',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pf-select is not quite doing what it's supposed to do.
It's a directive, so try this --

'<div ng-switch-when="choice" class="col-md-8">',
   '<select pf-select ng-options="opt as opt for opt in attr.choices" class="form-control" ng-model="vm.model[name]" />',
'</div>',

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

.then(getCredentialFormData)
.catch(miqService.handleFailure);
}
else {
Copy link
Contributor

@AparnaKarve AparnaKarve Mar 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move else up.

Please do a sweep of the whole JS file for all the else's.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. And I also did this sweep of the whole JS file .


// we need to merge options and vm.credentialModel
for (var opt in response.options) {
var item = vm.credential_options[vm.credentialModel.type]['attributes'][opt]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another missing semicolon... sorry, didn't catch that before.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@AparnaKarve
Copy link
Contributor

Oh, almost forgot...
It would be super if you could add a few jasmine specs...you know, our usual spec requirement prior to a merge.
Thanks.

@mzazrivec mzazrivec force-pushed the crud_for_embedded_ansible_credentials branch from 2d4d444 to e92273f Compare March 27, 2017 08:31
@mzazrivec
Copy link
Contributor Author

@AparnaKarve I can work on the specs, but if the PR is meant to be merged soon, I'd rather do them in a separate PR.

@mzazrivec mzazrivec force-pushed the crud_for_embedded_ansible_credentials branch from e92273f to e74101c Compare March 27, 2017 12:10
@miq-bot
Copy link
Member

miq-bot commented Mar 27, 2017

Checked commit mzazrivec@e74101c with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
4 files checked, 11 offenses detected

app/helpers/application_helper/toolbar/ansible_credential_center.rb

  • ❗ - Line 14, Col 26 - Style/MultilineMethodCallBraceLayout - Closing method call brace must be on the line after the last argument when opening brace is on a separate line from the first argument.
  • ❗ - Line 21, Col 92 - Style/MultilineMethodCallBraceLayout - Closing method call brace must be on the line after the last argument when opening brace is on a separate line from the first argument.
  • ❗ - Line 24, Col 3 - Style/IndentArray - Indent the right bracket the same as the first position after the preceding left parenthesis.
  • ❗ - Line 3, Col 5 - Style/IndentArray - Use 2 spaces for indentation in an array, relative to the first position after the preceding left parenthesis.

app/helpers/application_helper/toolbar/ansible_credentials_center.rb

  • ❗ - Line 14, Col 34 - Style/MultilineMethodCallBraceLayout - Closing method call brace must be on the line after the last argument when opening brace is on a separate line from the first argument.
  • ❗ - Line 21, Col 11 - Style/AlignHash - Align the elements of a hash literal if they span more than one line.
  • ❗ - Line 22, Col 35 - Style/MultilineMethodCallBraceLayout - Closing method call brace must be on the line after the last argument when opening brace is on a separate line from the first argument.
  • ❗ - Line 30, Col 11 - Style/AlignHash - Align the elements of a hash literal if they span more than one line.
  • ❗ - Line 31, Col 93 - Style/MultilineMethodCallBraceLayout - Closing method call brace must be on the line after the last argument when opening brace is on a separate line from the first argument.
  • ❗ - Line 34, Col 3 - Style/IndentArray - Indent the right bracket the same as the first position after the preceding left parenthesis.
  • ❗ - Line 3, Col 5 - Style/IndentArray - Use 2 spaces for indentation in an array, relative to the first position after the preceding left parenthesis.

@AparnaKarve
Copy link
Contributor

@AparnaKarve I can work on the specs, but if the PR is meant to be merged soon, I'd rather do them in a separate PR.

yeah, works for me.
I believe there is anyway going to be a Part II of this PR soon once the model/API changes are in and once we have something more workable to play with.

@AparnaKarve
Copy link
Contributor

@h-kataria I've listed all known issues here:
#641 (comment)
which will be addressed in follow-up PR(s).
Also, there will be a follow-up PR for Jasmine specs.

Unfortunately, due to lack of a working backend, from a reviewer/tester and I suppose even from a developer's point of view, there hasn't really been a "gratification" to see something working completely, in it's entire cycle.
Hopefully, the backend will be resolved soon.
For now, this is GTG.
Thanks.

@h-kataria
Copy link
Contributor

@mzazrivec can you remove WIP labels if this is ready for merging

@h-kataria
Copy link
Contributor

Removing WIP label from PR and merging, remaining issues and jasmine spec tests will be addressed in follow up PR.

@h-kataria h-kataria removed the wip label Mar 27, 2017
@h-kataria h-kataria changed the title [WIP] CRUD for embedded Ansible credentials CRUD for embedded Ansible credentials Mar 27, 2017
@h-kataria h-kataria merged commit c17b2f4 into ManageIQ:master Mar 27, 2017
@mzazrivec mzazrivec deleted the crud_for_embedded_ansible_credentials branch March 29, 2017 16:44
@chessbyte chessbyte added this to the Sprint 57 Ending Mar 27, 2017 milestone Oct 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants