Skip to content

Commit

Permalink
Update Administrate templates
Browse files Browse the repository at this point in the history
  • Loading branch information
jayvarner committed Sep 4, 2024
1 parent 363e868 commit 1763a47
Show file tree
Hide file tree
Showing 14 changed files with 58 additions and 116 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
AWS_ECS_SERVICE: ${{ secrets.AWS_ECS_SERVICE }}
AWS_REGION: ${{ secrets.AWS_REGION }}
RAIL_MASTER_KEY: ${{ secrets.RAIL_MASTER_KEY }}
REDIS_PROVIDER: ${{ secrets.REDIS_PROVIDER }}
RREDIS_URL: ${{ secrets.RREDIS_URL }}
run: |
chmod +x build.sh
./build.sh
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM ruby:3.3.4

ARG RAILS_MASTER_KEY
ARG REDIS_URL

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
Expand All @@ -11,7 +12,7 @@ WORKDIR /usr/src/app

ENV RAILS_MASTER_KEY=$RAILS_MASTER_KEY
ENV RAILS_ENV=production
ENV REDIS_PROVIDER=$REDIS_PROVIDER
ENV REDIS_URL=$REDIS_URL

COPY Gemfile* ./
RUN bundle install
Expand Down
6 changes: 2 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,16 @@ gem 'administrate-field-list', '~> 0.0.6'

gem 'httparty', '~> 0.20.0'

gem 'google-api-client'

gem 'roo', '~> 2.9'

gem 'namae', '~> 1.1'

gem 'administrate-field-active_storage', '~> 0.4.1'

gem 'capistrano-bundler', '~> 2.1'

gem 'active_record_doctor', '~> 1.10'

gem 'sidekiq', '~> 6.5.8'

gem 'uuid', '~> 2.3'

