Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement UI::Configuration so users can customize Flipper UI text
- Loading branch information
1 parent
e950c88
commit 3ced5fb
Showing
6 changed files
with
109 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
require 'flipper/ui/configuration/option' | ||
|
||
module Flipper | ||
module UI | ||
class Configuration | ||
attr_reader :actors, | ||
:delete, | ||
:groups, | ||
:percentage_of_actors, | ||
:percentage_of_time | ||
|
||
def initialize | ||
@actors = Option.new("Actors", "Enable actors using the form above.") | ||
@groups = Option.new("Groups", "Enable groups using the form above.") | ||
@percentage_of_actors = Option.new("Percentage of Actors", "Percentage of actors functions independently of percentage of time. If you enable 50% of Actors and 25% of Time then the feature will always be enabled for 50% of users and occasionally enabled 25% of the time for everyone.") | ||
@percentage_of_time = Option.new("Percentage of Time", "Percentage of actors functions independently of percentage of time. If you enable 50% of Actors and 25% of Time then the feature will always be enabled for 50% of users and occasionally enabled 25% of the time for everyone.") | ||
@delete = Option.new("Danger Zone", "Deleting a feature removes it from the list of features and disables it for everyone.") | ||
end | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module Flipper | ||
module UI | ||
class Option | ||
attr_accessor :title, :description | ||
|
||
def initialize(title, description) | ||
@title = title | ||
@description = description | ||
end | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
require 'helper' | ||
|
||
RSpec.describe Flipper::UI::Configuration do | ||
let(:configuration) { described_class.new } | ||
|
||
describe "#actors" do | ||
it "has default text" do | ||
expect(configuration.actors.title).to eq("Actors") | ||
expect(configuration.actors.description).to eq("Enable actors using the form above.") | ||
end | ||
|
||
it "can be updated" do | ||
configuration.actors.title = "Actors Section" | ||
expect(configuration.actors.title).to eq("Actors Section") | ||
end | ||
end | ||
|
||
describe "#groups" do | ||
it "has default text" do | ||
expect(configuration.groups.title).to eq("Groups") | ||
expect(configuration.groups.description).to eq("Enable groups using the form above.") | ||
end | ||
end | ||
|
||
describe "#percentage_of_actors" do | ||
it "has default text" do | ||
expect(configuration.percentage_of_actors.title).to eq("Percentage of Actors") | ||
expect(configuration.percentage_of_actors.description).to eq("Percentage of actors functions independently of percentage of time. If you enable 50% of Actors and 25% of Time then the feature will always be enabled for 50% of users and occasionally enabled 25% of the time for everyone.") | ||
end | ||
end | ||
|
||
describe "#percentage_of_time" do | ||
it "has default text" do | ||
expect(configuration.percentage_of_time.title).to eq("Percentage of Time") | ||
expect(configuration.percentage_of_time.description).to eq("Percentage of actors functions independently of percentage of time. If you enable 50% of Actors and 25% of Time then the feature will always be enabled for 50% of users and occasionally enabled 25% of the time for everyone.") | ||
end | ||
end | ||
|
||
describe "#delete" do | ||
it "has default text" do | ||
expect(configuration.delete.title).to eq("Danger Zone") | ||
expect(configuration.delete.description).to eq("Deleting a feature removes it from the list of features and disables it for everyone.") | ||
end | ||
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