active_admin_sidebar 2.0.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +91 -0
- data/.gitignore +6 -0
- data/Gemfile +12 -10
- data/README.md +59 -42
- data/Rakefile +0 -2
- data/active_admin_sidebar.gemspec +4 -3
- data/app/assets/javascripts/active_admin_sidebar.js +11 -11
- data/app/assets/stylesheets/active_admin_sidebar.scss +84 -28
- data/lib/active_admin_sidebar/activeadmin_views_pages_base.rb +9 -1
- data/lib/active_admin_sidebar/positions.rb +44 -14
- data/lib/active_admin_sidebar/version.rb +1 -1
- data/package.json +30 -0
- data/spec/sidebars_spec.rb +150 -15
- data/spec/spec_helper.rb +7 -7
- data/spec/support/admin.rb +52 -0
- data/spec/support/capybara.rb +6 -11
- data/spec/support/rails_template.rb +34 -28
- data/tasks/test.rake +0 -2
- metadata +18 -15
- data/.travis.yml +0 -23
- data/app/assets/stylesheets/active_admin_sidebar_pure_icons.scss +0 -66
- data/screen/sidebar.jpg +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 82c0aca50de9f10d89ff4757070bf989f62a3fed5c1e4dd4e63a54f1b5878245
|
|
4
|
+
data.tar.gz: d1c85dc11a5224392b5002538cfa449e15e76e35e627a6bf62be6d201e6b4898
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fe932df9e8af97da1c0cab3b1feadb3849c079d039e0df5a9d64a5d5f3aec939244c5800c7d1a03f005808fbb92870b8b0af19230a026afec954ec2f1f23bc98
|
|
7
|
+
data.tar.gz: 0c4c3b4b7cfac89a9e9a9a4d3de42b1f01213f293d206cca5d265ff4c61ce700fc9b15b578d158c4b239d79625cc55b93a13e5ae32c1bca932d30f7bea807ccb
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
on:
|
|
3
|
+
pull_request:
|
|
4
|
+
push:
|
|
5
|
+
branches: [master]
|
|
6
|
+
|
|
7
|
+
permissions:
|
|
8
|
+
contents: read
|
|
9
|
+
pages: write
|
|
10
|
+
id-token: write
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
test:
|
|
14
|
+
name: Ruby ${{ matrix.ruby }} / Rails ${{ matrix.rails }} / AA ${{ matrix.activeadmin }}
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
strategy:
|
|
17
|
+
fail-fast: false
|
|
18
|
+
matrix:
|
|
19
|
+
ruby: ['3.2', '3.3', '3.4']
|
|
20
|
+
rails: ['7.1.0', '7.2.0', '8.0.0']
|
|
21
|
+
activeadmin: ['3.2.0', '3.3.0', '3.4.0', '3.5.0']
|
|
22
|
+
exclude:
|
|
23
|
+
- rails: '8.0.0'
|
|
24
|
+
activeadmin: '3.2.0'
|
|
25
|
+
env:
|
|
26
|
+
RAILS: ${{ matrix.rails }}
|
|
27
|
+
AA: ${{ matrix.activeadmin }}
|
|
28
|
+
steps:
|
|
29
|
+
- uses: actions/checkout@v4
|
|
30
|
+
- uses: ruby/setup-ruby@v1
|
|
31
|
+
with:
|
|
32
|
+
ruby-version: ${{ matrix.ruby }}
|
|
33
|
+
bundler-cache: true
|
|
34
|
+
- name: Run tests
|
|
35
|
+
run: bundle exec rspec spec
|
|
36
|
+
|
|
37
|
+
- name: Generate badge.json
|
|
38
|
+
if: matrix.ruby == '3.4' && matrix.rails == '8.0.0' && matrix.activeadmin == '3.5.0'
|
|
39
|
+
run: |
|
|
40
|
+
LAST_RUN="coverage/.last_run.json"
|
|
41
|
+
if [ ! -f "$LAST_RUN" ]; then
|
|
42
|
+
mkdir -p badge
|
|
43
|
+
echo '{"schemaVersion":1,"label":"coverage","message":"unknown","color":"lightgrey"}' > badge/badge.json
|
|
44
|
+
exit 0
|
|
45
|
+
fi
|
|
46
|
+
PERCENT=$(ruby -rjson -e "puts JSON.parse(File.read('$LAST_RUN')).dig('result','line').round(1)")
|
|
47
|
+
PERCENT_NUM=$(ruby -rjson -e "puts JSON.parse(File.read('$LAST_RUN')).dig('result','line')")
|
|
48
|
+
if ruby -e "exit(($PERCENT_NUM >= 90) ? 0 : 1)"; then COLOR="brightgreen"
|
|
49
|
+
elif ruby -e "exit(($PERCENT_NUM >= 75) ? 0 : 1)"; then COLOR="green"
|
|
50
|
+
elif ruby -e "exit(($PERCENT_NUM >= 60) ? 0 : 1)"; then COLOR="yellow"
|
|
51
|
+
else COLOR="red"; fi
|
|
52
|
+
mkdir -p badge
|
|
53
|
+
echo "{\"schemaVersion\":1,\"label\":\"coverage\",\"message\":\"${PERCENT}%\",\"color\":\"${COLOR}\"}" > badge/badge.json
|
|
54
|
+
|
|
55
|
+
- name: Upload badge artifact
|
|
56
|
+
if: matrix.ruby == '3.4' && matrix.rails == '8.0.0' && matrix.activeadmin == '3.5.0'
|
|
57
|
+
uses: actions/upload-artifact@v4
|
|
58
|
+
with:
|
|
59
|
+
name: coverage-badge
|
|
60
|
+
path: badge
|
|
61
|
+
|
|
62
|
+
deploy-coverage:
|
|
63
|
+
needs: test
|
|
64
|
+
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
|
|
65
|
+
runs-on: ubuntu-latest
|
|
66
|
+
environment:
|
|
67
|
+
name: github-pages
|
|
68
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
|
69
|
+
|
|
70
|
+
steps:
|
|
71
|
+
- uses: actions/checkout@v4
|
|
72
|
+
with:
|
|
73
|
+
ref: gh-pages
|
|
74
|
+
|
|
75
|
+
- name: Download coverage badge
|
|
76
|
+
uses: actions/download-artifact@v4
|
|
77
|
+
with:
|
|
78
|
+
name: coverage-badge
|
|
79
|
+
path: .
|
|
80
|
+
|
|
81
|
+
- name: Setup Pages
|
|
82
|
+
uses: actions/configure-pages@v5
|
|
83
|
+
|
|
84
|
+
- name: Upload Pages artifact
|
|
85
|
+
uses: actions/upload-pages-artifact@v3
|
|
86
|
+
with:
|
|
87
|
+
path: .
|
|
88
|
+
|
|
89
|
+
- name: Deploy to GitHub Pages
|
|
90
|
+
id: deployment
|
|
91
|
+
uses: actions/deploy-pages@v4
|
data/.gitignore
ADDED
data/Gemfile
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
source 'https://rubygems.org'
|
|
2
|
-
|
|
3
|
-
# Specify your gem's dependencies in activeadmin_scoped_collection_actions.gemspec
|
|
4
2
|
gemspec
|
|
5
3
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
gem 'activeadmin', "~> #{ENV['AA'] || '1.3.1'}"
|
|
4
|
+
default_rails_version = '7.1.0'
|
|
5
|
+
default_activeadmin_version = '3.2.0'
|
|
9
6
|
|
|
7
|
+
gem 'rails', "~> #{ENV['RAILS'] || default_rails_version}"
|
|
8
|
+
gem 'activeadmin', "~> #{ENV['AA'] || default_activeadmin_version}"
|
|
9
|
+
gem 'sprockets-rails'
|
|
10
|
+
gem 'sass-rails'
|
|
11
|
+
|
|
12
|
+
group :test do
|
|
13
|
+
gem 'simplecov', require: false
|
|
10
14
|
gem 'rspec-rails'
|
|
11
|
-
gem 'sqlite3'
|
|
15
|
+
gem 'sqlite3', '~> 2.0'
|
|
12
16
|
gem 'database_cleaner'
|
|
13
17
|
gem 'capybara'
|
|
14
|
-
gem '
|
|
15
|
-
gem '
|
|
16
|
-
gem 'byebug'
|
|
17
|
-
gem 'sassc-rails'
|
|
18
|
+
gem 'cuprite'
|
|
19
|
+
gem 'webrick', require: false
|
|
18
20
|
end
|
data/README.md
CHANGED
|
@@ -1,81 +1,98 @@
|
|
|
1
|
+
[](https://badge.fury.io/rb/active_admin_sidebar)
|
|
2
|
+
[](https://badge.fury.io/js/@activeadmin-plugins%2Factive_admin_sidebar)
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+
|
|
1
6
|
# ActiveAdmin Sidebar
|
|
2
7
|
|
|
3
|
-
|
|
8
|
+
Manipulate sidebar position and add collapsible sidebar support for ActiveAdmin 3.x.
|
|
4
9
|
|
|
5
10
|
## Install
|
|
6
11
|
|
|
7
|
-
Add
|
|
12
|
+
Add to your `Gemfile`:
|
|
8
13
|
|
|
9
14
|
```ruby
|
|
10
15
|
gem 'active_admin_sidebar'
|
|
11
16
|
```
|
|
12
17
|
|
|
13
|
-
|
|
18
|
+
### Using assets via Sprockets
|
|
19
|
+
|
|
20
|
+
Add to `app/assets/stylesheets/active_admin.scss`:
|
|
14
21
|
|
|
15
22
|
```scss
|
|
16
|
-
|
|
23
|
+
@import "active_admin_sidebar";
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Add to `app/assets/javascripts/active_admin.js`:
|
|
27
|
+
|
|
28
|
+
```javascript
|
|
29
|
+
//= require active_admin_sidebar
|
|
17
30
|
```
|
|
18
31
|
|
|
19
|
-
|
|
32
|
+
### Using assets via NPM
|
|
33
|
+
|
|
34
|
+
$ npm i @activeadmin-plugins/active_admin_sidebar
|
|
35
|
+
|
|
36
|
+
Or
|
|
37
|
+
|
|
38
|
+
$ yarn add @activeadmin-plugins/active_admin_sidebar
|
|
20
39
|
|
|
21
|
-
|
|
22
|
-
|
|
40
|
+
Add to `app/assets/javascripts/active_admin.js`:
|
|
41
|
+
|
|
42
|
+
```javascript
|
|
43
|
+
import '@activeadmin-plugins/active_admin_sidebar';
|
|
23
44
|
```
|
|
24
45
|
|
|
25
|
-
to
|
|
46
|
+
Add to `app/assets/stylesheets/active_admin.scss`:
|
|
47
|
+
|
|
48
|
+
```scss
|
|
49
|
+
@import '@activeadmin-plugins/active_admin_sidebar';
|
|
50
|
+
```
|
|
26
51
|
|
|
27
|
-
|
|
52
|
+
## Configuration per resource
|
|
28
53
|
|
|
29
|
-
|
|
54
|
+
Change sidebar position with `before_action`:
|
|
30
55
|
|
|
31
56
|
```ruby
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
57
|
+
# app/admin/posts.rb
|
|
58
|
+
ActiveAdmin.register Post do
|
|
59
|
+
before_action only: [:index] do
|
|
60
|
+
left_sidebar!
|
|
35
61
|
end
|
|
62
|
+
end
|
|
36
63
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
64
|
+
# app/admin/comments.rb
|
|
65
|
+
ActiveAdmin.register Comment do
|
|
66
|
+
before_action do
|
|
67
|
+
right_sidebar!
|
|
40
68
|
end
|
|
69
|
+
end
|
|
41
70
|
```
|
|
42
71
|
|
|
43
72
|
## Global configuration
|
|
44
73
|
|
|
45
|
-
|
|
74
|
+
Move sidebar to the left for all resources in `config/initializers/active_admin.rb`:
|
|
46
75
|
|
|
47
76
|
```ruby
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
ActiveAdmin.setup do |config|
|
|
52
|
-
config.before_action do
|
|
53
|
-
left_sidebar! if respond_to?(:left_sidebar!)
|
|
54
|
-
end
|
|
77
|
+
ActiveAdmin.setup do |config|
|
|
78
|
+
config.before_action do
|
|
79
|
+
left_sidebar! if respond_to?(:left_sidebar!)
|
|
55
80
|
end
|
|
81
|
+
end
|
|
56
82
|
```
|
|
57
83
|
|
|
58
|
-
##
|
|
84
|
+
## Collapsible sidebar
|
|
59
85
|
|
|
60
|
-
|
|
61
|
-
It will add "hide/show" button. Shown/Hidden state is persisted across all pages.
|
|
86
|
+
Add a toggle button to collapse/expand the sidebar. State is persisted per-resource across page navigations.
|
|
62
87
|
|
|
63
88
|
```ruby
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
You can override button color according to your color theme. For example:
|
|
89
|
+
# Collapsible sidebar (starts expanded)
|
|
90
|
+
left_sidebar!(collapsible: true)
|
|
91
|
+
right_sidebar!(collapsible: true)
|
|
68
92
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
.collapse_btn, .uncollapse_btn {
|
|
73
|
-
background-color: #767270;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
93
|
+
# Collapsible sidebar (starts collapsed)
|
|
94
|
+
left_sidebar!(collapsible: true, start_collapsed: true)
|
|
95
|
+
right_sidebar!(collapsible: true, start_collapsed: true)
|
|
77
96
|
```
|
|
78
97
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-

|
|
98
|
+

|
data/Rakefile
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
|
2
1
|
$:.push File.expand_path("../lib", __FILE__)
|
|
3
2
|
require "active_admin_sidebar/version"
|
|
4
3
|
|
|
@@ -7,15 +6,17 @@ Gem::Specification.new do |s|
|
|
|
7
6
|
s.version = ActiveAdminSidebar::VERSION
|
|
8
7
|
s.authors = ["Igor"]
|
|
9
8
|
s.email = ["fedoronchuk@gmail.com"]
|
|
10
|
-
s.homepage = "https://github.com/
|
|
9
|
+
s.homepage = "https://github.com/activeadmin-plugins/active_admin_sidebar"
|
|
11
10
|
s.summary = %q{active_admin_sidebar gem}
|
|
12
11
|
s.description = %q{extension for activeadmin gem to manage sidebar}
|
|
12
|
+
s.license = "MIT"
|
|
13
13
|
|
|
14
|
-
s.
|
|
14
|
+
s.required_ruby_version = '>= 3.1.0'
|
|
15
15
|
|
|
16
16
|
s.files = `git ls-files`.split("\n")
|
|
17
17
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
18
18
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
|
19
19
|
s.require_paths = ["lib"]
|
|
20
20
|
|
|
21
|
+
s.add_dependency "activeadmin", ">= 3.0", "< 4.0"
|
|
21
22
|
end
|
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
(function() {
|
|
2
2
|
$(document).ready(function() {
|
|
3
|
-
var $aa_content, set_collapsed_sidebar;
|
|
4
3
|
if ($('body').hasClass('index') && ($('#active_admin_content').hasClass('collapsible_sidebar'))) {
|
|
5
|
-
$aa_content = $('#active_admin_content');
|
|
6
|
-
$aa_content.find('
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
var $aa_content = $('#active_admin_content');
|
|
5
|
+
var $sidebar = $aa_content.find('#sidebar');
|
|
6
|
+
|
|
7
|
+
var $toggleBtn = $('<span class="sidebar_toggle_btn" title="Toggle sidebar"><span class="chevron"></span></span>');
|
|
8
|
+
$sidebar.prepend($toggleBtn);
|
|
9
|
+
|
|
10
|
+
var set_collapsed_sidebar = function(value) {
|
|
9
11
|
return $.getJSON(this.href, {
|
|
10
12
|
collapsed_sidebar: value
|
|
11
13
|
});
|
|
12
14
|
};
|
|
13
|
-
|
|
15
|
+
|
|
16
|
+
$toggleBtn.on('click', function(e) {
|
|
14
17
|
if (!$aa_content.hasClass('collapsed_sidebar')) {
|
|
15
18
|
set_collapsed_sidebar(true);
|
|
16
|
-
$aa_content.removeClass('left_sidebar');
|
|
17
19
|
$aa_content.addClass('collapsed_sidebar');
|
|
18
|
-
|
|
20
|
+
$aa_content.trigger('collapsible_sidebar:collapsed');
|
|
19
21
|
} else {
|
|
20
22
|
set_collapsed_sidebar(false);
|
|
21
23
|
$aa_content.removeClass('collapsed_sidebar');
|
|
22
|
-
$aa_content.
|
|
23
|
-
return $aa_content.trigger('collapsible_sidebar:uncollapsed');
|
|
24
|
+
$aa_content.trigger('collapsible_sidebar:uncollapsed');
|
|
24
25
|
}
|
|
25
26
|
});
|
|
26
27
|
}
|
|
27
28
|
});
|
|
28
|
-
|
|
29
29
|
}).call(this);
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
$toggle-btn-width: 12px;
|
|
2
|
+
$toggle-btn-height: 48px;
|
|
2
3
|
|
|
4
|
+
// === Left sidebar layout ===
|
|
5
|
+
// Moves sidebar before main content in the DOM, so we need to
|
|
6
|
+
// reverse the default AA float layout.
|
|
3
7
|
body.active_admin {
|
|
4
|
-
#active_admin_content.left_sidebar
|
|
8
|
+
#active_admin_content.left_sidebar {
|
|
5
9
|
#sidebar {
|
|
6
10
|
display: block;
|
|
7
11
|
margin-left: 0;
|
|
@@ -25,67 +29,119 @@ body.active_admin {
|
|
|
25
29
|
float: inherit;
|
|
26
30
|
margin-left: 298px;
|
|
27
31
|
width: auto;
|
|
32
|
+
|
|
28
33
|
#main_content {
|
|
29
34
|
float: inherit;
|
|
30
35
|
margin: 0;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
36
|
+
|
|
37
|
+
.tabs .comments .active_admin_comment {
|
|
38
|
+
clear: none;
|
|
35
39
|
}
|
|
36
40
|
}
|
|
37
|
-
|
|
38
41
|
}
|
|
39
42
|
|
|
40
43
|
.table_tools:after {
|
|
41
44
|
clear: none;
|
|
42
45
|
padding-bottom: 16px;
|
|
43
46
|
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
44
49
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
50
|
+
// === Collapsible sidebar: toggle button ===
|
|
51
|
+
body.active_admin #active_admin_content.collapsible_sidebar {
|
|
52
|
+
#sidebar {
|
|
53
|
+
position: relative;
|
|
54
|
+
}
|
|
51
55
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
+
.sidebar_toggle_btn {
|
|
57
|
+
width: $toggle-btn-width;
|
|
58
|
+
height: $toggle-btn-height;
|
|
59
|
+
background-color: #767270;
|
|
60
|
+
border-radius: 3px;
|
|
61
|
+
cursor: pointer;
|
|
62
|
+
z-index: 10;
|
|
63
|
+
position: absolute;
|
|
64
|
+
top: 12px;
|
|
65
|
+
display: flex;
|
|
66
|
+
align-items: center;
|
|
67
|
+
justify-content: center;
|
|
68
|
+
|
|
69
|
+
&:hover {
|
|
70
|
+
background-color: #5a5857;
|
|
56
71
|
}
|
|
57
72
|
|
|
58
|
-
.
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
73
|
+
.chevron {
|
|
74
|
+
width: 0;
|
|
75
|
+
height: 0;
|
|
76
|
+
border-top: 4px solid transparent;
|
|
77
|
+
border-bottom: 4px solid transparent;
|
|
62
78
|
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Left sidebar expanded: button on right edge, chevron points left (collapse)
|
|
82
|
+
&.left_sidebar .sidebar_toggle_btn {
|
|
83
|
+
right: -$toggle-btn-width;
|
|
84
|
+
.chevron { border-right: 5px solid #fff; border-left: none; }
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Left sidebar collapsed: chevron points right (expand)
|
|
88
|
+
&.left_sidebar.collapsed_sidebar .sidebar_toggle_btn {
|
|
89
|
+
.chevron { border-left: 5px solid #fff; border-right: none; }
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Right sidebar expanded: button on left edge, chevron points right (collapse)
|
|
93
|
+
&:not(.left_sidebar) .sidebar_toggle_btn {
|
|
94
|
+
left: -$toggle-btn-width;
|
|
95
|
+
.chevron { border-left: 5px solid #fff; border-right: none; }
|
|
96
|
+
}
|
|
63
97
|
|
|
98
|
+
// Right sidebar collapsed: chevron points left (expand)
|
|
99
|
+
&:not(.left_sidebar).collapsed_sidebar .sidebar_toggle_btn {
|
|
100
|
+
.chevron { border-right: 5px solid #fff; border-left: none; }
|
|
64
101
|
}
|
|
65
102
|
}
|
|
66
103
|
|
|
67
|
-
|
|
104
|
+
// === Collapsed state: left sidebar ===
|
|
105
|
+
body.active_admin #active_admin_content.collapsible_sidebar.collapsed_sidebar.left_sidebar {
|
|
106
|
+
#sidebar {
|
|
107
|
+
width: 0;
|
|
108
|
+
overflow: visible;
|
|
109
|
+
|
|
110
|
+
.sidebar_section {
|
|
111
|
+
display: none;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
68
114
|
|
|
69
115
|
#main_content_wrapper {
|
|
70
|
-
margin-left:
|
|
116
|
+
margin-left: $toggle-btn-width + 8px;
|
|
71
117
|
}
|
|
118
|
+
}
|
|
72
119
|
|
|
120
|
+
// === Collapsed state: right sidebar (default AA position) ===
|
|
121
|
+
body.active_admin #active_admin_content.collapsible_sidebar.collapsed_sidebar:not(.left_sidebar) {
|
|
73
122
|
#sidebar {
|
|
74
|
-
|
|
75
|
-
|
|
123
|
+
width: 0;
|
|
124
|
+
margin-left: 0;
|
|
125
|
+
overflow: visible;
|
|
76
126
|
|
|
77
|
-
|
|
78
|
-
|
|
127
|
+
.sidebar_section {
|
|
128
|
+
display: none;
|
|
129
|
+
}
|
|
79
130
|
}
|
|
80
131
|
|
|
132
|
+
#main_content_wrapper #main_content {
|
|
133
|
+
margin-right: $toggle-btn-width + 8px;
|
|
134
|
+
}
|
|
81
135
|
}
|
|
82
136
|
|
|
83
|
-
|
|
137
|
+
// === Left sidebar expanded + collapsible: fix margin ===
|
|
138
|
+
body.active_admin.index #active_admin_content.with_sidebar.left_sidebar.collapsible_sidebar {
|
|
84
139
|
#main_content_wrapper #main_content {
|
|
85
140
|
margin-right: 0;
|
|
86
141
|
}
|
|
87
142
|
}
|
|
88
143
|
|
|
144
|
+
// === Comments overflow fix ===
|
|
89
145
|
.with_sidebar .comments .active_admin_comment {
|
|
90
146
|
overflow: auto;
|
|
91
147
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
module ActiveAdminSidebar::ActiveAdminViewsPagesBase
|
|
2
2
|
|
|
3
3
|
def build_page_content
|
|
4
|
+
# When no sidebar options are set, fall back to vanilla ActiveAdmin behavior
|
|
5
|
+
return super unless sidebar_options_present?
|
|
6
|
+
|
|
4
7
|
build_flash_messages
|
|
5
8
|
div id: "active_admin_content", class: main_content_classes do
|
|
6
9
|
build_sidebar unless skip_sidebar? || right_sidebar?
|
|
@@ -17,12 +20,16 @@ module ActiveAdminSidebar::ActiveAdminViewsPagesBase
|
|
|
17
20
|
end
|
|
18
21
|
end
|
|
19
22
|
|
|
23
|
+
def sidebar_options_present?
|
|
24
|
+
assigns[:sidebar_options].present?
|
|
25
|
+
end
|
|
26
|
+
|
|
20
27
|
def left_sidebar?
|
|
21
28
|
assigns[:sidebar_options].try!(:[], :position) == :left
|
|
22
29
|
end
|
|
23
30
|
|
|
24
31
|
def collapsible_sidebar?
|
|
25
|
-
|
|
32
|
+
!!assigns[:sidebar_options].try!(:[], :collapsible)
|
|
26
33
|
end
|
|
27
34
|
|
|
28
35
|
def sidebar_is_collapsed?
|
|
@@ -40,6 +47,7 @@ module ActiveAdminSidebar::ActiveAdminViewsPagesBase
|
|
|
40
47
|
else
|
|
41
48
|
classes << "with_sidebar"
|
|
42
49
|
classes << "left_sidebar" if left_sidebar?
|
|
50
|
+
classes << "right_sidebar" if right_sidebar?
|
|
43
51
|
if collapsible_sidebar?
|
|
44
52
|
classes << "collapsible_sidebar"
|
|
45
53
|
classes << "collapsed_sidebar" if sidebar_is_collapsed?
|
|
@@ -2,26 +2,56 @@ module ActiveAdminSidebar
|
|
|
2
2
|
module Positions
|
|
3
3
|
def left_sidebar!(options = {})
|
|
4
4
|
@sidebar_options = { position: :left }
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
|
|
6
|
+
validate_sidebar_options!(options)
|
|
7
|
+
|
|
8
|
+
collapsible = options.fetch(:collapsible, false)
|
|
9
|
+
start_collapsed = options.fetch(:start_collapsed, false)
|
|
10
|
+
|
|
11
|
+
apply_collapsible_options(start_collapsed) if collapsible
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
-
def right_sidebar!
|
|
14
|
+
def right_sidebar!(options = {})
|
|
15
15
|
@sidebar_options = { position: :right }
|
|
16
|
+
|
|
17
|
+
validate_sidebar_options!(options)
|
|
18
|
+
|
|
19
|
+
collapsible = options.fetch(:collapsible, false)
|
|
20
|
+
start_collapsed = options.fetch(:start_collapsed, false)
|
|
21
|
+
|
|
22
|
+
apply_collapsible_options(start_collapsed) if collapsible
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
private
|
|
26
|
+
|
|
27
|
+
def validate_sidebar_options!(options)
|
|
28
|
+
if options.key?(:collapsed)
|
|
29
|
+
raise ArgumentError,
|
|
30
|
+
"The :collapsed option has been removed in v3. " \
|
|
31
|
+
"Use `collapsible: true, start_collapsed: true` instead."
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def apply_collapsible_options(start_collapsed)
|
|
36
|
+
handle_sidebar_toggle_request
|
|
37
|
+
toggled = (session[:aas_toggled] || []).include?(controller_name)
|
|
38
|
+
is_collapsed = toggled ? !start_collapsed : start_collapsed
|
|
39
|
+
@sidebar_options.merge!(
|
|
40
|
+
collapsible: true,
|
|
41
|
+
is_collapsed: is_collapsed
|
|
42
|
+
)
|
|
16
43
|
end
|
|
17
44
|
|
|
18
|
-
def
|
|
19
|
-
if request.xhr?
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
45
|
+
def handle_sidebar_toggle_request
|
|
46
|
+
if request.xhr? && params[:collapsed_sidebar].present?
|
|
47
|
+
toggled = session[:aas_toggled] || []
|
|
48
|
+
if toggled.include?(controller_name)
|
|
49
|
+
toggled -= [controller_name]
|
|
50
|
+
else
|
|
51
|
+
toggled += [controller_name]
|
|
24
52
|
end
|
|
53
|
+
session[:aas_toggled] = toggled
|
|
54
|
+
render json: { collapsed_sidebar: params[:collapsed_sidebar] } and return
|
|
25
55
|
end
|
|
26
56
|
end
|
|
27
57
|
|
data/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@activeadmin-plugins/active_admin_sidebar",
|
|
3
|
+
"version": "3.0.0",
|
|
4
|
+
"description": "Extension for ActiveAdmin gem to manage sidebar",
|
|
5
|
+
"main": "src/active_admin_sidebar.js",
|
|
6
|
+
"style": "src/active_admin_sidebar.scss",
|
|
7
|
+
"repository": "git@github.com:activeadmin-plugins/active_admin_sidebar.git",
|
|
8
|
+
"author": "Igor Fedoronchuk <fedoronchuk@gmail.com>",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"private": false,
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/activeadmin-plugins/active_admin_sidebar.git"
|
|
14
|
+
},
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/activeadmin-plugins/active_admin_sidebar/issues"
|
|
17
|
+
},
|
|
18
|
+
"homepage": "https://github.com/activeadmin-plugins/active_admin_sidebar#readme",
|
|
19
|
+
"keywords": [
|
|
20
|
+
"active",
|
|
21
|
+
"admin",
|
|
22
|
+
"sidebar"
|
|
23
|
+
],
|
|
24
|
+
"files": [
|
|
25
|
+
"src/**/*"
|
|
26
|
+
],
|
|
27
|
+
"scripts": {
|
|
28
|
+
"prepublishOnly": "rm -rf src && cp -R app/assets/javascripts/ src && cp -R app/assets/stylesheets/ src"
|
|
29
|
+
}
|
|
30
|
+
}
|
data/spec/sidebars_spec.rb
CHANGED
|
@@ -5,49 +5,184 @@ describe 'authors index', type: :feature, js: true do
|
|
|
5
5
|
before do
|
|
6
6
|
Author.create!(name: 'John', last_name: 'Doe')
|
|
7
7
|
Author.create!(name: 'Jane', last_name: 'Roe')
|
|
8
|
-
add_author_resource
|
|
9
|
-
add_post_resource
|
|
10
8
|
end
|
|
11
9
|
|
|
12
|
-
context 'left-sidebar with
|
|
10
|
+
context 'left-sidebar with collapsible: true (starts expanded)' do
|
|
13
11
|
before do
|
|
12
|
+
add_author_resource
|
|
13
|
+
add_post_resource
|
|
14
14
|
visit '/admin/authors'
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
-
it 'has left-sidebar with
|
|
17
|
+
it 'has left-sidebar with toggle button' do
|
|
18
18
|
expect(page).to have_css('#filters_sidebar_section')
|
|
19
|
-
expect(page).to have_css('
|
|
19
|
+
expect(page).to have_css('.sidebar_toggle_btn')
|
|
20
20
|
expect(page).to have_css('#active_admin_content.with_sidebar.left_sidebar.collapsible_sidebar')
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
it 'sidebar starts expanded' do
|
|
24
|
+
expect(page).to have_css('#sidebar .sidebar_section', visible: :visible)
|
|
25
|
+
expect(page).not_to have_css('#active_admin_content.collapsed_sidebar')
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
context 'when click on toggle to collapse' do
|
|
24
29
|
before do
|
|
25
|
-
page.find('
|
|
30
|
+
page.find('.sidebar_toggle_btn').click
|
|
26
31
|
end
|
|
27
32
|
|
|
28
33
|
it "sidebar is hidden, and save it's state after going to another page" do
|
|
29
|
-
expect(page).to have_css('#
|
|
34
|
+
expect(page).to have_css('#active_admin_content.collapsed_sidebar')
|
|
30
35
|
|
|
31
36
|
# Posts page is configured as: "before_action :skip_sidebar!"
|
|
32
37
|
visit '/admin/posts'
|
|
33
|
-
# sidebar does not
|
|
38
|
+
# sidebar does not exist at all
|
|
34
39
|
expect(page).to have_css('#page_title', text: 'Posts')
|
|
35
40
|
expect(page).not_to have_css('#sidebar', visible: :all)
|
|
36
41
|
|
|
37
42
|
visit '/admin/authors'
|
|
38
|
-
# sidebar is
|
|
43
|
+
# sidebar is collapsed
|
|
39
44
|
expect(page).to have_css('#page_title', text: 'Authors')
|
|
40
|
-
expect(page).to have_css('#
|
|
45
|
+
expect(page).to have_css('#active_admin_content.collapsed_sidebar')
|
|
41
46
|
|
|
42
|
-
page.find('.
|
|
47
|
+
page.find('.sidebar_toggle_btn').click
|
|
43
48
|
|
|
44
49
|
# sidebar is visible
|
|
45
|
-
expect(page).to have_css('#sidebar', visible: :visible)
|
|
46
|
-
expect(page).
|
|
47
|
-
expect(page).not_to have_css('.uncollapse_btn')
|
|
50
|
+
expect(page).to have_css('#sidebar .sidebar_section', visible: :visible)
|
|
51
|
+
expect(page).not_to have_css('#active_admin_content.collapsed_sidebar')
|
|
48
52
|
end
|
|
49
53
|
end
|
|
50
54
|
|
|
51
55
|
end
|
|
52
56
|
|
|
57
|
+
context 'left-sidebar with collapsible: true, start_collapsed: true' do
|
|
58
|
+
before do
|
|
59
|
+
add_author_resource_with_start_collapsed
|
|
60
|
+
add_post_resource
|
|
61
|
+
visit '/admin/authors'
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
it 'has collapsible sidebar that starts collapsed' do
|
|
65
|
+
expect(page).to have_css('#active_admin_content.collapsible_sidebar.collapsed_sidebar')
|
|
66
|
+
expect(page).to have_css('.sidebar_toggle_btn')
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
it 'can be expanded by clicking toggle button' do
|
|
70
|
+
page.find('.sidebar_toggle_btn').click
|
|
71
|
+
|
|
72
|
+
expect(page).to have_css('#sidebar .sidebar_section', visible: :visible)
|
|
73
|
+
expect(page).not_to have_css('#active_admin_content.collapsed_sidebar')
|
|
74
|
+
|
|
75
|
+
# session remembers expanded state
|
|
76
|
+
visit '/admin/authors'
|
|
77
|
+
expect(page).to have_css('#sidebar .sidebar_section', visible: :visible)
|
|
78
|
+
expect(page).not_to have_css('#active_admin_content.collapsed_sidebar')
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
context 'deprecated collapsed option raises error' do
|
|
83
|
+
it 'raises ArgumentError for left_sidebar!' do
|
|
84
|
+
obj = Object.new
|
|
85
|
+
obj.extend(ActiveAdminSidebar::Positions)
|
|
86
|
+
expect { obj.left_sidebar!(collapsed: true) }.to raise_error(ArgumentError, /removed in v3/)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
it 'raises ArgumentError for right_sidebar!' do
|
|
90
|
+
obj = Object.new
|
|
91
|
+
obj.extend(ActiveAdminSidebar::Positions)
|
|
92
|
+
expect { obj.right_sidebar!(collapsed: true) }.to raise_error(ArgumentError, /removed in v3/)
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
context 'right-sidebar with collapsible: true (starts expanded)' do
|
|
97
|
+
before do
|
|
98
|
+
add_author_resource_right_sidebar
|
|
99
|
+
add_post_resource
|
|
100
|
+
visit '/admin/authors'
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
it 'has right-sidebar with toggle button' do
|
|
104
|
+
expect(page).to have_css('#filters_sidebar_section')
|
|
105
|
+
expect(page).to have_css('.sidebar_toggle_btn')
|
|
106
|
+
expect(page).to have_css('#active_admin_content.with_sidebar.collapsible_sidebar')
|
|
107
|
+
expect(page).not_to have_css('#active_admin_content.left_sidebar')
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
it 'sidebar starts expanded' do
|
|
111
|
+
expect(page).to have_css('#sidebar .sidebar_section', visible: :visible)
|
|
112
|
+
expect(page).not_to have_css('#active_admin_content.collapsed_sidebar')
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
context 'when click on toggle to collapse' do
|
|
116
|
+
before do
|
|
117
|
+
page.find('.sidebar_toggle_btn').click
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
it 'sidebar is hidden and toggle button is on the right side' do
|
|
121
|
+
expect(page).to have_css('#active_admin_content.collapsed_sidebar')
|
|
122
|
+
|
|
123
|
+
btn_left = page.evaluate_script("document.querySelector('.sidebar_toggle_btn').getBoundingClientRect().left")
|
|
124
|
+
page_width = page.evaluate_script('document.documentElement.clientWidth')
|
|
125
|
+
expect(btn_left).to be > (page_width / 2), "toggle button should be on the right side of the page"
|
|
126
|
+
|
|
127
|
+
page.find('.sidebar_toggle_btn').click
|
|
128
|
+
|
|
129
|
+
expect(page).not_to have_css('#active_admin_content.collapsed_sidebar')
|
|
130
|
+
expect(page).to have_css('#sidebar .sidebar_section', visible: :visible)
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
context 'right-sidebar with collapsible: true, start_collapsed: true' do
|
|
136
|
+
before do
|
|
137
|
+
add_author_resource_right_sidebar_start_collapsed
|
|
138
|
+
add_post_resource
|
|
139
|
+
visit '/admin/authors'
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
it 'has collapsible right-sidebar that starts collapsed' do
|
|
143
|
+
expect(page).to have_css('#active_admin_content.collapsible_sidebar.collapsed_sidebar')
|
|
144
|
+
expect(page).to have_css('.sidebar_toggle_btn')
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
it 'can be expanded by clicking toggle button' do
|
|
148
|
+
page.find('.sidebar_toggle_btn').click
|
|
149
|
+
|
|
150
|
+
expect(page).to have_css('#sidebar .sidebar_section', visible: :visible)
|
|
151
|
+
expect(page).not_to have_css('#active_admin_content.collapsed_sidebar')
|
|
152
|
+
|
|
153
|
+
# session remembers expanded state
|
|
154
|
+
visit '/admin/authors'
|
|
155
|
+
expect(page).to have_css('#sidebar .sidebar_section', visible: :visible)
|
|
156
|
+
expect(page).not_to have_css('#active_admin_content.collapsed_sidebar')
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
context 'per-resource sidebar state isolation' do
|
|
161
|
+
before do
|
|
162
|
+
Post.create!(title: 'Test', body: 'Body', author: Author.first)
|
|
163
|
+
add_author_resource_with_start_collapsed
|
|
164
|
+
add_post_resource_with_sidebar
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
it 'changing sidebar state on one resource does not affect another' do
|
|
168
|
+
# Authors starts collapsed (collapsible: true, start_collapsed: true)
|
|
169
|
+
visit '/admin/authors'
|
|
170
|
+
expect(page).to have_css('#active_admin_content.collapsed_sidebar')
|
|
171
|
+
|
|
172
|
+
# Expand authors
|
|
173
|
+
page.find('.sidebar_toggle_btn').click
|
|
174
|
+
expect(page).to have_css('#sidebar .sidebar_section', visible: :visible)
|
|
175
|
+
|
|
176
|
+
# Posts should still be in its default state (expanded, not collapsed)
|
|
177
|
+
visit '/admin/posts'
|
|
178
|
+
expect(page).to have_css('#active_admin_content.collapsible_sidebar')
|
|
179
|
+
expect(page).not_to have_css('#active_admin_content.collapsed_sidebar')
|
|
180
|
+
|
|
181
|
+
# Authors should still be expanded (from earlier toggle)
|
|
182
|
+
visit '/admin/authors'
|
|
183
|
+
expect(page).to have_css('#sidebar .sidebar_section', visible: :visible)
|
|
184
|
+
expect(page).not_to have_css('#active_admin_content.collapsed_sidebar')
|
|
185
|
+
end
|
|
186
|
+
end
|
|
187
|
+
|
|
53
188
|
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
require 'simplecov'
|
|
2
|
+
SimpleCov.start do
|
|
3
|
+
add_filter '/spec/'
|
|
4
|
+
end
|
|
5
|
+
|
|
1
6
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
|
2
7
|
$LOAD_PATH << File.expand_path('../support', __FILE__)
|
|
3
8
|
|
|
@@ -6,12 +11,10 @@ require "bundler"
|
|
|
6
11
|
Bundler.setup
|
|
7
12
|
|
|
8
13
|
ENV['RAILS_ENV'] = 'test'
|
|
9
|
-
# Ensure the Active Admin load path is happy
|
|
10
14
|
require 'rails'
|
|
11
15
|
ENV['RAILS'] = Rails.version
|
|
12
16
|
ENV['RAILS_ROOT'] = File.expand_path("../rails/rails-#{ENV['RAILS']}", __FILE__)
|
|
13
|
-
|
|
14
|
-
unless File.exists?(ENV['RAILS_ROOT'])
|
|
17
|
+
unless File.exist?(ENV['RAILS_ROOT'])
|
|
15
18
|
system 'rake setup'
|
|
16
19
|
end
|
|
17
20
|
|
|
@@ -19,15 +22,12 @@ require 'rails/all'
|
|
|
19
22
|
require 'active_admin'
|
|
20
23
|
ActiveAdmin.application.load_paths = [ENV['RAILS_ROOT'] + "/app/admin"]
|
|
21
24
|
require ENV['RAILS_ROOT'] + '/config/environment.rb'
|
|
22
|
-
# Disabling authentication in specs so that we don't have to worry about
|
|
23
|
-
# it allover the place
|
|
24
25
|
ActiveAdmin.application.authentication_method = false
|
|
25
26
|
ActiveAdmin.application.current_user_method = false
|
|
26
27
|
|
|
27
28
|
require 'rspec/rails'
|
|
28
29
|
require 'capybara/rails'
|
|
29
30
|
require 'capybara/rspec'
|
|
30
|
-
require 'selenium-webdriver'
|
|
31
31
|
|
|
32
32
|
require 'support/admin'
|
|
33
33
|
require 'support/capybara'
|
|
@@ -36,6 +36,7 @@ RSpec.configure do |config|
|
|
|
36
36
|
config.use_transactional_fixtures = false
|
|
37
37
|
|
|
38
38
|
config.before(:suite) do
|
|
39
|
+
ActiveRecord::Migration.maintain_test_schema!
|
|
39
40
|
DatabaseCleaner.strategy = :truncation
|
|
40
41
|
DatabaseCleaner.clean_with(:truncation)
|
|
41
42
|
end
|
|
@@ -46,5 +47,4 @@ RSpec.configure do |config|
|
|
|
46
47
|
config.after(:each) do
|
|
47
48
|
DatabaseCleaner.clean
|
|
48
49
|
end
|
|
49
|
-
|
|
50
50
|
end
|
data/spec/support/admin.rb
CHANGED
|
@@ -8,6 +8,44 @@ def add_author_resource(options = {}, &block)
|
|
|
8
8
|
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
+
def add_author_resource_with_start_collapsed(options = {}, &block)
|
|
12
|
+
|
|
13
|
+
ActiveAdmin.register Author do
|
|
14
|
+
config.filters = true
|
|
15
|
+
before_action do
|
|
16
|
+
left_sidebar!(collapsible: true, start_collapsed: true)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
Rails.application.reload_routes!
|
|
21
|
+
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def add_author_resource_right_sidebar(options = {}, &block)
|
|
25
|
+
|
|
26
|
+
ActiveAdmin.register Author do
|
|
27
|
+
config.filters = true
|
|
28
|
+
before_action do
|
|
29
|
+
right_sidebar!(collapsible: true)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
Rails.application.reload_routes!
|
|
34
|
+
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def add_author_resource_right_sidebar_start_collapsed(options = {}, &block)
|
|
38
|
+
|
|
39
|
+
ActiveAdmin.register Author do
|
|
40
|
+
config.filters = true
|
|
41
|
+
before_action do
|
|
42
|
+
right_sidebar!(collapsible: true, start_collapsed: true)
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
Rails.application.reload_routes!
|
|
47
|
+
|
|
48
|
+
end
|
|
11
49
|
|
|
12
50
|
def add_post_resource(options = {}, &block)
|
|
13
51
|
|
|
@@ -19,3 +57,17 @@ def add_post_resource(options = {}, &block)
|
|
|
19
57
|
Rails.application.reload_routes!
|
|
20
58
|
|
|
21
59
|
end
|
|
60
|
+
|
|
61
|
+
def add_post_resource_with_sidebar(options = {}, &block)
|
|
62
|
+
|
|
63
|
+
ActiveAdmin.register Post do
|
|
64
|
+
config.filters = true
|
|
65
|
+
skip_before_action :skip_sidebar!, raise: false
|
|
66
|
+
before_action do
|
|
67
|
+
left_sidebar!(collapsible: true)
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
Rails.application.reload_routes!
|
|
72
|
+
|
|
73
|
+
end
|
data/spec/support/capybara.rb
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
config.match = :prefer_exact
|
|
3
|
-
end
|
|
4
|
-
|
|
5
|
-
Capybara.register_driver :selenium_chrome do |app|
|
|
6
|
-
options = Selenium::WebDriver::Chrome::Options.new(
|
|
7
|
-
args: %w[headless disable-gpu no-sandbox]
|
|
8
|
-
)
|
|
9
|
-
Capybara::Selenium::Driver.new(app, browser: :chrome, options: options)
|
|
10
|
-
end
|
|
1
|
+
require 'capybara/cuprite'
|
|
11
2
|
|
|
12
3
|
Capybara.server = :webrick
|
|
13
|
-
Capybara.
|
|
4
|
+
Capybara.register_driver :cuprite do |app|
|
|
5
|
+
Capybara::Cuprite::Driver.new(app, headless: true, window_size: [1280, 800])
|
|
6
|
+
end
|
|
7
|
+
Capybara.javascript_driver = :cuprite
|
|
8
|
+
Capybara.default_max_wait_time = 5
|
|
@@ -1,21 +1,34 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Ensure Sprockets manifest exists (required by Rails 8+)
|
|
2
|
+
FileUtils.mkdir_p("app/assets/config")
|
|
3
|
+
File.write("app/assets/config/manifest.js",
|
|
4
|
+
"//= link_directory ../javascripts .js\n//= link_directory ../stylesheets .css\n")
|
|
2
5
|
|
|
3
|
-
generate :model, 'author name:string{10}:uniq last_name:string birthday:date'
|
|
4
|
-
generate :model, 'post title:string:uniq body:text author:references'
|
|
6
|
+
generate :model, 'author name:string{10}:uniq last_name:string birthday:date --force'
|
|
7
|
+
generate :model, 'post title:string:uniq body:text author:references --force'
|
|
5
8
|
|
|
6
|
-
|
|
7
|
-
inject_into_file "app/models/author.rb", " validates_presence_of :name\n validates_uniqueness_of :last_name\n", after: "Base\n"
|
|
9
|
+
inject_into_file "app/models/author.rb", " validates_presence_of :name\n validates_uniqueness_of :last_name\n", after: "ApplicationRecord\n"
|
|
8
10
|
inject_into_file "app/models/post.rb", " validates_presence_of :author\n", after: ":author\n"
|
|
9
11
|
|
|
10
|
-
#
|
|
11
|
-
inject_into_file "
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
# Add ransackable_attributes for Ransack 4+
|
|
13
|
+
inject_into_file "app/models/author.rb",
|
|
14
|
+
" def self.ransackable_attributes(auth_object = nil)\n" \
|
|
15
|
+
" [\"name\", \"last_name\", \"birthday\", \"created_at\", \"updated_at\"]\n" \
|
|
16
|
+
" end\n",
|
|
17
|
+
after: "ApplicationRecord\n"
|
|
18
|
+
|
|
19
|
+
inject_into_file "app/models/post.rb",
|
|
20
|
+
" def self.ransackable_attributes(auth_object = nil)\n" \
|
|
21
|
+
" [\"title\", \"body\", \"author_id\"]\n" \
|
|
22
|
+
" end\n" \
|
|
23
|
+
" def self.ransackable_associations(auth_object = nil)\n" \
|
|
24
|
+
" [\"author\"]\n" \
|
|
25
|
+
" end\n",
|
|
26
|
+
after: "ApplicationRecord\n"
|
|
27
|
+
|
|
28
|
+
# Add our local Active Admin to the load path (Rails 7.1+)
|
|
29
|
+
gsub_file "config/environment.rb",
|
|
30
|
+
'require_relative "application"',
|
|
31
|
+
"require_relative \"application\"\n$LOAD_PATH.unshift('#{File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib'))}')\nrequire \"active_admin\"\n"
|
|
19
32
|
|
|
20
33
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
21
34
|
|
|
@@ -24,26 +37,19 @@ generate :'formtastic:install'
|
|
|
24
37
|
|
|
25
38
|
# Initialize plugin
|
|
26
39
|
inject_into_file "config/initializers/active_admin.rb",
|
|
27
|
-
" config.before_action do\n left_sidebar!(
|
|
40
|
+
" config.before_action do\n left_sidebar!(collapsible: true) if respond_to?(:left_sidebar!)\n end\n\n",
|
|
28
41
|
after: "ActiveAdmin.setup do |config|\n"
|
|
29
42
|
|
|
30
43
|
inject_into_file "app/assets/stylesheets/active_admin.scss",
|
|
31
44
|
"@import \"active_admin_sidebar\";\n",
|
|
32
45
|
after: "@import \"active_admin/base\";\n"
|
|
33
46
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
after: "//= require active_admin/base\n"
|
|
38
|
-
else
|
|
39
|
-
inject_into_file "app/assets/javascripts/active_admin.js.coffee",
|
|
40
|
-
"#= require active_admin_sidebar\n",
|
|
41
|
-
after: "#= require active_admin/base\n"
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
run "rm -r test"
|
|
45
|
-
run "rm -r spec"
|
|
47
|
+
inject_into_file "app/assets/javascripts/active_admin.js",
|
|
48
|
+
"//= require active_admin_sidebar\n",
|
|
49
|
+
after: "//= require active_admin/base\n"
|
|
46
50
|
|
|
51
|
+
run "rm -rf test"
|
|
47
52
|
route "root :to => 'admin/dashboard#index'"
|
|
48
|
-
|
|
49
53
|
rake "db:migrate"
|
|
54
|
+
|
|
55
|
+
run "rm -f Gemfile Gemfile.lock"
|
data/tasks/test.rake
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
desc "Creates a test rails app for the specs to run against"
|
|
2
2
|
task :setup do
|
|
3
3
|
require 'rails/version'
|
|
4
|
-
system("mkdir spec/rails") unless File.exists?("spec/rails")
|
|
5
4
|
|
|
6
5
|
rails_new_opts = %w(
|
|
7
6
|
--skip-turbolinks
|
|
8
7
|
--skip-spring
|
|
9
8
|
--skip-bootsnap
|
|
10
|
-
--skip-webpack-install
|
|
11
9
|
-m
|
|
12
10
|
spec/support/rails_template.rb
|
|
13
11
|
)
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: active_admin_sidebar
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 3.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Igor
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: activeadmin
|
|
@@ -16,14 +15,20 @@ dependencies:
|
|
|
16
15
|
requirements:
|
|
17
16
|
- - ">="
|
|
18
17
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '0'
|
|
18
|
+
version: '3.0'
|
|
19
|
+
- - "<"
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: '4.0'
|
|
20
22
|
type: :runtime
|
|
21
23
|
prerelease: false
|
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
25
|
requirements:
|
|
24
26
|
- - ">="
|
|
25
27
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '0'
|
|
28
|
+
version: '3.0'
|
|
29
|
+
- - "<"
|
|
30
|
+
- !ruby/object:Gem::Version
|
|
31
|
+
version: '4.0'
|
|
27
32
|
description: extension for activeadmin gem to manage sidebar
|
|
28
33
|
email:
|
|
29
34
|
- fedoronchuk@gmail.com
|
|
@@ -31,7 +36,8 @@ executables: []
|
|
|
31
36
|
extensions: []
|
|
32
37
|
extra_rdoc_files: []
|
|
33
38
|
files:
|
|
34
|
-
- ".
|
|
39
|
+
- ".github/workflows/ci.yml"
|
|
40
|
+
- ".gitignore"
|
|
35
41
|
- Gemfile
|
|
36
42
|
- LICENSE
|
|
37
43
|
- README.md
|
|
@@ -39,22 +45,21 @@ files:
|
|
|
39
45
|
- active_admin_sidebar.gemspec
|
|
40
46
|
- app/assets/javascripts/active_admin_sidebar.js
|
|
41
47
|
- app/assets/stylesheets/active_admin_sidebar.scss
|
|
42
|
-
- app/assets/stylesheets/active_admin_sidebar_pure_icons.scss
|
|
43
48
|
- lib/active_admin_sidebar.rb
|
|
44
49
|
- lib/active_admin_sidebar/activeadmin_views_pages_base.rb
|
|
45
50
|
- lib/active_admin_sidebar/positions.rb
|
|
46
51
|
- lib/active_admin_sidebar/version.rb
|
|
47
|
-
-
|
|
52
|
+
- package.json
|
|
48
53
|
- spec/sidebars_spec.rb
|
|
49
54
|
- spec/spec_helper.rb
|
|
50
55
|
- spec/support/admin.rb
|
|
51
56
|
- spec/support/capybara.rb
|
|
52
57
|
- spec/support/rails_template.rb
|
|
53
58
|
- tasks/test.rake
|
|
54
|
-
homepage: https://github.com/
|
|
55
|
-
licenses:
|
|
59
|
+
homepage: https://github.com/activeadmin-plugins/active_admin_sidebar
|
|
60
|
+
licenses:
|
|
61
|
+
- MIT
|
|
56
62
|
metadata: {}
|
|
57
|
-
post_install_message:
|
|
58
63
|
rdoc_options: []
|
|
59
64
|
require_paths:
|
|
60
65
|
- lib
|
|
@@ -62,16 +67,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
62
67
|
requirements:
|
|
63
68
|
- - ">="
|
|
64
69
|
- !ruby/object:Gem::Version
|
|
65
|
-
version:
|
|
70
|
+
version: 3.1.0
|
|
66
71
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
67
72
|
requirements:
|
|
68
73
|
- - ">="
|
|
69
74
|
- !ruby/object:Gem::Version
|
|
70
75
|
version: '0'
|
|
71
76
|
requirements: []
|
|
72
|
-
|
|
73
|
-
rubygems_version: 2.7.6.2
|
|
74
|
-
signing_key:
|
|
77
|
+
rubygems_version: 3.7.1
|
|
75
78
|
specification_version: 4
|
|
76
79
|
summary: active_admin_sidebar gem
|
|
77
80
|
test_files:
|
data/.travis.yml
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
sudo: required
|
|
2
|
-
|
|
3
|
-
language: ruby
|
|
4
|
-
|
|
5
|
-
addons:
|
|
6
|
-
chrome: stable
|
|
7
|
-
|
|
8
|
-
before_install:
|
|
9
|
-
- gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true
|
|
10
|
-
- gem install bundler -v '< 2'
|
|
11
|
-
|
|
12
|
-
script: bundle exec rspec
|
|
13
|
-
|
|
14
|
-
env:
|
|
15
|
-
matrix:
|
|
16
|
-
- RAILS=5.1.6 AA=1.1.0
|
|
17
|
-
- RAILS=5.2.1 AA=1.4.0
|
|
18
|
-
- RAILS=5.2.2 AA=2.8.0
|
|
19
|
-
- RAILS=6.0.0 AA=2.8.0
|
|
20
|
-
|
|
21
|
-
rvm:
|
|
22
|
-
- 2.5
|
|
23
|
-
- 2.6
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
/* .icono-caret-left */
|
|
2
|
-
.icono-caret-right, .icono-caret-left {
|
|
3
|
-
height: 19px;
|
|
4
|
-
width: 19px;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
.icono-caret-right:before,
|
|
8
|
-
.icono-caret-right:after,
|
|
9
|
-
.icono-caret-left:before,
|
|
10
|
-
.icono-caret-left:after {
|
|
11
|
-
bottom: 1px;
|
|
12
|
-
box-shadow: inset 0 0 0 32px;
|
|
13
|
-
height: 2px;
|
|
14
|
-
margin: auto 0;
|
|
15
|
-
position: absolute;
|
|
16
|
-
right: 6px;
|
|
17
|
-
transform-origin: right;
|
|
18
|
-
width: 8px;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.icono-caret-right:before, .icono-caret-left:before {
|
|
22
|
-
top: 2px;
|
|
23
|
-
-moz-transform: rotate(45deg);
|
|
24
|
-
-ms-transform: rotate(45deg);
|
|
25
|
-
-o-transform: rotate(45deg);
|
|
26
|
-
-webkit-transform: rotate(45deg);
|
|
27
|
-
transform: rotate(45deg);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
.icono-caret-right:after, .icono-caret-left:after {
|
|
31
|
-
top: 0;
|
|
32
|
-
-moz-transform: rotate(-45deg);
|
|
33
|
-
-ms-transform: rotate(-45deg);
|
|
34
|
-
-o-transform: rotate(-45deg);
|
|
35
|
-
-webkit-transform: rotate(-45deg);
|
|
36
|
-
transform: rotate(-45deg);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
.icono-caret-left {
|
|
40
|
-
-moz-transform: rotate(180deg);
|
|
41
|
-
-ms-transform: rotate(180deg);
|
|
42
|
-
-o-transform: rotate(180deg);
|
|
43
|
-
-webkit-transform: rotate(180deg);
|
|
44
|
-
transform: rotate(180deg);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
[class*="icono-"] {
|
|
48
|
-
direction: ltr;
|
|
49
|
-
display: inline-block;
|
|
50
|
-
font-style: normal;
|
|
51
|
-
position: relative;
|
|
52
|
-
text-align: left;
|
|
53
|
-
text-indent: -9999px;
|
|
54
|
-
vertical-align: middle;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
[class*="icono-"]:before,
|
|
58
|
-
[class*="icono-"]:after {
|
|
59
|
-
content: "";
|
|
60
|
-
pointer-events: none;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
[class*="icono-"],
|
|
64
|
-
[class*="icono-"] * {
|
|
65
|
-
box-sizing: border-box;
|
|
66
|
-
}
|
data/screen/sidebar.jpg
DELETED
|
Binary file
|