Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SolidusAdmin #5068

Merged
merged 344 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
344 commits
Select commit Hold shift + click to select a range
81b4974
Show stimulus debug messages for local development
elia Jun 26, 2023
e51d0e7
Fix the component spec generator class and helper name
elia Jul 3, 2023
e4e0c3b
Add a spec for the component generator to avoid regressions
elia Jul 3, 2023
1aece89
Add sizes support to the ui/badge component
elia Jun 30, 2023
f812157
Add support for view_component previews
elia Jun 30, 2023
df51dc5
Add previews and specs for the ui/badge component
elia Jun 30, 2023
4bb907f
Generate component previews along with components
elia Jul 3, 2023
6c0b848
Add a color to the theme instead of hardcoding it
elia Jul 4, 2023
467c572
Replace hardcoded tailwind pixel values with spacing values
elia Jul 4, 2023
119ac99
Replace the max width for the image column
elia Jul 4, 2023
870d6ba
Add basic state styles to the main navigation
waiting-for-dev Jun 27, 2023
20e5f54
Move nav item markup to a template
waiting-for-dev Jun 28, 2023
4b93321
Set up nested main nav items for the admin
waiting-for-dev Jun 28, 2023
25a80d9
Style :hover on admin main navigation
waiting-for-dev Jun 29, 2023
34740df
Set up admin's main navigation routes
waiting-for-dev Jul 3, 2023
ccf8818
Handle active admin menu items from admin main navigation
waiting-for-dev Jul 3, 2023
ea791e8
Hide container details from the user to configure admin main navigation
waiting-for-dev Jul 3, 2023
c677219
Document admin main menu configuration
waiting-for-dev Jul 3, 2023
cc49e95
Use remix icons for admin's main navigation items
waiting-for-dev Jul 4, 2023
cc7ed6e
Use a context object to resolve admin man nav components
waiting-for-dev Jul 5, 2023
e22de02
Fix sidebar background color
waiting-for-dev Jul 5, 2023
69a1270
Set the generator root for solidus_admin testing to the toplevel tmp …
elia Jul 5, 2023
8effe6d
Remove unaccounted param from generated component previews
elia Jul 5, 2023
ac7e8df
Keep all preview related generic helpers into a module
elia Jul 5, 2023
d19f1f6
Add a preview and spec for the ui/table component
elia Jul 5, 2023
4b69036
Use the correct type for component preview YARD param directives
elia Jul 6, 2023
7fa58b8
Add the preview for the sidebar admin component
waiting-for-dev Jul 6, 2023
aeda743
Normalize cell content generation in the ui/table component
elia Jul 5, 2023
092eedb
Provide columns as an array to the ui/table component initializer
elia Jul 5, 2023
38cf775
Add a ui/checkbox component
elia Jul 7, 2023
ccaae19
Do not modify core routes in the base component specs
elia Jul 10, 2023
202db17
Add SolidusAdmin to the dummy app routes
elia Jul 6, 2023
cc4d504
Only show a product image if present on the product
elia Jul 6, 2023
16ad16c
Add solidus_backend to solidus_admin's dependecies
elia Jul 10, 2023
eb40ef7
Add a basic spec for the product listing
elia Jul 10, 2023
3fbc0c5
Fix typo in component preview HTML file
elia Jul 10, 2023
86169fb
Add a basic ui/button component
elia Jul 10, 2023
f4dc3cb
Configure admin's typography
waiting-for-dev Jul 10, 2023
757565e
Showcase admin typography classes in lookbook
waiting-for-dev Jul 10, 2023
df4dee4
Fix extension on erb file
waiting-for-dev Jul 11, 2023
6f4d4b3
Remove redundant tailwindcss dependency from admin
waiting-for-dev Jul 12, 2023
db71416
Improve component generator docs
kennyadsl Jul 11, 2023
8020666
Extract sidebar item's icon to a proper helper
kennyadsl Jul 12, 2023
817c2ea
Avoid specifying sidebar's icon fill color manually
kennyadsl Jul 12, 2023
af4783a
Add component preview for the sidebar item component
waiting-for-dev Jul 7, 2023
21bec92
Make clear that the component product methods are public and customiz…
waiting-for-dev Jun 23, 2023
8e22041
Add a Toast component
kennyadsl Jul 11, 2023
37ea2ac
Move the compiled tailwind config to a known location
elia Jul 13, 2023
0708f79
Adds HTML titles to admin pages
waiting-for-dev Jul 13, 2023
a851919
Fix accessibility for empty column headers in admin tables
waiting-for-dev Jul 13, 2023
6cf627e
Fix HTML tag not specifying language in the admin
waiting-for-dev Jul 13, 2023
9944dd2
Fix nested main menu items wrapped within "nav" instead of "ul"
waiting-for-dev Jul 13, 2023
509637b
Add h1 to products index page
waiting-for-dev Jul 13, 2023
fd086f4
Add automatic testing for accessibility in the new admin
waiting-for-dev Jul 13, 2023
3df0454
Show flash messages with the ui/toast component
elia Jul 12, 2023
c7a7eda
Add a missing join to the `ui/toast` component
elia Jul 14, 2023
490fb1d
Add account navigation component for the new admin
waiting-for-dev Jul 11, 2023
fb8210f
Add a `ui/tab` component
elia Jul 11, 2023
e7d106c
Add a dummy scopes toolbar to the ui/table component
elia Jul 12, 2023
7745c03
Add `geared_pagination` gem
rainerdema Jul 13, 2023
a6e3217
Implement pagination in Admin Products listing
rainerdema Jul 17, 2023
302f747
Introduce a `ui/pagination` component
rainerdema Jul 17, 2023
b914c18
Integrate `ui/pagination` component with `ui/table` component
rainerdema Jul 17, 2023
bbefebc
Refactor Products Index view to use the table component with pagination
rainerdema Jul 17, 2023
8360260
Reallocate Pagination Component into Table Component Module
rainerdema Jul 17, 2023
01cf54a
Cleanup unused ui/table component classes
elia Jul 13, 2023
abed8e9
Load hotwire gems when loading solidus_admin
elia Jul 17, 2023
e11f5ae
Use the digest path as the favicon for solidus_admin
elia Jul 17, 2023
87f74d8
Fix the ui/checkbox component style when focused & checked
elia Jul 18, 2023
550d344
Add missing items to the admin main navigation
waiting-for-dev Jul 20, 2023
4d3b2af
Inline ui/table components `render_cell` helper
elia Jul 19, 2023
ed07d0a
Support static strings in ui/table headers and columns
elia Jul 19, 2023
bec9ed8
Use a fixed layout for the ui/table component
elia Jul 18, 2023
e53f3b2
Move some ui/table header classes from `th` to `thead`
elia Jul 18, 2023
7e13fe1
Improve the style of ui/table data cells
elia Jul 18, 2023
3e9f56c
Enable partial double verification for admin specs
elia Jul 19, 2023
7d4430e
Keep translation files organized per controller
elia Jul 19, 2023
7d55601
Fallback on id for admin product index sorting
elia Jul 17, 2023
bb1ad76
Add text for the admin product/index image column header
elia Jul 17, 2023
bf10402
Set the role for the flash messages area
elia Jul 19, 2023
aa32692
Tweak admin sidebar styles
waiting-for-dev Jul 20, 2023
7575f1c
Add tailwind variants for the hidden attribute
elia Jul 19, 2023
2effa74
Accept a list of batch actions in the ui/table component
elia Jul 12, 2023
1f26428
Add batch actions checkboxes to the ui/table component
elia Jul 12, 2023
c5c7c85
Add a header for batch action buttons to the ui/table component
elia Jul 12, 2023
5fe547d
Add a header for the selected rows counter to the ui/table component
elia Jul 12, 2023
23f3dd2
Add a batch actions form to the ui/table component
elia Jul 12, 2023
94816de
Toggle toolbars and update the counter in the ui/table component
elia Jul 12, 2023
377e549
Add delete, discontinue, and activate actions to the products/index c…
elia Jul 12, 2023
f180761
Add labels to the batch actions checkboxes
elia Jul 17, 2023
8fa62fe
Use blank alt attribute for the decorative admin logo image
waiting-for-dev Jul 20, 2023
6e7ff48
Keep components classes into instance variables
elia Jul 17, 2023
1240cb6
Allow the button component to be rendered as a link
elia Jul 20, 2023
696d575
Add an "Add Product" button to the products/index component
elia Jul 20, 2023
31a7ce8
Make account navigation browsable by keyboard
waiting-for-dev Jul 21, 2023
2b29bae
Make admin account nav accessible by screen readers
waiting-for-dev Jul 21, 2023
e039f10
Add a skip link to the admin interface
waiting-for-dev Jul 21, 2023
bb3abed
Use the global icon helper for icons in the toast component
waiting-for-dev Jul 21, 2023
0cd4022
Hide decorative svg from screen readers
waiting-for-dev Jul 21, 2023
bae12fc
Make admin pagination accessible
waiting-for-dev Jul 21, 2023
ffb6d41
Mark product images as decorative by giving an empty alt attribute
waiting-for-dev Jul 21, 2023
6e19576
Skip duplicate product link when tabbing through product rows
waiting-for-dev Jul 21, 2023
8dc406a
Make the toast component accessible
waiting-for-dev Jul 21, 2023
b0c39ca
Mark the current admin link in the main mav for accessibility
waiting-for-dev Jul 21, 2023
9c1ea05
Keep the layout styles in the same file
elia Jul 20, 2023
d403cc8
Match the style of the upper sidebar between the two admins
elia Jul 20, 2023
c5357ec
Add alt names to images wrapped in links
elia Jul 24, 2023
62ee80c
Round hovered items in the sidebar
elia Jul 24, 2023
add4b0c
Replace the account nav toggle with a details element
elia Jul 24, 2023
59889c5
Remove unnecessary translation namespace from account nav translations
elia Jul 24, 2023
9e30792
Hide icons from screen readers by default
elia Jul 24, 2023
363754b
Use a single nav element
elia Jul 24, 2023
d315456
Move the icon to a full-blown `ui/icon` component
elia Jul 25, 2023
b24954c
Use the `class:` keyword argument for the `ui/button` component
elia Jul 26, 2023
b520799
Add icons to the ui/button component
elia Jul 26, 2023
47eaf37
Fix the icon for the new product button
elia Jul 27, 2023
c1e70f9
Allow the button to appear disabled if rendered as an anchor
elia Jul 27, 2023
de733e3
Use `aria-current` and `aria-disabled` instead of custom data-ui attr…
elia Jul 27, 2023
06b6d14
Set the ui/tab component class attribute in the initializer
elia Jul 27, 2023
171a17a
Let the ui/tab component only render as an anchor element
elia Jul 27, 2023
cd6321d
Add the `component` helper to preview templates
elia Jul 27, 2023
c2ab910
Move the ui/table component preview to a template
elia Jul 27, 2023
fe0aa27
Simplify the pagination component to just accept a prev and next link
elia Jul 27, 2023
6f6ddb2
Reimplement the pagination as `ui/button` components
elia Jul 26, 2023
15ee583
Add configuration endpoints for the admin authentication
elia Jul 3, 2023
ed2ad24
Start out by reusing the solidus_backend authentication method in the…
elia Jul 3, 2023
d5f1566
Add authorization stub before running specs
the-krg Jul 26, 2023
d8445d8
Keep `ui/table/pagination` button component class into instance varia…
rainerdema Jul 27, 2023
c77457b
Turn ui/table modes into stimulus values
elia Jul 28, 2023
1660577
Prettify long lines in ui/table component.js
elia Jul 28, 2023
6eb8399
Extract the ui/table plural resource name to a helper
elia Jul 28, 2023
0d59a9d
Remove dummy log from application.js
elia Jul 31, 2023
451c1f1
Add debounce() to JavaScript utility functions
elia Jul 31, 2023
ee4a1b9
Add the search toolbar to the ui/table component
elia Jul 28, 2023
c347a76
Decouple the ui/table component from the pagination implementation
elia Jul 31, 2023
ea2c3f0
Always render the batch actions toolbar
elia Jul 31, 2023
ce4068b
Connect the ui/table search bar to the controller
elia Jul 31, 2023
8624cfa
Add Turbo for live search in `ui/table` component
elia Jul 31, 2023
8b17b54
Introduce `product_search_key` configuration for admin search
rainerdema Jul 26, 2023
90134bb
Accept any callable instead of just Procs as table cells
elia Jul 26, 2023
aa0c995
Move product/index columns and batch actions to the component class
elia Jul 26, 2023
0985c7b
Fix the ui/table footer background color
elia Aug 1, 2023
d6c7272
Extract the feature spec sign_in helper
elia Aug 1, 2023
7837338
Use the current admin user page as the account path
elia Jul 31, 2023
7039d71
Add a helper to stub authorization when visiting backend pages
elia Aug 1, 2023
9354a4d
Use the ui/icon component to render the sidebar arrow
elia Jul 31, 2023
98a7ba1
Open the current store within a blank page
elia Jul 31, 2023
e46dc8e
Automatically include the backend auth adapter if Spree::Backend is d…
elia Aug 1, 2023
6041776
Connect the sidebar/account_nav component to the authentication helpers
elia Jul 31, 2023
1fbcb8c
Only accept strings for the `logout_link_path` configuration value
elia Aug 1, 2023
8ebe9a6
Add filter toolbar to table component
rainerdema Aug 2, 2023
46092ef
Add filter for discarded products
rainerdema Aug 2, 2023
d61bc96
Add external id param to enhance table component flexibility
rainerdema Aug 3, 2023
70b3780
Add clear button visibility check for search input
rainerdema Aug 3, 2023
ed8791e
Fix some spacing in the sidebar/account_nav component
elia Aug 2, 2023
2a4e87a
Add support for changing locale in the sidebar/account_nav component
elia Aug 2, 2023
4275c9f
Fallback on the default locale for component missing translations
elia Aug 3, 2023
cfae16f
Move the auth controller helper module to a dedicated namespace
elia Aug 3, 2023
a3b5f2a
Extract the locale helpers to a dedicated namespace
elia Aug 3, 2023
3de99ee
Don't override the admin locale session key
elia Aug 3, 2023
965113b
Add admin ui/forms/switch component
the-krg Aug 3, 2023
4a4dfdb
Use the newer tag syntax in the ui/icon component
elia Aug 4, 2023
2d67932
Keep menu item tailwind classes and translation keys in the template
elia Aug 4, 2023
c4cc5db
Adjust the spacing of the admin menu items
elia Aug 4, 2023
3514866
Align menu items between SolidusAdmin and backend
elia Aug 4, 2023
3a01983
Move the item translations out of the component
elia Aug 4, 2023
71168db
Align the admin and backend logo SVGs
elia Aug 4, 2023
56ae773
Move product index title logic to the component class
waiting-for-dev Aug 7, 2023
bde41f4
Add missing translation for the cancel button in admin filters
waiting-for-dev Aug 8, 2023
4fe24d4
Use shared Solidus logo for the admin
waiting-for-dev Aug 8, 2023
63eba3c
Remove unused data controller
the-krg Aug 8, 2023
ef512d1
Add toggle for new solidus admin on sidebar
the-krg Aug 8, 2023
01053b7
Fix the spacing for the index action area
elia Aug 8, 2023
c5b2d18
Add a button for giving feedback to the products page
elia Aug 8, 2023
d972268
Focus on the search field when rendered
waiting-for-dev Aug 9, 2023
fade16c
Add a label to the batch actions section to make it a landmark
waiting-for-dev Aug 9, 2023
5f7201d
Give role search to all the search and filters area
waiting-for-dev Aug 9, 2023
98469b8
Use "search" type for the search field in the admin UI
waiting-for-dev Aug 9, 2023
1f941cf
Use native aria-label instead of hidden text for labels within search
waiting-for-dev Aug 9, 2023
51eeb58
Add text_field component to solidus_admin
waiting-for-dev Aug 17, 2023
16d92bd
Fix wrong translation key in pagination component
waiting-for-dev Aug 21, 2023
d757ceb
Remove duplicated class in the text_field component
waiting-for-dev Aug 18, 2023
83457cf
Split preview tests for the text field component
waiting-for-dev Aug 18, 2023
a077db5
Fix description not showing up for param in the text_field preview
waiting-for-dev Aug 18, 2023
636dd04
Add text_area component for the admin
waiting-for-dev Aug 18, 2023
4161e2e
Extract product status component
waiting-for-dev Aug 21, 2023
d4b1710
Add `orders/index` component based completely on the `product/index`
rainerdema Aug 14, 2023
f4878f3
Add `Only show complete orders` filter
rainerdema Aug 22, 2023
c41ccfb
Create Feedback Component
rainerdema Aug 23, 2023
7484f4a
Add 'fade_row_proc' condition to Table Component
rainerdema Aug 24, 2023
00e6951
Add toggletip component
waiting-for-dev Aug 25, 2023
dc91886
Fix the legacy switcher not working on different paths
waiting-for-dev Aug 29, 2023
8459535
Fix color applied to the hint of disabled form fields
waiting-for-dev Aug 30, 2023
9a7d0de
Add admin's fieldset component
waiting-for-dev Aug 25, 2023
839dfb3
Add select component
waiting-for-dev Aug 30, 2023
182f93f
Add form component to the admin
waiting-for-dev Aug 29, 2023
1f5df1e
Fix parameter name in the select component
waiting-for-dev Sep 1, 2023
a077709
Make solidus_admin part of the gems required by default
elia Sep 5, 2023
fe079e8
Move the menu items configuration to a simple array
elia Sep 4, 2023
b68c2bf
Remove the MainNav configuration support classes
elia Sep 4, 2023
e51628e
Remove MainNavItem#with_child
elia Sep 4, 2023
5c68dd2
Use a Hash as the component registry
elia Sep 4, 2023
59ee02c
Drop the dependency on dry-system
elia Sep 4, 2023
a5ac22d
Rename the container_helper to components_helper
elia Sep 5, 2023
d0d7935
Stop injecting components through the initializer
elia Sep 4, 2023
fc397f9
Fix import paths in `solidus_admin/controllers/index.js`
rainerdema Sep 7, 2023
69a8832
Add a ui/panel component
elia Sep 5, 2023
e6a6975
Fix button icon spacing and sizing
elia Sep 5, 2023
7f4ca73
Adjust the admin menu layout
elia Sep 6, 2023
7fc62ba
Improve the ui/toggletip component
elia Sep 6, 2023
1e00e78
Update the deprecated data-target stimulus attributes
elia Sep 12, 2023
024c6cd
Improve the ui/forms/text_field style
elia Sep 12, 2023
78d4074
Allow SolidusAdmin to be loaded in the absence of an app
elia Sep 6, 2023
1c3ec41
Allow menu items to dynamically match paths
elia Sep 12, 2023
427e06a
Render admin components directly from controllers
elia Sep 12, 2023
50c08cf
Allow to forcefully disable the new admin dashboard via URL params
elia Sep 12, 2023
2244116
Add a missing aria-role to the batch actions toolbar
elia Sep 14, 2023
c69ade7
Add a spec for /admin/orders
elia Sep 14, 2023
6512445
Don't rely on SolidusAdmin::Engine inside the configuration
elia Sep 13, 2023
4a3aa34
Reorganize requires and constants in SolidusAdmin
elia Sep 13, 2023
9bf8494
Support only a single action as a link in the ui/panel component
elia Sep 13, 2023
8e06de4
Add a configuration for generating a product path on the storefront
elia Sep 13, 2023
4372cac
Add toggletip support for field components
elia Sep 13, 2023
68ce6a3
Add the layout and basic buttons for the products/show component
elia Sep 13, 2023
625cd87
Add the main and sidebar content for the products/show component
elia Sep 13, 2023
0395018
Use h2 for the ui/panel titles
elia Sep 14, 2023
e59b640
Fix the ui/button component focus and disabled styles
elia Sep 15, 2023
7679a4a
Add the danger scheme to the ui/button component
elia Sep 15, 2023
f66666a
Remove a leftover reference in ui/toggletip component
elia Sep 15, 2023
4e065a9
Let the products controller render the component instead of the view
elia Sep 18, 2023
b7c80d8
Add a spec showing a validation error for admin/products
elia Sep 19, 2023
4519f65
Remove the `aria-` prefix from the `role` attribute
elia Sep 19, 2023
cb3deda
Add a solidus_admin favicon
elia Sep 19, 2023
514d2e5
Add a title for the orders controller
elia Sep 19, 2023
bf0899f
Don't wrap text in the ui/badge component
elia Sep 19, 2023
442d949
Add a field component
elia Sep 15, 2023
f9e5064
Reimplement input fields using the ui/forms/field component
elia Sep 15, 2023
002c2f3
Remove unused form harness
elia Sep 15, 2023
09252f8
Add a low-level ui/input component
elia Sep 18, 2023
b4286ac
Reimplement text_field, selext, and text_area with the input component
elia Sep 18, 2023
2424e64
Disambiguate authentication and auhtorization
elia Sep 19, 2023
82545de
Ensure logout uses the correct HTTP method
elia Sep 20, 2023
a9b440c
Move authorization checks outside of the backend "auth" adapter
elia Sep 20, 2023
1d0b0e9
Put SolidusAdmin on a different version track
elia Sep 26, 2023
7efc958
Use bundler task helpers to release solidus_admin
elia Sep 26, 2023
b04a9bc
Extract the list of gems to a constant
elia Sep 27, 2023
bce1ca2
Don't try to build/install the frontend gem
elia Sep 27, 2023
9fd6307
Don't have solidus_admin as a solidus dependency
elia Sep 28, 2023
1288f9c
Keep translations for the admin dashboard toggle in core
elia Sep 29, 2023
a5372d3
Make SolidusAdmin opt-in while installing solidus
elia Sep 29, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ Style/FrozenStringLiteralComment:
- '*/lib/generators/**/*'
- '**/bin/**/*'
- '*/db/migrate/**/*'
- '*/config/importmap.rb'

