Changes in #3721 by @hstastna made refresh button on playbooks subpage disappear. It is now only present on the main repository show page. Was this an intention?
There is a [piece of code] in _ansible_repository_controller.rb_ handling the refresh button. It contains some rather obscure manipulation with the @display and params[:display] values: https://github.com/ManageIQ/manageiq-ui-classic/blob/37a9337bbd4383328f1d722b9318ece80efbaaa3/app/controllers/ansible_repository_controller.rb#L44 followed directly by https://github.com/ManageIQ/manageiq-ui-classic/blob/37a9337bbd4383328f1d722b9318ece80efbaaa3/app/controllers/mixins/generic_show_mixin.rb#L121. This still doesn鈥檛 work well if multiple browser windows are used.
If we want to have the refresh button there, I鈥檇 suggest:
@display and params[:display] handling. Currently it is not easily understandable what is going on there. init_show
template = 'show'
if self.class.display_methods.include?(params[:display])
display_nested_list(params[:display])
elsif self.class.custom_display_modes.include?(params[:display])
custom_display_call(params[:display])
template = custom_display_method_name(params[:display])
end
In case the refresh button should not be present on the subpages, it would be good to remove the code that is there only to support this feature:
@Glutexo In https://github.com/ManageIQ/manageiq-ui-classic/pull/3721 I removed only the lines of the code which I have added before by mistake, while adding tagging feature for Ansible Playbooks, ... (for example here: https://github.com/ManageIQ/manageiq-ui-classic/pull/3522) It turned out that that PR caused many problems (I mean the way I've added toolbar to the pages), especially for nested lists, tagging, etc. I fixed that by https://github.com/ManageIQ/manageiq-ui-classic/pull/3721. While displaying nested lists, Refresh button was never designed to be there. If you need Refresh button for some reason in Ansible Playbooks, ..., you need to make changes in _app/helpers/application_helper/toolbar/ansible_playbooks_center.rb_.
@hstastna I don鈥檛 need that button. It might make sense to have one there, since it is on the main show page, but if it was not intended, it鈥檚 still fine not to have it. My only concern was that there is already some code that handles this button on the Playbooks subpage.
I can prepare a PR that removes this remnants. 馃Ч That will clean up the code (and specs) a bit and also gets rid of the @display/params[:display] juggling. Which I think is 馃憤 .
@Glutexo Where exactly is the code that "handles this button on the Playbooks subpage" ? I can't see it, at least not in ansible playbook controller where I would expect that.
It鈥榮 this line: https://github.com/ManageIQ/manageiq-ui-classic/blob/29856637524202c4bac5a756bd019086e738dcf2/app/controllers/ansible_repository_controller.rb#L43 It tries to preserve the @display value (from memory I guess) by pretending it came in a request. It is then picked up by GenericShowMixin#init_show and stored back into @display instead of its default value 'main'.
If it wasn鈥檛 there, pushing the refresh button on the playbooks subpage would cause the main div content to be replaced by the main show content. It still doesn鈥檛 work well however, because @display is not stateless and must contain the correct value. If you move to main repository show page (e. g. in a different window) and then press the button on this page, it will still load the main page and not the playbooks subpage.
@Glutexo It's because Ansible Repositories have Refresh button. Others not. But.. I still don't understand the problem well. Could you write down _the exact_ steps to reproduce the problem? And let's assume that we don't want Refresh button on any subpage.
@hstastna If we assume that we don鈥檛 need the refresh button on the subpages, then it鈥檚 not necessary to fix this line and reproduce the bug it causes. In such case, the line is only redundant and can be removed with a few spec examples.
I created a PR that removes this unused code: #4163
If you were still interested in why this line was troublesome in the first place, here are steps to reproduce:
If you do this, the contents of the main div is replaced by the repository鈥檚 main show page. Normally it should be replaced by an updated version of the playbooks subpage contents. This doesn鈥檛 matter anymore though if the code is going to be removed and there is no intention in returning the reload button to the subpage.
Thank you, @Glutexo, for this great explanation. Yes, and I also have found the PR which added params[:display] = @display if @display to the code (https://github.com/ManageIQ/manageiq-ui-classic/pull/2419) and this made things more clear to me, too :)