Skip to content

Commit c0e104d

Browse files
authored
Initial project and component dashboards (#242)
Introduction of an admin dashboard for viewing and configuring editor projects
1 parent c601e7d commit c0e104d

38 files changed

+720
-88
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
RAILS_ENV: test
3131
steps:
3232
- checkout
33-
# - browser-tools/install-firefox
33+
- browser-tools/install-firefox
3434
- ruby/install-deps:
3535
key: gems-v2-
3636
- run:

.env.example

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,17 @@ POSTGRES_PASSWORD=changeme
1414
USERINFO_API_URL=http://localhost:6000
1515
USERINFO_API_KEY=1234
1616

17-
HYDRA_PUBLIC_URL=http://host.docker.internal:9001
17+
HYDRA_PUBLIC_URL=http://localhost:9001
18+
HYDRA_PUBLIC_TOKEN_URL=http://host.docker.internal:9001
19+
HYDRA_CLIENT_ID=editor-api-dev
20+
HYDRA_CLIENT_SECRET=secret
21+
22+
IDENTITY_URL=http://localhost:3002
1823

1924
SMEE_TUNNEL=https://smee.io/MLq0n9kvAes2vydX
2025

2126
# Add the below to bypass token authentication with hydra
2227
# BYPASS_AUTH=true
2328
# AUTH_USER_ID=<<set to match user_id for desired user>>
29+
30+
HOST_URL=http://localhost:3009

.rubocop.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
---
2-
require: rubocop-graphql
2+
require:
3+
- rubocop-graphql
4+
- rubocop-capybara
35
inherit_from:
46
- https://raspberrypifoundation.github.io/digital-engineering/configs/rubocop-base.yml
57
- https://raspberrypifoundation.github.io/digital-engineering/configs/rubocop-rails.yml
@@ -27,3 +29,7 @@ RSpec/DescribeClass:
2729

2830
RSpec/MultipleMemoizedHelpers:
2931
Max: 8
32+
33+
Metrics/BlockLength:
34+
Exclude:
35+
- "config/routes.rb"

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ WORKDIR /app
2121
RUN apt-get update \
2222
&& apt-get install --yes --no-install-recommends \
2323
build-essential libpq-dev libxml2-dev libxslt1-dev git \
24+
firefox-esr python2-dev \
2425
&& rm -rf /var/lib/apt/lists/* /var/lib/apt/archives/*.deb
2526
COPY Gemfile Gemfile.lock /app/
2627
RUN bundle install --jobs 4 \

Gemfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
55

66
ruby '~> 3.2.0'
77

8+
gem 'administrate', '~> 0.16.0'
9+
gem 'administrate-field-active_storage'
810
gem 'aws-sdk-s3', require: false
911
gem 'bootsnap', require: false
1012
gem 'cancancan', '~> 3.3'
@@ -16,9 +18,14 @@ gem 'globalid'
1618
gem 'good_job', '~> 3.12'
1719
gem 'graphql'
1820
gem 'graphql-client'
21+
gem 'image_processing'
1922
gem 'importmap-rails'
2023
gem 'jbuilder'
2124
gem 'kaminari'
25+
gem 'omniauth-rails_csrf_protection', '~> 1.0.1'
26+
gem 'omniauth-rpi',
27+
github: 'RaspberryPiFoundation/omniauth-rpi',
28+
tag: 'v1.3.1'
2229
gem 'open-uri'
2330
gem 'pg', '~> 1.1'
2431
gem 'puma', '~> 5.6'
@@ -46,7 +53,10 @@ group :development, :test do
4653
end
4754

4855
group :test do
56+
gem 'capybara'
4957
gem 'climate_control'
58+
gem 'selenium-webdriver'
5059
gem 'shoulda-matchers', '~> 5.0'
60+
gem 'webdrivers'
5161
gem 'webmock'
5262
end

Gemfile.lock

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
GIT
2+
remote: https://github.com/RaspberryPiFoundation/omniauth-rpi.git
3+
revision: b7cb36cbfbf9a66f2376bb1501a4bdb205f2a7bf
4+
tag: v1.3.1
5+
specs:
6+
omniauth-rpi (1.3.1)
7+
jwt (~> 2.2.3)
8+
omniauth (~> 2.0)
9+
omniauth-oauth2 (~> 1.4)
10+
111
GEM
212
remote: https://rubygems.org/
313
specs:
@@ -68,6 +78,19 @@ GEM
6878
tzinfo (~> 2.0)
6979
addressable (2.8.1)
7080
public_suffix (>= 2.0.2, < 6.0)
81+
administrate (0.16.0)
82+
actionpack (>= 5.0)
83+
actionview (>= 5.0)
84+
activerecord (>= 5.0)
85+
datetime_picker_rails (~> 0.0.7)
86+
jquery-rails (>= 4.0)
87+
kaminari (>= 1.0)
88+
momentjs-rails (~> 2.8)
89+
sassc-rails (~> 2.1)
90+
selectize-rails (~> 0.6)
91+
administrate-field-active_storage (1.0.1)
92+
administrate (>= 0.2.2)
93+
rails (>= 7.0)
7194
ast (2.4.2)
7295
aws-eventstream (1.2.0)
7396
aws-partitions (1.718.0)
@@ -85,6 +108,7 @@ GEM
85108
aws-sigv4 (~> 1.4)
86109
aws-sigv4 (1.5.2)
87110
aws-eventstream (~> 1, >= 1.0.2)
111+
base64 (0.2.0)
88112
bootsnap (1.16.0)
89113
msgpack (~> 1.2)
90114
builder (3.2.4)
@@ -93,6 +117,15 @@ GEM
93117
uniform_notifier (~> 1.11)
94118
byebug (11.1.3)
95119
cancancan (3.4.0)
120+
capybara (3.40.0)
121+
addressable
122+
matrix
123+
mini_mime (>= 0.1.3)
124+
nokogiri (~> 1.11)
125+
rack (>= 1.6.0)
126+
rack-test (>= 0.6.3)
127+
regexp_parser (>= 1.5, < 3.0)
128+
xpath (~> 3.2)
96129
climate_control (1.2.0)
97130
coderay (1.1.3)
98131
concurrent-ruby (1.2.2)
@@ -102,6 +135,8 @@ GEM
102135
rexml
103136
crass (1.0.6)
104137
date (3.3.3)
138+
datetime_picker_rails (0.0.7)
139+
momentjs-rails (>= 2.8.1)
105140
diff-lcs (1.5.0)
106141
docile (1.4.0)
107142
dotenv (2.8.1)
@@ -124,6 +159,7 @@ GEM
124159
faraday-net_http (>= 2.0, < 3.1)
125160
ruby2_keywords (>= 0.0.4)
126161
faraday-net_http (3.0.2)
162+
ffi (1.16.3)
127163
fugit (1.8.1)
128164
et-orbi (~> 1, >= 1.2.7)
129165
raabro (~> 1.4)
@@ -149,16 +185,25 @@ GEM
149185
activesupport (>= 3.0)
150186
graphql
151187
hashdiff (1.0.1)
188+
hashie (5.0.0)
152189
i18n (1.12.0)
153190
concurrent-ruby (~> 1.0)
191+
image_processing (1.12.2)
192+
mini_magick (>= 4.9.5, < 5)
193+
ruby-vips (>= 2.0.17, < 3)
154194
importmap-rails (1.1.5)
155195
actionpack (>= 6.0.0)
156196
railties (>= 6.0.0)
157197
jbuilder (2.11.5)
158198
actionview (>= 5.0.0)
159199
activesupport (>= 5.0.0)
160200
jmespath (1.6.2)
201+
jquery-rails (4.6.0)
202+
rails-dom-testing (>= 1, < 3)
203+
railties (>= 4.2.0)
204+
thor (>= 0.14, < 2.0)
161205
json (2.6.3)
206+
jwt (2.2.3)
162207
kaminari (1.2.2)
163208
activesupport (>= 4.1.0)
164209
kaminari-actionview (= 1.2.2)
@@ -180,10 +225,15 @@ GEM
180225
net-pop
181226
net-smtp
182227
marcel (1.0.2)
228+
matrix (0.4.2)
183229
method_source (1.0.0)
230+
mini_magick (4.12.0)
184231
mini_mime (1.1.2)
185232
minitest (5.17.0)
233+
momentjs-rails (2.29.4.1)
234+
railties (>= 3.1)
186235
msgpack (1.6.0)
236+
multi_xml (0.6.0)
187237
net-imap (0.3.4)
188238
date
189239
net-protocol
@@ -200,6 +250,23 @@ GEM
200250
racc (~> 1.4)
201251
nokogiri (1.14.2-x86_64-linux)
202252
racc (~> 1.4)
253+
oauth2 (2.0.9)
254+
faraday (>= 0.17.3, < 3.0)
255+
jwt (>= 1.0, < 3.0)
256+
multi_xml (~> 0.5)
257+
rack (>= 1.2, < 4)
258+
snaky_hash (~> 2.0)
259+
version_gem (~> 1.1)
260+
omniauth (2.1.2)
261+
hashie (>= 3.4.6)
262+
rack (>= 2.2.3)
263+
rack-protection
264+
omniauth-oauth2 (1.8.0)
265+
oauth2 (>= 1.4, < 3)
266+
omniauth (~> 2.0)
267+
omniauth-rails_csrf_protection (1.0.1)
268+
actionpack (>= 4.2)
269+
omniauth (~> 2.0)
203270
open-uri (0.3.0)
204271
stringio
205272
time
@@ -222,6 +289,9 @@ GEM
222289
rack (2.2.6.2)
223290
rack-cors (2.0.0)
224291
rack (>= 2.0.0)
292+
rack-protection (3.2.0)
293+
base64 (>= 0.1.0)
294+
rack (~> 2.2, >= 2.2.4)
225295
rack-test (2.0.2)
226296
rack (>= 1.3)
227297
rails (7.0.4.2)
@@ -304,10 +374,26 @@ GEM
304374
rubocop (~> 1.33)
305375
rubocop-capybara (~> 2.17)
306376
ruby-progressbar (1.11.0)
377+
ruby-vips (2.2.0)
378+
ffi (~> 1.12)
307379
ruby2_keywords (0.0.5)
308380
rubyzip (2.3.2)
381+
sassc (2.4.0)
382+
ffi (~> 1.9)
383+
sassc-rails (2.1.2)
384+
railties (>= 4.0.0)
385+
sassc (>= 2.0)
386+
sprockets (> 3.0)
387+
sprockets-rails
388+
tilt
309389
scout_apm (5.3.5)
310390
parser
391+
selectize-rails (0.12.6)
392+
selenium-webdriver (4.18.1)
393+
base64 (~> 0.2)
394+
rexml (~> 3.2, >= 3.2.5)
395+
rubyzip (>= 1.2.2, < 3.0)
396+
websocket (~> 1.0)
311397
sentry-rails (5.5.0)
312398
railties (>= 5.0)
313399
sentry-ruby (~> 5.5.0)
@@ -321,6 +407,9 @@ GEM
321407
simplecov_json_formatter (~> 0.1)
322408
simplecov-html (0.12.3)
323409
simplecov_json_formatter (0.1.4)
410+
snaky_hash (2.0.1)
411+
hashie
412+
version_gem (~> 1.1, >= 1.1.1)
324413
sprockets (4.2.0)
325414
concurrent-ruby (~> 1.0)
326415
rack (>= 2.2.4, < 4)
@@ -330,6 +419,7 @@ GEM
330419
sprockets (>= 3.0.0)
331420
stringio (3.0.5)
332421
thor (1.2.1)
422+
tilt (2.3.0)
333423
time (0.2.1)
334424
date
335425
timeout (0.3.2)
@@ -339,14 +429,22 @@ GEM
339429
unicode-display_width (2.4.2)
340430
uniform_notifier (1.16.0)
341431
uri (0.12.0)
432+
version_gem (1.1.3)
433+
webdrivers (5.2.0)
434+
nokogiri (~> 1.6)
435+
rubyzip (>= 1.3.0)
436+
selenium-webdriver (~> 4.0)
342437
webmock (3.18.1)
343438
addressable (>= 2.8.0)
344439
crack (>= 0.3.2)
345440
hashdiff (>= 0.4.0, < 2.0.0)
346441
webrick (1.8.1)
442+
websocket (1.2.10)
347443
websocket-driver (0.7.5)
348444
websocket-extensions (>= 0.1.0)
349445
websocket-extensions (0.1.5)
446+
xpath (3.2.0)
447+
nokogiri (~> 1.8)
350448
zeitwerk (2.6.7)
351449

352450
PLATFORMS
@@ -355,10 +453,13 @@ PLATFORMS
355453
x86_64-linux
356454

357455
DEPENDENCIES
456+
administrate (~> 0.16.0)
457+
administrate-field-active_storage
358458
aws-sdk-s3
359459
bootsnap
360460
bullet
361461
cancancan (~> 3.3)
462+
capybara
362463
climate_control
363464
countries
364465
dotenv-rails
@@ -372,9 +473,12 @@ DEPENDENCIES
372473
graphiql-rails
373474
graphql
374475
graphql-client
476+
image_processing
375477
importmap-rails
376478
jbuilder
377479
kaminari
480+
omniauth-rails_csrf_protection (~> 1.0.1)
481+
omniauth-rpi!
378482
open-uri
379483
pg (~> 1.1)
380484
pry-byebug
@@ -390,9 +494,11 @@ DEPENDENCIES
390494
rubocop-rails
391495
rubocop-rspec
392496
scout_apm
497+
selenium-webdriver
393498
sentry-rails (~> 5.5.0)
394499
shoulda-matchers (~> 5.0)
395500
simplecov
501+
webdrivers
396502
webmock
397503

398504
RUBY VERSION

app/assets/config/manifest.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//= link_tree ../images
22
//= link_directory ../stylesheets .css
33
//= link_tree ../../../vendor/javascript .js
4-
//= link graphiql/rails/application.css
5-
//= link graphiql/rails/application.js
4+
//= link administrate-field-active_storage/application.css
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# frozen_string_literal: true
2+
3+
module Admin
4+
class ApplicationController < Administrate::ApplicationController
5+
include AuthenticationHelper
6+
7+
before_action :authenticate_admin
8+
9+
helper_method :current_user
10+
11+
def authenticate_admin
12+
redirect_to '/', alert: I18n.t('errors.admin.unauthorized') unless current_user&.admin?
13+
end
14+
end
15+
end
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# frozen_string_literal: true
2+
3+
module Admin
4+
class ComponentsController < Admin::ApplicationController
5+
end
6+
end
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# frozen_string_literal: true
2+
3+
module Admin
4+
class ProjectsController < Admin::ApplicationController
5+
before_action :set_host_for_local_storage
6+
7+
def scoped_resource
8+
resource_class.internal_projects
9+
end
10+
11+
def destroy_image
12+
image = requested_resource.images.find(params[:image_id])
13+
image.purge
14+
redirect_back(fallback_location: requested_resource)
15+
end
16+
17+
private
18+
19+
def set_host_for_local_storage
20+
ActiveStorage::Current.host = request.base_url if Rails.application.config.active_storage.service == :local
21+
end
22+
end
23+
end

0 commit comments

Comments
 (0)