solidus_admin_bar 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.circleci/config.yml +41 -0
- data/.gem_release.yml +5 -0
- data/.github/stale.yml +17 -0
- data/.github_changelog_generator +2 -0
- data/.gitignore +20 -0
- data/.rspec +2 -0
- data/.rubocop.yml +5 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +33 -0
- data/LICENSE +26 -0
- data/README.md +91 -0
- data/Rakefile +6 -0
- data/app/assets/stylesheets/spree/frontend/solidus_admin_bar.scss +16 -0
- data/app/overrides/admin_bar.rb +6 -0
- data/app/views/spree/admin_bar/_admin_bar.html.erb +22 -0
- data/bin/console +17 -0
- data/bin/rails +7 -0
- data/bin/rails-engine +13 -0
- data/bin/rails-sandbox +16 -0
- data/bin/rake +7 -0
- data/bin/sandbox +86 -0
- data/bin/setup +8 -0
- data/config/locales/en.yml +15 -0
- data/config/routes.rb +5 -0
- data/lib/generators/solidus_admin_bar/install/install_generator.rb +15 -0
- data/lib/solidus_admin_bar.rb +5 -0
- data/lib/solidus_admin_bar/configuration.rb +21 -0
- data/lib/solidus_admin_bar/engine.rb +19 -0
- data/lib/solidus_admin_bar/testing_support/factories.rb +4 -0
- data/lib/solidus_admin_bar/version.rb +5 -0
- data/solidus_admin_bar.gemspec +36 -0
- data/spec/spec_helper.rb +44 -0
- data/spec/system/admin_bar_spec.rb +154 -0
- metadata +128 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5e66324464ed7ae44bf5374a6c1e53c27350febd954ef6e6ccb4adb11443eb53
|
4
|
+
data.tar.gz: 5ebf55dee0ce160bb3be80e8fc3802030c4999d9334e8ff0552c0c5cab9988f4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a74b9f9ae467b09daca7febff51d17c9598ef6a417fc5f8b30ac894849a4dccbbec95cca17698e417dfa5efa6b3667b337b3519fff107adf3a934b171143a03a
|
7
|
+
data.tar.gz: 3fc6cd443a87306f0dc0a98b3205dc03eb801d957a42f57abd073e3901e0f912b7adbb73c8bf2d8887f8f477b144b3a6faa87bf124866ff36348d901c78b5ab3
|
@@ -0,0 +1,41 @@
|
|
1
|
+
version: 2.1
|
2
|
+
|
3
|
+
orbs:
|
4
|
+
# Always take the latest version of the orb, this allows us to
|
5
|
+
# run specs against Solidus supported versions only without the need
|
6
|
+
# to change this configuration every time a Solidus version is released
|
7
|
+
# or goes EOL.
|
8
|
+
solidusio_extensions: solidusio/extensions@volatile
|
9
|
+
|
10
|
+
jobs:
|
11
|
+
run-specs-with-postgres:
|
12
|
+
executor: solidusio_extensions/postgres
|
13
|
+
steps:
|
14
|
+
- solidusio_extensions/run-tests
|
15
|
+
run-specs-with-mysql:
|
16
|
+
executor: solidusio_extensions/mysql
|
17
|
+
steps:
|
18
|
+
- solidusio_extensions/run-tests
|
19
|
+
lint-code:
|
20
|
+
executor: solidusio_extensions/sqlite-memory
|
21
|
+
steps:
|
22
|
+
- solidusio_extensions/lint-code
|
23
|
+
|
24
|
+
workflows:
|
25
|
+
"Run specs on supported Solidus versions":
|
26
|
+
jobs:
|
27
|
+
- run-specs-with-postgres
|
28
|
+
- run-specs-with-mysql
|
29
|
+
- lint-code
|
30
|
+
|
31
|
+
"Weekly run specs against master":
|
32
|
+
triggers:
|
33
|
+
- schedule:
|
34
|
+
cron: "0 0 * * 4" # every Thursday
|
35
|
+
filters:
|
36
|
+
branches:
|
37
|
+
only:
|
38
|
+
- master
|
39
|
+
jobs:
|
40
|
+
- run-specs-with-postgres
|
41
|
+
- run-specs-with-mysql
|
data/.gem_release.yml
ADDED
data/.github/stale.yml
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# Number of days of inactivity before an issue becomes stale
|
2
|
+
daysUntilStale: 60
|
3
|
+
# Number of days of inactivity before a stale issue is closed
|
4
|
+
daysUntilClose: false
|
5
|
+
# Issues with these labels will never be considered stale
|
6
|
+
exemptLabels:
|
7
|
+
- pinned
|
8
|
+
- security
|
9
|
+
# Label to use when marking an issue as stale
|
10
|
+
staleLabel: stale
|
11
|
+
# Comment to post when marking an issue as stale. Set to `false` to disable
|
12
|
+
markComment: >
|
13
|
+
This issue has been automatically marked as stale because it has not had
|
14
|
+
recent activity. It might be closed if no further activity occurs. Thank you
|
15
|
+
for your contributions.
|
16
|
+
# Comment to post when closing a stale issue. Set to `false` to disable
|
17
|
+
closeComment: false
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
5
|
+
|
6
|
+
branch = ENV.fetch('SOLIDUS_BRANCH', 'master')
|
7
|
+
gem 'solidus', github: 'solidusio/solidus', branch: branch
|
8
|
+
|
9
|
+
# Needed to help Bundler figure out how to resolve dependencies,
|
10
|
+
# otherwise it takes forever to resolve them.
|
11
|
+
# See https://github.com/bundler/bundler/issues/6677
|
12
|
+
gem 'rails', '>0.a'
|
13
|
+
|
14
|
+
# Provides basic authentication functionality for testing parts of your engine
|
15
|
+
gem 'solidus_auth_devise'
|
16
|
+
|
17
|
+
case ENV['DB']
|
18
|
+
when 'mysql'
|
19
|
+
gem 'mysql2'
|
20
|
+
when 'postgresql'
|
21
|
+
gem 'pg'
|
22
|
+
else
|
23
|
+
gem 'sqlite3'
|
24
|
+
end
|
25
|
+
|
26
|
+
gemspec
|
27
|
+
|
28
|
+
# Use a local Gemfile to include development dependencies that might not be
|
29
|
+
# relevant for the project or for other contributors, e.g. pry-byebug.
|
30
|
+
#
|
31
|
+
# We use `send` instead of calling `eval_gemfile` to work around an issue with
|
32
|
+
# how Dependabot parses projects: https://github.com/dependabot/dependabot-core/issues/1658.
|
33
|
+
send(:eval_gemfile, 'Gemfile-local') if File.exist? 'Gemfile-local'
|
data/LICENSE
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
Copyright (c) 2021 [name of plugin creator]
|
2
|
+
All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without modification,
|
5
|
+
are permitted provided that the following conditions are met:
|
6
|
+
|
7
|
+
* Redistributions of source code must retain the above copyright notice,
|
8
|
+
this list of conditions and the following disclaimer.
|
9
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
10
|
+
this list of conditions and the following disclaimer in the documentation
|
11
|
+
and/or other materials provided with the distribution.
|
12
|
+
* Neither the name Solidus nor the names of its contributors may be used to
|
13
|
+
endorse or promote products derived from this software without specific
|
14
|
+
prior written permission.
|
15
|
+
|
16
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
17
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
18
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
19
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
20
|
+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
21
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
22
|
+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
23
|
+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
24
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
25
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
26
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
# Solidus Admin Bar
|
2
|
+
|
3
|
+
[![CircleCI](https://circleci.com/gh/QuintinAdam/solidus_admin_bar.svg?style=shield)](https://circleci.com/gh/QuintinAdam/solidus_admin_bar)
|
4
|
+
[![codecov](https://codecov.io/gh/QuintinAdam/solidus_admin_bar/branch/master/graph/badge.svg)](https://codecov.io/gh/QuintinAdam/solidus_admin_bar)
|
5
|
+
|
6
|
+
This extension adds a admin navbar to the frontend of your Solidus store. It allows for a quick link to the admin dashboard. If you are on the taxon page it has quick links to edit the taxons. If you are in the product page, it has quick actions to all the product edit links.
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add solidus_admin_bar to your Gemfile:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
gem 'solidus_admin_bar'
|
14
|
+
```
|
15
|
+
|
16
|
+
Bundle your dependencies and run the installation generator:
|
17
|
+
|
18
|
+
```shell
|
19
|
+
bin/rails generate solidus_admin_bar:install
|
20
|
+
```
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
You can edit the style of the admin navbar and you can edit the admin bar view.
|
25
|
+
|
26
|
+
## Development
|
27
|
+
|
28
|
+
### Testing the extension
|
29
|
+
|
30
|
+
First bundle your dependencies, then run `bin/rake`. `bin/rake` will default to building the dummy
|
31
|
+
app if it does not exist, then it will run specs. The dummy app can be regenerated by using
|
32
|
+
`bin/rake extension:test_app`.
|
33
|
+
|
34
|
+
```shell
|
35
|
+
bin/rake
|
36
|
+
```
|
37
|
+
|
38
|
+
To run [Rubocop](https://github.com/bbatsov/rubocop) static code analysis run
|
39
|
+
|
40
|
+
```shell
|
41
|
+
bundle exec rubocop
|
42
|
+
```
|
43
|
+
|
44
|
+
When testing your application's integration with this extension you may use its factories.
|
45
|
+
Simply add this require statement to your `spec/spec_helper.rb`:
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
require 'solidus_admin_bar/testing_support/factories'
|
49
|
+
```
|
50
|
+
|
51
|
+
Or, if you are using `FactoryBot.definition_file_paths`, you can load Solidus core
|
52
|
+
factories along with this extension's factories using this statement:
|
53
|
+
|
54
|
+
```ruby
|
55
|
+
SolidusDevSupport::TestingSupport::Factories.load_for(SolidusAdminBar::Engine)
|
56
|
+
```
|
57
|
+
|
58
|
+
### Running the sandbox
|
59
|
+
|
60
|
+
To run this extension in a sandboxed Solidus application, you can run `bin/sandbox`. The path for
|
61
|
+
the sandbox app is `./sandbox` and `bin/rails` will forward any Rails commands to
|
62
|
+
`sandbox/bin/rails`.
|
63
|
+
|
64
|
+
Here's an example:
|
65
|
+
|
66
|
+
```
|
67
|
+
$ bin/rails server
|
68
|
+
=> Booting Puma
|
69
|
+
=> Rails 6.0.2.1 application starting in development
|
70
|
+
* Listening on tcp://127.0.0.1:3000
|
71
|
+
Use Ctrl-C to stop
|
72
|
+
```
|
73
|
+
|
74
|
+
### Updating the changelog
|
75
|
+
|
76
|
+
Before and after releases the changelog should be updated to reflect the up-to-date status of
|
77
|
+
the project:
|
78
|
+
|
79
|
+
```shell
|
80
|
+
bin/rake changelog
|
81
|
+
git add CHANGELOG.md
|
82
|
+
git commit -m "Update the changelog"
|
83
|
+
```
|
84
|
+
|
85
|
+
### Releasing new versions
|
86
|
+
|
87
|
+
Please refer to the dedicated [page](https://github.com/solidusio/solidus/wiki/How-to-release-extensions) on Solidus wiki.
|
88
|
+
|
89
|
+
## License
|
90
|
+
|
91
|
+
Copyright (c) 2021 [name of extension author], released under the New BSD License.
|
data/Rakefile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
<% if current_spree_user.try(:admin?) %>
|
2
|
+
<div id="admin_bar">
|
3
|
+
<strong><%= link_to t('spree.admin_bar.admin_dashboard_name'), admin_path %>: </strong>
|
4
|
+
<% if @product %>
|
5
|
+
<%= link_to t('spree.admin_bar.edit_product'), edit_admin_product_path(@product) %>
|
6
|
+
| <%= link_to t('spree.admin_bar.images'), admin_product_images_path(@product) %>
|
7
|
+
| <%= link_to t('spree.admin_bar.variants'), admin_product_variants_path(@product) %>
|
8
|
+
| <%= link_to t('spree.admin_bar.prices'), admin_product_prices_path(@product) %>
|
9
|
+
| <%= link_to t('spree.admin_bar.properties'), admin_product_product_properties_path(@product) %>
|
10
|
+
| <%= link_to t('spree.admin_bar.stock'), admin_product_stock_path(@product) %>
|
11
|
+
<% if defined? Spree::Relation %>
|
12
|
+
| <%= link_to t('spree.admin_bar.related'), related_admin_product_path(@product) %>
|
13
|
+
<% end %>
|
14
|
+
<!-- | <%#= link_to t('spree.admin_bar.delete_product'), admin_product_path(@product), data: { confirm: t('spree.admin_bar.are_you_sure')}, method: :delete %> -->
|
15
|
+
<% elsif @taxon %>
|
16
|
+
<%= link_to t('spree.admin_bar.edit_taxonomy'), edit_admin_taxonomy_path(@taxon.taxonomy) %>
|
17
|
+
| <%= link_to 'Edit Taxon', edit_admin_taxonomy_taxon_path(@taxon.taxonomy.id, @taxon.id) %>
|
18
|
+
<% elsif defined? Spree::Page and @page %>
|
19
|
+
<%= link_to t('spree.admin_bar.edit_page'), edit_admin_page_path(@page) %>
|
20
|
+
<% end %>
|
21
|
+
</div>
|
22
|
+
<% end %>
|
data/bin/console
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
5
|
+
require "bundler/setup"
|
6
|
+
require "solidus_admin_bar"
|
7
|
+
|
8
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
9
|
+
# with your gem easier. You can also use a different console, if you like.
|
10
|
+
$LOAD_PATH.unshift(*Dir["#{__dir__}/../app/*"])
|
11
|
+
|
12
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
13
|
+
# require "pry"
|
14
|
+
# Pry.start
|
15
|
+
|
16
|
+
require "irb"
|
17
|
+
IRB.start(__FILE__)
|
data/bin/rails
ADDED
data/bin/rails-engine
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails gems
|
3
|
+
# installed from the root of your application.
|
4
|
+
|
5
|
+
ENGINE_ROOT = File.expand_path('..', __dir__)
|
6
|
+
ENGINE_PATH = File.expand_path('../lib/solidus_admin_bar/engine', __dir__)
|
7
|
+
|
8
|
+
# Set up gems listed in the Gemfile.
|
9
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
|
10
|
+
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
|
11
|
+
|
12
|
+
require 'rails/all'
|
13
|
+
require 'rails/engine/commands'
|
data/bin/rails-sandbox
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
app_root = 'sandbox'
|
4
|
+
|
5
|
+
unless File.exist? "#{app_root}/bin/rails"
|
6
|
+
warn 'Creating the sandbox app...'
|
7
|
+
Dir.chdir "#{__dir__}/.." do
|
8
|
+
system "#{__dir__}/sandbox" or begin
|
9
|
+
warn 'Automatic creation of the sandbox app failed'
|
10
|
+
exit 1
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
Dir.chdir app_root
|
16
|
+
exec 'bin/rails', *ARGV
|
data/bin/rake
ADDED
data/bin/sandbox
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
set -e
|
4
|
+
|
5
|
+
case "$DB" in
|
6
|
+
postgres|postgresql)
|
7
|
+
RAILSDB="postgresql"
|
8
|
+
;;
|
9
|
+
mysql)
|
10
|
+
RAILSDB="mysql"
|
11
|
+
;;
|
12
|
+
sqlite|'')
|
13
|
+
RAILSDB="sqlite3"
|
14
|
+
;;
|
15
|
+
*)
|
16
|
+
echo "Invalid DB specified: $DB"
|
17
|
+
exit 1
|
18
|
+
;;
|
19
|
+
esac
|
20
|
+
|
21
|
+
if [ ! -z $SOLIDUS_BRANCH ]
|
22
|
+
then
|
23
|
+
BRANCH=$SOLIDUS_BRANCH
|
24
|
+
else
|
25
|
+
BRANCH="master"
|
26
|
+
fi
|
27
|
+
|
28
|
+
extension_name="solidus_admin_bar"
|
29
|
+
|
30
|
+
# Stay away from the bundler env of the containing extension.
|
31
|
+
function unbundled {
|
32
|
+
ruby -rbundler -e'b = proc {system *ARGV}; Bundler.respond_to?(:with_unbundled_env) ? Bundler.with_unbundled_env(&b) : Bundler.with_clean_env(&b)' -- $@
|
33
|
+
}
|
34
|
+
|
35
|
+
rm -rf ./sandbox
|
36
|
+
unbundled bundle exec rails new sandbox --database="$RAILSDB" \
|
37
|
+
--skip-bundle \
|
38
|
+
--skip-git \
|
39
|
+
--skip-keeps \
|
40
|
+
--skip-rc \
|
41
|
+
--skip-spring \
|
42
|
+
--skip-test \
|
43
|
+
--skip-javascript
|
44
|
+
|
45
|
+
if [ ! -d "sandbox" ]; then
|
46
|
+
echo 'sandbox rails application failed'
|
47
|
+
exit 1
|
48
|
+
fi
|
49
|
+
|
50
|
+
cd ./sandbox
|
51
|
+
cat <<RUBY >> Gemfile
|
52
|
+
gem 'solidus', github: 'solidusio/solidus', branch: '$BRANCH'
|
53
|
+
gem 'solidus_auth_devise', '>= 2.1.0'
|
54
|
+
gem 'rails-i18n'
|
55
|
+
gem 'solidus_i18n'
|
56
|
+
|
57
|
+
gem '$extension_name', path: '..'
|
58
|
+
|
59
|
+
group :test, :development do
|
60
|
+
platforms :mri do
|
61
|
+
gem 'pry-byebug'
|
62
|
+
end
|
63
|
+
end
|
64
|
+
RUBY
|
65
|
+
|
66
|
+
unbundled bundle install --gemfile Gemfile
|
67
|
+
|
68
|
+
unbundled bundle exec rake db:drop db:create
|
69
|
+
|
70
|
+
unbundled bundle exec rails generate solidus:install \
|
71
|
+
--auto-accept \
|
72
|
+
--user_class=Spree::User \
|
73
|
+
--enforce_available_locales=true \
|
74
|
+
--with-authentication=false \
|
75
|
+
--payment-method=none \
|
76
|
+
$@
|
77
|
+
|
78
|
+
unbundled bundle exec rails generate solidus:auth:install
|
79
|
+
unbundled bundle exec rails generate ${extension_name}:install
|
80
|
+
|
81
|
+
echo
|
82
|
+
echo "🚀 Sandbox app successfully created for $extension_name!"
|
83
|
+
echo "🚀 Using $RAILSDB and Solidus $BRANCH"
|
84
|
+
echo "🚀 Use 'export DB=[postgres|mysql|sqlite]' to control the DB adapter"
|
85
|
+
echo "🚀 Use 'export SOLIDUS_BRANCH=<BRANCH-NAME>' to control the Solidus version"
|
86
|
+
echo "🚀 This app is intended for test purposes."
|
data/bin/setup
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
en:
|
2
|
+
spree:
|
3
|
+
admin_bar:
|
4
|
+
admin_dashboard_name: Dashboard
|
5
|
+
edit_product: Edit Product
|
6
|
+
images: Images
|
7
|
+
variants: Variants
|
8
|
+
prices: Prices
|
9
|
+
properties: Properties
|
10
|
+
stock: Stock
|
11
|
+
related: Related
|
12
|
+
delete_product: Delete Product
|
13
|
+
edit_taxonomy: Edit Taxonomy
|
14
|
+
are_you_sure: Are you sure you want to delete this product?
|
15
|
+
edit_page: Edit Page
|
data/config/routes.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SolidusAdminBar
|
4
|
+
module Generators
|
5
|
+
class InstallGenerator < Rails::Generators::Base
|
6
|
+
class_option :auto_run_migrations, type: :boolean, default: false
|
7
|
+
source_root File.expand_path('templates', __dir__)
|
8
|
+
|
9
|
+
def add_stylesheets
|
10
|
+
inject_into_file 'vendor/assets/stylesheets/spree/frontend/all.css', " *= require spree/frontend/solidus_admin_bar\n", before: %r{\*/}, verbose: true # rubocop:disable Layout/LineLength
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SolidusAdminBar
|
4
|
+
class Configuration
|
5
|
+
# Define here the settings for this extension, e.g.:
|
6
|
+
#
|
7
|
+
# attr_accessor :my_setting
|
8
|
+
end
|
9
|
+
|
10
|
+
class << self
|
11
|
+
def configuration
|
12
|
+
@configuration ||= Configuration.new
|
13
|
+
end
|
14
|
+
|
15
|
+
alias config configuration
|
16
|
+
|
17
|
+
def configure
|
18
|
+
yield configuration
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'solidus_core'
|
4
|
+
require 'solidus_support'
|
5
|
+
|
6
|
+
module SolidusAdminBar
|
7
|
+
class Engine < Rails::Engine
|
8
|
+
include SolidusSupport::EngineExtensions
|
9
|
+
|
10
|
+
isolate_namespace ::Spree
|
11
|
+
|
12
|
+
engine_name 'solidus_admin_bar'
|
13
|
+
|
14
|
+
# use rspec for tests
|
15
|
+
config.generators do |g|
|
16
|
+
g.test_framework :rspec
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'lib/solidus_admin_bar/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'solidus_admin_bar'
|
7
|
+
spec.version = SolidusAdminBar::VERSION
|
8
|
+
spec.authors = ['QuintinAdam']
|
9
|
+
spec.email = 'quintinjadam@gmail.com'
|
10
|
+
|
11
|
+
spec.summary = 'Quick admin actions for Solidus frontend'
|
12
|
+
spec.description = 'Quick admin actions for Solidus frontend.'
|
13
|
+
spec.homepage = 'https://github.com/QuintinAdam/solidus_admin_bar#readme'
|
14
|
+
spec.license = 'BSD-3-Clause'
|
15
|
+
|
16
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
17
|
+
spec.metadata['source_code_uri'] = 'https://github.com/QuintinAdam/solidus_admin_bar'
|
18
|
+
spec.metadata['changelog_uri'] = 'https://github.com/QuintinAdam/solidus_admin_bar/blob/master/CHANGELOG.md'
|
19
|
+
|
20
|
+
spec.required_ruby_version = Gem::Requirement.new('~> 2.5')
|
21
|
+
|
22
|
+
# Specify which files should be added to the gem when it is released.
|
23
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
24
|
+
files = Dir.chdir(__dir__) { `git ls-files -z`.split("\x0") }
|
25
|
+
|
26
|
+
spec.files = files.grep_v(%r{^(test|spec|features)/})
|
27
|
+
spec.test_files = files.grep(%r{^(test|spec|features)/})
|
28
|
+
spec.bindir = "exe"
|
29
|
+
spec.executables = files.grep(%r{^exe/}) { |f| File.basename(f) }
|
30
|
+
spec.require_paths = ["lib"]
|
31
|
+
|
32
|
+
spec.add_dependency 'solidus_core', ['>= 2.0.0', '< 4']
|
33
|
+
spec.add_dependency 'solidus_support', '~> 0.5'
|
34
|
+
|
35
|
+
spec.add_development_dependency 'solidus_dev_support', '~> 2.5'
|
36
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Configure Rails Environment
|
4
|
+
ENV['RAILS_ENV'] = 'test'
|
5
|
+
|
6
|
+
# Run Coverage report
|
7
|
+
require 'solidus_dev_support/rspec/coverage'
|
8
|
+
|
9
|
+
# Create the dummy app if it's still missing.
|
10
|
+
dummy_env = "#{__dir__}/dummy/config/environment.rb"
|
11
|
+
system 'bin/rake extension:test_app' unless File.exist? dummy_env
|
12
|
+
require dummy_env
|
13
|
+
|
14
|
+
# Requires factories and other useful helpers defined in spree_core.
|
15
|
+
require 'solidus_dev_support/rspec/feature_helper'
|
16
|
+
|
17
|
+
# Requires supporting ruby files with custom matchers and macros, etc,
|
18
|
+
# in spec/support/ and its subdirectories.
|
19
|
+
Dir["#{__dir__}/support/**/*.rb"].sort.each { |f| require f }
|
20
|
+
|
21
|
+
# Requires factories defined in lib/solidus_admin_bar/testing_support/factories.rb
|
22
|
+
SolidusDevSupport::TestingSupport::Factories.load_for(SolidusAdminBar::Engine)
|
23
|
+
|
24
|
+
Capybara.register_driver :selenium_chrome_headless do |app|
|
25
|
+
browser_options = ::Selenium::WebDriver::Chrome::Options.new
|
26
|
+
browser_options.args << '--headless'
|
27
|
+
browser_options.args << '--disable-gpu'
|
28
|
+
browser_options.args << '--window-size=1920,1080'
|
29
|
+
Capybara::Selenium::Driver.new(app, browser: :chrome, options: browser_options)
|
30
|
+
end
|
31
|
+
|
32
|
+
RSpec.configure do |config|
|
33
|
+
config.infer_spec_type_from_file_location!
|
34
|
+
config.use_transactional_fixtures = true
|
35
|
+
|
36
|
+
config.before :suite do
|
37
|
+
DatabaseCleaner.clean_with :truncation
|
38
|
+
end
|
39
|
+
|
40
|
+
if Spree.solidus_gem_version < Gem::Version.new('2.11')
|
41
|
+
config.extend Spree::TestingSupport::AuthorizationHelpers::Request, type: :system
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
@@ -0,0 +1,154 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
context 'admin bar home page' do
|
6
|
+
context "an admin user" do
|
7
|
+
before do
|
8
|
+
sign_in_as_admin!
|
9
|
+
visit spree.root_path
|
10
|
+
end
|
11
|
+
it "should display the admin bar and links to dashboard" do
|
12
|
+
within('#admin_bar'){ click_link 'Dashboard' }
|
13
|
+
expect(current_path).to eq(spree.admin_orders_path)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
it "does not allow a regular user to see the admin bar" do
|
18
|
+
sign_in_as_user!
|
19
|
+
visit spree.root_path
|
20
|
+
expect(page).not_to have_content('Dashboard')
|
21
|
+
end
|
22
|
+
|
23
|
+
it "does not allow a guest user to see the admin bar" do
|
24
|
+
visit spree.root_path
|
25
|
+
expect(page).not_to have_content('Dashboard')
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe 'products admin bar' do
|
30
|
+
let!(:product) { create(:product, name: "Superman T-Shirt") }
|
31
|
+
context "an admin user" do
|
32
|
+
before do
|
33
|
+
sign_in_as_admin!
|
34
|
+
visit spree.root_path
|
35
|
+
click_link 'Superman T-Shirt'
|
36
|
+
end
|
37
|
+
it "can navigate to edit the product in the admin" do
|
38
|
+
within('#admin_bar'){ click_link 'Edit Product' }
|
39
|
+
expect(page).to have_content(product.name)
|
40
|
+
expect(current_path).to eq(spree.edit_admin_product_path(product))
|
41
|
+
end
|
42
|
+
it "allows an admin user to edit product images in the admin" do
|
43
|
+
within('#admin_bar'){ click_link 'Images' }
|
44
|
+
expect(current_path).to eq(spree.admin_product_images_path(product))
|
45
|
+
end
|
46
|
+
it "allows an admin user to edit variants in the admin" do
|
47
|
+
within('#admin_bar'){ click_link 'Variants' }
|
48
|
+
expect(current_path).to eq(spree.admin_product_variants_path(product))
|
49
|
+
end
|
50
|
+
it "allows an admin user to edit prices in the admin" do
|
51
|
+
within('#admin_bar'){ click_link 'Prices' }
|
52
|
+
expect(current_path).to eq(spree.admin_product_prices_path(product))
|
53
|
+
end
|
54
|
+
it "allows an admin user to edit properties in the admin" do
|
55
|
+
within('#admin_bar'){ click_link 'Properties' }
|
56
|
+
expect(current_path).to eq(spree.admin_product_product_properties_path(product))
|
57
|
+
end
|
58
|
+
it "allows an admin user to edit stock in the admin" do
|
59
|
+
within('#admin_bar'){ click_link 'Stock' }
|
60
|
+
expect(current_path).to eq(spree.admin_product_stock_path(product))
|
61
|
+
end
|
62
|
+
# it "allows an admin user to edit related products in the admin" do
|
63
|
+
# within('#admin_bar'){ click_link 'Related' }
|
64
|
+
# expect(current_path).to eq(spree.related_admin_product_path(product))
|
65
|
+
# end
|
66
|
+
end
|
67
|
+
|
68
|
+
it "does not allow a regular user to navigate to the admin" do
|
69
|
+
sign_in_as_user!
|
70
|
+
visit spree.root_path
|
71
|
+
click_link 'Superman T-Shirt'
|
72
|
+
expect(page).not_to have_content('Dashboard')
|
73
|
+
expect(page).to_not have_content('Edit Product')
|
74
|
+
end
|
75
|
+
|
76
|
+
it "does not allow a guest user to navigate to the admin" do
|
77
|
+
visit spree.root_path
|
78
|
+
click_link 'Superman T-Shirt'
|
79
|
+
expect(page).not_to have_content('Dashboard')
|
80
|
+
expect(page).to_not have_content('Edit Product')
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
describe 'taxons admin bar' do
|
85
|
+
let!(:taxonomy) { create(:taxonomy, name: "Category") }
|
86
|
+
let!(:taxon) { taxonomy.root.children.create(name: "Clothing", taxonomy_id: taxonomy.id) }
|
87
|
+
context "an admin user" do
|
88
|
+
before do
|
89
|
+
sign_in_as_admin!
|
90
|
+
visit spree.root_path
|
91
|
+
click_link 'Clothing'
|
92
|
+
end
|
93
|
+
it "can navigate to edit the taxonomy in the admin" do
|
94
|
+
within('#admin_bar'){ click_link 'Edit Taxonomy' }
|
95
|
+
expect(current_path).to eq(spree.edit_admin_taxonomy_path(taxonomy))
|
96
|
+
end
|
97
|
+
it "can navigate to edit the taxon in the admin" do
|
98
|
+
within('#admin_bar'){ click_link 'Edit Taxon' }
|
99
|
+
expect(current_path).to eq(spree.edit_admin_taxonomy_taxon_path(taxonomy.id, taxon.id))
|
100
|
+
end
|
101
|
+
end
|
102
|
+
it "does not allow a normal user to navigate to the admin" do
|
103
|
+
sign_in_as_user!
|
104
|
+
visit spree.root_path
|
105
|
+
click_link 'Clothing'
|
106
|
+
expect(page).not_to have_content('Dashboard')
|
107
|
+
expect(page).to_not have_content('Edit Taxonomy')
|
108
|
+
expect(page).to_not have_content('Edit Taxon')
|
109
|
+
end
|
110
|
+
it "does not allow a guest user to navigate to the admin" do
|
111
|
+
visit spree.root_path
|
112
|
+
click_link 'Clothing'
|
113
|
+
expect(page).not_to have_content('Dashboard')
|
114
|
+
expect(page).to_not have_content('Edit Taxonomy')
|
115
|
+
expect(page).to_not have_content('Edit Taxon')
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
# describe 'pages admin bar' do
|
120
|
+
# let!(:store) { create(:store, default: true) }
|
121
|
+
# let!(:content_page) { Spree::Page.create!(slug: '/page2', title: 'TestPage2', body: 'Body2', visible: true, stores: [store]) }
|
122
|
+
# it "an admin user can navigate to edit the page in the admin" do
|
123
|
+
# sign_in_as_admin!
|
124
|
+
# visit '/page2'
|
125
|
+
# expect(page).to have_content('Edit Page')
|
126
|
+
# within('#admin_bar'){ click_link 'Edit Page' }
|
127
|
+
# current_path.expect == spree.edit_admin_page_path(content_page)
|
128
|
+
# end
|
129
|
+
# it "does not allow a regular user to navigate to the admin" do
|
130
|
+
# visit '/page2'
|
131
|
+
# page.expect_not have_content('Edit Page')
|
132
|
+
# end
|
133
|
+
# end
|
134
|
+
|
135
|
+
def sign_in_as_admin!
|
136
|
+
user = create(:admin_user)
|
137
|
+
visit '/login'
|
138
|
+
fill_in 'Email', with: user.email
|
139
|
+
fill_in 'Password', with: 'secret'
|
140
|
+
click_button 'Login'
|
141
|
+
end
|
142
|
+
|
143
|
+
def sign_in_as_user!
|
144
|
+
user = create(:user)
|
145
|
+
visit '/login'
|
146
|
+
fill_in 'Email', with: user.email
|
147
|
+
fill_in 'Password', with: 'secret'
|
148
|
+
click_button 'Login'
|
149
|
+
end
|
150
|
+
|
151
|
+
def create_taxon
|
152
|
+
taxonomy = create(:taxonomy, name: "Category")
|
153
|
+
create(:taxon, name: "T-Shirts", parent: taxonomy.root, taxonomy: taxonomy)
|
154
|
+
end
|
metadata
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: solidus_admin_bar
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 3.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- QuintinAdam
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-07-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: solidus_core
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.0.0
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '4'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 2.0.0
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '4'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: solidus_support
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0.5'
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0.5'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: solidus_dev_support
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '2.5'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '2.5'
|
61
|
+
description: Quick admin actions for Solidus frontend.
|
62
|
+
email: quintinjadam@gmail.com
|
63
|
+
executables: []
|
64
|
+
extensions: []
|
65
|
+
extra_rdoc_files: []
|
66
|
+
files:
|
67
|
+
- ".circleci/config.yml"
|
68
|
+
- ".gem_release.yml"
|
69
|
+
- ".github/stale.yml"
|
70
|
+
- ".github_changelog_generator"
|
71
|
+
- ".gitignore"
|
72
|
+
- ".rspec"
|
73
|
+
- ".rubocop.yml"
|
74
|
+
- CHANGELOG.md
|
75
|
+
- Gemfile
|
76
|
+
- LICENSE
|
77
|
+
- README.md
|
78
|
+
- Rakefile
|
79
|
+
- app/assets/stylesheets/spree/frontend/solidus_admin_bar.scss
|
80
|
+
- app/overrides/admin_bar.rb
|
81
|
+
- app/views/spree/admin_bar/_admin_bar.html.erb
|
82
|
+
- bin/console
|
83
|
+
- bin/rails
|
84
|
+
- bin/rails-engine
|
85
|
+
- bin/rails-sandbox
|
86
|
+
- bin/rake
|
87
|
+
- bin/sandbox
|
88
|
+
- bin/setup
|
89
|
+
- config/locales/en.yml
|
90
|
+
- config/routes.rb
|
91
|
+
- lib/generators/solidus_admin_bar/install/install_generator.rb
|
92
|
+
- lib/solidus_admin_bar.rb
|
93
|
+
- lib/solidus_admin_bar/configuration.rb
|
94
|
+
- lib/solidus_admin_bar/engine.rb
|
95
|
+
- lib/solidus_admin_bar/testing_support/factories.rb
|
96
|
+
- lib/solidus_admin_bar/version.rb
|
97
|
+
- solidus_admin_bar.gemspec
|
98
|
+
- spec/spec_helper.rb
|
99
|
+
- spec/system/admin_bar_spec.rb
|
100
|
+
homepage: https://github.com/QuintinAdam/solidus_admin_bar#readme
|
101
|
+
licenses:
|
102
|
+
- BSD-3-Clause
|
103
|
+
metadata:
|
104
|
+
homepage_uri: https://github.com/QuintinAdam/solidus_admin_bar#readme
|
105
|
+
source_code_uri: https://github.com/QuintinAdam/solidus_admin_bar
|
106
|
+
changelog_uri: https://github.com/QuintinAdam/solidus_admin_bar/blob/master/CHANGELOG.md
|
107
|
+
post_install_message:
|
108
|
+
rdoc_options: []
|
109
|
+
require_paths:
|
110
|
+
- lib
|
111
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - "~>"
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '2.5'
|
116
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
requirements: []
|
122
|
+
rubygems_version: 3.1.6
|
123
|
+
signing_key:
|
124
|
+
specification_version: 4
|
125
|
+
summary: Quick admin actions for Solidus frontend
|
126
|
+
test_files:
|
127
|
+
- spec/spec_helper.rb
|
128
|
+
- spec/system/admin_bar_spec.rb
|