Solidus: Admin sidebar tab routes are breaking in custom admin pages

Created on 3 Feb 2017  路  2Comments  路  Source: solidusio/solidus

Steps to reproduce

Create an app, in the routes namespace the solidus engine e.g.

mount Spree::Core::Engine, :at => '/solidus'

Then generate a new controller (inheriting) and action for a new admin page:

rails g controller spree/admin/mything index

This should inherit admin capabilities:

class Spree::Admin::ModelsController < Spree::Admin::BaseController

Add a route for it, then a tab item for it in the config e.g.

config.menu_items << config.class::MenuItem.new([:models], 'icon-name', url: '/admin/models')

Navigate to the new route, then try clicking on the other tabs. You'll see these routes are no longer namespaced by /solidus and will break.

Expected behavior

The other tab items should have namespaced routes like /solidus/admin/products.

Actual behavior

The other tab items aren't namespaced so the result is: /admin/products.

System configuration

Solidus 2.0.0

Possible cause

I think this is down to the way the tab items are set as fixed URLs in:
backend_configuration.rb ?

Challenge SolidusConf Hack Day

Most helpful comment

I was unable to reproduce this bug.

I made everything work by adding the code like so:

config/routes.rb:
```Rails.application.routes.draw do
mount Spree::Core::Engine, :at => '/solidus'

Spree::Core::Engine.routes.draw do
namespace :admin do
get 'models/index'
end
end
end

`spree/admin/models_controller.rb`:

class Spree::Admin::ModelsController < Spree::Admin::BaseController
def index
end
end

Configuration for the additional menu item:

config.menu_items << config.class::MenuItem.new([:models], 'icon-name', url: :admin_models_index_path)
```

And everything pretty much worked like expected. @digitalWestie could you try this configuration and see if you still get the unexpected behavior?

All 2 comments

I was unable to reproduce this bug.

I made everything work by adding the code like so:

config/routes.rb:
```Rails.application.routes.draw do
mount Spree::Core::Engine, :at => '/solidus'

Spree::Core::Engine.routes.draw do
namespace :admin do
get 'models/index'
end
end
end

`spree/admin/models_controller.rb`:

class Spree::Admin::ModelsController < Spree::Admin::BaseController
def index
end
end

Configuration for the additional menu item:

config.menu_items << config.class::MenuItem.new([:models], 'icon-name', url: :admin_models_index_path)
```

And everything pretty much worked like expected. @digitalWestie could you try this configuration and see if you still get the unexpected behavior?

Closing, the solution seems to be here and there has not been any activity for a while.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vfonic picture vfonic  路  4Comments

mamhoff picture mamhoff  路  3Comments

cdrage picture cdrage  路  3Comments

merlielmag picture merlielmag  路  3Comments

ericsaupe picture ericsaupe  路  4Comments