Skip to content
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

Closed
wants to merge 4 commits into from
Closed

Conversation

teclator
Copy link
Contributor

@teclator teclator commented Jan 16, 2017

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

=== OLD ===

Yast::LanItems.summary(:type => "one_line")
or
Yast::LanItemsSummary.new(:type => "one_line").summary
or
Yast::LanItemsSummary::OneLine.new.summary

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

networkoneinterface

With multiple interfaces and different bootproto

networkmultipleinterfaces

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.1%) to 48.542% when pulling 7ce2bac on teclator:lan_items_summary into 027fc19 on yast:master.

@imobachgs
Copy link
Contributor

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:

  • Using classes for each type of summary looks overkill to me (after all, logic is not that complex and you are not maintaining state). Maybe I would implement different methods and that's all.
  • I would avoid using a generic @options hash. I rather prefer to use real parameters (using keywords, for example). If we're going to have a lot of options, then @options would be a reasonable approach.

Just my opinion :)

@mchf
Copy link
Member

mchf commented Jan 16, 2017

for the first view it seems to be a bit over engineered, I'll give it even second look ;-)

@teclator
Copy link
Contributor Author

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The license is trunca

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.1%) to 48.542% when pulling 7a182d9 on teclator:lan_items_summary into 027fc19 on yast:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.1%) to 48.542% when pulling 08e146b on teclator:lan_items_summary into 027fc19 on yast:master.

@teclator teclator force-pushed the lan_items_summary branch 2 times, most recently from 6119116 to f582f05 Compare January 16, 2017 13:04
@teclator
Copy link
Contributor Author

@mchf @mvidner ok, as no updates I will modify current PR based on @imobachgs review.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.1%) to 48.581% when pulling f51c832 on teclator:lan_items_summary into 027fc19 on yast:master.


LanItems.Items.each do |item, conf|
next if !Yast::LanItems.IsItemConfigured(item)

Copy link
Contributor

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?

Copy link
Contributor

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 .
Copy link
Contributor

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" }
}
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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.

Copy link
Contributor Author

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>

Copy link
Contributor

@imobachgs imobachgs Jan 17, 2017

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."

Copy link
Contributor Author

@teclator teclator Jan 17, 2017

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"
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated!

end
let(:no_interfaces) { _("Not configured") }
let(:multiple_interfaces) { _("Multiple Interfaces") }
Copy link
Contributor

@imobachgs imobachgs Jan 17, 2017

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.

@teclator teclator force-pushed the lan_items_summary branch 4 times, most recently from 8c74e79 to 9a42b69 Compare January 17, 2017 14:40
@teclator teclator changed the title [RFC] Added LanItems summary Added LanItems summary Jan 17, 2017
@coveralls
Copy link

Coverage Status

Coverage increased (+0.3%) to 48.581% when pulling 9a42b69 on teclator:lan_items_summary into bdd94f3 on yast:master.

@teclator teclator changed the base branch from master to SLE-12-SP2 January 17, 2017 15:17
@teclator teclator changed the base branch from SLE-12-SP2 to master January 17, 2017 15:18
@teclator teclator closed this Jan 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants