Module: Yast::NisServerWhatInclude

Defined in:
../../src/include/nis_server/what.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) initialize_nis_server_what(include_target)



41
42
43
44
45
46
47
48
49
50
51
# File '../../src/include/nis_server/what.rb', line 41

def initialize_nis_server_what(include_target)
  Yast.import "UI"

  textdomain "nis_server"

  Yast.import "Wizard"
  Yast.import "Label"
  Yast.import "Popup"
  Yast.import "NisServer"
  Yast.include include_target, "nis_server/routines.rb"
end

- (Object) WhatToConfigure

Dialog for choosing the way of the flow

Returns:

  • abort,exit, nothing,master, slave orfinish



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
# File '../../src/include/nis_server/what.rb', line 55

def WhatToConfigure
  # help text 1/2
  helptext = _(
    "<p>Select whether to configure the NIS server as a <b>master</b> or a\n<b>slave</b> or not to configure a NIS server.</p>\n"
  )

  detected = NisServer.ui_what
  labels = VBox()
  labels = Builtins.add(labels, VSpacing(1.5))

  master_setup_label = ""
  slave_setup_label = ""
  none_setup_label = ""

  if detected == :none
    # help text 2/2
    helptext = Ops.add(
      helptext,
      _(
        "<p>The NIS server package will be <b>installed</b> first if you want to\nconfigure it.</p>"
      )
    )

    # To translators: label in the dialog
    labels = Builtins.add(
      labels,
      Left(Label(_("No NIS Software is installed.")))
    )
    # To translators: label in the dialog
    labels = Builtins.add(
      labels,
      Left(Label(_("No NIS Server is configured.")))
    )

    # To translators: label in the dialog
    master_setup_label = _("Install and set up an NIS &Master Server")
    # To translators: label in the dialog
    slave_setup_label = _("Install and set up an NIS &Slave Server")
    # To translators: label in the dialog
    none_setup_label = _("&Do nothing and leave set up")
  elsif isYPServerConfigured
    isMaster = detected == :master

    labels = Builtins.add(
      labels,
      Left(Label(_("NIS Software is installed.")))
    )
    slave_or_master = isMaster ?
      # To translators: part of the label in the dialog
      _("Master") :
      # To translators: part of the label in the dialog
      _("Slave")
    # To translators: label in the dialog, %1 is Master or Slave above
    labels = Builtins.add(
      labels,
      Left(
        Label(
          Builtins.sformat(
            _("A NIS %1 Server is configured."),
            slave_or_master
          )
        )
      )
    )

    # To translators: label in the dialog
    reconfigure_master = _("Reconfigure NIS &Master Server")
    # To translators: label in the dialog
    change_to_master = _("Change to NIS &Master Server")
    # To translators: label in the dialog
    reconfigure_slave = _("Reconfigure NIS &Slave Server")
    # To translators: label in the dialog
    change_to_slave = _("Change to NIS &Slave Server")

    master_setup_label = isMaster ? reconfigure_master : change_to_master
    slave_setup_label = isMaster ? change_to_slave : reconfigure_slave
    # To translators: label in the dialog
    none_setup_label = _("&Deactivate any NIS server configuration")
  else
    # To translators: label in the dialog
    labels = Builtins.add(
      labels,
      Left(Label(_("NIS Software is installed.")))
    )
    # To translators: label in the dialog
    labels = Builtins.add(
      labels,
      Left(Label(_("No NIS Server is configured.")))
    )

    # To translators: checkbox label
    master_setup_label = _("Create NIS &Master Server")
    # To translators: checkbox label
    slave_setup_label = _("Create NIS &Slave Server")
    # To translators: checkbox label
    none_setup_label = _("&Do nothing and leave set up")
  end

  info = HBox()
  # To translators: label in the dialog
  info = Builtins.add(info, VBox(Label(_("Current status:"))))
  info = Builtins.add(info, HSpacing(4))
  info = Builtins.add(info, labels)
  buttons = VBox()
  buttons = Builtins.add(buttons, VSpacing(0.5))
  buttons = Builtins.add(
    buttons,
    Left(
      RadioButton(
        Id(:master),
        Opt(:notify),
        master_setup_label,
        detected == :master
      )
    )
  )
  buttons = Builtins.add(buttons, VSpacing(0.2))
  buttons = Builtins.add(
    buttons,
    Left(
      RadioButton(
        Id(:slave),
        Opt(:notify),
        slave_setup_label,
        detected == :slave
      )
    )
  )
  buttons = Builtins.add(buttons, VSpacing(0.2))
  buttons = Builtins.add(
    buttons,
    Left(
      RadioButton(
        Id(:none),
        Opt(:notify),
        none_setup_label,
        detected == :none
      )
    )
  )
  buttons = Builtins.add(buttons, VSpacing(0.5))

  buttons = HBox(HSpacing(0.5), buttons, HSpacing(0.5))

  buttons = HVSquash(RadioButtonGroup(Id(:rb), buttons))

  contents = VBox()
  contents = Builtins.add(contents, info)
  contents = Builtins.add(contents, VSpacing())
  # To translators: frame label
  contents = Builtins.add(
    contents,
    VCenter(Frame(_("Select what you want to do"), buttons))
  )
  contents = Builtins.add(contents, VStretch())

  # To translators: dialog label
  Wizard.SetContents(
    _("Network Information Service (NIS) Server Setup"),
    contents,
    helptext,
    true,
    true
  )

  ui = nil
  current_button = nil
  begin
    current_button = Convert.to_symbol(
      UI.QueryWidget(Id(:rb), :CurrentButton)
    )

    if current_button == :none
      Wizard.SetNextButton(:finish, Label.FinishButton)
    elsif Builtins.contains([:master, :slave], current_button)
      Wizard.RestoreNextButton
    end

    Wizard.SetFocusToNextButton

    ui = Convert.to_symbol(UI.UserInput)
    ui = :abort if ui == :cancel || ui == :back

    if ui == :abort && NisServer.modified && !Popup.ReallyAbort(true)
      ui = :again
    end
  end until Builtins.contains([:back, :next, :abort, :finish], ui)

  return :abort if ui == :abort
  return :exit if ui == :back
  if ui == :finish && (detected == :none || !isYPServerConfigured)
    return :nothing
  end

  current_button = Convert.to_symbol(
    UI.QueryWidget(Id(:rb), :CurrentButton)
  )

  NisServer.modified = true if NisServer.ui_what != current_button

  NisServer.ui_what = current_button
  ui == :next ? current_button : ui
end