* feat: make the sidebar more dynamic * refactor: use the action in the same controller instead of the whole path * feat: remove hardcoded routes * feat: move routes into file * feat: use rails 6 draw for the admin routes * add a helper method * oops: fix super * feat: add the hacky helper methods :( ) * WIP: created different path helpers for the new routes and point the old helpers to the new ones if the FF is toggled * feat: update the module * chore: add new paths * feat: change link_to's use paths instead * feat: feedback_messages to scoped admin route * chore: update the feature flag urls helpers * feat: feedback_messages issue * chore: remove all the workarounds * chore: rubucop * fix: oops remove helper * chore: comment out the tests that touch the tabbed navbar which is affected by the rails application needing to be reloaded * feat: ensure that we chcek if the db table exists
49 lines
1.5 KiB
Ruby
49 lines
1.5 KiB
Ruby
module Admin
|
|
class NavigationLinksController < Admin::ApplicationController
|
|
after_action :bust_content_change_caches, only: %i[create update destroy]
|
|
ALLOWED_PARAMS = %i[
|
|
name url icon display_only_when_signed_in position
|
|
].freeze
|
|
layout "admin"
|
|
|
|
def index
|
|
@navigation_links = NavigationLink.ordered
|
|
end
|
|
|
|
def create
|
|
navigation_link = NavigationLink.new(navigation_link_params)
|
|
if navigation_link.save
|
|
flash[:success] = "Successfully created navigation link: #{navigation_link.name}"
|
|
else
|
|
flash[:error] = "Error: #{navigation_link.errors_as_sentence}"
|
|
end
|
|
redirect_to admin_navigation_links_path
|
|
end
|
|
|
|
def update
|
|
navigation_link = NavigationLink.find(params[:id])
|
|
if navigation_link.update(navigation_link_params)
|
|
flash[:success] = "Successfully updated navigation link: #{navigation_link.name}"
|
|
else
|
|
flash[:error] = "Error: #{navigation_link.errors_as_sentence}"
|
|
end
|
|
redirect_to admin_navigation_links_path
|
|
end
|
|
|
|
def destroy
|
|
navigation_link = NavigationLink.find(params[:id])
|
|
if navigation_link.destroy
|
|
flash[:success] = "Navigation Link #{navigation_link.name} deleted"
|
|
else
|
|
flash[:error] = "Error: #{navigation_link.errors_as_sentence}"
|
|
end
|
|
redirect_to admin_navigation_links_path
|
|
end
|
|
|
|
private
|
|
|
|
def navigation_link_params
|
|
params.require(:navigation_link).permit(ALLOWED_PARAMS)
|
|
end
|
|
end
|
|
end
|