Class: Installation::SelectSystemRole

Inherits:
UI::InstallationDialog
  • Object
show all
Includes:
UI::TextHelpers
Defined in:
src/lib/installation/select_system_role.rb

Instance Method Summary collapse

Constructor Details

#initializeSelectSystemRole

Returns a new instance of SelectSystemRole.



43
44
45
46
47
# File 'src/lib/installation/select_system_role.rb', line 43

def initialize
  super

  textdomain "installation"
end

Instance Method Details

#create_dialogObject



96
97
98
99
100
101
# File 'src/lib/installation/select_system_role.rb', line 96

def create_dialog
  clear_role
  ok = super
  Yast::UI.SetFocus(Id(:role_selector)) if ok
  ok
end

#dialog_contentObject



82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'src/lib/installation/select_system_role.rb', line 82

def dialog_content
  preselected_role_id = SystemRole.current
  preselected_role_id ||= roles.first&.id if SystemRole.default?

  VBox(
    Left(Label(Yast::ProductControl.GetTranslatedText("roles_text"))),
    VSpacing(2),
    SingleItemSelector(
      Id(:role_selector),
      roles_items(preselected_role_id)
    )
  )
end

#dialog_titleObject



74
75
76
# File 'src/lib/installation/select_system_role.rb', line 74

def dialog_title
  Yast::ProductControl.GetTranslatedText("roles_caption")
end

#help_textObject



78
79
80
# File 'src/lib/installation/select_system_role.rb', line 78

def help_text
  Yast::ProductControl.GetTranslatedText("roles_help")
end

#next_handlerObject



103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'src/lib/installation/select_system_role.rb', line 103

def next_handler
  result = select_role(selected_role_id)
  # We show the main role dialog; but the additional clients have
  # drawn over it, so draw it again and go back to input loop.
  # create_dialog do not create new dialog if it already exist like in this
  # case.
  if result == :back
    create_dialog
    nil
  else
    finish_dialog(result)
  end
end

#runObject



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'src/lib/installation/select_system_role.rb', line 49

def run
  if roles(refresh: true).empty?
    log.info "No roles defined, skipping their dialog"
    return :auto # skip forward or backward
  end

  if Yast::GetInstArgs.going_back
    # If coming back, we have to run the additional dialogs first...
    clients = additional_clients_for(SystemRole.current)
    direction = run_clients(clients, going_back: true)
    # ...and only run the main dialog (super) if there is more than one role (fate#324713) and
    # we are *still* going back
    return direction if single_role? || direction != :back
  end

  if single_role?
    # Apply the role and skip the dialog when there is only one (fate#324713)
    log.info "Only one role available, applying it and skipping the dialog"
    clear_role
    return select_role(roles.first.id)
  end

  super
end