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) { {} }
DEFAULT_DISABLE_FULLY_ENABLE_MESSAGE =
"Fully enabling features via the UI is disabled."

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/flipper/ui/configuration.rb', line 114

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
  @version_check_enabled = 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
  @disable_fully_enable = nil
  @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.



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

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 “,”.



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

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



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

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.



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

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.



83
84
85
# File 'lib/flipper/ui/configuration.rb', line 83

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.



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

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.



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

def descriptions_source
  @descriptions_source
end

#disable_fully_enableObject

Public: Set to disable the Fully Enable button in the UI, preventing users from fully enabling features via the web interface. Set to true for a default message, or a string for a custom message. Defaults to nil.

Note: This only affects the UI. If flipper-api is mounted, full enable is still possible via the API.

Examples:

config.disable_fully_enable = true
config.disable_fully_enable = "Use deploy pipeline instead."


97
98
99
# File 'lib/flipper/ui/configuration.rb', line 97

def disable_fully_enable
  @disable_fully_enable
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.



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

def show_feature_description_in_list
  @show_feature_description_in_list
end

#version_check_enabledObject

Public: Set to false to disable the version check that fetches the latest release from flippercloud.io. Useful when a strict Content Security Policy is in place. Defaults to true.



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

def version_check_enabled
  @version_check_enabled
end

Instance Method Details

#disable_fully_enable_messageObject



146
147
148
149
150
151
152
# File 'lib/flipper/ui/configuration.rb', line 146

def disable_fully_enable_message
  if @disable_fully_enable.is_a?(String)
    @disable_fully_enable
  else
    DEFAULT_DISABLE_FULLY_ENABLE_MESSAGE
  end
end

#show_feature_description_in_list?Boolean

Returns:

  • (Boolean)


142
143
144
# File 'lib/flipper/ui/configuration.rb', line 142

def show_feature_description_in_list?
  using_descriptions? && @show_feature_description_in_list
end

#using_descriptions?Boolean

Returns:

  • (Boolean)


138
139
140
# File 'lib/flipper/ui/configuration.rb', line 138

def using_descriptions?
  @descriptions_source != DEFAULT_DESCRIPTIONS_SOURCE
end