gem 'addressable', '~> 2.8'
81 changes: 1 addition & 80 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -98,29 +98,12 @@ GEM
administrate-field-list (0.0.6)
administrate
rails (>= 5.0)
airbrussh (1.5.2)
sshkit (>= 1.6.1, != 1.7.0)
ast (2.4.2)
base64 (0.2.0)
bigdecimal (3.1.8)
bootsnap (1.18.4)
msgpack (~> 1.2)
builder (3.3.0)
capistrano (3.19.1)
airbrussh (>= 1.0.0)
i18n
rake (>= 10.0.0)
sshkit (>= 1.9.0)
capistrano-bundler (2.1.1)
capistrano (~> 3.1)
capistrano-passenger (0.2.1)
capistrano (~> 3.0)
capistrano-rails (1.6.3)
capistrano (~> 3.1)
capistrano-bundler (>= 1.1, < 3)
capistrano-rbenv (2.2.0)
capistrano (~> 3.1)
sshkit (~> 1.3)
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
crass (1.0.6)
Expand All @@ -129,7 +112,6 @@ GEM
debug (1.9.2)
irb (~> 1.10)
reline (>= 0.3.8)
declarative (0.0.20)
diff-lcs (1.5.1)
drb (2.2.1)
elasticsearch (7.17.11)
Expand Down Expand Up @@ -164,42 +146,12 @@ GEM
ffi (1.17.0-x86_64-darwin)
ffi (1.17.0-x86_64-linux-gnu)
ffi (1.17.0-x86_64-linux-musl)
gems (1.2.0)
globalid (1.2.1)
activesupport (>= 6.1)
google-api-client (0.53.0)
google-apis-core (~> 0.1)
google-apis-generator (~> 0.1)
google-apis-core (0.15.1)
addressable (~> 2.5, >= 2.5.1)
googleauth (~> 1.9)
httpclient (>= 2.8.3, < 3.a)
mini_mime (~> 1.0)
mutex_m
representable (~> 3.0)
retriable (>= 2.0, < 4.a)
google-apis-discovery_v1 (0.19.0)
google-apis-core (>= 0.15.0, < 2.a)
google-apis-generator (0.15.1)
activesupport (>= 5.0)
gems (~> 1.2)
google-apis-core (>= 0.15.0, < 2.a)
google-apis-discovery_v1 (~> 0.18)
thor (>= 0.20, < 2.a)
google-cloud-env (2.1.1)
faraday (>= 1.0, < 3.a)
googleauth (1.11.0)
faraday (>= 1.0, < 3.a)
google-cloud-env (~> 2.1)
jwt (>= 1.4, < 3.0)
multi_json (~> 1.11)
os (>= 0.9, < 2.0)
signet (>= 0.16, < 2.a)
hashie (5.0.0)
httparty (0.20.0)
mime-types (~> 3.0)
multi_xml (>= 0.5.2)
httpclient (2.8.3)
i18n (1.14.5)
concurrent-ruby (~> 1.0)
image_processing (1.13.0)
Expand All @@ -217,8 +169,6 @@ GEM
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json (2.7.2)
jwt (2.8.2)
base64
kaminari (1.2.2)
activesupport (>= 4.1.0)
kaminari-actionview (= 1.2.2)
Expand Down Expand Up @@ -255,7 +205,6 @@ GEM
multi_xml (0.7.1)
bigdecimal (~> 3.1)
mustache (1.1.1)
mutex_m (0.2.0)
namae (1.2.0)
racc (~> 1.7)
net-http (0.4.1)
Expand All @@ -267,13 +216,8 @@ GEM
net-protocol
net-protocol (0.2.2)
timeout
net-scp (4.0.0)
net-ssh (>= 2.6.5, < 8.0.0)
net-sftp (4.0.0)
net-ssh (>= 5.0.0, < 8.0.0)
net-smtp (0.5.0)
net-protocol
net-ssh (7.2.3)
nio4r (2.7.3)
nokogiri (1.16.7-aarch64-linux)
racc (~> 1.4)
Expand All @@ -287,7 +231,6 @@ GEM
racc (~> 1.4)
nokogiri (1.16.7-x86_64-linux)
racc (~> 1.4)
os (1.1.4)
parallel (1.26.3)
parser (3.3.4.2)
ast (~> 2.4.1)
Expand Down Expand Up @@ -348,11 +291,6 @@ GEM
regexp_parser (2.9.2)
reline (0.5.9)
io-console (~> 0.5)
representable (3.2.0)
declarative (< 0.1.0)
trailblazer-option (>= 0.1.1, < 0.2.0)
uber (< 0.2.0)
retriable (3.1.2)
rexml (3.3.6)
strscan
roo (2.10.1)
Expand Down Expand Up @@ -432,35 +370,23 @@ GEM
connection_pool (>= 2.2.5, < 3)
rack (~> 2.0)
redis (>= 4.5.0, < 5)
signet (0.19.0)
addressable (~> 2.8)
faraday (>= 0.17.5, < 3.a)
jwt (>= 1.5, < 3.0)
multi_json (~> 1.10)
sprockets (4.2.1)
concurrent-ruby (~> 1.0)
rack (>= 2.2.4, < 4)
sprockets-rails (3.5.2)
actionpack (>= 6.1)
activesupport (>= 6.1)
sprockets (>= 3.0.0)
sshkit (1.23.0)
base64
net-scp (>= 1.1.2)
net-sftp (>= 2.1.2)
net-ssh (>= 2.8.0)
stringio (3.1.1)
strscan (3.1.0)
systemu (2.6.5)
thor (1.3.1)
tilt (2.4.0)
timeout (0.4.1)
trailblazer-option (0.1.2)
trix-rails (2.4.0)
rails (> 4.1)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
uber (0.1.0)
unicode-display_width (2.5.0)
uri (0.13.0)
useragent (0.16.10)
Expand Down Expand Up @@ -490,23 +416,18 @@ PLATFORMS
DEPENDENCIES
active_record_doctor (~> 1.10)
acts-as-taggable-on (~> 11.0.0)
addressable (~> 2.8)
administrate
administrate-field-active_storage (~> 0.4.1)
administrate-field-acts_as_taggable
administrate-field-jsonb
administrate-field-list (~> 0.0.6)
bootsnap
capistrano (~> 3.10)
capistrano-bundler (~> 2.1)
capistrano-passenger (~> 0.2.1)
capistrano-rails (~> 1.6)
capistrano-rbenv (~> 2.2)
csv
debug
elasticsearch (~> 7.17.1)
factory_bot_rails
faker
google-api-client
httparty (~> 0.20.0)
image_processing (~> 1.2)
jbuilder (~> 2.11)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin/about_pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module Admin
class AboutPagesController < Admin::ApplicationController
def valid_action?(name, resource = resource_class)
def accessible_action?(name, resource = resource_class)
%w[destroy add new create].exclude?(name.to_s) && super
end
end
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/admin/letters_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require 'addressable/uri'

