Skip to content

Initial project and component dashboards #242

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
RAILS_ENV: test
steps:
- checkout
# - browser-tools/install-firefox
- browser-tools/install-firefox
- ruby/install-deps:
key: gems-v2-
- run:
Expand Down
9 changes: 8 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,17 @@ POSTGRES_PASSWORD=changeme
USERINFO_API_URL=http://localhost:6000
USERINFO_API_KEY=1234

HYDRA_PUBLIC_URL=http://host.docker.internal:9001
HYDRA_PUBLIC_URL=http://localhost:9001
HYDRA_PUBLIC_TOKEN_URL=http://host.docker.internal:9001
HYDRA_CLIENT_ID=editor-api-dev
HYDRA_CLIENT_SECRET=secret

IDENTITY_URL=http://localhost:3002

SMEE_TUNNEL=https://smee.io/MLq0n9kvAes2vydX

# Add the below to bypass token authentication with hydra
# BYPASS_AUTH=true
# AUTH_USER_ID=<<set to match user_id for desired user>>

HOST_URL=http://localhost:3009
8 changes: 7 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
---
require: rubocop-graphql
require:
- rubocop-graphql
- rubocop-capybara
inherit_from:
- https://raspberrypifoundation.github.io/digital-engineering/configs/rubocop-base.yml
- https://raspberrypifoundation.github.io/digital-engineering/configs/rubocop-rails.yml
Expand Down Expand Up @@ -27,3 +29,7 @@ RSpec/DescribeClass:

RSpec/MultipleMemoizedHelpers:
Max: 8

