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

Remove copy and paste button for automation simulation #9308

Merged
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
32 changes: 0 additions & 32 deletions app/controllers/application_controller/automate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,36 +33,6 @@ def resolve_button_throw
end
private :resolve_button_throw

# Copy current URI as an automate button
def resolve_button_copy
session[:resolve_object] = copy_hash(@resolve)
head :ok
end
private :resolve_button_copy

# Copy current URI as an automate button
def resolve_button_paste
@resolve = copy_hash(session[:resolve_object])
@edit = session[:edit]
@custom_button = @edit[:custom_button]
@edit[:instance_names] = @resolve[:instance_names]
@edit[:new][:instance_name] = @resolve[:new][:instance_name]
@edit[:new][:object_message] = @resolve[:new][:object_message]
@edit[:new][:object_request] = @resolve[:new][:object_request]
@edit[:new][:attrs] = @resolve[:new][:attrs]
@edit[:new][:target_class] = @resolve[:target_class] = @resolve[:new][:target_class]
@edit[:uri] = @resolve[:uri]
(ApplicationController::AE_MAX_RESOLUTION_FIELDS - @resolve[:new][:attrs].length).times { @edit[:new][:attrs].push([]) }
@changed = (@edit[:new] != @edit[:current])
render :update do |page|
page << javascript_prologue
page.replace_html("main_div", :partial => "shared/buttons/ab_list")
page << javascript_for_miq_button_visibility_changed(@changed)
page << "miqSparkle(false);"
end
end
private :resolve_button_paste

# Copy current URI as an automate button
def resolve_button_simulate
@edit = copy_hash(session[:resolve])
Expand Down Expand Up @@ -126,8 +96,6 @@ def resolve

case params[:button]
when "throw", "retry" then resolve_button_throw
when "copy" then resolve_button_copy
when "paste" then resolve_button_paste
when "simulate" then resolve_button_simulate
else resolve_button_reset_or_none
end
Expand Down
8 changes: 0 additions & 8 deletions app/helpers/application_helper/button/ae_copy_simulate.rb

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,2 @@
class ApplicationHelper::Toolbar::MiqAeToolsSimulateCenter < ApplicationHelper::Toolbar::Basic
Copy link
Member

Choose a reason for hiding this comment

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

If there's nothing left in this toolbar, is it possible to delete the toolbar?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried doing that, but the application was saying it expected the class definition for some reason. I was trying to find where that was happening but wasn't able to. Do you know where that might be?

Copy link
Member

@Fryguy Fryguy Nov 11, 2024

Choose a reason for hiding this comment

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

Looks like

class_name = 'ApplicationHelper::Toolbar::' + ActiveSupport::Inflector.camelize(tb_name.sub(/_tb$/, ''))

Copy link
Member

Choose a reason for hiding this comment

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

I don't really understand how it gets there though - do you have a stack track when it fails when you delete 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.

There's no stack trace in my terminal, just this error message shows up on my UI
Screenshot 2024-11-11 at 3 30 03 PM

Copy link
Member

Choose a reason for hiding this comment

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

you should see a stack trace in possibly the development.log or the evm.log

Copy link
Contributor Author

@liu-samuel liu-samuel Nov 11, 2024

Choose a reason for hiding this comment

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

Hmm i don't see anything that relates to the toolbar in the evm.log, just that it connects to the database

