-
Notifications
You must be signed in to change notification settings - Fork 358
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
Add Ansible Repository refresh output page #3762
Add Ansible Repository refresh output page #3762
Conversation
@Glutexo Could you please add some screenshots if there is some change in the UI? I'm not sure if I understand your change. Thanks! |
And in specs, I would better use
instead of |
@@ -97,6 +111,12 @@ def new | |||
@in_a_form = true | |||
end | |||
|
|||
def show_output | |||
drop_breadcrumb(:name => "Refresh output", :url => show_output_link) |
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.
Missing gettext.
Here there the screenshots requested. They show the Repository show page and its new output subpage. Before this PR, all Repositories looked the same. This adds a subpage (display mode) for the failed ones. The Status: failed row turns into a link. For the non-failed repo’s too, the Status row is not clickable, she subpage can be accessed directly by the url though. The Refresh button in the toolbar should reload the subpage contents via AJAX, not returning to the Summary. The back-arrow button should return to the Summary. |
436dfea
to
c6beb47
Compare
I fixed the missing gettext spotted by @mzazrivec, squashed it and rebased onto current upstream master. @hstastna As for the parentheses in the Technically, the |
end | ||
|
||
it 'calls show_output method' do | ||
controller.params[:display] = 'output' |
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 that you set controller.params[:display]
in more it
blocks exactly like this. You can use context
blocks and set params[:display]
in them by using let
for lazy evaluation and it
blocks then. For example like this:
context 'calling show_output method' do
let(:display) { 'output' }
it 'calls show_output method' do
receives_init_show
expect(controller).to receive(:show_output)
renders
controller.send(:button)
end
end
If you do so, you may also want to change line 125 https://github.com/ManageIQ/manageiq-ui-classic/pull/3762/files#diff-62ca34af6656484e37abce1fb2fe1461R125 like this, to set params[:display]
for the spec properly:
let(:params) { {:action => "button", :pressed => "ansible_repository_reload", :display => display} }
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.
Cool! I didn’t know that more nested let
s can be used from outside context too. Thanks!
c6beb47
to
ce87ef5
Compare
In reaction to a review comment by @hstastna, I grouped the “refreshing an actual repository page” specs into contexts based on the Just a note: We decided to store the output capture for all repositories, not only for the failed ones. This requires no code change in the UI, it is just not a bug when the “Status: successful” row becomes clickable. Capturing stdout makes sense for non-failed repositories as well, since there might be warnings or other useful information. |
This pull request is not mergeable. Please rebase and repush. |
When I created this PR, there was a refresh button on subpages (custom display modes) as it was on main show page. When I now want to test it after rebasing, I don’t see the refresh button anymore. Custom display mode (subpage) toolbar: Is it possible that toolbar behavior changed? I added a custom display mode in this PR and along with that a piece of code handling the refresh button. If the button is really no longer there, I can remove this newly introduced code and thus reduce complexity. Also in such case the refresh button handling could be simplified, not in this PR though. Maybe @mzazrivec or @himdel could know? |
ce87ef5
to
31f9f59
Compare
@miq-bot add_label pending core |
|
||
template = 'show' | ||
if self.class.display_methods.include?(params[:display]) | ||
display_nested_list(params[:display]) |
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.
how is display_nested_list
relevant here? Are you introducing any nested lists?
(or is this just reimplementing the parts of show
that were already needed?)
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.
@himdel This is a piece taken from the show
method in a not very DRY way.
The show
method doesn’t reach the custom_display_call
at all, so at least this one would have to remain here. Because of that and some other struggles I decided to leave only what’s necessary here from the show
method.
That is: init_show
and those two if
s. The first is for playbooks
subpage, which is a nested list, the second is for the new output
subpage. I am however not sure whether it decreases complexity – the whole show
method is not called here – or increases it – there are two decision points introduced.
However, since the Refresh button disappeared, this might not be actually needed at all. Moreover, the existing code there could be safely removed.
end | ||
end | ||
|
||
def receives_init_show |
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.
Cc @skateman , I think you may have some comments here..
(Methods in a spec.)
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.
@Glutexo methods in a spec are evil, can you rewrite them using shared examples and shared contexts?
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.
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.
TL;DR: mixing two patterns that do the same thing (rspec ruby vs pure ruby) is never a good idea
If you want a longer explanation, I can try next week if that's okay for you 😉
@Glutexo you may need to explicitly set |
I get it now. The playbooks subpage used the same toolbar as its parent repository page. Because of that the Policy › Add Tags button added tags to the repository and not to the playbooks. That was addressed and fixed by #3721. However at the same time the repository toolbar contained a refresh button. This button appeared on the playbooks subpage too. There is a piece of code that handles the button press. Thanks to the magic in the generic show mixin it works for the playbooks subpage correctly too. Still there is some rather obscure manipulation with the
For a mix of reasons, this piece of code didn’t work automatically for the new stdout subpage I introduced. Because of that I made some controversial modifications to the refresh button handling. But since the button is no longer there, although not necessary intentionally, this piece of code is not necessary and can be removed from this PR. |
31f9f59
to
51dfdbf
Compare
So, the refresh button is gone for subpages (be in intentional or not). Thanks to that I could simplify this PR. Removed changes to the refresh button handling making it work for the new subpage as well as the related tests. Those can be added in case the refresh button would return. Still this is not mergeable, because of dependencies on other PRs. It is however hopefully at least simple enough to be reviewed. |
@Glutexo It looks good (except the specs). Maybe you could divide the code into more commits to make your changes more clear to anyone. At least 2 commits: commit for the changes + commit for specs ;) |
@Glutexo Travis is failing here and it looks like it is related to your changes. Specs are failing for me locally, too, with your changes (they pass without your changes). Could you check it, please? Thank you! 👍 |
Okay, I’ll check more deeply. |
51dfdbf
to
1338d45
Compare
Failing specsOh, of course the specs are failing! It’s because these changes depend on a model/schema update: Please checkout https://github.com/Glutexo/manageiq/tree/add_configuration_script_source_last_update_stdout and https://github.com/Glutexo/manageiq-schema/tree/add_configuration_script_source_last_update_stdout to update the database schema and the Rails model. Unfortunately I am currently not able to quickly test it locally, because Bundler and updates fail for me for some unknown reason. But that above is necessary to test both by rspec and manually. How to test the UI behaviorPrerequisities
Steps
|
Of course I've updated the db schema. And specs are still failing. |
@hstastna I know you said you updated the schema, but still I’d like to verify you don’t have the same problem as I did. I double- (triple-) checked and got failing specs too. This was really because of the missing column, at least on my machine, in the |
Try from the manageiq core repo: RAILS_ENV=test bin/rake db:migrate Might help, but just a guess 😉 |
@hstastna Just to be sure. When you run the
which would mean that the schema is bad. If it’s something different, then I am wrong with all those schema-rants for the whole time. |
Create a custom display mode for Ansible Repository show page with last refresh output capture. If an Ansible Tower Repository has this capture from its last failed refresh, the Status row becomes a link to this subpage.
1338d45
to
c847860
Compare
@hstastna I’d prefer not to split the commit to have executive code in a different one than tests. I like that the commit is atomic and tested by itself. Moreover, the spec changes are so little that it doesn't make much sense to extract those. Sorry. 😔 May I ask you to check running the specs with the new column name? |
Checked commit Glutexo@c847860 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 |
@Glutexo Finally, the specs passed 👍 for me, locally. |
All related PRs merged now. @miq-bot remove_label pending core |
Tested, looks good 👍 :) The only thing:
this is called |
Create a custom display mode for Ansible Repository show page with last refresh output capture. If an Ansible Tower Repository has this capture from its last failed refresh, the Status row becomes a link to this subpage.
Presenting this information is a workaround for cloning repositories from HTTPS servers with untrusted SSL certificates. Tower API does not offer an option to disable SSL check, so with the stdout user can at least see, why the cloning actually failed.
Along with RSpec examples for this feature, refactor a bit other tests related to the page refresh button:
https://bugzilla.redhat.com/show_bug.cgi?id=1513616
Prior merging this PR, following PRs are required to be merged:
/cc @ZitaNemeckova, @hstastna for review