Metrics/BlockLength:
Exclude:
- "config/routes.rb"
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ WORKDIR /app
RUN apt-get update \
&& apt-get install --yes --no-install-recommends \
build-essential libpq-dev libxml2-dev libxslt1-dev git \
firefox-esr python2-dev \
&& rm -rf /var/lib/apt/lists/* /var/lib/apt/archives/*.deb
COPY Gemfile Gemfile.lock /app/
RUN bundle install --jobs 4 \
Expand Down
10 changes: 10 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '~> 3.2.0'

gem 'administrate', '~> 0.16.0'
gem 'administrate-field-active_storage'
gem 'aws-sdk-s3', require: false
gem 'bootsnap', require: false
gem 'cancancan', '~> 3.3'
Expand All @@ -16,9 +18,14 @@ gem 'globalid'
gem 'good_job', '~> 3.12'
gem 'graphql'
gem 'graphql-client'
gem 'image_processing'
gem 'importmap-rails'
gem 'jbuilder'
gem 'kaminari'
gem 'omniauth-rails_csrf_protection', '~> 1.0.1'
gem 'omniauth-rpi',
github: 'RaspberryPiFoundation/omniauth-rpi',
tag: 'v1.3.1'
gem 'open-uri'
gem 'pg', '~> 1.1'
gem 'puma', '~> 5.6'
Expand Down Expand Up @@ -46,7 +53,10 @@ group :development, :test do
end

group :test do
gem 'capybara'
gem 'climate_control'
gem 'selenium-webdriver'
gem 'shoulda-matchers', '~> 5.0'
gem 'webdrivers'
gem 'webmock'
end
106 changes: 106 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
GIT
remote: https://github.com/RaspberryPiFoundation/omniauth-rpi.git
revision: b7cb36cbfbf9a66f2376bb1501a4bdb205f2a7bf
tag: v1.3.1
specs:
omniauth-rpi (1.3.1)
jwt (~> 2.2.3)
omniauth (~> 2.0)
omniauth-oauth2 (~> 1.4)

GEM
remote: https://rubygems.org/
specs:
Expand Down Expand Up @@ -68,6 +78,19 @@ GEM
tzinfo (~> 2.0)
addressable (2.8.1)
public_suffix (>= 2.0.2, < 6.0)
administrate (0.16.0)
actionpack (>= 5.0)
actionview (>= 5.0)
activerecord (>= 5.0)
datetime_picker_rails (~> 0.0.7)
jquery-rails (>= 4.0)
kaminari (>= 1.0)
momentjs-rails (~> 2.8)
sassc-rails (~> 2.1)
selectize-rails (~> 0.6)
administrate-field-active_storage (1.0.1)
administrate (>= 0.2.2)
rails (>= 7.0)
ast (2.4.2)
aws-eventstream (1.2.0)
aws-partitions (1.718.0)
Expand All @@ -85,6 +108,7 @@ GEM
aws-sigv4 (~> 1.4)
aws-sigv4 (1.5.2)
aws-eventstream (~> 1, >= 1.0.2)
base64 (0.2.0)
bootsnap (1.16.0)
msgpack (~> 1.2)
builder (3.2.4)
Expand All @@ -93,6 +117,15 @@ GEM
uniform_notifier (~> 1.11)
byebug (11.1.3)
cancancan (3.4.0)
capybara (3.40.0)
addressable
matrix
mini_mime (>= 0.1.3)
nokogiri (~> 1.11)
rack (>= 1.6.0)
rack-test (>= 0.6.3)
regexp_parser (>= 1.5, < 3.0)
xpath (~> 3.2)
climate_control (1.2.0)
coderay (1.1.3)
concurrent-ruby (1.2.2)
Expand All @@ -102,6 +135,8 @@ GEM
rexml
crass (1.0.6)
date (3.3.3)
datetime_picker_rails (0.0.7)
momentjs-rails (>= 2.8.1)
diff-lcs (1.5.0)
docile (1.4.0)
dotenv (2.8.1)
Expand All @@ -124,6 +159,7 @@ GEM
faraday-net_http (>= 2.0, < 3.1)
ruby2_keywords (>= 0.0.4)
faraday-net_http (3.0.2)
ffi (1.16.3)
fugit (1.8.1)
et-orbi (~> 1, >= 1.2.7)
raabro (~> 1.4)
Expand All @@ -149,16 +185,25 @@ GEM
activesupport (>= 3.0)
graphql
hashdiff (1.0.1)
hashie (5.0.0)
i18n (1.12.0)
concurrent-ruby (~> 1.0)
image_processing (1.12.2)
mini_magick (>= 4.9.5, < 5)
ruby-vips (>= 2.0.17, < 3)
importmap-rails (1.1.5)
actionpack (>= 6.0.0)
railties (>= 6.0.0)
jbuilder (2.11.5)
actionview (>= 5.0.0)
activesupport (>= 5.0.0)
jmespath (1.6.2)
jquery-rails (4.6.0)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json (2.6.3)
jwt (2.2.3)
kaminari (1.2.2)
activesupport (>= 4.1.0)
kaminari-actionview (= 1.2.2)
Expand All @@ -180,10 +225,15 @@ GEM
net-pop
net-smtp
marcel (1.0.2)
matrix (0.4.2)
method_source (1.0.0)
mini_magick (4.12.0)
mini_mime (1.1.2)
minitest (5.17.0)
momentjs-rails (2.29.4.1)
railties (>= 3.1)
msgpack (1.6.0)
multi_xml (0.6.0)
net-imap (0.3.4)
date
net-protocol
Expand All @@ -200,6 +250,23 @@ GEM
racc (~> 1.4)
nokogiri (1.14.2-x86_64-linux)
racc (~> 1.4)
oauth2 (2.0.9)
faraday (>= 0.17.3, < 3.0)
jwt (>= 1.0, < 3.0)
multi_xml (~> 0.5)
rack (>= 1.2, < 4)
snaky_hash (~> 2.0)
version_gem (~> 1.1)
omniauth (2.1.2)
hashie (>= 3.4.6)
rack (>= 2.2.3)
rack-protection
omniauth-oauth2 (1.8.0)
oauth2 (>= 1.4, < 3)
omniauth (~> 2.0)
omniauth-rails_csrf_protection (1.0.1)
actionpack (>= 4.2)
omniauth (~> 2.0)
open-uri (0.3.0)
stringio
time
Expand All @@ -222,6 +289,9 @@ GEM
rack (2.2.6.2)
rack-cors (2.0.0)
rack (>= 2.0.0)
rack-protection (3.2.0)
base64 (>= 0.1.0)
rack (~> 2.2, >= 2.2.4)
rack-test (2.0.2)
rack (>= 1.3)
rails (7.0.4.2)
Expand Down Expand Up @@ -304,10 +374,26 @@ GEM
rubocop (~> 1.33)
rubocop-capybara (~> 2.17)
ruby-progressbar (1.11.0)
ruby-vips (2.2.0)
ffi (~> 1.12)
ruby2_keywords (0.0.5)
rubyzip (2.3.2)
sassc (2.4.0)
ffi (~> 1.9)
sassc-rails (2.1.2)
railties (>= 4.0.0)
sassc (>= 2.0)
sprockets (> 3.0)
sprockets-rails
tilt
scout_apm (5.3.5)
parser
selectize-rails (0.12.6)
selenium-webdriver (4.18.1)
base64 (~> 0.2)
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2, < 3.0)
websocket (~> 1.0)
sentry-rails (5.5.0)
railties (>= 5.0)
sentry-ruby (~> 5.5.0)
Expand All @@ -321,6 +407,9 @@ GEM
simplecov_json_formatter (~> 0.1)
simplecov-html (0.12.3)
simplecov_json_formatter (0.1.4)
snaky_hash (2.0.1)
hashie
version_gem (~> 1.1, >= 1.1.1)
sprockets (4.2.0)
concurrent-ruby (~> 1.0)
rack (>= 2.2.4, < 4)
Expand All @@ -330,6 +419,7 @@ GEM
sprockets (>= 3.0.0)
stringio (3.0.5)
thor (1.2.1)
tilt (2.3.0)
time (0.2.1)
date
timeout (0.3.2)
Expand All @@ -339,14 +429,22 @@ GEM
unicode-display_width (2.4.2)
uniform_notifier (1.16.0)
uri (0.12.0)
version_gem (1.1.3)
webdrivers (5.2.0)
nokogiri (~> 1.6)
rubyzip (>= 1.3.0)
selenium-webdriver (~> 4.0)
webmock (3.18.1)
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
webrick (1.8.1)
websocket (1.2.10)
websocket-driver (0.7.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
xpath (3.2.0)
nokogiri (~> 1.8)
zeitwerk (2.6.7)

PLATFORMS
Expand All @@ -355,10 +453,13 @@ PLATFORMS
x86_64-linux

DEPENDENCIES
administrate (~> 0.16.0)
administrate-field-active_storage
aws-sdk-s3
bootsnap
bullet
cancancan (~> 3.3)
capybara
climate_control
countries
dotenv-rails
Expand All @@ -372,9 +473,12 @@ DEPENDENCIES
graphiql-rails
graphql
graphql-client
image_processing
importmap-rails
jbuilder
kaminari
omniauth-rails_csrf_protection (~> 1.0.1)
omniauth-rpi!
open-uri
pg (~> 1.1)
pry-byebug
Expand All @@ -390,9 +494,11 @@ DEPENDENCIES
rubocop-rails
rubocop-rspec
scout_apm
selenium-webdriver
sentry-rails (~> 5.5.0)
shoulda-matchers (~> 5.0)
simplecov
webdrivers
webmock

RUBY VERSION
Expand Down
3 changes: 1 addition & 2 deletions app/assets/config/manifest.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//= link_tree ../images
//= link_directory ../stylesheets .css
//= link_tree ../../../vendor/javascript .js
//= link graphiql/rails/application.css
//= link graphiql/rails/application.js
//= link administrate-field-active_storage/application.css
15 changes: 15 additions & 0 deletions app/controllers/admin/application_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# frozen_string_literal: true

module Admin
class ApplicationController < Administrate::ApplicationController
include AuthenticationHelper

before_action :authenticate_admin

helper_method :current_user

def authenticate_admin
redirect_to '/', alert: I18n.t('errors.admin.unauthorized') unless current_user&.admin?
end
end
end
6 changes: 6 additions & 0 deletions app/controllers/admin/components_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# frozen_string_literal: true

module Admin
class ComponentsController < Admin::ApplicationController
end
end
23 changes: 23 additions & 0 deletions app/controllers/admin/projects_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# frozen_string_literal: true

module Admin
class ProjectsController < Admin::ApplicationController
before_action :set_host_for_local_storage

def scoped_resource
resource_class.internal_projects
end

def destroy_image
image = requested_resource.images.find(params[:image_id])
image.purge
redirect_back(fallback_location: requested_resource)
end

private

def set_host_for_local_storage
ActiveStorage::Current.host = request.base_url if Rails.application.config.active_storage.service == :local
end
end
end
Loading