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

Migrating Admin::SearchController to API endpoints #7444

Merged
merged 9 commits into from Jun 28, 2016

Conversation

Projects
None yet
4 participants
@damianlegawiec
Member

damianlegawiec commented Jun 25, 2016

This is the first part of the bigger movement to phase out a lot of backend/frontend controllers in favor of using just API endpoints. This will result in cleaner codebase will less duplicated code.

  • Admin::SearchController#users => Api::V1::UsersController#index + added caching
  • Admin::SearchController#products => Api::V1::ProdyctsController#index + added caching
  • Admin::SearchController#tags => Api::V1::TagsController#index
  • removed Admin::BaseController#check_json_authenticity
  • removed Admin::TaxonsController#search

@damianlegawiec damianlegawiec added this to the v3.2.x milestone Jun 25, 2016

@@ -18,8 +18,9 @@ $.fn.tagAutocomplete = function () {
callback(data);
},
ajax: {
url: Spree.routes.tags_search,
url: Spree.routes.tags_api,

This comment has been minimized.

@houndci-bot

houndci-bot Jun 25, 2016

Identifier 'tags_api' is not in camel case.
'Spree' is not defined.

@houndci-bot

houndci-bot Jun 25, 2016

Identifier 'tags_api' is not in camel case.
'Spree' is not defined.

ids: element.val().split(','),
token: Spree.api_key
}, function (data) {
callback(multiple ? data.products : data.products[0]);
});
},
ajax: {
url: Spree.routes.product_search,
url: Spree.routes.products_api,

This comment has been minimized.

@houndci-bot

houndci-bot Jun 25, 2016

Identifier 'products_api' is not in camel case.
'Spree' is not defined.

@houndci-bot

houndci-bot Jun 25, 2016

Identifier 'products_api' is not in camel case.
'Spree' is not defined.

@@ -13,16 +13,17 @@ $.fn.productAutocomplete = function (options) {
minimumInputLength: 3,
multiple: multiple,
initSelection: function (element, callback) {
$.get(Spree.routes.product_search, {
$.get(Spree.routes.products_api, {

This comment has been minimized.

@houndci-bot

houndci-bot Jun 25, 2016

Identifier 'products_api' is not in camel case.
'Spree' is not defined.

@houndci-bot

houndci-bot Jun 25, 2016

Identifier 'products_api' is not in camel case.
'Spree' is not defined.

@@ -16,8 +16,9 @@ $(document).ready(function() {
$("#customer_search").select2({
placeholder: Spree.translations.choose_a_customer,
ajax: {
url: Spree.routes.user_search,
url: Spree.routes.users_api,

This comment has been minimized.

@houndci-bot

houndci-bot Jun 25, 2016

Identifier 'users_api' is not in camel case.

@houndci-bot

houndci-bot Jun 25, 2016

Identifier 'users_api' is not in camel case.

Spree.routes.user_search = Spree.adminPathFor('search/users')
Spree.routes.tags_search = Spree.adminPathFor('search/tags')
Spree.routes.users_api = Spree.pathFor('api/v1/users')
Spree.routes.tags_api = Spree.pathFor('api/v1/tags')

This comment has been minimized.

@houndci-bot

houndci-bot Jun 25, 2016

Identifier 'tags_api' is not in camel case.
Missing semicolon.

@houndci-bot

houndci-bot Jun 25, 2016

Identifier 'tags_api' is not in camel case.
Missing semicolon.

Spree.routes.shipments_api = Spree.pathFor('api/v1/shipments')
Spree.routes.checkouts_api = Spree.pathFor('api/v1/checkouts')
Spree.routes.stock_locations_api = Spree.pathFor('api/v1/stock_locations')
Spree.routes.taxon_products_api = Spree.pathFor('api/v1/taxons/products')
Spree.routes.taxons_search = Spree.pathFor('api/v1/taxons')
Spree.routes.user_search = Spree.adminPathFor('search/users')
Spree.routes.tags_search = Spree.adminPathFor('search/tags')
Spree.routes.users_api = Spree.pathFor('api/v1/users')

This comment has been minimized.

@houndci-bot

houndci-bot Jun 25, 2016

Identifier 'users_api' is not in camel case.
Missing semicolon.

@houndci-bot

houndci-bot Jun 25, 2016

Identifier 'users_api' is not in camel case.
Missing semicolon.

context "pagination" do
it "can select the next page of tags" do
second_tag = create(:tag)

This comment has been minimized.

@houndci-bot

houndci-bot Jun 25, 2016

Useless assignment to variable - second_tag.

@houndci-bot

houndci-bot Jun 25, 2016

Useless assignment to variable - second_tag.

damianlegawiec added some commits Jun 23, 2016

Admin Panel: removing SearchController#users in favor of Api::V1::Use…
…rsController#index

All XHR actions performed in the admin panel should be done via API.
Admin Panel: removing SearchController#products in favor of Api::V1::…
…ProductsController#index

All XHR actions performed in the admin panel should be done via API.

Previously performance was an issue, which actually wasn’t resolved -
adding `cache: true` to ajax calls to skip jQuery digest.
Admin Panel: removing SearchController#tags in favor of Api::V1::Tags…
…Controller#index

All XHR actions performed in the admin panel should be done via API.
Removing unused :search_variants route from Admin Panel
Variant search in admin panel uses API endpoint. This code is
completely pointless.
Removing Admin::BaseController#check_json_authenticity method
This method is not used anymore because all of the JSON endpoints in
Admin Panel were moved to API.
Removing unused Admin::TaxonsController#search action
Taxon searching is done via API and this code is only leftover from the
old pre-bootstrap admin panel
ids: element.val().split(','),
token: Spree.api_key
}, function (data) {
callback(multiple ? data : data[0]);
});
},
ajax: {
url: Spree.routes.option_value_search,
url: Spree.routes.option_values_api,

This comment has been minimized.

@houndci-bot

houndci-bot Jun 25, 2016

Identifier 'option_values_api' is not in camel case.

@houndci-bot

houndci-bot Jun 25, 2016

Identifier 'option_values_api' is not in camel case.

@@ -11,15 +11,15 @@ $.fn.optionValueAutocomplete = function (options) {
minimumInputLength: 3,
multiple: multiple,
initSelection: function (element, callback) {
$.get(Spree.routes.option_value_search, {
$.get(Spree.routes.option_values_api, {

This comment has been minimized.

@houndci-bot

houndci-bot Jun 25, 2016

Identifier 'option_values_api' is not in camel case.

@houndci-bot

houndci-bot Jun 25, 2016

Identifier 'option_values_api' is not in camel case.

@@ -19,7 +19,7 @@ $(document).ready(function () {
});
},
ajax: {
url: Spree.routes.option_type_search,
url: Spree.routes.option_types_api,

This comment has been minimized.

@houndci-bot

houndci-bot Jun 25, 2016

Identifier 'option_types_api' is not in camel case.
'Spree' is not defined.

@houndci-bot

houndci-bot Jun 25, 2016

Identifier 'option_types_api' is not in camel case.
'Spree' is not defined.

@@ -10,7 +10,7 @@ $(document).ready(function () {
placeholder: Spree.translations.option_type_placeholder,
multiple: true,
initSelection: function (element, callback) {
var url = Spree.url(Spree.routes.option_type_search, {
var url = Spree.url(Spree.routes.option_types_api, {

This comment has been minimized.

@houndci-bot

houndci-bot Jun 25, 2016

Identifier 'option_types_api' is not in camel case.
'Spree' is not defined.

@houndci-bot

houndci-bot Jun 25, 2016

Identifier 'option_types_api' is not in camel case.
'Spree' is not defined.

Spree.routes.option_type_search = Spree.pathFor('api/v1/option_types')
Spree.routes.option_value_search = Spree.pathFor('api/v1/option_values')
Spree.routes.option_types_api = Spree.pathFor('api/v1/option_types')
Spree.routes.option_values_api = Spree.pathFor('api/v1/option_values')

This comment has been minimized.

@houndci-bot

houndci-bot Jun 25, 2016

Identifier 'option_values_api' is not in camel case.
Missing semicolon.

@houndci-bot

houndci-bot Jun 25, 2016

Identifier 'option_values_api' is not in camel case.
Missing semicolon.

@@ -52,18 +52,17 @@
Spree.routes.clear_cache = Spree.adminPathFor('general_settings/clear_cache')
Spree.routes.checkouts_api = Spree.pathFor('api/v1/checkouts')
Spree.routes.classifications_api = Spree.pathFor('api/v1/classifications')
Spree.routes.option_type_search = Spree.pathFor('api/v1/option_types')
Spree.routes.option_value_search = Spree.pathFor('api/v1/option_values')
Spree.routes.option_types_api = Spree.pathFor('api/v1/option_types')

This comment has been minimized.

@houndci-bot

houndci-bot Jun 25, 2016

Identifier 'option_types_api' is not in camel case.
Missing semicolon.

@houndci-bot

houndci-bot Jun 25, 2016

Identifier 'option_types_api' is not in camel case.
Missing semicolon.

@Mafi88 Mafi88 merged commit 76b93e2 into spree:master Jun 28, 2016

2 checks passed

ci/circleci Your tests passed on CircleCI!
Details
hound 22 violations found.

@Mafi88 Mafi88 deleted the spark-solutions:hotfix/admin-migrate-search-to-api branch Jun 28, 2016

damianlegawiec added a commit to spark-solutions/spree that referenced this pull request Jul 15, 2016

damianlegawiec added a commit to spark-solutions/spree that referenced this pull request Jul 15, 2016

damianlegawiec added a commit that referenced this pull request Jul 15, 2016

Merge pull request #7473 from spark-solutions/hotfix/7444-tests-cleanup
PR #7444 introduced some minor specs glitches removed here

damianlegawiec added a commit to spark-solutions/spree that referenced this pull request Jul 19, 2016

mauazua added a commit that referenced this pull request Jul 20, 2016

Merge pull request #7488 from spark-solutions/hotfix/admin-promotions…
…-user-picker-fix

PR #7444 removed `user_search` route so we need to use new `users_api`

damianlegawiec added a commit to spark-solutions/spree that referenced this pull request Dec 5, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment