Skip to content

Commit

Permalink
Merge branch 'main' into 5086-nav-bar-enhancement
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Williams committed Oct 22, 2023
2 parents cb513cc + 21b46c0 commit 64724b3
Show file tree
Hide file tree
Showing 67 changed files with 2,611 additions and 1,075 deletions.
3 changes: 3 additions & 0 deletions .allow_skipping_tests
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ mailers/application_mailer.rb
models/application_record.rb
models/concerns/by_organization_scope.rb
models/concerns/roles.rb
models/concerns/generate_token.rb
models/fund_request.rb
models/notification.rb
notifications/base_notification.rb
notifications/delivery_methods/sms.rb
notifications/emancipation_checklist_reminder_notification.rb
notifications/followup_notification.rb
notifications/followup_resolved_notification.rb
notifications/reimbursement_complete_notification.rb
notifications/youth_birthday_notification.rb
policies/fund_request_policy.rb
policies/learning_hour_policy.rb
Expand All @@ -54,3 +56,4 @@ values/casa_admin_parameters.rb
values/supervisor_parameters.rb
values/user_parameters.rb
values/volunteer_parameters.rb
blueprints/api/v1/session_blueprint.rb
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ password for all users: 12345678

### Questions? Join Slack!

We highly recommend that you join us in slack https://rubyforgood.herokuapp.com/ #casa channel to ask questions quickly and hear about office hours (currently Tuesday 5-7pm Pacific), stakeholder news, and upcoming new issues.
We highly recommend that you join us in slack https://rubyforgood.herokuapp.com/ #casa channel to ask questions quickly. And [discord](https://discord.gg/qJcw2RZH8Q) for office hours (currently Tuesday 5-7pm Pacific), stakeholder news, and upcoming new issues.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ password for all users: 12345678

### Questions? Join Slack!

We highly recommend that you join us in slack https://rubyforgood.herokuapp.com/ #casa channel to ask questions quickly and hear about office hours (currently Tuesday 5-7pm Pacific), stakeholder news, and upcoming new issues.
We highly recommend that you join us in slack https://rubyforgood.herokuapp.com/ #casa channel to ask questions quickly. And [discord](https://discord.gg/qJcw2RZH8Q) for office hours (currently Tuesday 5-7pm Pacific), stakeholder news, and upcoming new issues.
6 changes: 6 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,18 @@ gem "pretender"
gem "puma", "6.4.0" # 6.2.2 fails to install on m1 # Use Puma as the app server
gem "pundit" # for authorization management - based on user.role field
gem "rack-attack" # for blocking & throttling abusive requests
gem "rack-cors" # for allowing cross-origin resource sharing
gem "request_store"
gem "sablon" # Word document templating tool for Case Court Reports
gem "scout_apm"
gem "sprockets-rails" # The original asset pipeline for Rails [https://github.com/rails/sprockets-rails]
gem "stimulus-rails"
gem "strong_migrations"
gem "tzinfo-data", platforms: %i[mingw mswin x64_mingw jruby] # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem "rswag-api"
gem "rswag-ui"
gem "blueprinter" # for JSON serialization
gem "oj" # faster JSON parsing 🍊

group :development, :test do
gem "bullet" # Detect and fix N+1 queries
Expand All @@ -55,6 +60,7 @@ group :development, :test do
gem "pry"
gem "pry-byebug"
gem "rspec-rails"
gem "rswag-specs"
gem "shoulda-matchers"
gem "standard", "1.5.0" # 1.6.0 errors on all factorybot create variables
end
Expand Down
38 changes: 30 additions & 8 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ GEM
faraday_middleware (~> 1.0, >= 1.0.0.rc1)
net-http-persistent (~> 4.0)
nokogiri (~> 1, >= 1.10.8)
bcrypt (3.1.18)
bcrypt (3.1.19)
better_html (2.0.2)
actionview (>= 6.0)
activesupport (>= 6.0)
Expand All @@ -95,11 +95,12 @@ GEM
parser (>= 2.4)
smart_properties
bindex (0.8.1)
blueprinter (0.25.3)
brakeman (6.0.1)
bugsnag (6.26.0)
concurrent-ruby (~> 1.0)
builder (3.2.4)
bullet (7.0.7)
bullet (7.1.1)
activesupport (>= 3.0.0)
uniform_notifier (~> 1.11)
bundler-audit (0.9.1)
Expand Down Expand Up @@ -145,7 +146,7 @@ GEM
delayed_job_active_record (4.1.7)
activerecord (>= 3.0, < 8.0)
delayed_job (>= 3.0, < 5)
devise (4.9.2)
devise (4.9.3)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0)
Expand Down Expand Up @@ -248,6 +249,8 @@ GEM
activesupport (>= 5.0.0)
jsbundling-rails (1.2.1)
railties (>= 6.0.0)
json-schema (3.0.0)
addressable (>= 2.8)
jwt (2.7.1)
launchy (2.5.0)
addressable (~> 2.7)
Expand All @@ -261,7 +264,7 @@ GEM
activesupport (>= 4)
railties (>= 4)
request_store (~> 1.0)
loofah (2.21.3)
loofah (2.21.4)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
mail (2.8.1)
Expand All @@ -279,7 +282,7 @@ GEM
multipart-post (2.3.0)
net-http-persistent (4.0.1)
connection_pool (~> 2.2)
net-imap (0.3.7)
net-imap (0.4.1)
date
net-protocol
net-pop (0.1.2)
Expand All @@ -298,6 +301,7 @@ GEM
noticed (1.6.3)
http (>= 4.0.0)
rails (>= 5.2.0)
oj (3.16.1)
orm_adapter (0.5.0)
parallel (1.23.0)
paranoia (2.6.2)
Expand Down Expand Up @@ -327,6 +331,8 @@ GEM
rack (2.2.8)
rack-attack (6.7.0)
rack (>= 1.0, < 4)
rack-cors (2.0.1)
rack (>= 2.0.0)
rack-test (2.1.0)
rack (>= 1.3)
rails (7.0.8)
Expand Down Expand Up @@ -366,7 +372,7 @@ GEM
regexp_parser (2.8.1)
request_store (1.5.1)
rack (>= 1.4)
responders (3.1.0)
responders (3.1.1)
actionpack (>= 5.2)
railties (>= 5.2)
rexml (3.2.6)
Expand All @@ -387,6 +393,16 @@ GEM
rspec-mocks (~> 3.12)
rspec-support (~> 3.12)
rspec-support (3.12.0)
rswag-api (2.10.1)
railties (>= 3.1, < 7.1)
rswag-specs (2.10.1)
activesupport (>= 3.1, < 7.1)
json-schema (>= 2.2, < 4.0)
railties (>= 3.1, < 7.1)
rspec-core (>= 2.14)
rswag-ui (2.10.1)
actionpack (>= 3.1, < 7.1)
railties (>= 3.1, < 7.1)
rubocop (1.23.0)
parallel (~> 1.10)
parser (>= 3.0.0.0)
Expand Down Expand Up @@ -446,7 +462,7 @@ GEM
timeout (0.4.0)
traceroute (0.8.1)
rails (>= 3.0.0)
twilio-ruby (6.7.0)
twilio-ruby (6.7.1)
faraday (>= 0.9, < 3.0)
jwt (>= 1.5, < 3.0)
nokogiri (>= 1.6, < 2.0)
Expand Down Expand Up @@ -478,7 +494,7 @@ GEM
websocket-extensions (0.1.5)
xpath (3.2.0)
nokogiri (~> 1.8)
zeitwerk (2.6.11)
zeitwerk (2.6.12)

