rollout-ui 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,70 @@
1
+ a.text-sm.text-blue-600(href=index_path class='hover:text-blue-700 hover:underline') ← back to overview
2
+
3
+ h2.font-semibold.text-xl.text-gray-500.pt-12
4
+ = @feature.name
5
+
6
+ .w-8.h-1.bg-gray-300.my-10
7
+
8
+ form.p-6.bg-gray-100.max-w-lg.w-full.text-sm.rounded-sm action=feature_path(@feature.name) method='POST'
9
+ .mb-5
10
+ label.block.text-gray-500.mb-2(for='description') Description
11
+ input.appearance-none.border.rounded-sm.w-full.py-2.px-4.text-gray-600.leading-relaxed.bg-white(
12
+ name='description'
13
+ id='description'
14
+ value=@feature.data['description']
15
+ class='hover:border-gray-500'
16
+ )
17
+
18
+ .mb-5
19
+ label.block.text-gray-500.mb-2(for='groups')
20
+ | Groups
21
+ span.ml-1.text-gray-400
22
+ | (multi-select)
23
+ select.block.appearance-none.w-full.bg-white.border.border-gray-300.px-4.py-3.rounded-sm.leading-relaxed(name="groups[]" id='groups' multiple=true size=$rollout.groups.count)
24
+ option.py-1.px-1(value='' selected=(@feature.groups.count == 0))
25
+ = '(none)'
26
+ - @rollout.groups.each do |group|
27
+ option.py-1.px-1(
28
+ value=group
29
+ selected=@feature.groups.include?(group)
30
+ )
31
+ = group
32
+
33
+ .mb-5
34
+ label.block.text-gray-500.mb-2(for='percentage') Percentage
35
+ input.appearance-none.border.rounded-sm.w-full.py-2.px-4.text-gray-600.leading-relaxed.bg-white(
36
+ name='percentage'
37
+ id='percentage'
38
+ value=@feature.percentage
39
+ class='hover:border-gray-500'
40
+ type='number'
41
+ min='0'
42
+ max='100'
43
+ step='10'
44
+ )
45
+
46
+ .mb-5
47
+ label.block.text-gray-500.mb-2 Users
48
+
49
+ - if @feature.users.count > 100
50
+ .appearance-none.border.rounded-sm.w-full.py-2.px-4.text-gray-600.leading-relaxed.bg-gray-100
51
+ = @feature.users.count
52
+ - else
53
+ textarea.appearance-none.border.rounded-sm.w-full.py-2.px-4.text-gray-600.leading-relaxed.bg-white(
54
+ name='users'
55
+ id='users'
56
+ value=@feature.users.join(', ')
57
+ class='hover:border-gray-500'
58
+ rows='2'
59
+ )
60
+ = @feature.users.join(', ')
61
+
62
+ .flex.items-center.justify-end
63
+ form action=delete_feature_path(@feature.name) method='POST'
64
+ button.mr-5.text-gray-600(class='hover:underline' type='submit' onclick="return confirm('Are you sure you want to delete #{@feature.name}?')")
65
+ ' Delete
66
+ button.py-4.px-5.bg-gray-700.text-gray-200.rounded-sm.font-bold.leading-none.transition-colors.duration-200(class='hover:bg-gray-800' type='submit') Update
67
+
68
+ - history_events = @rollout.respond_to?(:logging) ? @rollout.logging.events(@feature.name).reverse : []
69
+
70
+ == slim :"features/partials/event_log", locals: { events: history_events }
@@ -0,0 +1,17 @@
1
+ doctype html
2
+ html
3
+ head
4
+ title Rollout UI
5
+ meta name='viewport' content='width=device-width initial-scale=1'
6
+ link rel='stylesheet' href=stylesheet_path('tailwind.min')
7
+
8
+ body
9
+ / Addresses https://stackoverflow.com/questions/21147149/flash-of-unstyled-content-fouc-in-firefox-only-is-ff-slow-renderer
10
+ script 0
11
+
12
+ .container.mx-auto.font-mono.text-gray-700.px-5.pb-20
13
+ h1.font-light.text-4xl.text-gray-600.pt-20
14
+ a href=index_path class='hover:text-blue-700'
15
+ ' Rollout
16
+
17
+ == yield
@@ -0,0 +1,75 @@
1
+ require "sinatra"
2
+ require "rollout"
3
+
4
+ require "rollout/ui/version"
5
+ require "rollout/ui/config"
6
+ require "rollout/ui/helpers"
7
+
8
+ module Rollout::UI
9
+ class Web < Sinatra::Base
10
+ set :static, true
11
+ set :public_folder, File.dirname(__FILE__) + '/public'
12
+
13
+ helpers Helpers
14
+
15
+ get '/' do
16
+ @rollout = config.get(:instance)
17
+ @features = @rollout.features.sort_by(&:downcase)
18
+
19
+ slim :'features/index'
20
+ end
21
+
22
+ get '/features/new' do
23
+ slim :'features/new'
24
+ end
25
+
26
+ post '/features/new' do
27
+ redirect feature_path(params[:name])
28
+ end
29
+
30
+ get '/features/:feature_name' do
31
+ @rollout = config.get(:instance)
32
+ @feature = @rollout.get(params[:feature_name])
33
+
34
+ slim :'features/show'
35
+ end
36
+
37
+ post '/features/:feature_name' do
38
+ rollout = config.get(:instance)
39
+ actor = config.get(:actor, scope: self)
40
+
41
+ rollout.logging.with_context(actor: actor) do
42
+ rollout.with_feature(params[:feature_name]) do |feature|
43
+ feature.percentage = params[:percentage].to_f.clamp(0.0, 100.0)
44
+ feature.groups = (params[:groups] || []).reject(&:empty?).map(&:to_sym)
45
+ if params[:users]
46
+ feature.users = params[:users].split(',').map(&:strip).uniq.sort
47
+ end
48
+ feature.data.update(description: params[:description])
49
+ end
50
+ end
51
+
52
+ redirect feature_path(params[:feature_name])
53
+ end
54
+
55
+ post '/features/:feature_name/activate-percentage' do
56
+ rollout = config.get(:instance)
57
+ actor = config.get(:actor, scope: self)
58
+
59
+ rollout.logging.with_context(actor: actor) do
60
+ rollout.with_feature(params[:feature_name]) do |feature|
61
+ feature.percentage = params[:percentage].to_f.clamp(0.0, 100.0)
62
+ end
63
+ end
64
+
65
+ redirect index_path
66
+ end
67
+
68
+ post '/features/:feature_name/delete' do
69
+ @rollout = config.get(:instance)
70
+ @rollout.delete(params[:feature_name])
71
+
72
+ redirect index_path
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,32 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "rollout/ui/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rollout-ui"
8
+ spec.version = Rollout::UI::VERSION
9
+ spec.authors = ["FetLife"]
10
+ spec.email = ["dev@fetlife.com"]
11
+
12
+ spec.summary = %q{}
13
+ spec.description = %q{}
14
+ spec.homepage = "https://github.com/fetlife/rollout-ui"
15
+ spec.license = "MIT"
16
+
17
+ # Specify which files should be added to the gem when it is released.
18
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
19
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
20
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
+ end
22
+ spec.bindir = "exe"
23
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
+ spec.require_paths = ["lib"]
25
+
26
+ spec.add_dependency "rollout", "~> 2.5"
27
+ spec.add_dependency "sinatra", "~> 2.0"
28
+
29
+ spec.add_development_dependency "bundler", "~> 1.17"
30
+ spec.add_development_dependency "rake", "~> 10.0"
31
+ spec.add_development_dependency "rspec", "~> 3.0"
32
+ end
Binary file
Binary file
metadata ADDED
@@ -0,0 +1,135 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rollout-ui
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - FetLife
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-07-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rollout
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.5'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: sinatra
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.17'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.17'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.0'
83
+ description: ''
84
+ email:
85
+ - dev@fetlife.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - Gemfile
93
+ - LICENSE.txt
94
+ - README.md
95
+ - Rakefile
96
+ - bin/console
97
+ - bin/setup
98
+ - lib/rollout/ui.rb
99
+ - lib/rollout/ui/config.rb
100
+ - lib/rollout/ui/helpers.rb
101
+ - lib/rollout/ui/public/css/tailwind.min.css
102
+ - lib/rollout/ui/version.rb
103
+ - lib/rollout/ui/views/features/index.slim
104
+ - lib/rollout/ui/views/features/new.slim
105
+ - lib/rollout/ui/views/features/partials/event_log.slim
106
+ - lib/rollout/ui/views/features/show.slim
107
+ - lib/rollout/ui/views/layout.slim
108
+ - lib/rollout/ui/web.rb
109
+ - rollout-ui.gemspec
110
+ - screenshot_index.png
111
+ - screenshot_show.png
112
+ homepage: https://github.com/fetlife/rollout-ui
113
+ licenses:
114
+ - MIT
115
+ metadata: {}
116
+ post_install_message:
117
+ rdoc_options: []
118
+ require_paths:
119
+ - lib
120
+ required_ruby_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ required_rubygems_version: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ requirements: []
131
+ rubygems_version: 3.0.3
132
+ signing_key:
133
+ specification_version: 4
134
+ summary: ''
135
+ test_files: []