How to customize

While Uchi comes with a set of sensible defaults you’ll inevitably find the need to customize things to fit your application.

The default navigation menu renders a sorted list of all the repositories included in Uchi. If you want more control over how this is done, you have a few options:

  1. Override the component
  2. Add your own navigation partial

Override the component

The navigation is generated by a View Component called Uchi::Ui::Navigation. If you add a component with that name in your application (probably at app/components/uchi/ui/navigation.rb) you can customize how your main navigation menu is rendered:

module Uchi
  module Ui
    class Navigation < ViewComponent::Base
      def call
        "This is my navigation"
      end
    end
  end
end

See ViewComponent docs for more details.

Your own navigation partial

If you want even more control over the navigation menu, including being able to remove it entirely, you can add a partial in your application at app/views/uchi/navigation/_main.html.erb.

Creating your own navigation partial gives you full control over the navigation menu, including the nav element that wraps the navigation area, allowing you to remove the menu entirely by rendering an empty partial.

The default partial also renders the global search link (Uchi::Ui::Navigation::SearchLink) and the menu for small viewports. Your partial replaces all of it, so copy the default partial as a starting point if you want to keep those.

Routes

Uchi automatically adds routes for each repository and uses the first repository, sorted alphabetically by class name, as the root route (ie what you’ll get at /uchi).

Mounting at a Custom Path

By default, Uchi is mounted at /uchi. To use a different path:

Rails.application.routes.draw do
  Uchi.routes.mount(self, at: "admin")

  namespace :admin do
    # Your other admin routes
  end
end

Now Uchi will be available at /admin instead of /uchi.

Note

When changing the default mount point you need to update your controllers to use the custom namespace as well. i.e. if Uchi is mounted at /admin, your repository controllers need to live in an Admin namespace (class Admin::UsersController), not Uchi (class Uchi::UsersController). A path with multiple segments maps to nested namespaces, ie at: "admin/uchi" requires Admin::Uchi::UsersController.

Inside a nested Uchi module, Uchi::RepositoryController resolves to the nested module. Reference the base class as ::Uchi::RepositoryController:

module Admin
  module Uchi
    class UsersController < ::Uchi::RepositoryController
    end
  end
end

How to change the root URL

If you want the root URL (i.e. /uchi) to go to another repository than the default, pass a block to mount and draw the route yourself:

# config/routes.rb
Rails.application.routes.draw do
  Uchi.routes.mount(self) do
    root to: "projects#index"
  end
end