summaryrefslogtreecommitdiff
path: root/lib/gitlab/themes.rb
diff options
context:
space:
mode:
authorRubén Dávila <ruben@gitlab.com>2017-09-08 14:48:44 +0000
committerRubén Dávila <ruben@gitlab.com>2017-09-08 14:48:44 +0000
commit52a2423e373e6552023faaff43ae07dbb7423c00 (patch)
treef6855f30c1f0ec08583707d54191e20c2e561e37 /lib/gitlab/themes.rb
parentaf930b83a097f4ab83e6361bc3c210462e507cd9 (diff)
downloadgitlab-ce-52a2423e373e6552023faaff43ae07dbb7423c00.tar.gz
Revert "Merge branch '35012-navigation-add-option-to-change-navigation-color-palette' into 'master'"revert-f2421b2b
This reverts merge request !13619
Diffstat (limited to 'lib/gitlab/themes.rb')
-rw-r--r--lib/gitlab/themes.rb84
1 files changed, 0 insertions, 84 deletions
diff --git a/lib/gitlab/themes.rb b/lib/gitlab/themes.rb
deleted file mode 100644
index d43eff5ba4a..00000000000
--- a/lib/gitlab/themes.rb
+++ /dev/null
@@ -1,84 +0,0 @@
-module Gitlab
- # Module containing GitLab's application theme definitions and helper methods
- # for accessing them.
- module Themes
- extend self
-
- # Theme ID used when no `default_theme` configuration setting is provided.
- APPLICATION_DEFAULT = 1
-
- # Struct class representing a single Theme
- Theme = Struct.new(:id, :name, :css_class)
-
- # All available Themes
- THEMES = [
- Theme.new(1, 'Indigo', 'ui_indigo'),
- Theme.new(2, 'Dark', 'ui_dark'),
- Theme.new(3, 'Light', 'ui_light'),
- Theme.new(4, 'Blue', 'ui_blue'),
- Theme.new(5, 'Green', 'ui_green')
- ].freeze
-
- # Convenience method to get a space-separated String of all the theme
- # classes that might be applied to the `body` element
- #
- # Returns a String
- def body_classes
- THEMES.collect(&:css_class).uniq.join(' ')
- end
-
- # Get a Theme by its ID
- #
- # If the ID is invalid, returns the default Theme.
- #
- # id - Integer ID
- #
- # Returns a Theme
- def by_id(id)
- THEMES.detect { |t| t.id == id } || default
- end
-
- # Returns the number of defined Themes
- def count
- THEMES.size
- end
-
- # Get the default Theme
- #
- # Returns a Theme
- def default
- by_id(default_id)
- end
-
- # Iterate through each Theme
- #
- # Yields the Theme object
- def each(&block)
- THEMES.each(&block)
- end
-
- # Get the Theme for the specified user, or the default
- #
- # user - User record
- #
- # Returns a Theme
- def for_user(user)
- if user
- by_id(user.theme_id)
- else
- default
- end
- end
-
- private
-
- def default_id
- @default_id ||= begin
- id = Gitlab.config.gitlab.default_theme.to_i
- theme_ids = THEMES.map(&:id)
-
- theme_ids.include?(id) ? id : APPLICATION_DEFAULT
- end
- end
- end
-end