# json.() is idiomatic in jbuilder files
Style/LambdaCall:
Expand All @@ -337,6 +338,7 @@ Lint/SuppressedException:

Lint/MissingSuper:
Exclude:
- '*/app/components/**/*' # components need pristine initializer methods
- 'core/lib/spree/deprecated_instance_variable_proxy.rb' # this is a known class that doesn't require super
- 'core/lib/spree/preferences/configuration.rb' # this class has no superclass defining `self.inherited`

Expand Down
6 changes: 6 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ group :backend do
gem 'webrick', require: false
end

group :admin do
gem 'solidus_admin', path: 'admin', require: false
gem 'axe-core-rspec', '~> 4.7', require: false
gem 'axe-core-capybara', '~> 4.7', require: false
end

group :utils do
gem 'pry'
gem 'launchy', require: false
Expand Down
2 changes: 2 additions & 0 deletions Procfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
web: env RUBY_DEBUG_OPEN=true bin/rails server
admin_tailwind: bin/rails solidus_admin:tailwindcss:watch
6 changes: 4 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,16 @@ task :clean do
end
end

SOLIDUS_GEM_NAMES = %w[core api backend sample]

namespace :gem do
def version
require_relative 'core/lib/spree/core/version'
Spree.solidus_version
end

def for_each_gem
%w(core api backend frontend sample).each do |gem_name|
SOLIDUS_GEM_NAMES.each do |gem_name|
print_title(gem_name)
yield "pkg/solidus_#{gem_name}-#{version}.gem"
end
Expand All @@ -72,7 +74,7 @@ namespace :gem do
pkgdir = File.expand_path('pkg', __dir__)
FileUtils.mkdir_p pkgdir

