Class: Flipper::UI::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/flipper/ui/configuration.rb

Constant Summary collapse

VALID_BANNER_CLASS_VALUES =
%w(
  danger
  dark
  info
  light
  primary
  secondary
  success
  warning
).freeze
DEFAULT_DESCRIPTIONS_SOURCE =
->(_keys) { {} }
DEFAULT_ACTOR_NAMES_SOURCE =
->(_keys) { {} }

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/flipper/ui/configuration.rb', line 94

def initialize
  @delete = Option.new("Danger Zone", "Deleting a feature removes it from the list of features and disables it for everyone.")
  @banner_text = nil
  @banner_class = 'danger'
  @feature_creation_enabled = true
  @feature_removal_enabled = true
  @fun = true
  @cloud_recommendation = true
  @add_actor_placeholder = "a flipper id"
  @descriptions_source = DEFAULT_DESCRIPTIONS_SOURCE
  @actor_names_source = DEFAULT_ACTOR_NAMES_SOURCE
  @show_feature_description_in_list = false
  @actors_separator = ','
  @confirm_fully_enable = false
  @confirm_disable = true
  @read_only = false
  @nav_items = [
    { title: "Features", href: "features" },
    { title: "Settings", href: "settings" },
  ]
end

Instance Attribute Details

#actor_names_sourceObject

Public: If you set this, Flipper::UI will fetch actor names from your external source. Descriptions for ‘actors` will be shown on `feature` page. Defaults to empty block.



61
62
63
# File 'lib/flipper/ui/configuration.rb', line 61

def actor_names_source
  @actor_names_source
end

#actors_separatorObject

Public: What should be used to denote you are trying to add multiple actors at once (instead of just a single actor). Default is comma “,”.



70
71
72
# File 'lib/flipper/ui/configuration.rb', line 70

def actors_separator
  @actors_separator
end

#add_actor_placeholderObject

Public: What should show up in the form to add actors. This can be different per application since flipper_id’s can be whatever an application needs. Defaults to “a flipper id”.



51
52
53
# File 'lib/flipper/ui/configuration.rb', line 51

def add_actor_placeholder
  @add_actor_placeholder
end

#application_hrefObject Also known as: application_breadcrumb_href

Public: If you set this, the UI will always have a first nav item that says “App” which points to this href. The href can be a path (ie: “/”) or full url (“app.example.com/”).



19
20
21
# File 'lib/flipper/ui/configuration.rb', line 19

def application_href
  @application_href
end

Returns the value of attribute banner_class.



8
9
10
# File 'lib/flipper/ui/configuration.rb', line 8

def banner_class
  @banner_class
end

Returns the value of attribute banner_text.



8
9
10
# File 'lib/flipper/ui/configuration.rb', line 8

def banner_text
  @banner_text
end

#cloud_recommendationObject

Public: Tired of seeing the awesome message about Cloud? Set this to false and it will go away. Defaults to true.



46
47
48
# File 'lib/flipper/ui/configuration.rb', line 46

def cloud_recommendation
  @cloud_recommendation
end

#confirm_disableObject

Public: if you want to get a confirm pop up box while disabling a feature Default is false.



78
79
80
# File 'lib/flipper/ui/configuration.rb', line 78

def confirm_disable
  @confirm_disable
end

#confirm_fully_enableObject

Public: if you want to get a confirm pop up box while fully enabling a feature Default is false.



74
75
76
# File 'lib/flipper/ui/configuration.rb', line 74

def confirm_fully_enable
  @confirm_fully_enable
end

#deleteObject (readonly)

Returns the value of attribute delete.



6
7
8
# File 'lib/flipper/ui/configuration.rb', line 6

def delete
  @delete
end

#descriptions_sourceObject

Public: If you set this, Flipper::UI will fetch descriptions from your external source. Descriptions for ‘features` will be shown on `feature` page, and optionally the `features` pages. Defaults to empty block.



56
57
58
# File 'lib/flipper/ui/configuration.rb', line 56

def descriptions_source
  @descriptions_source
end

#feature_creation_enabledObject

Public: Is feature creation allowed from the UI? Defaults to true. If set to false, users of the UI cannot create features. All feature creation will need to be done through the configured flipper instance.



34
35
36
# File 'lib/flipper/ui/configuration.rb', line 34

def feature_creation_enabled
  @feature_creation_enabled
end

#feature_removal_enabledObject

Public: Is feature deletion allowed from the UI? Defaults to true. If set to false, users won’t be able to delete features from the UI.



38
39
40
# File 'lib/flipper/ui/configuration.rb', line 38

def feature_removal_enabled
  @feature_removal_enabled
end

#funObject

Public: Are you feeling lucky? Defaults to true. If set to false, users won’t see a videoclip of Taylor Swift when there aren’t any features



42
43
44
# File 'lib/flipper/ui/configuration.rb', line 42

def fun
  @fun
end

Public: An array of nav items to show. By default “Features” and “Settings” are shown, but you can add your own. Each item must have a ‘:title` and `:href` key:

config.nav_items << { title: "Custom", href: "/custom/page" }


29
30
31
# File 'lib/flipper/ui/configuration.rb', line 29

def nav_items
  @nav_items
end

#read_onlyObject

Public: Is the UI in read only mode or not. Default is false. This supersedes all other write-related options such as (feature_creation_enabled and feature_removal_enabled).



14
15
16
# File 'lib/flipper/ui/configuration.rb', line 14

def read_only
  @read_only
end

#show_feature_description_in_listObject

Public: Should feature descriptions be show on the ‘features` list page. Default false. Only works when using descriptions.



65
66
67
# File 'lib/flipper/ui/configuration.rb', line 65

def show_feature_description_in_list
  @show_feature_description_in_list
end

Instance Method Details

#show_feature_description_in_list?Boolean

Returns:

  • (Boolean)


120
121
122
# File 'lib/flipper/ui/configuration.rb', line 120

def show_feature_description_in_list?
  using_descriptions? && @show_feature_description_in_list
end

#using_descriptions?Boolean

Returns:

  • (Boolean)


116
117
118
# File 'lib/flipper/ui/configuration.rb', line 116

def using_descriptions?
  @descriptions_source != DEFAULT_DESCRIPTIONS_SOURCE
end