-
Notifications
You must be signed in to change notification settings - Fork 356
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show native viewer button for redhat providers and allow connection file (usually named console.vv) to be dowloaded after requiring via task
- Loading branch information
Showing
5 changed files
with
111 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
app/helpers/application_helper/button/vm_native_viewer_console.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
class ApplicationHelper::Button::VmNativeViewerConsole < ApplicationHelper::Button::Basic | ||
needs :@record | ||
|
||
def visible? | ||
@record.vendor == 'redhat' | ||
end | ||
|
||
def disabled? | ||
begin | ||
@record.validate_native_viewer_support | ||
rescue MiqException::RemoteConsoleNotSupportedError => err | ||
@error_message = _('VM Native viewer error: %{error}') % {:error => err} | ||
end | ||
@error_message.present? | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
spec/helpers/application_helper/buttons/vm_native_viewer_console_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
describe ApplicationHelper::Button::VmNativeViewerConsole do | ||
let(:view_context) { setup_view_context_with_sandbox({}) } | ||
let(:ems) { FactoryBot.create(:ems_redhat) } | ||
let(:record) { FactoryBot.create(:vm_redhat, :ext_management_system => ems) } | ||
let(:button) { described_class.new(view_context, {}, {'record' => record}, {}) } | ||
|
||
describe '#visible?' do | ||
subject { button.visible? } | ||
|
||
it { is_expected.to be true } | ||
end | ||
|
||
describe '#calculate_properties' do | ||
before(:each) do | ||
remote_console_validation | ||
button.calculate_properties | ||
end | ||
|
||
context 'and remote control is supported' do | ||
let(:remote_console_validation) do | ||
allow(record).to receive(:validate_native_viewer_support).and_return(true) | ||
end | ||
it_behaves_like 'an enabled button' | ||
end | ||
context 'and remote control is not supported' do | ||
let(:err_msg) { 'Remote console is not supported' } | ||
let(:remote_console_validation) do | ||
allow(record).to receive(:validate_native_viewer_support) | ||
.and_raise(MiqException::RemoteConsoleNotSupportedError, err_msg) | ||
end | ||
it_behaves_like 'a disabled button', "VM Native viewer error: Remote console is not supported" | ||
end | ||
end | ||
end |