%w(core api backend frontend sample).each do |gem_name|
SOLIDUS_GEM_NAMES.each do |gem_name|
Dir.chdir(gem_name) do
sh "gem build solidus_#{gem_name}.gemspec"
mv "solidus_#{gem_name}-#{version}.gem", pkgdir
Expand Down
7 changes: 7 additions & 0 deletions admin/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright © 2023 Solidus Team

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 changes: 31 additions & 0 deletions admin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# solidus_admin (WIP)

A Rails engine that provides an administrative interface to the Solidus ecommerce platform.

## Development

- [Customizing tailwind](docs/customizing_tailwind.md)
- [Customizing view components](docs/customizing_view_components.md)
- [Customizing the main navigation](docs/customizing_main_navigation.md)

### Adding components to Solidus Admin

When using the component generator from within the admin folder it will generate the component in the library
instead of the sandbox application.

```bash
# the `solidus_admin/` namespace is added by default
bin/rails admin g solidus_admin:component foo
create app/components/solidus_admin/foo/component.rb
create app/components/solidus_admin/foo/component.html.erb
create app/components/solidus_admin/foo/component.yml
create app/components/solidus_admin/foo/component.js
create spec/components/solidus_admin/foo/component_spec.rb
```

## Releasing

1. Update the version in `lib/solidus_admin/version.rb`
2. Commit the changes with the message `Release v1.2.3`
3. `cd admin; bundle exec rake release`
4. Manually release on GitHub
21 changes: 21 additions & 0 deletions admin/Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true

