• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

yast / yast-installation / 8705582428

16 Apr 2024 12:27PM UTC coverage: 40.913% (-0.2%) from 41.105%
8705582428

Pull #1114

github

shundhammer
Version bump and change log
Pull Request #1114: WIP: Handle autoinst AND autoupgrade (bsc#1222153)

0 of 1 new or added line in 1 file covered. (0.0%)

95 existing lines in 13 files now uncovered.

4489 of 10972 relevant lines covered (40.91%)

6.24 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.38
/src/lib/installation/dialogs/complex_welcome.rb
1
# ------------------------------------------------------------------------------
2
# Copyright (c) 2017 SUSE LLC, All Rights Reserved.
3
#
4
# This program is free software; you can redistribute it and/or modify it under
5
# the terms of version 2 of the GNU General Public License as published by the
6
# Free Software Foundation.
7
#
8
# This program is distributed in the hope that it will be useful, but WITHOUT
9
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
11
# ------------------------------------------------------------------------------
12

13
require "yast"
1✔
14
require "cwm"
1✔
15
require "cwm/dialog"
1✔
16

17
require "installation/widgets/product_selector"
1✔
18
require "y2country/widgets/language_selection"
1✔
19
require "y2country/widgets/keyboard_selection"
1✔
20
require "y2packager/widgets/product_license"
1✔
21

22
Yast.import "UI"
1✔
23
Yast.import "Wizard"
1✔
24
Yast.import "OSRelease"
1✔
25
Yast.import "ProductControl"
1✔
26

27
module Installation
1✔
28
  module Dialogs
1✔
29
    # This class implements a welcome dialog for the installer
30
    #
31
    # The dialog contains:
32
    #
33
    # * A language/keyboard selector
34
    # * If only 1 product is available, it shows the product's license.
35
    # * If more than 1 product is available, it shows the product selector.
36
    class ComplexWelcome < CWM::Dialog
1✔
37
      # @return [Array<Y2Packager::Product>] List of available products
38
      attr_reader :products
1✔
39

40
      # @return [Array<Symbol>] list of buttons to disable (:next, :abort, :back)
41
      attr_reader :disable_buttons
1✔
42

43
      # Constructor
44
      #
45
      # @param products        [Array<Y2Packager::Product>] List of available products
46
      # @param disable_buttons [Array<Symbol>] List of buttons to disable
47
      def initialize(products, disable_buttons: [])
1✔
48
        super()
13✔
49
        textdomain "installation"
13✔
50

51
        @products = products
13✔
52
        @disable_buttons = disable_buttons.map { |b| "#{b}_button" }
13✔
53
        @language_selection = Y2Country::Widgets::LanguageSelection.new(emit_event: true)
13✔
54
      end
55

56
      # Returns the dialog title
57
      #
58
      # The title can vary depending if the license agreement or the product
59
      # selection is shown.
60
      #
61
      # @return [String] Dialog's title
62
      def title
1✔
63
        if products.size > 1
4✔
64
          _("Language, Keyboard and Product Selection")
1✔
65
        elsif show_license?
3✔
66
          _("Language, Keyboard and License Agreement")
1✔
67
        else
68
          _("Language and Keyboard Selection")
2✔
69
        end
70
      end
71

72
      # Dialog content
73
      #
74
      # @return [Yast::Term] Dialog's content
75
      def contents
1✔
76
        VBox(
9✔
77
          filling,
78
          console_button,
79
          locale_settings,
80
          license_or_product_content,
81
          filling
82
        )
83
      end
84

85
      def skip_store_for
1✔
86
        [:redraw]
×
87
      end
88

89
      def run
1✔
90
        res = nil
1✔
91

92
        loop do
1✔
93
          res = super
1✔
94
          Yast::Wizard.RetranslateButtons
1✔
95
          Yast::ProductControl.RetranslateWizardSteps
1✔
96
          break if res != :redraw
1✔
97
        end
98

99
        res
1✔
100
      end
101

102
    private
1✔
103

104
      def display_console_button?
1✔
105
        # for now display the configuration button only in openSUSE Tumbleweed
106
        # TODO: later enable it also for SLE15-SP4 and Leap 15.4
107
        Yast::OSRelease.id.match?(/tumbleweed/i)
9✔
108
      end
109

110
      def console_button
1✔
111
        return Empty() unless display_console_button?
9✔
112

UNCOV
113
        require "installation/widgets/console_button"
×
UNCOV
114
        Right(Widgets::ConsoleButton.new(@language_selection))
×
115
      end
116

117
      def locale_settings
1✔
118
        Left(
9✔
119
          VBox(
120
            Left(
121
              HBox(
122
                HWeight(1, Left(@language_selection)),
123
                HSpacing(3),
124
                HWeight(1, Left(Y2Country::Widgets::KeyboardSelectionCombo.new))
125
              )
126
            ),
127
            Left(
128
              HBox(
129
                HWeight(1, HStretch()),
130
                HSpacing(3),
131
                HWeight(
132
                  1,
133
                  Left(InputField(Id(:keyboard_test), Opt(:hstretch), _("K&eyboard Test")))
134
                )
135
              )
136
            )
137
          )
138
        )
139
      end
140

141
      # Product selection widget
142
      #
143
      # @return [::Installation::Widgets::ProductSelector]
144
      def product_selector
1✔
145
        ::Installation::Widgets::ProductSelector.new(products, skip_validation: true)
3✔
146
      end
147

148
      # Product license widget
149
      #
150
      # @return [Y2Packager::Widgets::ProductLicense]
151
      def product_license
1✔
152
        Y2Packager::Widgets::ProductLicense.new(products.first, skip_validation: true)
3✔
153
      end
154

155
      # Determine whether the license must be shown
156
      #
157
      # The license will be shown when only one product with license information is available.
158
      #
159
      # @return [Boolean] true if the license must be shown; false otherwise
160
      def show_license?
1✔
161
        products.size == 1 && products.first.license?
25✔
162
      end
163

164
      # Determine whether some product is available or not
165
      #
166
      # @return [Boolean] false if no product available; true otherwise
167
      def available_products?
1✔
168
        !products.empty?
9✔
169
      end
170

171
      # License or Product content
172
      #
173
      # Shows the product selection if there is more than one product or the
174
      # license agreement if there is only one.
175
      #
176
      # @return [Yast::Term] Product selection content; Empty() if no products
177
      def license_or_product_content
1✔
178
        return Empty() unless available_products?
9✔
179
        return product_selector if products.size > 1
7✔
180

181
        show_license? ? product_license : Empty()
4✔
182
      end
183

184
      # UI to fill space if needed
185
      def filling
1✔
186
        if show_license? || Yast::UI.TextMode
18✔
187
          Empty()
6✔
188
        else
189
          VWeight(1, VStretch())
12✔
190
        end
191
      end
192
    end
193
  end
194
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc