forked from ManageIQ/manageiq-ui-classic
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor quadicon settings logic under My Settings
- Loading branch information
Showing
6 changed files
with
43 additions
and
98 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,31 @@ | ||
module ConfigurationHelper | ||
include_concern 'ConfigurationViewHelper' | ||
|
||
# Model class name comparison method that sorts provider models first | ||
def compare_decorator_class(a, b) | ||
if a.to_s.starts_with?('ManageIQ::Providers') == b.to_s.starts_with?('ManageIQ::Providers') | ||
a.to_s <=> b.to_s | ||
elsif a.to_s.starts_with?('ManageIQ::Providers') | ||
-1 | ||
elsif b.to_s.starts_with?('ManageIQ::Providers') | ||
1 | ||
end | ||
end | ||
|
||
# Returns with a hash of allowed quadicons for the current user | ||
def allowed_quadicons | ||
MiqDecorator.descendants # Get all the decorator classes | ||
.select { |klass| klass.method_defined?(:quadicon) } # Select only the decorators that define a quadicon | ||
.sort(&method(:compare_decorator_class)) | ||
.map do |decorator| | ||
# Get the model name by removing Decorator from the class name | ||
klass = decorator.to_s.chomp('Decorator') | ||
# Retrieve the related root feature node | ||
feature = klass.constantize.model_name.singular_route_key.to_sym | ||
# Just return nil if the feature is not allowed for the current user | ||
next unless role_allows?(:feature => feature, :any => true) | ||
|
||
[klass.demodulize.underscore.to_sym, ui_lookup(:model => klass)] | ||
end.compact.to_h | ||
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
This file was deleted.
Oops, something went wrong.