-
Notifications
You must be signed in to change notification settings - Fork 12
/
nfs_version.rb
102 lines (87 loc) · 2.63 KB
/
nfs_version.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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
# Copyright (c) [2022] 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 LLC about this file by physical or electronic mail, you may
# find current contact information at www.suse.com.
require "yast"
require "y2storage/filesystems/nfs_version"
Yast.import "UI"
module Y2NfsClient
module Widgets
# Widget to select a NFS version
class NfsVersion
include Yast::UIShortcuts
include Yast::I18n
# Constructor
#
# @param initial_version [Y2Storage::Filesystems::NfsVersion]
def initialize(initial_version)
super()
textdomain "nfs"
@initial_version = initial_version
end
# @return [Yast::Term]
def contents
ComboBox(widget_id, _("NFS &Version"), items)
end
# Version currently selected in the widget
#
# @return [Y2Storage::Filesystems::NfsVersion]
def value
value = Yast::UI.QueryWidget(widget_id, :Value)
Y2Storage::Filesystems::NfsVersion.find_by_value(value)
end
private
# @return [Y2Storage::Filesystems::NfsVersion]
attr_reader :initial_version
# @return [Yast::Term]
def widget_id
Id(:nfs_version)
end
# @return [Array<Yast::Term>]
def items
Y2Storage::Filesystems::NfsVersion.all.map { |v| generate_item(v) }
end
# Generates a selection item from the given version
#
# @param version [Y2Storage::Filesystems::NfsVersion]
# @return [Yast::Term]
def generate_item(version)
Item(Id(version.value), label_for(version), version == initial_version)
end
# Label for the given version
#
# @param version [Y2Storage::Filesystems::NfsVersion]
# @return [String]
def label_for(version)
case version.value
when "any"
_("Any (Highest Available)")
when "3"
_("Force NFSv3")
when "4"
_("Force NFSv4")
when "4.1"
_("Force pNFS (v4.1)")
when "4.2"
_("Force NFSv4.2")
else
version.value
end
end
end
end
end