-
-
Notifications
You must be signed in to change notification settings - Fork 483
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into 5086-nav-bar-enhancement
- Loading branch information
Showing
67 changed files
with
2,611 additions
and
1,075 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
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
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
web: bin/rails server -p 3000 | ||
web: bin/rails server -p 3000 -b 0.0.0.0 | ||
js: yarn build --watch | ||
css: yarn build:css --watch |
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
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,9 @@ | ||
#feature-flags { | ||
padding-top: 1em; | ||
h1 { | ||
padding-bottom: 1em; | ||
} | ||
.flag-name { | ||
padding-right: 2em; | ||
} | ||
} |
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,5 @@ | ||
class Api::V1::SessionBlueprint < Blueprinter::Base | ||
identifier :id | ||
|
||
fields :id, :display_name, :email, :token | ||
end |
10 changes: 10 additions & 0 deletions
10
app/controllers/all_casa_admins/feature_flags_controller.rb
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,10 @@ | ||
class AllCasaAdmins::FeatureFlagsController < AllCasaAdminsController | ||
def index | ||
@feature_flags = FeatureFlag.all.order(name: "asc") | ||
end | ||
|
||
def update | ||
@feature_flag = FeatureFlag.find(params[:id]) | ||
@feature_flag.update(enabled: !@feature_flag.enabled) | ||
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,18 @@ | ||
class Api::V1::BaseController < ActionController::API | ||
rescue_from ActiveRecord::RecordNotFound, with: :not_found | ||
before_action :authenticate_user!, except: [:create] | ||
|
||
def authenticate_user! | ||
token, options = ActionController::HttpAuthentication::Token.token_and_options(request) | ||
user = User.find_by(email: options[:email]) | ||
if user && token && ActiveSupport::SecurityUtils.secure_compare(user.token, token) | ||
@current_user = user | ||
else | ||
render json: {message: "Wrong password or email"}, status: 401 | ||
end | ||
end | ||
|
||
def not_found | ||
api_error(status: 404, errors: "Not found") | ||
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,23 @@ | ||
class Api::V1::Users::SessionsController < Api::V1::BaseController | ||
def create | ||
load_resource | ||
if @user | ||
render json: Api::V1::SessionBlueprint.render(@user), status: 201 | ||
else | ||
render json: {message: "Wrong password or email"}, status: 401 | ||
end | ||
end | ||
|
||
private | ||
|
||
def user_params | ||
params.permit(:email, :password) | ||
end | ||
|
||
def load_resource | ||
@user = User.find_by(email: user_params[:email]) | ||
unless @user&.valid_password?(user_params[:password]) | ||
@user = nil | ||
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
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
require('./src/all_casa_admin/tables') | ||
require('./src/all_casa_admin/patch_notes') | ||
require('./src/all_casa_admin/feature_flags') | ||
require('./src/session_timeout_poller.js') | ||
require('./src/display_app_metric.js') |
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,30 @@ | ||
$(function () { | ||
const checkboxes = $('.form-check-input.toggle-switch') | ||
|
||
checkboxes.on('change', function (e) { | ||
e.preventDefault() | ||
const featureFlagId = $(this).data('feature-flag-id') | ||
const uniqueCheckbox = $('#feature-checkbox-' + featureFlagId) | ||
const csrfToken = $('meta[name=csrf-token]').attr('content') | ||
const isChecked = this.checked | ||
toggleSwitch(uniqueCheckbox, csrfToken, featureFlagId, isChecked) | ||
}) | ||
|
||
function toggleSwitch (uniqueCheckbox, csrfToken, featureFlagId, checked) { | ||
$.ajax({ | ||
url: `/all_casa_admins/feature_flags/${featureFlagId}`, | ||
method: 'PATCH', | ||
contentType: 'application/json', | ||
headers: { | ||
'X-CSRF-Token': csrfToken | ||
}, | ||
success: function () { | ||
if (checked) { | ||
uniqueCheckbox.prop('checked', true) | ||
} else { | ||
uniqueCheckbox.prop('checked', false) | ||
} | ||
} | ||
}) | ||
} | ||
}) |
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
Oops, something went wrong.