diff --git a/app/controllers/admin/application_controller.rb b/app/controllers/resource_admin/application_controller.rb similarity index 97% rename from app/controllers/admin/application_controller.rb rename to app/controllers/resource_admin/application_controller.rb index 5645b011b..bc9f79a52 100644 --- a/app/controllers/admin/application_controller.rb +++ b/app/controllers/resource_admin/application_controller.rb @@ -4,7 +4,7 @@ # # If you want to add pagination or other controller-level concerns, # you're free to overwrite the RESTful controller actions. -module Admin +module ResourceAdmin class ApplicationController < Administrate::ApplicationController include Pundit before_action :authorize_admin diff --git a/app/controllers/admin/articles_controller.rb b/app/controllers/resource_admin/articles_controller.rb similarity index 93% rename from app/controllers/admin/articles_controller.rb rename to app/controllers/resource_admin/articles_controller.rb index 286a9e703..5f87d727c 100644 --- a/app/controllers/admin/articles_controller.rb +++ b/app/controllers/resource_admin/articles_controller.rb @@ -1,5 +1,5 @@ -module Admin - class ArticlesController < Admin::ApplicationController +module ResourceAdmin + class ArticlesController < ResourceAdmin::ApplicationController def create resource = resource_class.new(resource_params) authorize_resource(resource) diff --git a/app/controllers/admin/badge_achievements_controller.rb b/app/controllers/resource_admin/badge_achievements_controller.rb similarity index 84% rename from app/controllers/admin/badge_achievements_controller.rb rename to app/controllers/resource_admin/badge_achievements_controller.rb index a3c17190a..46f43f81f 100644 --- a/app/controllers/admin/badge_achievements_controller.rb +++ b/app/controllers/resource_admin/badge_achievements_controller.rb @@ -1,5 +1,5 @@ -module Admin - class BadgeAchievementsController < Admin::ApplicationController +module ResourceAdmin + class BadgeAchievementsController < ResourceAdmin::ApplicationController # To customize the behavior of this controller, # you can overwrite any of the RESTful actions. For example: # diff --git a/app/controllers/admin/badges_controller.rb b/app/controllers/resource_admin/badges_controller.rb similarity index 85% rename from app/controllers/admin/badges_controller.rb rename to app/controllers/resource_admin/badges_controller.rb index ffdacac0c..a469ffa31 100644 --- a/app/controllers/admin/badges_controller.rb +++ b/app/controllers/resource_admin/badges_controller.rb @@ -1,5 +1,5 @@ -module Admin - class BadgesController < Admin::ApplicationController +module ResourceAdmin + class BadgesController < ResourceAdmin::ApplicationController # To customize the behavior of this controller, # you can overwrite any of the RESTful actions. For example: # diff --git a/app/controllers/admin/collections_controller.rb b/app/controllers/resource_admin/collections_controller.rb similarity index 84% rename from app/controllers/admin/collections_controller.rb rename to app/controllers/resource_admin/collections_controller.rb index be43cfd9c..f0bdc0156 100644 --- a/app/controllers/admin/collections_controller.rb +++ b/app/controllers/resource_admin/collections_controller.rb @@ -1,5 +1,5 @@ -module Admin - class CollectionsController < Admin::ApplicationController +module ResourceAdmin + class CollectionsController < ResourceAdmin::ApplicationController # To customize the behavior of this controller, # simply overwrite any of the RESTful actions. For example: # diff --git a/app/controllers/admin/comments_controller.rb b/app/controllers/resource_admin/comments_controller.rb similarity index 86% rename from app/controllers/admin/comments_controller.rb rename to app/controllers/resource_admin/comments_controller.rb index 3db862bf8..be8625513 100644 --- a/app/controllers/admin/comments_controller.rb +++ b/app/controllers/resource_admin/comments_controller.rb @@ -1,5 +1,5 @@ -module Admin - class CommentsController < Admin::ApplicationController +module ResourceAdmin + class CommentsController < ResourceAdmin::ApplicationController def update comment = Comment.find(params[:id]) if comment.update(comment_params) diff --git a/app/controllers/admin/display_ads_controller.rb b/app/controllers/resource_admin/display_ads_controller.rb similarity index 85% rename from app/controllers/admin/display_ads_controller.rb rename to app/controllers/resource_admin/display_ads_controller.rb index 5996530d2..4da50e894 100644 --- a/app/controllers/admin/display_ads_controller.rb +++ b/app/controllers/resource_admin/display_ads_controller.rb @@ -1,5 +1,5 @@ -module Admin - class DisplayAdsController < Admin::ApplicationController +module ResourceAdmin + class DisplayAdsController < ResourceAdmin::ApplicationController # To customize the behavior of this controller, # you can overwrite any of the RESTful actions. For example: # diff --git a/app/controllers/admin/email_messages_controller.rb b/app/controllers/resource_admin/email_messages_controller.rb similarity index 85% rename from app/controllers/admin/email_messages_controller.rb rename to app/controllers/resource_admin/email_messages_controller.rb index bdae7940f..fcefcac44 100644 --- a/app/controllers/admin/email_messages_controller.rb +++ b/app/controllers/resource_admin/email_messages_controller.rb @@ -1,5 +1,5 @@ -module Admin - class EmailMessagesController < Admin::ApplicationController +module ResourceAdmin + class EmailMessagesController < ResourceAdmin::ApplicationController # To customize the behavior of this controller, # simply overwrite any of the RESTful actions. For example: # diff --git a/app/controllers/admin/feedback_messages_controller.rb b/app/controllers/resource_admin/feedback_messages_controller.rb similarity index 84% rename from app/controllers/admin/feedback_messages_controller.rb rename to app/controllers/resource_admin/feedback_messages_controller.rb index 0f724c449..147a973d2 100644 --- a/app/controllers/admin/feedback_messages_controller.rb +++ b/app/controllers/resource_admin/feedback_messages_controller.rb @@ -1,5 +1,5 @@ -module Admin - class FeedbackMessagesController < Admin::ApplicationController +module ResourceAdmin + class FeedbackMessagesController < ResourceAdmin::ApplicationController # To customize the behavior of this controller, # you can overwrite any of the RESTful actions. For example: # diff --git a/app/controllers/admin/follows_controller.rb b/app/controllers/resource_admin/follows_controller.rb similarity index 85% rename from app/controllers/admin/follows_controller.rb rename to app/controllers/resource_admin/follows_controller.rb index 092458ad0..41bf613ed 100644 --- a/app/controllers/admin/follows_controller.rb +++ b/app/controllers/resource_admin/follows_controller.rb @@ -1,5 +1,5 @@ -module Admin - class FollowsController < Admin::ApplicationController +module ResourceAdmin + class FollowsController < ResourceAdmin::ApplicationController # To customize the behavior of this controller, # simply overwrite any of the RESTful actions. For example: # diff --git a/app/controllers/admin/html_variant_successes_controller.rb b/app/controllers/resource_admin/html_variant_successes_controller.rb similarity index 90% rename from app/controllers/admin/html_variant_successes_controller.rb rename to app/controllers/resource_admin/html_variant_successes_controller.rb index 9c5c30166..788a103cc 100644 --- a/app/controllers/admin/html_variant_successes_controller.rb +++ b/app/controllers/resource_admin/html_variant_successes_controller.rb @@ -1,5 +1,5 @@ -module Admin - class HtmlVariantSuccessesController < Admin::ApplicationController +module ResourceAdmin + class HtmlVariantSuccessesController < ResourceAdmin::ApplicationController # Overwrite any of the RESTful controller actions to implement custom behavior # For example, you may want to send an email after a foo is updated. # diff --git a/app/controllers/admin/html_variant_trials_controller.rb b/app/controllers/resource_admin/html_variant_trials_controller.rb similarity index 90% rename from app/controllers/admin/html_variant_trials_controller.rb rename to app/controllers/resource_admin/html_variant_trials_controller.rb index f1fae85d7..ad51b942c 100644 --- a/app/controllers/admin/html_variant_trials_controller.rb +++ b/app/controllers/resource_admin/html_variant_trials_controller.rb @@ -1,5 +1,5 @@ -module Admin - class HtmlVariantTrialsController < Admin::ApplicationController +module ResourceAdmin + class HtmlVariantTrialsController < ResourceAdmin::ApplicationController # Overwrite any of the RESTful controller actions to implement custom behavior # For example, you may want to send an email after a foo is updated. # diff --git a/app/controllers/admin/html_variants_controller.rb b/app/controllers/resource_admin/html_variants_controller.rb similarity index 85% rename from app/controllers/admin/html_variants_controller.rb rename to app/controllers/resource_admin/html_variants_controller.rb index 0ca6e91f7..35265b3e6 100644 --- a/app/controllers/admin/html_variants_controller.rb +++ b/app/controllers/resource_admin/html_variants_controller.rb @@ -1,5 +1,5 @@ -module Admin - class HtmlVariantsController < Admin::ApplicationController +module ResourceAdmin + class HtmlVariantsController < ResourceAdmin::ApplicationController # To customize the behavior of this controller, # you can overwrite any of the RESTful actions. For example: # diff --git a/app/controllers/admin/listing_categories_controller.rb b/app/controllers/resource_admin/listing_categories_controller.rb similarity index 93% rename from app/controllers/admin/listing_categories_controller.rb rename to app/controllers/resource_admin/listing_categories_controller.rb index 04164fa12..4a5792b12 100644 --- a/app/controllers/admin/listing_categories_controller.rb +++ b/app/controllers/resource_admin/listing_categories_controller.rb @@ -1,5 +1,5 @@ -module Admin - class ListingCategoriesController < Admin::ApplicationController +module ResourceAdmin + class ListingCategoriesController < ResourceAdmin::ApplicationController # Overwrite any of the RESTful controller actions to implement custom behavior # For example, you may want to send an email after a foo is updated. # diff --git a/app/controllers/admin/organizations_controller.rb b/app/controllers/resource_admin/organizations_controller.rb similarity index 86% rename from app/controllers/admin/organizations_controller.rb rename to app/controllers/resource_admin/organizations_controller.rb index 353c0df9f..c4f1351cc 100644 --- a/app/controllers/admin/organizations_controller.rb +++ b/app/controllers/resource_admin/organizations_controller.rb @@ -1,5 +1,5 @@ -module Admin - class OrganizationsController < Admin::ApplicationController +module ResourceAdmin + class OrganizationsController < ResourceAdmin::ApplicationController # To customize the behavior of this controller, # simply overwrite any of the RESTful actions. For example: # diff --git a/app/controllers/admin/podcast_episodes_controller.rb b/app/controllers/resource_admin/podcast_episodes_controller.rb similarity index 84% rename from app/controllers/admin/podcast_episodes_controller.rb rename to app/controllers/resource_admin/podcast_episodes_controller.rb index af782327b..98ce24d45 100644 --- a/app/controllers/admin/podcast_episodes_controller.rb +++ b/app/controllers/resource_admin/podcast_episodes_controller.rb @@ -1,5 +1,5 @@ -module Admin - class PodcastEpisodesController < Admin::ApplicationController +module ResourceAdmin + class PodcastEpisodesController < ResourceAdmin::ApplicationController # To customize the behavior of this controller, # simply overwrite any of the RESTful actions. For example: # diff --git a/app/controllers/admin/podcasts_controller.rb b/app/controllers/resource_admin/podcasts_controller.rb similarity index 85% rename from app/controllers/admin/podcasts_controller.rb rename to app/controllers/resource_admin/podcasts_controller.rb index 76cd1cf92..0502064e2 100644 --- a/app/controllers/admin/podcasts_controller.rb +++ b/app/controllers/resource_admin/podcasts_controller.rb @@ -1,5 +1,5 @@ -module Admin - class PodcastsController < Admin::ApplicationController +module ResourceAdmin + class PodcastsController < ResourceAdmin::ApplicationController def create resource = resource_class.new(resource_params) authorize_resource(resource) diff --git a/app/controllers/admin/reactions_controller.rb b/app/controllers/resource_admin/reactions_controller.rb similarity index 84% rename from app/controllers/admin/reactions_controller.rb rename to app/controllers/resource_admin/reactions_controller.rb index c8de8d65b..e51e8134b 100644 --- a/app/controllers/admin/reactions_controller.rb +++ b/app/controllers/resource_admin/reactions_controller.rb @@ -1,5 +1,5 @@ -module Admin - class ReactionsController < Admin::ApplicationController +module ResourceAdmin + class ReactionsController < ResourceAdmin::ApplicationController # To customize the behavior of this controller, # simply overwrite any of the RESTful actions. For example: # diff --git a/app/controllers/admin/sponsorships_controller.rb b/app/controllers/resource_admin/sponsorships_controller.rb similarity index 85% rename from app/controllers/admin/sponsorships_controller.rb rename to app/controllers/resource_admin/sponsorships_controller.rb index 672c7a7f1..ffc4225d9 100644 --- a/app/controllers/admin/sponsorships_controller.rb +++ b/app/controllers/resource_admin/sponsorships_controller.rb @@ -1,5 +1,5 @@ -module Admin - class SponsorshipsController < Admin::ApplicationController +module ResourceAdmin + class SponsorshipsController < ResourceAdmin::ApplicationController # To customize the behavior of this controller, # you can overwrite any of the RESTful actions. For example: # diff --git a/app/controllers/admin/tags_controller.rb b/app/controllers/resource_admin/tags_controller.rb similarity index 92% rename from app/controllers/admin/tags_controller.rb rename to app/controllers/resource_admin/tags_controller.rb index e0bd32b2d..1cff8742b 100644 --- a/app/controllers/admin/tags_controller.rb +++ b/app/controllers/resource_admin/tags_controller.rb @@ -1,5 +1,5 @@ -module Admin - class TagsController < Admin::ApplicationController +module ResourceAdmin + class TagsController < ResourceAdmin::ApplicationController def update @tag = Tag.find(params[:id]) if @tag.update(tag_params) && @tag.errors.messages.blank? diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/resource_admin/users_controller.rb similarity index 92% rename from app/controllers/admin/users_controller.rb rename to app/controllers/resource_admin/users_controller.rb index 67c4c190a..73635fbbf 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/resource_admin/users_controller.rb @@ -1,10 +1,10 @@ -module Admin - class UsersController < Admin::ApplicationController +module ResourceAdmin + class UsersController < ResourceAdmin::ApplicationController def update user = User.find(params[:id]) if user.errors.messages.blank? && user.update(user_params) flash[:notice] = "User successfully updated" - redirect_to "/admin/users/#{params[:id]}" + redirect_to "/ResourceAdmin/users/#{params[:id]}" else render :new, locals: { page: Administrate::Page::Form.new(dashboard, user) } end diff --git a/app/views/admin/application/_collection.html.erb b/app/views/resouce_admin/application/_collection.html.erb similarity index 100% rename from app/views/admin/application/_collection.html.erb rename to app/views/resouce_admin/application/_collection.html.erb diff --git a/app/views/admin/application/index.html.erb b/app/views/resouce_admin/application/index.html.erb similarity index 100% rename from app/views/admin/application/index.html.erb rename to app/views/resouce_admin/application/index.html.erb diff --git a/app/views/service_worker/index.js.erb b/app/views/service_worker/index.js.erb index b1f554459..f8ffca725 100644 --- a/app/views/service_worker/index.js.erb +++ b/app/views/service_worker/index.js.erb @@ -106,7 +106,7 @@ !url.href.includes('?preview=') && // Skip for preview pages. !url.href.includes('?signin') && // Don't run on sign in. - !url.href.includes('/admin') && // Don't fetch for administrate dashboard. + !url.href.includes('/resource_admin') && // Don't fetch for administrate dashboard. !url.href.includes('/api/') && // Don't run on API endpoints. !url.href.includes('/embed/') && // Don't fetch for embeded content. !url.href.includes('/feed') && // Skip the RSS feed diff --git a/config/routes.rb b/config/routes.rb index 8fcc76cf0..ddb3ebeda 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -29,7 +29,7 @@ Rails.application.routes.draw do mount FieldTest::Engine, at: "abtests" end - namespace :admin do + namespace :resource_admin do # Check administrate gem docs DashboardManifest::DASHBOARDS.each do |dashboard_resource| resources dashboard_resource diff --git a/docs/backend/configuration.md b/docs/backend/configuration.md index 85312e431..387394f7d 100644 --- a/docs/backend/configuration.md +++ b/docs/backend/configuration.md @@ -22,7 +22,7 @@ credentials and third party services. Examples: Settings managed via ENVied can be found in [`Envfile`](https://github.com/forem/forem/blob/master/Envfile) (see [Configuring Environment Variables](../getting-started/config-env.md)) and -viewed at `/internal/config` (see [Accessing the admin panel](./admin.md)): +viewed at `/internal/config` (see [the Internal guide](../internal/readme.md)): ![Screenshot of env variable admin interface](https://user-images.githubusercontent.com/47985/73627243-67d41f80-467e-11ea-9121-221275ff8a89.png) @@ -38,9 +38,9 @@ Examples: These settings can be accessed via the [`SiteConfig`](https://github.com/forem/forem/blob/master/app/models/site_config.rb) object and viewed / modified via `/internal/config` (see -[Accessing the admin panel](./admin.md)). +[the Internal guide](../internal/readme.md)). -![Screenshot of site configuration admin interface](https://user-images.githubusercontent.com/47985/73627238-6276d500-467e-11ea-8724-afb703f056bc.png) +![Screenshot of site configuration internal interface](https://user-images.githubusercontent.com/47985/73627238-6276d500-467e-11ea-8724-afb703f056bc.png) ## Vault diff --git a/docs/backend/readme.md b/docs/backend/readme.md index 28b405e96..2ae37b8d7 100644 --- a/docs/backend/readme.md +++ b/docs/backend/readme.md @@ -12,7 +12,7 @@ items: - fastly.md - roles.md - pusher.md - - admin.md + - resource-admin.md - previewing-emails.md - notification.md - scheduled-jobs.md diff --git a/docs/backend/admin.md b/docs/backend/resource-admin.md similarity index 70% rename from docs/backend/admin.md rename to docs/backend/resource-admin.md index 90bfd15cf..1ace7f8ef 100644 --- a/docs/backend/admin.md +++ b/docs/backend/resource-admin.md @@ -1,18 +1,19 @@ --- -title: Admin Panel +title: Resource Admin Panel --- -# What is the admin panel? +# What is the resource admin panel? -The admin panel is a CRUD interface generated via the +The resource admin panel is a CRUD interface generated via the [Administrate gem](https://github.com/thoughtbot/administrate). In production, this is generally not used often and will be deprecated in favor of the internal panel (`http://localhost:3000/internal/*`). For more details, see [the internal guide](/internal). -# Accessing the admin panel +# Accessing the resource admin panel -There is an admin panel located at . +There is an resource admin panel located at +. To access the panel, you must be logged with a user with the `admin` role activated. @@ -35,4 +36,4 @@ Loading development environment (Rails 5.2.3) ``` Now you'll be able to access the -[administration panel](http://localhost:3000/admin). +[resource administration panel](http://localhost:3000/resource_admin). diff --git a/docs/backend/roles.md b/docs/backend/roles.md index 8a5993199..6cf2a6ed1 100644 --- a/docs/backend/roles.md +++ b/docs/backend/roles.md @@ -72,4 +72,4 @@ User.joins(:roles).order(:id).group(:id).pluck(:id, :username, Arel.sql("array_a [2]: https://github.com/forem/forem/blob/master/app/models/role.rb [3]: https://github.com/forem/forem/search?q=has_role&unscoped_q=has_role [4]: https://stackoverflow.com/a/16096790/1511504 -[5]: /backend/admin +[5]: /backend/resource-admin diff --git a/spec/requests/admin/podcasts_spec.rb b/spec/requests/admin/podcasts_spec.rb index 5fc069b07..471194ff5 100644 --- a/spec/requests/admin/podcasts_spec.rb +++ b/spec/requests/admin/podcasts_spec.rb @@ -23,20 +23,20 @@ RSpec.describe "Admin::Podcasts", type: :request do it "creates a podcast" do expect do - post "/admin/podcasts", params: { podcast: valid_attributes } + post "/resource_admin/podcasts", params: { podcast: valid_attributes } end.to change(Podcast, :count).by(1) end it "enqueues a job after creating a podcast" do sidekiq_assert_enqueued_jobs(1, only: Podcasts::GetEpisodesWorker) do - post "/admin/podcasts", params: { podcast: valid_attributes } + post "/resource_admin/podcasts", params: { podcast: valid_attributes } end end it "doesn't enqueue a job when creating an unpublished podcast" do valid_attributes[:published] = false sidekiq_assert_no_enqueued_jobs(only: Podcasts::GetEpisodesWorker) do - post "/admin/podcasts", params: { podcast: valid_attributes } + post "/resource_admin/podcasts", params: { podcast: valid_attributes } end end end diff --git a/spec/system/admin/admin_dashboard_presented_spec.rb b/spec/system/admin/admin_dashboard_presented_spec.rb index 7bb1da2a2..44eeb6e1f 100644 --- a/spec/system/admin/admin_dashboard_presented_spec.rb +++ b/spec/system/admin/admin_dashboard_presented_spec.rb @@ -10,18 +10,18 @@ RSpec.describe "Admin dashboard is presented", type: :system do it "loads the admin dashboard articles view", js: true do sign_in admin - visit "/admin" + visit "/resource_admin" expect(page).to have_content("Articles") end it "loads the admin dashboard podcasts view", js: true do sign_in admin - visit "/admin/podcasts" + visit "/resource_admin/podcasts" expect(page).to have_content("Podcast Episodes") end it "fails to load admin view for unauthorized users" do - expect { visit "/admin" }.to raise_error(Pundit::NotAuthorizedError) - expect { visit "/admin/podcasts" }.to raise_error(Pundit::NotAuthorizedError) + expect { visit "/resource_admin" }.to raise_error(Pundit::NotAuthorizedError) + expect { visit "/resource_admin/podcasts" }.to raise_error(Pundit::NotAuthorizedError) end end