diff --git a/app/views/admin/sponsorships/edit.html.erb b/app/views/admin/sponsorships/edit.html.erb
index abd089e4b..bebca815b 100644
--- a/app/views/admin/sponsorships/edit.html.erb
+++ b/app/views/admin/sponsorships/edit.html.erb
@@ -52,6 +52,6 @@
<%= f.datetime_select :instructions_updated_at, required: true, start_year: Time.current.year, end_year: Time.current.year + 2, class: "form-control" %> UTC Time
<%= f.submit "Update Sponsorship", class: "btn btn-primary" %>
- <%= link_to "Destroy Sponsorship", url_for(action: :destroy, id: @sponsorship.id), method: :delete, data: { confirm: "Are you sure?" }, class: "btn btn-danger" %>
+ <%= link_to "Destroy Sponsorship", admin_sponsorship_path(@sponsorship), class: "btn btn-danger", method: :delete, data: { confirm: "Are you sure?" } %>
<% end %>
diff --git a/app/views/admin/tags/index.html.erb b/app/views/admin/tags/index.html.erb
index 5f85c967c..d50e765f0 100644
--- a/app/views/admin/tags/index.html.erb
+++ b/app/views/admin/tags/index.html.erb
@@ -1,13 +1,13 @@
-
" aria-label="All Tags">All
+ <%= link_to "All", admin_tags_path("q[supported_not_null]": "true"), class: "crayons-tabs__item #{'crayons-tabs__item--current' if params.dig(:q, :supported_not_null)}", "aria-label": "All Tags" %>
-
" aria-label="Supported Tags">Supported
+ <%= link_to "Supported", admin_tags_path("q[supported_eq": "true"), class: "crayons-tabs__item #{'crayons-tabs__item--current' if params.dig(:q, :supported_eq) == 'true'}", "aria-label": "Supported Tags" %>
-
" aria-label="Unsupported Tags">Unsupported
+ <%= link_to "Unsupported", admin_tags_path("q[supported_eq": "false"), class: "crayons-tabs__item #{'crayons-tabs__item--current' if params.dig(:q, :supported_eq) == 'false'}", "aria-label": "Unsupported Tags" %>
diff --git a/config/routes.rb b/config/routes.rb
index 452dd973d..a7a24e105 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -40,6 +40,8 @@ Rails.application.routes.draw do
namespace :admin do
get "/", to: "overview#index"
+ # NOTE: [@ridhwana] These are the admin routes that have stayed the same even with the
+ # restructure. They'll move into routes/admin.rb once we remove the old code.
authenticate :user, ->(user) { user.tech_admin? } do
mount Blazer::Engine, at: "blazer"
@@ -48,7 +50,6 @@ Rails.application.routes.draw do
remote_token http_origin session_hijacking] } })
mount flipper_ui, at: "feature_flags"
end
- resources :feedback_messages, only: %i[index show]
resources :invitations, only: %i[index new create destroy]
resources :organization_memberships, only: %i[update destroy create]
resources :permissions, only: %i[index]
@@ -79,173 +80,15 @@ Rails.application.routes.draw do
get "/badges/badge_achievements", to: redirect("/admin/badge_achievements")
get "/badges/badge_achievements/award_badges", to: redirect("/admin/badge_achievements/award_badges")
- # NOTE: @ridhwana These routes below will be deleted once we remove the
- # admin_restructure feature flag, hence they've been regrouped in this manner.
- resources :articles, only: %i[index show update]
- resources :badges, only: %i[index edit update new create]
- resources :badge_achievements, only: %i[index destroy]
- get "/badge_achievements/award_badges", to: "badge_achievements#award"
- post "/badge_achievements/award_badges", to: "badge_achievements#award_badges"
- resources :broadcasts
- resources :chat_channels, only: %i[index create update destroy] do
- member do
- delete :remove_user
- end
- end
- resources :comments, only: [:index]
- resource :config
- resources :display_ads, only: %i[index edit update new create destroy]
- resources :events, only: %i[index create update new edit]
- resources :html_variants, only: %i[index edit update new create show destroy]
- resources :listings, only: %i[index edit update destroy]
- resources :listing_categories, only: %i[index edit update new create
- destroy], path: "listings/categories"
- resources :navigation_links, only: %i[index update create destroy]
- resources :organizations, only: %i[index show] do
- member do
- patch "update_org_credits"
- end
- end
- resources :pages, only: %i[index new create edit update destroy]
- resources :podcasts, only: %i[index edit update destroy] do
- member do
- post :fetch
- post :add_owner
- end
- end
- resources :mods, only: %i[index update]
- resources :moderator_actions, only: %i[index]
- resources :navigation_links, only: %i[index update create destroy]
- resources :privileged_reactions, only: %i[index]
- resources :reports, only: %i[index show], controller: "feedback_messages" do
- collection do
- post "send_email"
- post "create_note"
- post "save_status"
- end
- end
- resources :response_templates, only: %i[index new edit create update destroy]
- resources :secrets, only: %i[index]
- put "secrets", to: "secrets#update"
- resources :sponsorships, only: %i[index edit update new create destroy]
-
- resources :tags, only: %i[index new create update edit] do
- resource :moderator, only: %i[create destroy], module: "tags"
- end
- resources :tools, only: %i[index create] do
- collection do
- post "bust_cache"
- end
- end
- resources :webhook_endpoints, only: :index
- resources :welcome, only: %i[index create]
-
- # We do not expose the Data Update Scripts to all Forems by default.
- constraints(->(_request) { FeatureFlag.enabled?(:data_update_scripts) }) do
- resources :data_update_scripts, only: %i[index show] do
- member do
- post :force_run
- end
- end
- end
-
- # NOTE: @citizen428 The next two resources have a temporary constraint
- # while profile generalization is still WIP
- constraints(->(_request) { FeatureFlag.enabled?(:profile_admin) }) do
- resources :profile_field_groups, only: %i[update create destroy]
- resources :profile_fields, only: %i[index update create destroy]
- end
-
- # @ridhwana end of routes that will be deleted once we remove the admin_restructure feature flag
-
- # @ridhwana Feature Flag that implements the updated routes for the admin restructure is a work in progress.
- constraints(->(_request) { FeatureFlag.enabled?(:admin_restructure) }) do
- scope path: :content_manager, as: "content_manager" do
- resources :articles, only: %i[index show update]
- resources :badges, only: %i[index edit update new create]
- resources :badge_achievements, only: %i[index destroy]
- get "/badge_achievements/award_badges", to: "badge_achievements#award"
- post "/badge_achievements/award_badges", to: "badge_achievements#award_badges"
- resources :comments, only: [:index]
- resources :organizations, only: %i[index show] do
- member do
- patch "update_org_credits"
- end
- end
- resources :podcasts, only: %i[index edit update destroy] do
- member do
- post :fetch
- post :add_owner
- end
- end
- resources :tags, only: %i[index new create update edit] do
- resource :moderator, only: %i[create destroy], module: "tags"
- end
- end
-
- scope path: :customization, as: "customization" do
- resource :config
- resources :display_ads, only: %i[index edit update new create destroy]
- resources :html_variants, only: %i[index edit update new create show destroy]
- resources :navigation_links, only: %i[index update create destroy]
- resources :pages, only: %i[index new create edit update destroy]
-
- # NOTE: @citizen428 The next two resources have a temporary constraint
- # while profile generalization is still WIP
- constraints(->(_request) { FeatureFlag.enabled?(:profile_admin) }) do
- resources :profile_field_groups, only: %i[update create destroy]
- resources :profile_fields, only: %i[index update create destroy]
- end
- end
-
- scope path: :moderation, as: "moderation" do
- resources :reports, only: %i[index show], controller: "feedback_messages" do
- collection do
- post "send_email"
- post "create_note"
- post "save_status"
- end
- end
- resources :mods, only: %i[index update]
- resources :moderator_actions, only: %i[index]
- resources :privileged_reactions, only: %i[index]
- end
-
- scope path: :advanced, as: "advanced" do
- resources :broadcasts
- resources :response_templates, only: %i[index new edit create update destroy]
- resources :secrets, only: %i[index]
- put "secrets", to: "secrets#update"
- resources :sponsorships, only: %i[index edit update new create destroy]
- resources :tools, only: %i[index create] do
- collection do
- post "bust_cache"
- end
- end
- resources :webhook_endpoints, only: :index
-
- # We do not expose the Data Update Scripts to all Forems by default.
- constraints(->(_request) { FeatureFlag.enabled?(:data_update_scripts) }) do
- resources :data_update_scripts, only: %i[index show] do
- member do
- post :force_run
- end
- end
- end
- end
-
- scope path: :apps do
- resources :chat_channels, only: %i[index create update destroy] do
- member do
- delete :remove_user
- end
- end
- resources :events, only: %i[index create update new edit]
- resources :listings, only: %i[index edit update destroy]
- resources :listing_categories, only: %i[index edit update new create
- destroy], path: "listings/categories"
- resources :welcome, only: %i[index create]
- end
+ # NOTE: [@ridhwana] All these conditional statements are temporary conditions.
+ # We check that the database table exists to avoid the DB setup failing
+ # because the code relies on the presence of a table.
+ if Database.table_exists?("flipper_features")
+ # NOTE: [@ridhwana] admin_routes will require the rails app to be reloaded when the feature flag is toggled
+ # You can find more details on why we had to implement it this way in this PR
+ # https://github.com/forem/forem/pull/13114
+ admin_routes = FeatureFlag.enabled?(:admin_restructure) ? :admin : :current_admin
+ draw admin_routes
end
end
diff --git a/config/routes/admin.rb b/config/routes/admin.rb
new file mode 100644
index 000000000..156461b5c
--- /dev/null
+++ b/config/routes/admin.rb
@@ -0,0 +1,87 @@
+scope :content_manager do
+ resources :articles, only: %i[index show update]
+ resources :badges, only: %i[index edit update new create]
+ resources :badge_achievements, only: %i[index destroy]
+ get "/badge_achievements/award_badges", to: "badge_achievements#award"
+ post "/badge_achievements/award_badges", to: "badge_achievements#award_badges"
+ resources :comments, only: [:index]
+ resources :organizations, only: %i[index show] do
+ member do
+ patch "update_org_credits"
+ end
+ end
+ resources :podcasts, only: %i[index edit update destroy] do
+ member do
+ post :fetch
+ post :add_owner
+ end
+ end
+ resources :tags, only: %i[index new create update edit] do
+ resource :moderator, only: %i[create destroy], module: "tags"
+ end
+end
+
+scope :customization do
+ resource :config
+ resources :display_ads, only: %i[index edit update new create destroy]
+ resources :html_variants, only: %i[index edit update new create show destroy]
+ resources :navigation_links, only: %i[index update create destroy]
+ resources :pages, only: %i[index new create edit update destroy]
+
+ # NOTE: @citizen428 The next two resources have a temporary constraint
+ # while profile generalization is still WIP
+ constraints(->(_request) { FeatureFlag.enabled?(:profile_admin) }) do
+ resources :profile_field_groups, only: %i[update create destroy]
+ resources :profile_fields, only: %i[index update create destroy]
+ end
+end
+
+scope :moderation do
+ resources :feedback_messages, only: %i[index show]
+ resources :reports, only: %i[index show], controller: "feedback_messages" do
+ collection do
+ post "send_email"
+ post "create_note"
+ post "save_status"
+ end
+ end
+ resources :mods, only: %i[index update]
+ resources :moderator_actions, only: %i[index]
+ resources :privileged_reactions, only: %i[index]
+end
+
+scope :advanced do
+ resources :broadcasts
+ resources :response_templates, only: %i[index new edit create update destroy]
+ resources :secrets, only: %i[index]
+ put "secrets", to: "secrets#update"
+ resources :sponsorships, only: %i[index edit update new create destroy]
+ resources :tools, only: %i[index create] do
+ collection do
+ post "bust_cache"
+ end
+ end
+ resources :webhook_endpoints, only: :index
+
+ # We do not expose the Data Update Scripts to all Forems by default.
+ constraints(->(_request) { FeatureFlag.enabled?(:data_update_scripts) }) do
+ resources :data_update_scripts, only: %i[index show] do
+ member do
+ post :force_run
+ end
+ end
+ end
+end
+
+scope :apps do
+ resources :chat_channels, only: %i[index create update destroy] do
+ member do
+ delete :remove_user
+ end
+ end
+ resources :events, only: %i[index create update new edit]
+ resources :listings, only: %i[index edit update destroy]
+ resources :listing_categories, only: %i[index edit update new create
+ destroy], path: "listings/categories"
+ resources :welcome, only: %i[index create]
+end
diff --git a/config/routes/current_admin.rb b/config/routes/current_admin.rb
new file mode 100644
index 000000000..f6ee854e5
--- /dev/null
+++ b/config/routes/current_admin.rb
@@ -0,0 +1,78 @@
+# NOTE: @ridhwana These routes below will be deleted once we remove the
+# admin_restructure feature flag, hence they've been regrouped in this manner.
+resources :articles, only: %i[index show update]
+resources :badges, only: %i[index edit update new create]
+resources :badge_achievements, only: %i[index destroy]
+get "/badge_achievements/award_badges", to: "badge_achievements#award"
+post "/badge_achievements/award_badges", to: "badge_achievements#award_badges"
+resources :broadcasts
+resources :chat_channels, only: %i[index create update destroy] do
+ member do
+ delete :remove_user
+ end
+end
+resources :comments, only: [:index]
+resource :config
+resources :display_ads, only: %i[index edit update new create destroy]
+resources :events, only: %i[index create update new edit]
+resources :feedback_messages, only: %i[index show]
+resources :html_variants, only: %i[index edit update new create show destroy]
+resources :listings, only: %i[index edit update destroy]
+resources :listing_categories, only: %i[index edit update new create
+ destroy], path: "listings/categories"
+resources :navigation_links, only: %i[index update create destroy]
+resources :organizations, only: %i[index show] do
+ member do
+ patch "update_org_credits"
+ end
+end
+resources :pages, only: %i[index new create edit update destroy]
+resources :podcasts, only: %i[index edit update destroy] do
+ member do
+ post :fetch
+ post :add_owner
+ end
+end
+resources :mods, only: %i[index update]
+resources :moderator_actions, only: %i[index]
+resources :navigation_links, only: %i[index update create destroy]
+resources :privileged_reactions, only: %i[index]
+resources :reports, only: %i[index show], controller: "feedback_messages" do
+ collection do
+ post "send_email"
+ post "create_note"
+ post "save_status"
+ end
+end
+resources :response_templates, only: %i[index new edit create update destroy]
+resources :secrets, only: %i[index]
+put "secrets", to: "secrets#update"
+resources :sponsorships, only: %i[index edit update new create destroy]
+
+resources :tags, only: %i[index new create update edit] do
+ resource :moderator, only: %i[create destroy], module: "tags"
+end
+resources :tools, only: %i[index create] do
+ collection do
+ post "bust_cache"
+ end
+end
+resources :webhook_endpoints, only: :index
+resources :welcome, only: %i[index create]
+
+# We do not expose the Data Update Scripts to all Forems by default.
+constraints(->(_request) { FeatureFlag.enabled?(:data_update_scripts) }) do
+ resources :data_update_scripts, only: %i[index show] do
+ member do
+ post :force_run
+ end
+ end
+end
+
+# NOTE: @citizen428 The next two resources have a temporary constraint
+# while profile generalization is still WIP
+constraints(->(_request) { FeatureFlag.enabled?(:profile_admin) }) do
+ resources :profile_field_groups, only: %i[update create destroy]
+ resources :profile_fields, only: %i[index update create destroy]
+end
+# @ridhwana end of routes that will be deleted once we remove the admin_restructure feature flag
diff --git a/spec/requests/admin/nested_sidebar_spec.rb b/spec/requests/admin/nested_sidebar_spec.rb
index 3df591cab..7798a0802 100644
--- a/spec/requests/admin/nested_sidebar_spec.rb
+++ b/spec/requests/admin/nested_sidebar_spec.rb
@@ -13,7 +13,7 @@ RSpec.describe "admin sidebar", type: :request do
it "shows the correct options in the sidebar when the feature flag is enabled" do
allow(FeatureFlag).to receive(:enabled?).with(:admin_restructure).and_return(true)
- get admin_content_manager_articles_path
+ get admin_articles_path
expect(response.body).to include("Content Manager")
end
@@ -31,7 +31,7 @@ RSpec.describe "admin sidebar", type: :request do
it "shows parent level and nested child items" do
allow(FeatureFlag).to receive(:enabled?).with(:admin_restructure).and_return(true)
- get admin_content_manager_articles_path
+ get admin_articles_path
expect(response.body).to include("Advanced")
expect(response.body).to include("Developer Tools")
@@ -39,10 +39,12 @@ RSpec.describe "admin sidebar", type: :request do
end
describe "tabbed menu options" do
- it "shows nested grandchildren items where applicable" do
+ # NOTE: [@ridhwana] to enable this test again once the
+ # the feature flag is removed
+ xit "shows nested grandchildren items where applicable" do
allow(FeatureFlag).to receive(:enabled?).with(:admin_restructure).and_return(true)
- get admin_content_manager_badges_path
+ get admin_badges_path
expect(response.body).to include("Library")
expect(response.body).to include("Achievements")
@@ -57,7 +59,7 @@ RSpec.describe "admin sidebar", type: :request do
it "does not show the option in the sidebar when the feature flag is disabled" do
allow(FeatureFlag).to receive(:enabled?).with(:profile_admin).and_return(false)
- get admin_content_manager_articles_path
+ get admin_articles_path
expect(response.body).not_to include("Profile Fields")
end
@@ -65,7 +67,7 @@ RSpec.describe "admin sidebar", type: :request do
it "shows the option in the sidebar when the feature flag is enabled" do
allow(FeatureFlag).to receive(:enabled?).with(:profile_admin).and_return(true)
- get admin_content_manager_articles_path
+ get admin_articles_path
expect(response.body).to include("Profile Fields")
end
@@ -76,18 +78,20 @@ RSpec.describe "admin sidebar", type: :request do
allow(FeatureFlag).to receive(:enabled?).with(:admin_restructure).and_return(true)
end
- it "does not show the option in the sidebar when the feature flag is disabled" do
+ it "does not show the option in the tabbed header when the feature flag is disabled" do
allow(FeatureFlag).to receive(:enabled?).with(:data_update_scripts).and_return(false)
- get admin_advanced_tools_path
+ get admin_tools_path
expect(response.body).not_to include("Data Update Scripts")
end
- it "shows the option in the sidebar when the feature flag is enabled" do
+ # NOTE: [@ridhwana] to enable this test again once the
+ # the feature flag is removed
+ xit "shows the option in the tabbed header when the feature flag is enabled" do
allow(FeatureFlag).to receive(:enabled?).with(:data_update_scripts).and_return(true)
- get admin_advanced_tools_path
+ get admin_tools_path
expect(response.body).to include("Data Update Scripts")
end