[----] I, [2024-11-11T15:55:34.662273#18468:5ec4]  INFO -- evm: MIQ(ManageIQ::Session.configure_session_store) Using session_store: ActionDispatch::Session::MemCacheStore
[----] I, [2024-11-11T15:55:34.820424#18468:5ec4]  INFO -- evm: MIQ(Vmdb::Initializer.init) Initializing Application: Program Name: bin/rails, PID: 18468, ENV['EVMSERVER']: 
[----] I, [2024-11-11T15:55:34.820474#18468:5ec4]  INFO -- evm: MIQ(Vmdb::Initializer.log_db_connectable) Successfully connected to the database.
[----] I, [2024-11-11T15:55:35.881939#18468:5ec4]  INFO -- evm: MIQ(Vmdb::Loggers.apply_config) Log level for azure has been changed to [WARN]
[----] I, [2024-11-11T15:55:35.882076#18468:5ec4]  INFO -- evm: MIQ(Vmdb::Loggers.apply_config) Log level for vim has been changed to [WARN]
[----] I, [2024-11-11T15:55:35.882171#18468:5ec4]  INFO -- evm: MIQ(Vmdb::Initializer.init) Initializing Application: Program Name: bin/rails, PID: 18468, ENV['EVMSERVER']: 
[----] I, [2024-11-11T15:55:35.882213#18468:5ec4]  INFO -- evm: MIQ(Vmdb::Initializer.log_db_connectable) Successfully connected to the database.

Copy link
Member

Choose a reason for hiding this comment

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

Ok, then let's leave it for now

button_group('miq_ae_tools_vmdb', [
button(
:ae_copy_simulate,
'fa fa-files-o fa-lg',
N_('Copy object details for use in a Button'),
N_('Copy'),
:url => "resolve",
:url_parms => "?button=copy",
:klass => ApplicationHelper::Button::AeCopySimulate),
Copy link
Member

Choose a reason for hiding this comment

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

Do you see any other usages of this class? If not, can we delete it?

Copy link
Member

@Fryguy Fryguy Nov 11, 2024

Choose a reason for hiding this comment

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

I searched and I think you can delete all references to AeCopySimulate: https://github.com/search?q=org%3AManageIQ%20AeCopySimulate&type=code

])
end
21 changes: 0 additions & 21 deletions app/views/shared/buttons/_ab_form.html.haml
Original file line number Diff line number Diff line change
@@ -1,25 +1,4 @@
#ab_form
#policy_bar
- if session[:resolve_object].present?
- copied_target_class = session[:resolve_object][:new][:target_class]
- current_target_class = @edit[:new][:target_class]
- if copied_target_class == current_target_class
= link_to({:action => "resolve", :button => "paste"},
Copy link
Member

Choose a reason for hiding this comment

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

There's probably also a "resolve" action in the simulation controller that can be removed as well. Might involve some more searching though.

Copy link
Contributor Author

@liu-samuel liu-samuel Nov 12, 2024

Choose a reason for hiding this comment

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

def resolve
    custom_button_redirect = params[:button] == 'simulate' || params[:simulate] == 'simulate'
    assert_privileges(custom_button_redirect ? 'ab_button_simulate' : 'miq_ae_class_simulation')
    @explorer = true
    @breadcrumbs = []
    drop_breadcrumb(:name => _("Resolve"), :url => "/miq_ae_tools/resolve")
    @lastaction = "resolve"
    @right_cell_text = _("Simulation")
    case params[:button]
    when "throw", "retry" then resolve_button_throw
    when "copy"     then resolve_button_copy
    when "paste"    then resolve_button_paste
    when "simulate" then resolve_button_simulate
    else                 resolve_button_reset_or_none
    end
  end

I think this is what the resolve is referring to, so I should be able to remove the copy and paste cases but not the others since they deal with the actual simulation

"data-miq_sparkle_on" => true,
"data-miq_sparkle_off" => true,
:remote => true,
"data-method" => :post,
:class => 'btn btn-default',
:title => _("Paste object details for use in a Button.")) do
%i.fa.fa-clipboard
- else
%button.btn.btn-default.disabled{:title => _("Paste is not available, target class differs from the target class of the object copied from the Simulation screen")}
%i.fa.fa-clipboard
- else
%button.btn.btn-default.disabled{:title => _("Paste is not available, no object information has been copied from the Simulation screen")}
%i.fa.fa-clipboard
= render :partial => "layouts/flash_msg"

#custom_button_tabs
%ul.nav.nav-tabs{'role' => 'tablist'}
= miq_tab_header('ab_options_tab', @sb[:active_tab]) do
Expand Down

This file was deleted.

30 changes: 0 additions & 30 deletions spec/views/shared/buttons/_ab_form.html.haml_spec.rb

This file was deleted.