require 'rubygems'
require 'rake'
require 'rake/testtask'
require 'rspec/core/rake_task'
require 'spree/testing_support/dummy_app/rake_tasks'
require 'bundler/gem_tasks'

RSpec::Core::RakeTask.new
task default: :spec

DummyApp::RakeTasks.new(
gem_root: File.expand_path(__dir__),
lib_name: 'solidus_admin'
)

task test_app: 'db:reset'

# Namespace release tags, e.g. 'solidus_admin/v1.2.3'
Bundler::GemHelper.tag_prefix = 'solidus_admin/'
4 changes: 4 additions & 0 deletions admin/app/assets/config/solidus_admin_manifest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
//= link_tree ../images
//= link_tree ../stylesheets .css
//= link_tree ../../javascript .js
//= link_tree ../../components .js
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
11 changes: 11 additions & 0 deletions admin/app/assets/images/solidus_admin/remixicon.symbol.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions admin/app/assets/stylesheets/solidus_admin/application.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/*
* = require solidus_admin/tailwind.css
*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

@layer base {
.body-tiny {
@apply font-sans font-normal text-xs leading-5;
}

.body-tiny-bold {
@apply font-sans font-semibold text-xs leading-5;
}

.body-small {
@apply font-sans font-normal text-sm leading-6;
}

.body-small-bold {
@apply font-sans font-semibold text-sm leading-6;
}

.body-text {
@apply font-sans font-normal text-base leading-6;
}

.body-text-bold {
@apply font-sans font-semibold text-base leading-6;
}

.body-title {
@apply font-sans font-semibold text-xl leading-5;
}
}

<%= SolidusAdmin::Config.tailwind_stylesheets.map { File.read(_1) }.join("\n") %>
42 changes: 42 additions & 0 deletions admin/app/components/solidus_admin/base_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# frozen_string_literal: true

module SolidusAdmin
# BaseComponent is the base class for all components in Solidus Admin.
class BaseComponent < ViewComponent::Base
include SolidusAdmin::ComponentsHelper
include Turbo::FramesHelper

def icon_tag(name, **attrs)
render component("ui/icon").new(name: name, **attrs)
end

def missing_translation(key, options)
keys = I18n.normalize_keys(options[:locale] || I18n.locale, key, options[:scope])

logger.debug " [#{self.class}] Missing translation: #{keys.join('.')}"

if options[:locale] != :en
t(key, **options, locale: :en)
else
"translation missing: #{keys.join('.')}"
end
end

def self.stimulus_id
@stimulus_id ||= name.underscore
.sub(/^solidus_admin\/(.*)\/component$/, '\1')
.gsub("/", "--")
.tr("_", "-")
end

delegate :stimulus_id, to: :class

def spree
@spree ||= Spree::Core::Engine.routes.url_helpers
end

def solidus_admin
@solidus_admin ||= SolidusAdmin::Engine.routes.url_helpers
end
end
end
11 changes: 11 additions & 0 deletions admin/app/components/solidus_admin/feedback/component.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<span class="max-w-xs text-xs text-right text-gray-600 hidden lg:block">
<%= t(".feedback_description") %>
</span>
<%= render component("ui/button").new(
tag: :a,
text: t(".give_feedback"),
href: "https://solidus.io/feedback?category=solidus-admin",
icon: "feedback-line",
scheme: :secondary,
target: :_blank,
) %>
4 changes: 4 additions & 0 deletions admin/app/components/solidus_admin/feedback/component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# frozen_string_literal: true

class SolidusAdmin::Feedback::Component < SolidusAdmin::BaseComponent
end
5 changes: 5 additions & 0 deletions admin/app/components/solidus_admin/feedback/component.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Add your component translations here.
# Use the translation in the example in your template with `t(".hello")`.
en:
give_feedback: 'Give feedback'
feedback_description: 'We are constantly trying to improve. Please let us know what you think about this admin page.'
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<div class="<%= stimulus_id %> px-4">
<header class="py-6 flex items-center">
<h1 class="body-title">
<%= title %>
</h1>

<div class="ml-auto flex gap-2 items-center">
<%= render component("feedback").new %>
<%= render component("ui/button").new(
tag: :a,
text: t('.create_order'),
href: spree.new_admin_order_path,
icon: "add-line",
) %>
</div>
</header>

<%= render component('ui/table').new(
id: 'orders-list',
model_class: Spree::Order,
rows: @page.records,
fade_row_proc: fade_row_proc,
search_key: SolidusAdmin::Config[:order_search_key],
search_url: solidus_admin.orders_path,
batch_actions: batch_actions,
filters: filters,
columns: columns,
prev_page_link: prev_page_link,
next_page_link: next_page_link,
) %>
</div>
118 changes: 118 additions & 0 deletions admin/app/components/solidus_admin/orders/index/component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# frozen_string_literal: true

class SolidusAdmin::Orders::Index::Component < SolidusAdmin::BaseComponent
def initialize(page:)
@page = page
end

class_attribute :fade_row_proc, default: ->(order) { order.paid? && order.shipped? }

def title
Spree::Order.model_name.human.pluralize
end

def prev_page_link
@page.first? ? nil : solidus_admin.url_for(host: request.host, port: request.port, **request.params, page: @page.number - 1)
end

def next_page_link
@page.last? ? nil : solidus_admin.url_for(host: request.host, port: request.port, **request.params, page: @page.next_param)
end

def batch_actions
[]
end

def filters
[
{
name: 'q[completed_at_not_null]',
value: 1,
label: t('.filters.only_show_complete_orders'),
},
]
end

def columns
[
number_column,
date_column,
customer_column,
total_column,
items_column,
payment_column,
shipment_column,
]
end

def number_column
{
header: :order,
data: ->(order) do
order_path = spree.edit_admin_order_path(order)

if !fade_row_proc.call(order)
link_to order.number, order_path, class: 'font-semibold'
else
link_to order.number, order_path
end
end
}
end

def date_column
{
header: :date,
data: ->(order) do
content_tag :div, l(order.created_at, format: :short)
end
}
end

def customer_column
{
class_name: "w-[400px]",
header: :customer,
data: ->(order) do
customer_email = order.user&.email
content_tag :div, String(customer_email)
end
}
end

def total_column
{
header: :total,
data: ->(order) do
content_tag :div, number_to_currency(order.total)
end
}
end

def items_column
{
header: :items,
data: ->(order) do
content_tag :div, t('.columns.items', count: order.line_items.sum(:quantity))
end
}
end

def payment_column
{
header: :payment,
data: ->(order) do
component('ui/badge').new(name: order.payment_state&.humanize, color: order.paid? ? :green : :yellow)
end
}
end

def shipment_column
{
header: :shipment,
data: ->(order) do
component('ui/badge').new(name: order.shipment_state&.humanize, color: order.shipped? ? :green : :yellow)
end
}
end
end
Loading
Loading