Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • A administrate
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 96
    • Issues 96
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 32
    • Merge requests 32
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • thoughtbot, inc.
  • administrate
  • Merge requests
  • !1298

Allow controllers without a related model

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Administrator requested to merge frm/custom-dashboard into master Feb 26, 2019
  • Overview 29
  • Commits 3
  • Pipelines 0
  • Changes 14

Created by: frm

  • Fixes #481 (closed) and #507 (closed)
  • Possibly replaces #514. This fix assumes the controller will use the administrate layout and stylings. A complete replacement would be to implement route blacklisting.

Why:

  • Currently administrate assumes there is a model for routes within the admin namespace. The navigation partial and application helper use the associated model to get the resource name.
  • The workaround for this is overriding the navigation partial to blacklist certain routes from appearing.
  • This workaround means users need to use custom styling and don’t get the default administrate layout styling.
  • A consequence of the navigation partial is that administrate assumes there is an index route, since it tries to place all the resources in the navigation sidebar. It might not be necessarily true that an administrated model might have an index route.
  • A proposed solution might be the one suggested by @archonic in https://github.com/thoughtbot/administrate/issues/507#issuecomment-311232431

This change addresses the need by:

  • Changing the namespace to return only routes with the index route (including custom controllers)
  • Updating the navigation partial and application helper to get the resource name from the dashboard.
  • Adding Administrate::CustomDashboard with defaults for the resource name. Users can now add custom controllers without related models:
# app/dashboards/stat_dashboard.rb

require "administrate/custom_dashboard"

class StatDashboard < Administrate::CustomDashboard
  resource "Stats"
end
# config/router.rb

namespace :admin do
  # ...
  resources :stats, only: [:index]
end
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: frm/custom-dashboard