-
Notifications
You must be signed in to change notification settings - Fork 356
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
TextualSummary: unify power states. #4085
Merged
himdel
merged 1 commit into
ManageIQ:master
from
martinpovolny:textual_summary_power_unification
Jun 11, 2018
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,22 @@ | ||
module TextualMixins::TextualPowerState | ||
def textual_power_state | ||
state = @record.current_state.downcase | ||
state = "unknown" if state.blank? | ||
h = {:label => _("Power State"), :value => state} | ||
h[:image] = "svg/currentstate-#{@record.template? ? 'template' : state}.svg" | ||
h | ||
VALID_POWER_STATE = %w( | ||
archived connecting disconnected image_locked install_failed maintenance | ||
migrating never non_operational not_responding off on orphaned paused | ||
powering_down powering-down powering_up powering-up preparing_for_maintenance | ||
reboot_in_progress retired shelved_offloaded shelved standby suspended | ||
template terminated unknown wait_for_launch | ||
).freeze | ||
|
||
def power_state_to_image(state) | ||
"svg/currentstate-#{state}.svg" if VALID_POWER_STATE.include?(state) | ||
end | ||
|
||
def textual_power_state_whitelisted(state) | ||
state = state.blank? ? 'unknown' : state.downcase | ||
{:label => _('Power State'), :value => state, :image => power_state_to_image(state)} | ||
end | ||
|
||
def textual_power_state_whitelisted_with_template | ||
textual_power_state_whitelisted(@record.template? ? 'template' : @record.current_state) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This looks suspiciously similar to
QuadiconHelper#MACHINE_STATE_QUADRANT
(except that one uses fonticons for those same states)Should we try to unify those two as well?
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.
Similar, but not the same. Yes, we could and should unify that. But I don't have an authoritative set of values for this. That would have to come from the backend. Or do we know what are the valid values? @skateman ?
I see two options:
QuadionHelper
ignoring the couple of extra values (powering*
).I don't have a strong opinion here.
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.
Using this for now, eventually we should be using fonticons instead of svgs here as well.