New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added LanItems summary #488
Conversation
I'm fine with the general approach (having a new class that takes care of generating the summary), but I would simplify it a little bit:
Just my opinion :) |
for the first view it seems to be a bit over engineered, I'll give it even second look ;-) |
I tried to make it general and as much open as possible. For example with the OneLine type currently we only show on interface or multiple interfaces, but maybe we could change the number of the items to show per line being an option to pass, but don't like to use as a specific option in LanItem, but as commented. The current types are mostly like presenters, I could by now instead of create separate class just call LanItemsSummary.send(@summary_type) and move the logic to methods as @imobachgs has suggested. |
# 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The license is trunca
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
7a182d9
to
08e146b
Compare
6119116
to
f582f05
Compare
@mchf @mvidner ok, as no updates I will modify current PR based on @imobachgs review. |
|
||
LanItems.Items.each do |item, conf| | ||
next if !Yast::LanItems.IsItemConfigured(item) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you separate the body with blank lines?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
np: A more elegant solution (in my opinion) would be using reduce
(please, feel free to ignore this comment as it's just a matter of taste).
Summary.DevicesList(items) | ||
end | ||
|
||
# Generates a one line text summary showing the . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Showing what?
0 => { "ifcfg" => "eth0" }, | ||
1 => { "ifcfg" => "eth1" }, | ||
2 => { "ifcfg" => "br0" } | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.freeze?
end | ||
|
||
describe "#default" do | ||
it "retuns a Richtext summary of the configured interfaces" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
returns
|
||
context "when there are no configured interfaces" do | ||
let(:items) { {} } | ||
it "returns 'Not configured'" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Above you're referencing to Yast::Summary.NotConfigured
. Please, keep consistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but Summary.NotConfigured returns richtext
Yast::Summary.NotConfigured => <ul><li>Not configured yet.</li></ul>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I'm missing something, but looking at its definition:
Yast.import "Summary"
Yast::Summary.NotConfigured #=> "Not configured yet."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I was thinking in the previous output that was based on Yast::Summary.DevicesList([])
, updated! and thnx for check it.
when 1 | ||
output << configured.join(", ") | ||
else | ||
output << "Multiple Interfaces" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PLS mark text for translators
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated!
1f069a1
to
dcf3477
Compare
end | ||
let(:no_interfaces) { _("Not configured") } | ||
let(:multiple_interfaces) { _("Multiple Interfaces") } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
np: Maybe these ones are just constants.
8c74e79
to
9a42b69
Compare
This is just the firs request for comments, I could make it simpler if needed or if we consider it as over-engineering.
I decided to use the LanItems.summary but permitting to used different types of summaries being the Default based on Summary class as it is in others networks modules like:
https://github.com/yast/yast-network/blob/master/src/modules/Host.rb#L263
https://github.com/yast/yast-network/blob/master/src/modules/DNS.rb#L532
https://github.com/yast/yast-network/blob/master/src/modules/DNS.rb#L532
So for CASP one click dialog we could use:
Yast::LanItems.summary("one_line")
or
Yast::LanItemsSummary.new.one_line
And in case of a proposal in the future just
Yast::LanItems.summary
Here screenshots with the current CASP one dialog overview: yast/yast-installation#487
With one interface configured
With multiple interfaces and different bootproto