Skip to content

Commit

Permalink
Draft PR push
Browse files Browse the repository at this point in the history
  • Loading branch information
aisayo committed Oct 11, 2023
1 parent 166be97 commit b4218bb
Show file tree
Hide file tree
Showing 13 changed files with 159 additions and 3 deletions.
1 change: 1 addition & 0 deletions app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
@use "pages/case_contacts";
@use "pages/court_dates";
@use "pages/emancipation";
@use "pages/feature_flags";
@use "pages/login";
@use "pages/password";
@use "pages/patch_notes";
Expand Down
75 changes: 75 additions & 0 deletions app/assets/stylesheets/pages/feature_flags.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/* The switch - the box around the slider */
.switch {
position: relative;
display: inline-block;
width: 60px;
height: 34px;
}

/* Hide default HTML checkbox */
.switch input {
opacity: 0;
width: 0;
height: 0;
}

/* The slider */
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #4a6cf7;
-webkit-transition: .4s;
transition: .4s;
}

.slider:before {
position: absolute;
content: "";
height: 26px;
width: 26px;
left: 4px;
bottom: 4px;
background-color: white;
-webkit-transition: .4s;
transition: .4s;
}

input:checked + .slider {
background-color: #4a6cf7;
}

input:focus + .slider {
box-shadow: 0 0 1px #4a6cf7;
}

input:checked + .slider:before {
-webkit-transform: translateX(26px);
-ms-transform: translateX(26px);
transform: translateX(26px);
}

/* Rounded sliders */
.slider.round-on {
border-radius: 34px;
padding-left: 100px;
}
span.slider.round-off {
border-radius: 34px;
padding-left: 100px;
}

.slider.round-off:before {
border-radius: 50%;
}



.custom-switch .custom-control-label::before {
border-radius: 50%; /* Makes the toggle button round */
width: 2rem; /* Adjust the width as needed */
height: 2rem; /* Adjust the height as needed */
}
18 changes: 18 additions & 0 deletions app/controllers/all_casa_admins/feature_flags_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
class AllCasaAdmins::FeatureFlagsController < AllCasaAdminsController

def index
@feature_flags = FeatureFlag.all
end


# update: toggle
# feature is disabled, when clicked on, update it to enabled

def update
byebug
@feature_flag = FeatureFlag.find(params[:id])
@feature_flag.update(enabled: !@feature_flag.enabled)
end


end
1 change: 1 addition & 0 deletions app/models/feature_flag.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
class FeatureFlag < ApplicationRecord
validates :name, presence: true, uniqueness: true
end

# == Schema Information
Expand Down
1 change: 1 addition & 0 deletions app/models/learning_hour.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def user_org_learning_topic_enable?
# id :bigint not null, primary key
# duration_hours :integer not null
# duration_minutes :integer not null
# learning_type :integer default(5)
# name :string not null
# occurred_at :datetime not null
# created_at :datetime not null
Expand Down
28 changes: 28 additions & 0 deletions app/views/all_casa_admins/feature_flags/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<h1>Feature Flags</h1>
<table>
<thead>
<tr>
<th>Name</th>
</tr>
</thead>
<tbody>
<% @feature_flags.each do |feature_flag| %>
<tr>
<td><%= feature_flag.name %></td>
<td>
<%= form_with(model: [ :all_casa_admins, feature_flag ], url: all_casa_admins_feature_flag_path(feature_flag), method: :patch, local: true) do |form| %>
<div class="feature-flag-div">
<label class="switch">
<input type="checkbox">
<span class="slider round-<%= feature_flag.enabled ? 'on' : 'off' %>"></span>
</label>
</div>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>



6 changes: 6 additions & 0 deletions app/views/layouts/_all_casa_admin_sidebar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@
Edit Profile
<% end %>
</li>
<li class="<%= active_class(all_casa_admins_feature_flags_path) %> nav-item">
<%= link_to all_casa_admins_feature_flags_path do %>
<i class="lni lni-pencil-alt mr-10"></i>
Feature Flags
<% end %>
</li>
<li class="nav-item">
<%= link_to destroy_all_casa_admin_session_path, id:"all-casa-log-out" do %>
<i class="lni lni-exit mr-10"></i>
Expand Down
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@
end

resources :patch_notes, only: %i[create destroy index update]

resources :feature_flags, only: %i[index update]
end

resources :all_casa_admins, only: [:new, :create] do
Expand Down
2 changes: 0 additions & 2 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.


ActiveRecord::Schema[7.0].define(version: 2023_09_03_182657) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"

Expand Down
2 changes: 1 addition & 1 deletion public/assets/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -3859,4 +3859,4 @@ h6,
font-weight: 800; }

.fw-900 {
font-weight: 900; }
font-weight: 900; }
4 changes: 4 additions & 0 deletions spec/decorators/admin/feature_flag_decorator_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
require 'rails_helper'

RSpec.describe Admin::FeatureFlagDecorator do
end
15 changes: 15 additions & 0 deletions spec/helpers/admin/feature_flags_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require 'rails_helper'

# Specs in this file have access to a helper object that includes
# the Admin::FeatureFlagsHelper. For example:
#
# describe Admin::FeatureFlagsHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# expect(helper.concat_strings("this","that")).to eq("this that")
# end
# end
# end
RSpec.describe Admin::FeatureFlagsHelper, type: :helper do
pending "add some examples to (or delete) #{__FILE__}"
end
7 changes: 7 additions & 0 deletions spec/requests/admin/feature_flags_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require 'rails_helper'

RSpec.describe "Admin::FeatureFlags", type: :request do
describe "GET /index" do
pending "add some examples (or delete) #{__FILE__}"
end
end

0 comments on commit b4218bb

Please sign in to comment.