module Admin
class LettersController < Admin::ApplicationController
before_action :original_params, only: %i[index]
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions app/views/admin/entities/_collection.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ to display a collection of resources in an HTML table.
<tbody>
<% resources.each do |resource| %>
<tr class="js-table-row"
<% if accessible_action? :show, resource %>
<% if accessible_action?(resource, :show) %>
<%= %(tabindex=0 role=link data-url=#{polymorphic_path([namespace, resource])}) %>
<% end %>
>
<% collection_presenter.attributes_for(resource).each do |attribute| %>
<td class="cell-data cell-data--<%= attribute.html_class %>">
<% if accessible_action? :show, resource -%>
<% if accessible_action?(resource, :show) -%>
<a href="<%= polymorphic_path([namespace, resource]) -%>"
tabindex="-1"
class="action-show"
Expand Down
4 changes: 2 additions & 2 deletions app/views/admin/entities/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ It displays a header, and renders the `_form` partial to do the heavy lifting.
</h1>
<div>
<%= link_to(
t("administrate.actions.show_resource", name: ''),
t("administrate.actions.show_resource", name: page.page_title),
[namespace, page.resource],
class: "button",
) if valid_action?(:show) && accessible_action?(:show, page.resource) %>
) if accessible_action?(page.resource, :show) %>
</div>
</header>
<section class="main-content__body">
Expand Down
38 changes: 26 additions & 12 deletions app/views/admin/entities/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,17 @@ as well as a link to its edit page.
</h1>
<div>
<%= link_to(
t("administrate.actions.edit_resource", name: ''),
t("administrate.actions.edit_resource", name: page.page_title),
[:edit, namespace, page.resource],
class: "button",
) if valid_action?(:edit) && accessible_action?(:edit, page.resource) %>
) if accessible_action?(page.resource, :edit) %>
<%= link_to(
t("administrate.actions.destroy"),
[namespace, page.resource],
class: "button button--danger",
method: :delete,
data: { confirm: t("administrate.actions.confirm") }
) if accessible_action?(page.resource, :destroy) %>
</div>
</header>
<section class="main-content__body">
Expand All @@ -74,16 +81,23 @@ as well as a link to its edit page.
</section>
<section class="main-content__body">
<dl>
<% page.attributes.each do |attribute| %>
<% next unless page.resource.allowed_attributes.include? attribute.name.to_sym %>
<dt class="attribute-label" id="<%= attribute.name %>">
<%= t(
"helpers.label.#{resource_name}.#{attribute.name}",
default: page.resource.class.human_attribute_name(attribute.name),
) %>
</dt>
<dd class="attribute-data attribute-data--<%=attribute.html_class%>"
><%= render_field attribute, page: page %></dd>
<% page.attributes.each do |title, attributes| %>
<fieldset class="<%= "field-unit--nested" if title.present? %>">
<% if title.present? %>
<legend><%= t "helpers.label.#{page.resource_name}.#{title}", default: title %></legend>
<% end %>
<% attributes.each do |attribute| %>
<% next unless page.resource.allowed_attributes.include? attribute.name.to_sym %>
<dt class="attribute-label" id="<%= attribute.name %>">
<%= t(
"helpers.label.#{resource_name}.#{attribute.name}",
default: page.resource.class.human_attribute_name(attribute.name),
) %>
</dt>
<dd class="attribute-data attribute-data--<%=attribute.html_class%>"
><%= render_field attribute, page: page %></dd>
<% end %>
</fieldset>
<% end %>
</dl>
</section>
Expand Down
4 changes: 2 additions & 2 deletions app/views/admin/letters/_collection.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ to display a collection of resources in an HTML table.
<tbody>
<% resources.each do |resource| %>
<tr class="js-table-row"
<% if accessible_action? :show, resource %>
<% if accessible_action?(resource, :show) %>
<%= %(tabindex=0 role=link data-url=#{polymorphic_path([namespace, resource])}) %>
<% end %>
>
<% collection_presenter.attributes_for(resource).each do |attribute| %>
<td class="cell-data cell-data--<%= attribute.html_class %>">
<% if accessible_action? :show, resource -%>
<% if accessible_action?(resource, :show) %>
<a href="<%= polymorphic_path([namespace, resource]) -%>"
tabindex="-1"
class="action-show"
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/letters/_index_header.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
),
[:new, namespace, page.resource_path.to_sym],
class: "button",
) if valid_action?(:new) && accessible_action?(:new, new_resource) %>
) if accessible_action?(new_resource, :new) %>
</div>
</header>
Loading

0 comments on commit 1763a47

Please sign in to comment.