PLATFORMS
arm64-darwin-20
Expand All @@ -496,6 +512,7 @@ DEPENDENCIES
amazing_print
annotate
azure-storage-blob
blueprinter
brakeman
bugsnag
bullet
Expand Down Expand Up @@ -529,6 +546,7 @@ DEPENDENCIES
net-pop
net-smtp
noticed
oj
paranoia
pdf-forms
pg
Expand All @@ -538,12 +556,16 @@ DEPENDENCIES
puma (= 6.4.0)
pundit
rack-attack
rack-cors
rails (~> 7.0.8)
rails-controller-testing
rake
request_store
rexml
rspec-rails
rswag-api
rswag-specs
rswag-ui
sablon
scout_apm
selenium-webdriver
Expand Down
2 changes: 1 addition & 1 deletion Procfile.dev
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
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
18 changes: 0 additions & 18 deletions app/assets/stylesheets/pages/case_contacts.scss
Original file line number Diff line number Diff line change
Expand Up @@ -133,21 +133,3 @@ legend {
.cc-italic {
font-style: italic;
}

.notes-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 0.5em;

h2 {
margin-bottom: 0;
}
}

.highlight-button {
background: none;
border: none;
color: var(--blue);
font-size: 1.1em;
}
9 changes: 9 additions & 0 deletions app/assets/stylesheets/pages/feature_flags.scss
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;
}
}
5 changes: 5 additions & 0 deletions app/blueprints/api/v1/session_blueprint.rb
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 app/controllers/all_casa_admins/feature_flags_controller.rb
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
18 changes: 18 additions & 0 deletions app/controllers/api/v1/base_controller.rb
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
23 changes: 23 additions & 0 deletions app/controllers/api/v1/users/sessions_controller.rb
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
1 change: 1 addition & 0 deletions app/controllers/casa_cases_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ def casa_case_params
params.require(:casa_case).permit(
:case_number,
:birth_month_year_youth,
:date_in_care,
:court_report_due_date,
:empty_court_date,
casa_case_contact_types_attributes: [:contact_type_id],
Expand Down
3 changes: 3 additions & 0 deletions app/controllers/reimbursements_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ def change_complete_status
@grouped_case_contacts = fetch_reimbursements
.where({occurred_at: @case_contact.occurred_at, creator_id: @case_contact.creator_id})
@grouped_case_contacts.update_all(reimbursement_params.to_h)
notification_recipients = [@case_contact.creator]
notification_recipients << @case_contact.supervisor if @case_contact.supervisor
ReimbursementCompleteNotification.with(case_contact: @case_contact).deliver(notification_recipients)
redirect_to reimbursements_path unless params[:ajax]
end

Expand Down
1 change: 1 addition & 0 deletions app/javascript/all_casa_admin.js
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')
30 changes: 30 additions & 0 deletions app/javascript/src/all_casa_admin/feature_flags.js
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)
}
}
})
}
})
6 changes: 0 additions & 6 deletions app/javascript/src/case_contact.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,6 @@ async function fireSwalFollowupAlert () {
})
}

function displayHighlightModal (event) {
event.preventDefault()
$('#caseContactHighlight').modal('show')
}

$(() => { // JQuery's callback for the DOM loading
const milesDriven = $('#case_contact_miles_driven')
const durationHoursElement = $('#case-contact-duration-hours-display')
Expand Down Expand Up @@ -170,7 +165,6 @@ $(() => { // JQuery's callback for the DOM loading

$('[data-toggle="tooltip"]').tooltip()
$('.followup-button').on('click', displayFollowupAlert)
$('#open-highlight-modal').on('click', displayHighlightModal)

if (/\/case_contacts\/*.*\?.*success=true/.test(window.location.href)) {
$('#thank_you').modal()
Expand Down
Loading

0 comments on commit 64724b3

Please sign in to comment.