-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
283 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
/.yardoc | ||
/coverage | ||
*.bz2 | ||
*.pot |
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
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,122 @@ | ||
# ------------------------------------------------------------------------------ | ||
# Copyright (c) 2015 SUSE LLC, All Rights Reserved. | ||
# | ||
# | ||
# This program is free software; you can redistribute it and/or modify it under | ||
# the terms of version 2 of the GNU General Public License as | ||
# published by the Free Software Foundation. | ||
# | ||
# This program is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | ||
# details. | ||
# | ||
# You should have received a copy of the GNU General Public License along with | ||
# this program; if not, contact SUSE LLC. | ||
# | ||
# To contact SUSE about this file by physical or electronic mail, you may find | ||
# current contact information at www.suse.com. | ||
# ------------------------------------------------------------------------------ | ||
|
||
require "yast" | ||
|
||
module Migration | ||
# Display the "finished" dialog, allow rebooting the machine | ||
class FinishDialog | ||
include Yast::Logger | ||
include Yast::I18n | ||
include Yast::UIShortcuts | ||
|
||
Yast.import "UI" | ||
Yast.import "Wizard" | ||
Yast.import "Popup" | ||
Yast.import "Label" | ||
|
||
attr_accessor :reboot | ||
|
||
# constructor | ||
def initialize | ||
textdomain "migration" | ||
|
||
@reboot = false | ||
end | ||
|
||
# display and run the dialog | ||
# @return [Symbol] user input | ||
def run | ||
Yast::Wizard.SetContents( | ||
# TRANSLATORS: dialog title | ||
_("Migration Finished"), | ||
dialog_content, | ||
help, | ||
# going back is not possible | ||
false, | ||
true | ||
) | ||
|
||
Yast::Wizard.SetNextButton(:next, Yast::Label.FinishButton) | ||
|
||
loop do | ||
ret = Yast::UI.UserInput | ||
|
||
if ret == :next && reboot? | ||
# TRANSLATORS: popup message, restart can be canceled by the [Cancel] button | ||
if Yast::Popup.ContinueCancel(_("The system will be restarted in one minute\n" \ | ||
"after closing this YaST module.")) | ||
|
||
store_values | ||
else | ||
next | ||
end | ||
end | ||
|
||
return ret if [:next, :back, :cancel, :abort].include?(ret) | ||
end | ||
end | ||
|
||
private | ||
|
||
def help | ||
# TRANSLATORS: a short help text (the details are directly in the dialog) | ||
_("<p><b>Finish</b> will close the migration and you should restart " \ | ||
"the system as soon as possible.</b>") | ||
end | ||
|
||
# the main dialog content | ||
# @return [Yast::Term] UI term | ||
def dialog_content | ||
VBox( | ||
VSpacing(1), | ||
RichText(Id(:details), Opt(:vstretch), message), | ||
VSpacing(1), | ||
# TRANSLATORS: check button label, if checked the system will be rebooted | ||
CheckBox(Id(:reboot), _("Restart the System"), reboot), | ||
VSpacing(1) | ||
) | ||
end | ||
|
||
def message | ||
# TRANSLATORS: The final congratulation displayed at the end of migration, | ||
# in RichText format, %s = URL link to the SUSE home page | ||
_("<h2>Congratulations!</h2><br> | ||
<p>You have just successfully finished the on-line migration.<br> | ||
The system has been upgraded, it should be restarted | ||
as soon as possible to activate the changes.</p> | ||
<p>Please visit us at %s.</p> | ||
<br> | ||
<p>Have a lot of fun!</p> | ||
<p> | ||
Your SUSE Development Team</p>") % "http://www.suse.com" | ||
end | ||
|
||
# store the current UI values | ||
def store_values | ||
self.reboot = reboot? | ||
log.info "Reboot flag: #{reboot}" | ||
end | ||
|
||
def reboot? | ||
Yast::UI.QueryWidget(:reboot, :Value) | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# ------------------------------------------------------------------------------ | ||
# Copyright (c) 2015 SUSE LLC, All Rights Reserved. | ||
# | ||
# | ||
# This program is free software; you can redistribute it and/or modify it under | ||
# the terms of version 2 of the GNU General Public License as | ||
# published by the Free Software Foundation. | ||
# | ||
# This program is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | ||
# details. | ||
# | ||
# You should have received a copy of the GNU General Public License along with | ||
# this program; if not, contact SUSE LLC. | ||
# | ||
# To contact SUSE about this file by physical or electronic mail, you may find | ||
# current contact information at www.suse.com. | ||
# ------------------------------------------------------------------------------ | ||
|
||
require_relative "test_helper" | ||
|
||
describe Migration::FinishDialog do | ||
describe ".run" do | ||
it "displays the finish message" do | ||
# check the displayed content | ||
expect(Yast::Wizard).to receive(:SetContents) do |_title, content, _help, _back, _next| | ||
richtext = content.nested_find do |t| | ||
t.respond_to?(:value) && t.value == :RichText && | ||
t.params[2].match(/Congratulations!/) | ||
end | ||
|
||
expect(richtext).to_not eq(nil) | ||
end | ||
|
||
# user pressed the "Abort" button | ||
allow(Yast::UI).to receive(:UserInput).and_return(:abort) | ||
subject.run | ||
end | ||
|
||
it "when aborted reboot flag is not set and return :abort" do | ||
# check the displayed content | ||
allow(Yast::Wizard).to receive(:SetContents) | ||
|
||
# user pressed the "Abort" button | ||
expect(Yast::UI).to receive(:UserInput).and_return(:abort) | ||
|
||
expect(subject.run).to eq(:abort) | ||
expect(subject.reboot).to eq(false) | ||
end | ||
|
||
it "displays a confirmation when reboot is requested" do | ||
allow(Yast::Wizard).to receive(:SetContents) | ||
|
||
# user pressed the "Next" button | ||
expect(Yast::UI).to receive(:UserInput).and_return(:next) | ||
allow(Yast::UI).to receive(:QueryWidget).with(:reboot, :Value).and_return(true) | ||
|
||
expect(Yast::Popup).to receive(:ContinueCancel).and_return(true) | ||
|
||
expect(subject.run).to eq(:next) | ||
expect(subject.reboot).to eq(true) | ||
end | ||
|
||
it "goes back when reboot is rejected" do | ||
allow(Yast::Wizard).to receive(:SetContents) | ||
|
||
# user pressed the "Next" button | ||
allow(Yast::UI).to receive(:UserInput).and_return(:next) | ||
# reboot is disabled at the second attempt | ||
allow(Yast::UI).to receive(:QueryWidget).with(:reboot, :Value).and_return(true, false) | ||
|
||
expect(Yast::Popup).to receive(:ContinueCancel).and_return(false) | ||
|
||
expect(subject.run).to eq(:next) | ||
expect(subject.reboot).to eq(false) | ||
end | ||
|
||
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