disco_app 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Rakefile +37 -0
- data/app/assets/images/disco_app/icon.svg +1 -0
- data/app/assets/images/disco_app/icons.svg +0 -0
- data/app/assets/javascripts/disco_app/components/custom/filterable_shop_list.js.jsx +61 -0
- data/app/assets/javascripts/disco_app/components/custom/inline-radio-options.es6.jsx +59 -0
- data/app/assets/javascripts/disco_app/components/custom/rules-editor.es6.jsx +432 -0
- data/app/assets/javascripts/disco_app/components/custom/shop_filter_query.js.jsx +13 -0
- data/app/assets/javascripts/disco_app/components/custom/shop_filter_tab.js.jsx +34 -0
- data/app/assets/javascripts/disco_app/components/custom/shop_filter_tabs.js.jsx +21 -0
- data/app/assets/javascripts/disco_app/components/custom/shop_list.js.jsx +142 -0
- data/app/assets/javascripts/disco_app/components/custom/shop_row.js.jsx +43 -0
- data/app/assets/javascripts/disco_app/components/custom/shopify_admin_link.js.jsx +29 -0
- data/app/assets/javascripts/disco_app/components/ui-kit/cards/card-footer.es6.jsx +11 -0
- data/app/assets/javascripts/disco_app/components/ui-kit/cards/card-header.es6.jsx +11 -0
- data/app/assets/javascripts/disco_app/components/ui-kit/cards/card-section.es6.jsx +30 -0
- data/app/assets/javascripts/disco_app/components/ui-kit/cards/card.es6.jsx +16 -0
- data/app/assets/javascripts/disco_app/components/ui-kit/cards/cart-section-title.es6.jsx +9 -0
- data/app/assets/javascripts/disco_app/components/ui-kit/forms/base_form.es6.jsx +72 -0
- data/app/assets/javascripts/disco_app/components/ui-kit/forms/base_input.es6.jsx +20 -0
- data/app/assets/javascripts/disco_app/components/ui-kit/forms/button.es6.jsx +14 -0
- data/app/assets/javascripts/disco_app/components/ui-kit/forms/input-checkbox.es6.jsx +30 -0
- data/app/assets/javascripts/disco_app/components/ui-kit/forms/input-radio.es6.jsx +30 -0
- data/app/assets/javascripts/disco_app/components/ui-kit/forms/input-select.es6.jsx +39 -0
- data/app/assets/javascripts/disco_app/components/ui-kit/forms/input-text.es6.jsx +59 -0
- data/app/assets/javascripts/disco_app/components/ui-kit/forms/input-textarea.es6.jsx +48 -0
- data/app/assets/javascripts/disco_app/components/ui-kit/icons/icon-chevron.es6.jsx +33 -0
- data/app/assets/javascripts/disco_app/components/ui-kit/icons/next-icon.es6.jsx +18 -0
- data/app/assets/javascripts/disco_app/components/ui-kit/input_select.es6.jsx +21 -0
- data/app/assets/javascripts/disco_app/components/ui-kit/tables/table.es6.jsx +22 -0
- data/app/assets/javascripts/disco_app/components/ui-kit/ui-layout/ui-annotated-section.es6.jsx +29 -0
- data/app/assets/javascripts/disco_app/components/ui-kit/ui-layout/ui-empty-state.es6.jsx +35 -0
- data/app/assets/javascripts/disco_app/components/ui-kit/ui-layout/ui-footer-help.es6.jsx +13 -0
- data/app/assets/javascripts/disco_app/components/ui-kit/ui-layout/ui-layout-item.es6.jsx +11 -0
- data/app/assets/javascripts/disco_app/components/ui-kit/ui-layout/ui-layout-section.es6.jsx +19 -0
- data/app/assets/javascripts/disco_app/components/ui-kit/ui-layout/ui-layout-sections.es6.jsx +11 -0
- data/app/assets/javascripts/disco_app/components/ui-kit/ui-layout/ui-layout.es6.jsx +11 -0
- data/app/assets/javascripts/disco_app/components/ui-kit/ui-layout/ui-page-actions.es6.jsx +48 -0
- data/app/assets/javascripts/disco_app/components.js +2 -0
- data/app/assets/javascripts/disco_app/disco_app.js +9 -0
- data/app/assets/javascripts/disco_app/frame.js +152 -0
- data/app/assets/javascripts/disco_app/shopify-turbolinks.js +7 -0
- data/app/assets/javascripts/disco_app/ui-kit.js +1 -0
- data/app/assets/stylesheets/disco_app/admin/_header.scss +75 -0
- data/app/assets/stylesheets/disco_app/admin/_layout.scss +32 -0
- data/app/assets/stylesheets/disco_app/admin/_nav.scss +184 -0
- data/app/assets/stylesheets/disco_app/admin.scss +11 -0
- data/app/assets/stylesheets/disco_app/disco_app.scss +19 -0
- data/app/assets/stylesheets/disco_app/frame/_buttons.scss +54 -0
- data/app/assets/stylesheets/disco_app/frame/_forms.scss +26 -0
- data/app/assets/stylesheets/disco_app/frame/_layout.scss +77 -0
- data/app/assets/stylesheets/disco_app/frame/_type.scss +25 -0
- data/app/assets/stylesheets/disco_app/frame.scss +10 -0
- data/app/assets/stylesheets/disco_app/mixins/_flexbox.scss +400 -0
- data/app/assets/stylesheets/disco_app/ui-kit/_ui-empty-state.scss +121 -0
- data/app/assets/stylesheets/disco_app/ui-kit/_ui-footer-help.scss +28 -0
- data/app/assets/stylesheets/disco_app/ui-kit/_ui-icons.scss +28 -0
- data/app/assets/stylesheets/disco_app/ui-kit/_ui-kit.scss +5113 -0
- data/app/assets/stylesheets/disco_app/ui-kit/_ui-layout.scss +15 -0
- data/app/assets/stylesheets/disco_app/ui-kit/_ui-page-actions.scss +21 -0
- data/app/assets/stylesheets/disco_app/ui-kit/_ui-tabs.scss +75 -0
- data/app/assets/stylesheets/disco_app/ui-kit/_ui-type.scss +13 -0
- data/app/controllers/disco_app/admin/app_settings_controller.rb +3 -0
- data/app/controllers/disco_app/admin/application_controller.rb +3 -0
- data/app/controllers/disco_app/admin/concerns/app_settings_controller.rb +24 -0
- data/app/controllers/disco_app/admin/concerns/authenticated_controller.rb +20 -0
- data/app/controllers/disco_app/admin/concerns/plans_controller.rb +54 -0
- data/app/controllers/disco_app/admin/concerns/shops_controller.rb +7 -0
- data/app/controllers/disco_app/admin/concerns/subscriptions_controller.rb +29 -0
- data/app/controllers/disco_app/admin/plans_controller.rb +3 -0
- data/app/controllers/disco_app/admin/resources/shops_controller.rb +3 -0
- data/app/controllers/disco_app/admin/shops_controller.rb +3 -0
- data/app/controllers/disco_app/admin/subscriptions_controller.rb +3 -0
- data/app/controllers/disco_app/charges_controller.rb +47 -0
- data/app/controllers/disco_app/concerns/app_proxy_controller.rb +40 -0
- data/app/controllers/disco_app/concerns/authenticated_controller.rb +56 -0
- data/app/controllers/disco_app/concerns/carrier_request_controller.rb +21 -0
- data/app/controllers/disco_app/frame_controller.rb +9 -0
- data/app/controllers/disco_app/install_controller.rb +27 -0
- data/app/controllers/disco_app/subscriptions_controller.rb +32 -0
- data/app/controllers/disco_app/webhooks_controller.rb +46 -0
- data/app/controllers/sessions_controller.rb +28 -0
- data/app/helpers/disco_app/application_helper.rb +50 -0
- data/app/jobs/disco_app/app_installed_job.rb +3 -0
- data/app/jobs/disco_app/app_uninstalled_job.rb +3 -0
- data/app/jobs/disco_app/concerns/app_installed_job.rb +39 -0
- data/app/jobs/disco_app/concerns/app_uninstalled_job.rb +20 -0
- data/app/jobs/disco_app/concerns/render_asset_group_job.rb +8 -0
- data/app/jobs/disco_app/concerns/shop_update_job.rb +13 -0
- data/app/jobs/disco_app/concerns/subscription_changed_job.rb +7 -0
- data/app/jobs/disco_app/concerns/synchronise_carrier_service_job.rb +55 -0
- data/app/jobs/disco_app/concerns/synchronise_resources_job.rb +12 -0
- data/app/jobs/disco_app/concerns/synchronise_webhooks_job.rb +52 -0
- data/app/jobs/disco_app/render_asset_group_job.rb +3 -0
- data/app/jobs/disco_app/shop_job.rb +27 -0
- data/app/jobs/disco_app/shop_update_job.rb +3 -0
- data/app/jobs/disco_app/subscription_changed_job.rb +3 -0
- data/app/jobs/disco_app/synchronise_carrier_service_job.rb +3 -0
- data/app/jobs/disco_app/synchronise_resources_job.rb +3 -0
- data/app/jobs/disco_app/synchronise_webhooks_job.rb +3 -0
- data/app/models/disco_app/app_settings.rb +3 -0
- data/app/models/disco_app/application_charge.rb +18 -0
- data/app/models/disco_app/concerns/app_settings.rb +7 -0
- data/app/models/disco_app/concerns/can_be_liquified.rb +45 -0
- data/app/models/disco_app/concerns/has_metafields.rb +48 -0
- data/app/models/disco_app/concerns/plan.rb +26 -0
- data/app/models/disco_app/concerns/plan_code.rb +15 -0
- data/app/models/disco_app/concerns/renders_assets.rb +166 -0
- data/app/models/disco_app/concerns/shop.rb +78 -0
- data/app/models/disco_app/concerns/subscription.rb +60 -0
- data/app/models/disco_app/concerns/synchronises.rb +54 -0
- data/app/models/disco_app/concerns/taggable.rb +16 -0
- data/app/models/disco_app/plan.rb +3 -0
- data/app/models/disco_app/plan_code.rb +3 -0
- data/app/models/disco_app/recurring_application_charge.rb +18 -0
- data/app/models/disco_app/session_storage.rb +18 -0
- data/app/models/disco_app/shop.rb +3 -0
- data/app/models/disco_app/subscription.rb +3 -0
- data/app/resources/disco_app/admin/resources/concerns/shop_resource.rb +100 -0
- data/app/resources/disco_app/admin/resources/shop_resource.rb +4 -0
- data/app/services/disco_app/carrier_request_service.rb +15 -0
- data/app/services/disco_app/charges_service.rb +81 -0
- data/app/services/disco_app/proxy_service.rb +17 -0
- data/app/services/disco_app/subscription_service.rb +46 -0
- data/app/services/disco_app/webhook_service.rb +30 -0
- data/app/views/disco_app/admin/app_settings/edit.html.erb +5 -0
- data/app/views/disco_app/admin/plans/_form.html.erb +72 -0
- data/app/views/disco_app/admin/plans/_plan_code_fields.html.erb +15 -0
- data/app/views/disco_app/admin/plans/edit.html.erb +7 -0
- data/app/views/disco_app/admin/plans/index.html.erb +43 -0
- data/app/views/disco_app/admin/plans/new.html.erb +7 -0
- data/app/views/disco_app/admin/shops/index.html.erb +13 -0
- data/app/views/disco_app/admin/subscriptions/edit.html.erb +33 -0
- data/app/views/disco_app/charges/activate.html.erb +1 -0
- data/app/views/disco_app/charges/create.html.erb +1 -0
- data/app/views/disco_app/charges/new.html.erb +23 -0
- data/app/views/disco_app/frame/frame.html.erb +36 -0
- data/app/views/disco_app/install/installing.html.erb +7 -0
- data/app/views/disco_app/install/uninstalling.html.erb +1 -0
- data/app/views/disco_app/proxy_errors/404.html.erb +1 -0
- data/app/views/disco_app/shared/_card.html.erb +14 -0
- data/app/views/disco_app/shared/_icons.html.erb +1 -0
- data/app/views/disco_app/shared/_section.html.erb +17 -0
- data/app/views/disco_app/subscriptions/new.html.erb +25 -0
- data/app/views/layouts/admin/_nav_items.erb +20 -0
- data/app/views/layouts/admin.html.erb +67 -0
- data/app/views/layouts/application.html.erb +18 -0
- data/app/views/layouts/embedded_app.html.erb +44 -0
- data/app/views/layouts/embedded_app_modal.html.erb +28 -0
- data/app/views/sessions/new.html.erb +26 -0
- data/config/routes.rb +48 -0
- data/db/migrate/20150525000000_create_shops_if_not_existent.rb +15 -0
- data/db/migrate/20150525162112_add_status_to_shops.rb +5 -0
- data/db/migrate/20150525171422_add_meta_to_shops.rb +11 -0
- data/db/migrate/20150629210346_add_charge_status_to_shop.rb +5 -0
- data/db/migrate/20150814214025_add_more_meta_to_shops.rb +15 -0
- data/db/migrate/20151017231302_create_disco_app_plans.rb +13 -0
- data/db/migrate/20151017232027_create_disco_app_subscriptions.rb +15 -0
- data/db/migrate/20151017234409_move_shop_to_disco_app_engine.rb +5 -0
- data/db/migrate/20160112233706_create_disco_app_sessions.rb +12 -0
- data/db/migrate/20160113194418_add_shop_id_to_disco_app_sessions.rb +6 -0
- data/db/migrate/20160223111044_create_disco_app_settings.rb +8 -0
- data/db/migrate/20160301223215_update_plans.rb +22 -0
- data/db/migrate/20160301224558_update_subscriptions.rb +13 -0
- data/db/migrate/20160302104816_create_disco_app_recurring_application_charges.rb +14 -0
- data/db/migrate/20160302105259_create_disco_app_application_charges.rb +14 -0
- data/db/migrate/20160302134728_drop_charge_status_from_shops.rb +5 -0
- data/db/migrate/20160302142941_add_shopify_attributes_to_charges.rb +8 -0
- data/db/migrate/20160331093148_create_disco_app_plan_codes.rb +14 -0
- data/db/migrate/20160401044420_add_status_to_plan_codes.rb +5 -0
- data/db/migrate/20160401045551_add_amount_and_plan_code_to_disco_app_subscriptions.rb +7 -0
- data/db/migrate/20160425205211_add_source_to_disco_app_subscriptions.rb +5 -0
- data/db/migrate/20160426033520_add_trial_period_days_to_disco_app_subscriptions.rb +5 -0
- data/db/migrate/20160513140727_add_name_to_disco_app_shops.rb +5 -0
- data/db/migrate/20160521135510_move_shop_to_synchronises.rb +61 -0
- data/lib/disco_app/configuration.rb +45 -0
- data/lib/disco_app/constants.rb +4 -0
- data/lib/disco_app/engine.rb +26 -0
- data/lib/disco_app/session.rb +14 -0
- data/lib/disco_app/support/file_fixtures.rb +23 -0
- data/lib/disco_app/test_help.rb +11 -0
- data/lib/disco_app/version.rb +3 -0
- data/lib/disco_app.rb +7 -0
- data/lib/generators/disco_app/USAGE +5 -0
- data/lib/generators/disco_app/disco_app_generator.rb +239 -0
- data/lib/generators/disco_app/templates/assets/javascripts/application.js +17 -0
- data/lib/generators/disco_app/templates/assets/javascripts/components.js +3 -0
- data/lib/generators/disco_app/templates/assets/stylesheets/application.scss +5 -0
- data/lib/generators/disco_app/templates/config/database.yml.tt +20 -0
- data/lib/generators/disco_app/templates/config/newrelic.yml +26 -0
- data/lib/generators/disco_app/templates/config/puma.rb +15 -0
- data/lib/generators/disco_app/templates/controllers/home_controller.rb +7 -0
- data/lib/generators/disco_app/templates/initializers/disco_app.rb +28 -0
- data/lib/generators/disco_app/templates/initializers/rollbar.rb +19 -0
- data/lib/generators/disco_app/templates/initializers/session_store.rb +2 -0
- data/lib/generators/disco_app/templates/initializers/shopify_app.rb +7 -0
- data/lib/generators/disco_app/templates/initializers/shopify_session_repository.rb +7 -0
- data/lib/generators/disco_app/templates/root/CHECKS +4 -0
- data/lib/generators/disco_app/templates/root/Procfile +2 -0
- data/lib/generators/disco_app/templates/views/home/index.html.erb +2 -0
- data/lib/tasks/carrier_service.rake +10 -0
- data/lib/tasks/database.rake +8 -0
- data/lib/tasks/sessions.rake +9 -0
- data/lib/tasks/shops.rake +10 -0
- data/lib/tasks/start.rake +3 -0
- data/lib/tasks/webhooks.rake +10 -0
- data/test/controllers/disco_app/admin/shops_controller_test.rb +54 -0
- data/test/controllers/disco_app/charges_controller_test.rb +99 -0
- data/test/controllers/disco_app/install_controller_test.rb +50 -0
- data/test/controllers/disco_app/subscriptions_controller_test.rb +68 -0
- data/test/controllers/disco_app/webhooks_controller_test.rb +58 -0
- data/test/controllers/home_controller_test.rb +92 -0
- data/test/controllers/proxy_controller_test.rb +42 -0
- data/test/disco_app_test.rb +7 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/javascripts/application.js +17 -0
- data/test/dummy/app/assets/stylesheets/application.scss +5 -0
- data/test/dummy/app/controllers/application_controller.rb +6 -0
- data/test/dummy/app/controllers/carrier_request_controller.rb +10 -0
- data/test/dummy/app/controllers/disco_app/admin/shops_controller.rb +8 -0
- data/test/dummy/app/controllers/home_controller.rb +7 -0
- data/test/dummy/app/controllers/proxy_controller.rb +8 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/jobs/disco_app/app_installed_job.rb +16 -0
- data/test/dummy/app/jobs/disco_app/app_uninstalled_job.rb +11 -0
- data/test/dummy/app/jobs/products_create_job.rb +7 -0
- data/test/dummy/app/jobs/products_delete_job.rb +7 -0
- data/test/dummy/app/jobs/products_update_job.rb +7 -0
- data/test/dummy/app/models/disco_app/shop.rb +15 -0
- data/test/dummy/app/models/js_configuration.rb +8 -0
- data/test/dummy/app/models/product.rb +9 -0
- data/test/dummy/app/models/widget_configuration.rb +10 -0
- data/test/dummy/app/views/assets/script_tag.js.erb +1 -0
- data/test/dummy/app/views/assets/test.js.erb +1 -0
- data/test/dummy/app/views/assets/widget.js.erb +2 -0
- data/test/dummy/app/views/assets/widget.scss.erb +3 -0
- data/test/dummy/app/views/home/index.html.erb +2 -0
- data/test/dummy/app/views/snippets/widget.liquid.erb +1 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +29 -0
- data/test/dummy/config/application.rb +38 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.codeship.yml +23 -0
- data/test/dummy/config/database.gitlab-ci.yml +24 -0
- data/test/dummy/config/database.yml +20 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +41 -0
- data/test/dummy/config/environments/production.rb +85 -0
- data/test/dummy/config/environments/test.rb +42 -0
- data/test/dummy/config/initializers/assets.rb +11 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/test/dummy/config/initializers/disco_app.rb +28 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/omniauth.rb +9 -0
- data/test/dummy/config/initializers/session_store.rb +2 -0
- data/test/dummy/config/initializers/shopify_app.rb +7 -0
- data/test/dummy/config/initializers/shopify_session_repository.rb +7 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +11 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/db/migrate/20160307182229_create_products.rb +11 -0
- data/test/dummy/db/migrate/20160530160739_create_asset_models.rb +19 -0
- data/test/dummy/db/schema.rb +141 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/fixtures/api/widget_store/assets/create_script_tag_js_request.json +6 -0
- data/test/fixtures/api/widget_store/assets/create_script_tag_js_response.json +12 -0
- data/test/fixtures/api/widget_store/assets/create_script_tag_request.json +6 -0
- data/test/fixtures/api/widget_store/assets/create_script_tag_response.json +10 -0
- data/test/fixtures/api/widget_store/assets/create_test_js_request.json +6 -0
- data/test/fixtures/api/widget_store/assets/create_test_js_response.json +12 -0
- data/test/fixtures/api/widget_store/assets/create_widget_js_request.json +6 -0
- data/test/fixtures/api/widget_store/assets/create_widget_js_response.json +12 -0
- data/test/fixtures/api/widget_store/assets/create_widget_liquid_request.json +6 -0
- data/test/fixtures/api/widget_store/assets/create_widget_liquid_response.json +12 -0
- data/test/fixtures/api/widget_store/assets/create_widget_scss_request.json +6 -0
- data/test/fixtures/api/widget_store/assets/create_widget_scss_response.json +12 -0
- data/test/fixtures/api/widget_store/assets/get_script_tags_empty_request.json +1 -0
- data/test/fixtures/api/widget_store/assets/get_script_tags_empty_response.json +1 -0
- data/test/fixtures/api/widget_store/assets/get_script_tags_preexisting_request.json +1 -0
- data/test/fixtures/api/widget_store/assets/get_script_tags_preexisting_response.json +12 -0
- data/test/fixtures/api/widget_store/assets/update_script_tag_request.json +10 -0
- data/test/fixtures/api/widget_store/assets/update_script_tag_response.json +10 -0
- data/test/fixtures/api/widget_store/carrier_services.json +1 -0
- data/test/fixtures/api/widget_store/carrier_services_create.json +8 -0
- data/test/fixtures/api/widget_store/charges/activate_application_charge_request.json +16 -0
- data/test/fixtures/api/widget_store/charges/activate_application_charge_response.json +1 -0
- data/test/fixtures/api/widget_store/charges/activate_recurring_application_charge_request.json +20 -0
- data/test/fixtures/api/widget_store/charges/activate_recurring_application_charge_response.json +1 -0
- data/test/fixtures/api/widget_store/charges/create_application_charge_request.json +9 -0
- data/test/fixtures/api/widget_store/charges/create_application_charge_response.json +16 -0
- data/test/fixtures/api/widget_store/charges/create_recurring_application_charge_request.json +9 -0
- data/test/fixtures/api/widget_store/charges/create_recurring_application_charge_response.json +20 -0
- data/test/fixtures/api/widget_store/charges/create_second_recurring_application_charge_request.json +9 -0
- data/test/fixtures/api/widget_store/charges/create_second_recurring_application_charge_response.json +20 -0
- data/test/fixtures/api/widget_store/charges/get_accepted_application_charge_response.json +16 -0
- data/test/fixtures/api/widget_store/charges/get_accepted_recurring_application_charge_response.json +20 -0
- data/test/fixtures/api/widget_store/charges/get_declined_application_charge_response.json +16 -0
- data/test/fixtures/api/widget_store/charges/get_declined_recurring_application_charge_response.json +20 -0
- data/test/fixtures/api/widget_store/charges/get_pending_application_charge_response.json +16 -0
- data/test/fixtures/api/widget_store/charges/get_pending_recurring_application_charge_response.json +20 -0
- data/test/fixtures/api/widget_store/products/write_metafields_multiple_namespaces_request.json +31 -0
- data/test/fixtures/api/widget_store/products/write_metafields_multiple_namespaces_response.json +1 -0
- data/test/fixtures/api/widget_store/products/write_metafields_single_namespace_request.json +19 -0
- data/test/fixtures/api/widget_store/products/write_metafields_single_namespace_response.json +1 -0
- data/test/fixtures/api/widget_store/shop.json +46 -0
- data/test/fixtures/api/widget_store/webhooks.json +1 -0
- data/test/fixtures/assets/test.js +1 -0
- data/test/fixtures/assets/test.min.js +1 -0
- data/test/fixtures/disco_app/application_charges.yml +11 -0
- data/test/fixtures/disco_app/plan_codes.yml +13 -0
- data/test/fixtures/disco_app/plans.yml +37 -0
- data/test/fixtures/disco_app/recurring_application_charges.yml +11 -0
- data/test/fixtures/disco_app/shops.yml +10 -0
- data/test/fixtures/disco_app/subscriptions.yml +22 -0
- data/test/fixtures/js_configurations.yml +3 -0
- data/test/fixtures/liquid/model.liquid +8 -0
- data/test/fixtures/products.yml +4 -0
- data/test/fixtures/webhooks/app_uninstalled.json +46 -0
- data/test/fixtures/webhooks/product_created.json +167 -0
- data/test/fixtures/webhooks/product_deleted.json +3 -0
- data/test/fixtures/webhooks/product_updated.json +167 -0
- data/test/fixtures/widget_configurations.yml +4 -0
- data/test/integration/synchronises_test.rb +55 -0
- data/test/jobs/disco_app/app_installed_job_test.rb +57 -0
- data/test/jobs/disco_app/app_uninstalled_job_test.rb +30 -0
- data/test/jobs/disco_app/synchronise_carrier_service_job_test.rb +25 -0
- data/test/jobs/disco_app/synchronise_webhooks_job_test.rb +30 -0
- data/test/models/disco_app/can_be_liquified_test.rb +55 -0
- data/test/models/disco_app/has_metafields_test.rb +40 -0
- data/test/models/disco_app/plan_test.rb +5 -0
- data/test/models/disco_app/renders_assets_test.rb +109 -0
- data/test/models/disco_app/session_test.rb +31 -0
- data/test/models/disco_app/shop_test.rb +35 -0
- data/test/models/disco_app/subscription_test.rb +19 -0
- data/test/services/disco_app/charges_service_test.rb +112 -0
- data/test/services/disco_app/subscription_service_test.rb +60 -0
- data/test/support/test_file_fixtures.rb +29 -0
- data/test/support/test_shopify_api.rb +16 -0
- data/test/test_helper.rb +55 -0
- metadata +857 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 285d584cb7956611a8b08c8953cf35351d99f016b4e50c92952206bcab8cbfcb
|
4
|
+
data.tar.gz: 2c5914c7710a458e119c13f974cef9e342c46581711246e61f5a88c656e0aa6e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 21019b2b798f8141eaada02664aee5c9cf97aa751f2923afcfb12d7104d525055ee38ea6fb05581b1c440904e870accc6a5ef5f559f7a9139264e46102a5001d
|
7
|
+
data.tar.gz: 208e54ea47e1e1b7a244f472a83a1a56ad1b7dfa80c86379d1fd1a723db48c1aa0c2610dc917353b44d32346e6ef2b0ba137fa49c6a3cbc1d41716177525d21b
|
data/Rakefile
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'DiscoApp'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
|
21
|
+
load 'rails/tasks/statistics.rake'
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
Bundler::GemHelper.install_tasks
|
26
|
+
|
27
|
+
require 'rake/testtask'
|
28
|
+
|
29
|
+
Rake::TestTask.new(:test) do |t|
|
30
|
+
t.libs << 'lib'
|
31
|
+
t.libs << 'test'
|
32
|
+
t.pattern = 'test/**/*_test.rb'
|
33
|
+
t.verbose = false
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
task default: :test
|
@@ -0,0 +1 @@
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><style>.st0{fill:#231F20;} .st1{fill:#FBAF41;} .st2{fill:#8676D5;} .st3{fill:#9CCC6B;} .st4{fill:#FBCC6B;} .st5{fill:#9CCCD5;} .st6{fill:#FFFFFF;}</style><path id="XMLID_7_" class="st0" d="M12 24l-5.2-3-5.2-3V6l5.2-3L12 0l5.2 3 5.2 3v12l-5.2 3-5.2 3z"/><path id="XMLID_6_" class="st1" d="M2.9 6.8v10.4h18.2z"/><path id="XMLID_5_" class="st2" d="M2.9 17.2h18.2V6.8z"/><path id="XMLID_4_" class="st3" d="M21.1 17.2L12 1.5 2.9 17.2z"/><path id="XMLID_3_" class="st4" d="M7.5 9.4l-4.6 7.8h18.2z"/><path id="XMLID_2_" class="st5" d="M2.9 17.2h18.2l-4.6-7.8z"/><path id="XMLID_1_" class="st6" d="M12 12l-9.1 5.2 9.1 5.3 9.1-5.3z"/></svg>
|
File without changes
|
@@ -0,0 +1,61 @@
|
|
1
|
+
var FilterableShopList = React.createClass({
|
2
|
+
|
3
|
+
getDefaultProps: function() {
|
4
|
+
return {
|
5
|
+
filterTabs: [
|
6
|
+
{ label: 'All Shops', filter: {} },
|
7
|
+
{ label: 'Installed', filter: { 'filter[status]': 'installed' } },
|
8
|
+
{ label: 'Uninstalled', filter: { 'filter[status]': 'uninstalled' } }
|
9
|
+
],
|
10
|
+
availableFilters: {
|
11
|
+
'filter[status]': {
|
12
|
+
getLabel: function(value) {
|
13
|
+
return 'Status is ' + value;
|
14
|
+
}
|
15
|
+
}
|
16
|
+
}
|
17
|
+
}
|
18
|
+
},
|
19
|
+
|
20
|
+
getInitialState: function() {
|
21
|
+
return {
|
22
|
+
filter: {}
|
23
|
+
};
|
24
|
+
},
|
25
|
+
|
26
|
+
onFilterReplace: function(filter) {
|
27
|
+
this.setState({
|
28
|
+
filter: filter
|
29
|
+
});
|
30
|
+
},
|
31
|
+
|
32
|
+
onFilterSet: function(name, value) {
|
33
|
+
this.onFiltersSet([{
|
34
|
+
name: name,
|
35
|
+
value: value
|
36
|
+
}]);
|
37
|
+
},
|
38
|
+
|
39
|
+
onFiltersSet: function(filters) {
|
40
|
+
var nextFilter = $.extend({}, this.state.filter);
|
41
|
+
filters.forEach(function(filter) {
|
42
|
+
if(!filter.value) {
|
43
|
+
delete nextFilter[filter.name];
|
44
|
+
} else {
|
45
|
+
nextFilter[filter.name] = filter.value;
|
46
|
+
}
|
47
|
+
});
|
48
|
+
this.onFilterReplace(nextFilter);
|
49
|
+
},
|
50
|
+
|
51
|
+
render: function() {
|
52
|
+
return (
|
53
|
+
<div className="next-card">
|
54
|
+
<ShopFilterTabs filterTabs={this.props.filterTabs} filter={this.state.filter} onFilterReplace={this.onFilterReplace} />
|
55
|
+
<ShopFilterQuery filter={this.state.filter} onFilterSet={this.onFilterSet} />
|
56
|
+
<ShopList shopsUrl={this.props.shopsUrl} editShopUrl={this.props.editShopUrl} editSubscriptionUrl={this.props.editSubscriptionUrl} filter={this.state.filter} />
|
57
|
+
</div>
|
58
|
+
);
|
59
|
+
}
|
60
|
+
|
61
|
+
});
|
@@ -0,0 +1,59 @@
|
|
1
|
+
class InlineRadioOptions extends React.Component {
|
2
|
+
|
3
|
+
constructor(props) {
|
4
|
+
super(props);
|
5
|
+
this.state = {
|
6
|
+
value: props.value
|
7
|
+
}
|
8
|
+
}
|
9
|
+
|
10
|
+
onChange(value) {
|
11
|
+
this.setState({
|
12
|
+
value: value
|
13
|
+
})
|
14
|
+
}
|
15
|
+
|
16
|
+
render() {
|
17
|
+
const { name, label, options } = this.props;
|
18
|
+
|
19
|
+
const optionElements = options.map((option, optionIndex) => {
|
20
|
+
return (
|
21
|
+
<InputRadio
|
22
|
+
key={option.value}
|
23
|
+
name={name}
|
24
|
+
value={option.value}
|
25
|
+
label={option.label}
|
26
|
+
inline={true}
|
27
|
+
isLast={optionIndex === (options.length - 1)}
|
28
|
+
checked={option.value === this.state.value}
|
29
|
+
onChange={this.onChange.bind(this)}
|
30
|
+
/>
|
31
|
+
);
|
32
|
+
});
|
33
|
+
|
34
|
+
return (
|
35
|
+
<CardSection wrappable={true}>
|
36
|
+
<div className="wrappable__item wrappable__item--no-flex">
|
37
|
+
<span>{label}</span>
|
38
|
+
</div>
|
39
|
+
<div className="wrappable__item">
|
40
|
+
{optionElements}
|
41
|
+
</div>
|
42
|
+
</CardSection>
|
43
|
+
);
|
44
|
+
}
|
45
|
+
|
46
|
+
}
|
47
|
+
|
48
|
+
InlineRadioOptions.propTypes = {
|
49
|
+
name: React.PropTypes.string,
|
50
|
+
options: React.PropTypes.arrayOf(
|
51
|
+
React.PropTypes.shape({
|
52
|
+
label: React.PropTypes.string.isRequired,
|
53
|
+
value: React.PropTypes.oneOfType([
|
54
|
+
React.PropTypes.string,
|
55
|
+
React.PropTypes.bool
|
56
|
+
]).isRequired
|
57
|
+
})
|
58
|
+
).isRequired
|
59
|
+
};
|
@@ -0,0 +1,432 @@
|
|
1
|
+
/**
|
2
|
+
* Defines a generic RulesEditor class. This class can't be used directly, but
|
3
|
+
* should be inherited, with the inheriting class defining a list of column
|
4
|
+
* types and corresponding relations and condition data types, like so:
|
5
|
+
*
|
6
|
+
* class MyRulesEditor extends RulesEditor {};
|
7
|
+
* MyRulesEditor.defaultProps = {
|
8
|
+
* columns: {
|
9
|
+
* title: {
|
10
|
+
* label: 'Product title',
|
11
|
+
* column: 'title',
|
12
|
+
* relations: RulesEditor.buildRelationsObj([RulesEditor.EQUALS_STRING])
|
13
|
+
* }
|
14
|
+
* }
|
15
|
+
*/
|
16
|
+
class RulesEditor extends React.Component {
|
17
|
+
|
18
|
+
/**
|
19
|
+
* Initialise the Rules Editor, and set the initial state.
|
20
|
+
* @param props
|
21
|
+
*/
|
22
|
+
constructor(props) {
|
23
|
+
super(props);
|
24
|
+
this.state = {
|
25
|
+
rules: props.rules.map((rule, i) => {
|
26
|
+
return Object.assign({}, rule, {
|
27
|
+
column: Object.keys(this.props.columns).filter((columnKey) => {
|
28
|
+
return this.props.columns[columnKey].column == rule.column;
|
29
|
+
})[0]
|
30
|
+
});
|
31
|
+
})
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
35
|
+
componentDidMount() {
|
36
|
+
if(this.state.rules.length === 0 && this.props.blankOk === false) {
|
37
|
+
this.onAddRule();
|
38
|
+
}
|
39
|
+
}
|
40
|
+
|
41
|
+
/**
|
42
|
+
* Add a new rule, with an immutable state change.
|
43
|
+
*/
|
44
|
+
onAddRule() {
|
45
|
+
const column = Object.keys(this.props.columns)[0];
|
46
|
+
const relation = this.getNextRelation(column);
|
47
|
+
const condition = this.getNextCondition(column, relation);
|
48
|
+
|
49
|
+
this.setState({
|
50
|
+
rules: this.state.rules.concat([{
|
51
|
+
column,
|
52
|
+
relation,
|
53
|
+
condition
|
54
|
+
}])
|
55
|
+
});
|
56
|
+
}
|
57
|
+
|
58
|
+
/**
|
59
|
+
* Remove a rule, with an immutable state change.
|
60
|
+
*/
|
61
|
+
onRemoveRule(index) {
|
62
|
+
this.setState({
|
63
|
+
rules: [
|
64
|
+
...this.state.rules.slice(0, index),
|
65
|
+
...this.state.rules.slice(index + 1)
|
66
|
+
]
|
67
|
+
});
|
68
|
+
}
|
69
|
+
|
70
|
+
/**
|
71
|
+
* Handle a change in a rule's column attribute.
|
72
|
+
*
|
73
|
+
* @param index
|
74
|
+
* @param column
|
75
|
+
*/
|
76
|
+
onRuleColumnChange(index, column) {
|
77
|
+
const relation = this.getNextRelation(column, this.state.rules[index]);
|
78
|
+
const condition = this.getNextCondition(column, relation, this.state.rules[index]);
|
79
|
+
|
80
|
+
this.updateRule(index, {
|
81
|
+
column,
|
82
|
+
relation,
|
83
|
+
condition
|
84
|
+
})
|
85
|
+
}
|
86
|
+
|
87
|
+
/**
|
88
|
+
* Handle a change in a rule's relation attribute.
|
89
|
+
*
|
90
|
+
* @param index
|
91
|
+
* @param relation
|
92
|
+
*/
|
93
|
+
onRuleRelationChange(index, relation) {
|
94
|
+
const condition = this.getNextCondition(this.state.rules[index].column, relation, this.state.rules[index]);
|
95
|
+
|
96
|
+
this.updateRule(index, {
|
97
|
+
relation,
|
98
|
+
condition
|
99
|
+
});
|
100
|
+
}
|
101
|
+
|
102
|
+
/**
|
103
|
+
* Handle a change in a rule's condition attribute.
|
104
|
+
*
|
105
|
+
* @param index
|
106
|
+
* @param condition
|
107
|
+
*/
|
108
|
+
onRuleConditionChange(index, condition) {
|
109
|
+
this.updateRule(index, {
|
110
|
+
condition
|
111
|
+
});
|
112
|
+
}
|
113
|
+
|
114
|
+
/**
|
115
|
+
* Handle a change in a rule's variables
|
116
|
+
*
|
117
|
+
* @param index
|
118
|
+
* @param name
|
119
|
+
* @param value
|
120
|
+
*/
|
121
|
+
onRuleVariableChange(index, name, value) {
|
122
|
+
this.updateRule(index, {
|
123
|
+
[name]: value
|
124
|
+
});
|
125
|
+
}
|
126
|
+
|
127
|
+
/**
|
128
|
+
* Given the column we're changing to and the current rule, return the next
|
129
|
+
* relation value.
|
130
|
+
*
|
131
|
+
* @param nextColumn
|
132
|
+
* @param currentRule
|
133
|
+
*/
|
134
|
+
getNextRelation(nextColumn, currentRule) {
|
135
|
+
// If the new column provides for the same relation, keep it.
|
136
|
+
if(currentRule && (this.props.columns[nextColumn].relations[currentRule.relation] !== undefined)) {
|
137
|
+
return currentRule.relation;
|
138
|
+
}
|
139
|
+
// Otherwise, return the first relation for the new column.
|
140
|
+
return Object.keys(this.props.columns[nextColumn].relations)[0];
|
141
|
+
}
|
142
|
+
|
143
|
+
/**
|
144
|
+
* Given the column and relation we're changing to and the current condition,
|
145
|
+
* return the value that the condition should be changed to.
|
146
|
+
*
|
147
|
+
* @param nextColumn
|
148
|
+
* @param nextRelation
|
149
|
+
* @param currentRule
|
150
|
+
*/
|
151
|
+
getNextCondition(nextColumn, nextRelation, currentRule) {
|
152
|
+
// If the new relation provides for the same condition type, keep it.
|
153
|
+
if(currentRule) {
|
154
|
+
const currentConditionType = this.props.columns[currentRule.column].relations[currentRule.relation].type;
|
155
|
+
const nextConditionType = this.props.columns[nextColumn].relations[nextRelation].type;
|
156
|
+
|
157
|
+
if(currentConditionType === nextConditionType) {
|
158
|
+
return currentRule.condition;
|
159
|
+
}
|
160
|
+
}
|
161
|
+
|
162
|
+
// Otherwise, reset the condition to an empty string.
|
163
|
+
return '';
|
164
|
+
}
|
165
|
+
|
166
|
+
/**
|
167
|
+
* Handle the updating of a rule in our array in an immutable manner.
|
168
|
+
*
|
169
|
+
* @param index
|
170
|
+
* @param updates
|
171
|
+
*/
|
172
|
+
updateRule(index, updates) {
|
173
|
+
let updatedRule = Object.assign({}, this.state.rules[index], updates);
|
174
|
+
|
175
|
+
// Ensure only valid variables are present in the rule
|
176
|
+
const columnPath = this.props.columns[updatedRule.column].column;
|
177
|
+
const columnVariables = RulesEditor.getColumnPathVariables(columnPath);
|
178
|
+
Object.keys(updatedRule).forEach(function (key) {
|
179
|
+
if ('$' === key[0] && -1 === columnVariables.indexOf(key)) {
|
180
|
+
delete updatedRule[key];
|
181
|
+
}
|
182
|
+
});
|
183
|
+
|
184
|
+
this.setState({
|
185
|
+
rules: [
|
186
|
+
...this.state.rules.slice(0, index),
|
187
|
+
updatedRule,
|
188
|
+
...this.state.rules.slice(index + 1)
|
189
|
+
]
|
190
|
+
});
|
191
|
+
}
|
192
|
+
|
193
|
+
/**
|
194
|
+
* Render the Rules Editor.
|
195
|
+
*/
|
196
|
+
render() {
|
197
|
+
const { name } = this.props;
|
198
|
+
const { rules } = this.state;
|
199
|
+
|
200
|
+
const ruleElements = rules.map((rule, i) => {
|
201
|
+
return <RulesEditorRule
|
202
|
+
key={i}
|
203
|
+
rule={rule}
|
204
|
+
columns={this.props.columns}
|
205
|
+
onRemove={this.onRemoveRule.bind(this, i)}
|
206
|
+
onColumnChange={this.onRuleColumnChange.bind(this, i)}
|
207
|
+
onRelationChange={this.onRuleRelationChange.bind(this, i)}
|
208
|
+
onConditionChange={this.onRuleConditionChange.bind(this, i)}
|
209
|
+
onVariableChange={this.onRuleVariableChange.bind(this, i)}
|
210
|
+
ruleCount={rules.length}
|
211
|
+
blankOk = {this.props.blankOk}
|
212
|
+
/>
|
213
|
+
});
|
214
|
+
|
215
|
+
// Convert the current rules JSON into a format using the correct column
|
216
|
+
// format used by our more advanced key checker.
|
217
|
+
const rulesJSON = JSON.stringify(this.state.rules.map((rule, i) => {
|
218
|
+
return Object.assign({}, rule, {
|
219
|
+
column: this.props.columns[rule.column].column
|
220
|
+
});
|
221
|
+
}));
|
222
|
+
|
223
|
+
return(
|
224
|
+
<CardSection>
|
225
|
+
<div className="next-grid next-grid--no-outside-padding">
|
226
|
+
<div style={{ width: '100%'}}>
|
227
|
+
{ruleElements}
|
228
|
+
</div>
|
229
|
+
</div>
|
230
|
+
<Button onClick={this.onAddRule.bind(this)}>
|
231
|
+
Add another condition
|
232
|
+
</Button>
|
233
|
+
<input type="hidden" name={name} value={rulesJSON} />
|
234
|
+
</CardSection>
|
235
|
+
);
|
236
|
+
}
|
237
|
+
|
238
|
+
/**
|
239
|
+
* Get the variable names present in a column definition
|
240
|
+
*
|
241
|
+
* @param column
|
242
|
+
* @returns {Array.<String>}
|
243
|
+
*/
|
244
|
+
static getColumnPathVariables(column) {
|
245
|
+
return column.split(/[^$a-z_A-Z]/).filter((key) => '$' === key[0]);
|
246
|
+
}
|
247
|
+
|
248
|
+
/**
|
249
|
+
* Return a relations object, which is just the passed array
|
250
|
+
* turned into an object which is keyed by the `relation` value
|
251
|
+
*
|
252
|
+
* @param relations
|
253
|
+
* @returns {{}}
|
254
|
+
*/
|
255
|
+
static buildRelationsObj(relations) {
|
256
|
+
var relationsObj = {};
|
257
|
+
|
258
|
+
relations.forEach(function (relation) {
|
259
|
+
return relationsObj[relation.relation] = relation;
|
260
|
+
});
|
261
|
+
|
262
|
+
return relationsObj;
|
263
|
+
}
|
264
|
+
|
265
|
+
}
|
266
|
+
|
267
|
+
|
268
|
+
RulesEditor.EQUALS_STRING = {
|
269
|
+
label: 'is equal to',
|
270
|
+
relation: 'is_equal_to',
|
271
|
+
type: 'text'
|
272
|
+
};
|
273
|
+
RulesEditor.NOT_EQUALS_STRING = {
|
274
|
+
label: 'is not equal to',
|
275
|
+
relation: 'is_not_equal_to',
|
276
|
+
type: 'text'
|
277
|
+
};
|
278
|
+
RulesEditor.EQUALS_COUNTRY_CODE = {
|
279
|
+
label: 'is equal to',
|
280
|
+
relation: 'is_equal_to',
|
281
|
+
type: 'country_code'
|
282
|
+
};
|
283
|
+
RulesEditor.NOT_EQUALS_COUNTRY_CODE = {
|
284
|
+
label: 'is not equal to',
|
285
|
+
relation: 'is_not_equal_to',
|
286
|
+
type: 'country_code'
|
287
|
+
};
|
288
|
+
RulesEditor.CONTAINS_STRING = {
|
289
|
+
label: 'contains',
|
290
|
+
relation: 'contains_string',
|
291
|
+
type: 'text'
|
292
|
+
};
|
293
|
+
RulesEditor.DOES_NOT_CONTAIN_STRING = {
|
294
|
+
label: 'does not contain',
|
295
|
+
relation: 'does_not_contain_string',
|
296
|
+
type: 'text'
|
297
|
+
};
|
298
|
+
RulesEditor.EQUALS_TAG = {
|
299
|
+
label: 'is equal to',
|
300
|
+
relation: 'find_in_set',
|
301
|
+
type: 'tag'
|
302
|
+
};
|
303
|
+
RulesEditor.GREATER_THAN = {
|
304
|
+
label: 'is greater than',
|
305
|
+
relation: 'is_greater_than',
|
306
|
+
type: 'numeric'
|
307
|
+
};
|
308
|
+
RulesEditor.LESS_THAN = {
|
309
|
+
label: 'is less than',
|
310
|
+
relation: 'is_less_than',
|
311
|
+
type: 'numeric'
|
312
|
+
};
|
313
|
+
|
314
|
+
const RulesEditorRule = ({ rule, columns, onRemove, onColumnChange, onVariableChange, onRelationChange, onConditionChange, ruleCount, blankOk }) => {
|
315
|
+
const { column, relation, condition } = rule;
|
316
|
+
|
317
|
+
const currentColumn = columns[column];
|
318
|
+
const currentRelation = currentColumn.relations[relation];
|
319
|
+
|
320
|
+
let conditionEditor = null;
|
321
|
+
switch(currentRelation.type) {
|
322
|
+
case 'text':
|
323
|
+
case 'numeric':
|
324
|
+
case 'tag':
|
325
|
+
conditionEditor = <RulesEditorConditionInputText condition={condition} onChange={onConditionChange} />;
|
326
|
+
break;
|
327
|
+
case 'country_code':
|
328
|
+
conditionEditor = <RulesEditorConditionInputCountryCode condition={condition} onChange={onConditionChange} />;
|
329
|
+
break;
|
330
|
+
}
|
331
|
+
|
332
|
+
let deleteIconCell = null;
|
333
|
+
if(ruleCount > 1 || blankOk === true) {
|
334
|
+
deleteIconCell = (
|
335
|
+
<div className="sl">
|
336
|
+
<button type="button" className="btn btn--icon" onClick={onRemove}>
|
337
|
+
<i className="ico ico-14-svg ico-delete" />
|
338
|
+
</button>
|
339
|
+
</div>
|
340
|
+
);
|
341
|
+
}
|
342
|
+
|
343
|
+
const columnVariables = RulesEditor.getColumnPathVariables(currentColumn.column);
|
344
|
+
|
345
|
+
let variablesEditor = columnVariables.map(function(name) {
|
346
|
+
return (
|
347
|
+
<div className="next-grid__cell" key={name}>
|
348
|
+
<RulesEditorVariableInput name={name} value={rule[name]} onChange={onVariableChange.bind(this, name)} />
|
349
|
+
</div>
|
350
|
+
);
|
351
|
+
});
|
352
|
+
|
353
|
+
return (
|
354
|
+
<div>
|
355
|
+
<div className="next-grid next-grid--no-padding next-grid--compact">
|
356
|
+
<div className="next-grid__cell">
|
357
|
+
<div className="next-grid next-grid--compact next-grid--no-outside-padding">
|
358
|
+
<div className="next-grid__cell">
|
359
|
+
<RulesEditorColumnSelect currentColumnName={column} columns={columns} onChange={onColumnChange} />
|
360
|
+
</div>
|
361
|
+
{variablesEditor}
|
362
|
+
<div className="next-grid__cell">
|
363
|
+
<RulesEditorRelationSelect currentRelationName={relation} relations={currentColumn.relations} onChange={onRelationChange} />
|
364
|
+
</div>
|
365
|
+
<div className="next-grid__cell">
|
366
|
+
{conditionEditor}
|
367
|
+
</div>
|
368
|
+
</div>
|
369
|
+
</div>
|
370
|
+
{deleteIconCell}
|
371
|
+
</div>
|
372
|
+
<hr className="next-card__section__separator" />
|
373
|
+
</div>
|
374
|
+
);
|
375
|
+
|
376
|
+
};
|
377
|
+
|
378
|
+
const RulesEditorColumnSelect = ({ currentColumnName, columns, onChange }) => {
|
379
|
+
const options = Object.keys(columns).map((columnName) => {
|
380
|
+
return { label: columns[columnName].label, value: columnName }
|
381
|
+
});
|
382
|
+
|
383
|
+
return <InputSelect options={options} value={currentColumnName} onChange={onChange} label="Field" labelHidden={true} />;
|
384
|
+
};
|
385
|
+
|
386
|
+
const RulesEditorVariableInput = ({ name, value, onChange }) => {
|
387
|
+
|
388
|
+
const handleChange = (e) => {
|
389
|
+
onChange && onChange(e);
|
390
|
+
};
|
391
|
+
|
392
|
+
let label = name.substr(1).trim().replace( /([A-Z])/g, " $1" );
|
393
|
+
label = label.charAt(0).toUpperCase() + label.substr(1);
|
394
|
+
|
395
|
+
return (
|
396
|
+
<InputText value={value} onChange={handleChange} label={label} labelHidden={true} placeholder={label} required={true} />
|
397
|
+
);
|
398
|
+
};
|
399
|
+
|
400
|
+
const RulesEditorRelationSelect = ({ currentRelationName, relations, onChange }) => {
|
401
|
+
const options = Object.keys(relations).map((relationName) => {
|
402
|
+
return { label: relations[relationName].label, value: relationName }
|
403
|
+
});
|
404
|
+
|
405
|
+
return <InputSelect options={options} value={currentRelationName} onChange={onChange} label="Relation" labelHidden={true} />;
|
406
|
+
};
|
407
|
+
|
408
|
+
const RulesEditorConditionInputText = ({ condition, onChange }) => {
|
409
|
+
|
410
|
+
const handleChange = (e) => {
|
411
|
+
onChange && onChange(e);
|
412
|
+
};
|
413
|
+
|
414
|
+
return (
|
415
|
+
<InputText value={condition} onChange={handleChange} label="Value" labelHidden={true} />
|
416
|
+
);
|
417
|
+
|
418
|
+
};
|
419
|
+
|
420
|
+
const RulesEditorConditionInputCountryCode = ({ condition, onChange }) => {
|
421
|
+
|
422
|
+
const handleChange = (e) => {
|
423
|
+
onChange && onChange(e);
|
424
|
+
};
|
425
|
+
|
426
|
+
const countryOptions = [{"label":"Australia","value":"AU"},{"label":"Canada","value":"CA"},{"label":"United Kingdom","value":"GB"},{"label":"United States","value":"US"},{"label":"Afghanistan","value":"AF"},{"label":"Åland Islands","value":"AX"},{"label":"Albania","value":"AL"},{"label":"Algeria","value":"DZ"},{"label":"Andorra","value":"AD"},{"label":"Angola","value":"AO"},{"label":"Anguilla","value":"AI"},{"label":"Antigua & Barbuda","value":"AG"},{"label":"Argentina","value":"AR"},{"label":"Armenia","value":"AM"},{"label":"Aruba","value":"AW"},{"label":"Australia","value":"AU"},{"label":"Austria","value":"AT"},{"label":"Azerbaijan","value":"AZ"},{"label":"Bahamas","value":"BS"},{"label":"Bahrain","value":"BH"},{"label":"Bangladesh","value":"BD"},{"label":"Barbados","value":"BB"},{"label":"Belarus","value":"BY"},{"label":"Belgium","value":"BE"},{"label":"Belize","value":"BZ"},{"label":"Benin","value":"BJ"},{"label":"Bermuda","value":"BM"},{"label":"Bhutan","value":"BT"},{"label":"Bolivia","value":"BO"},{"label":"Bosnia & Herzegovina","value":"BA"},{"label":"Botswana","value":"BW"},{"label":"Bouvet Island","value":"BV"},{"label":"Brazil","value":"BR"},{"label":"British Indian Ocean Territory","value":"IO"},{"label":"British Virgin Islands","value":"VG"},{"label":"Brunei","value":"BN"},{"label":"Bulgaria","value":"BG"},{"label":"Burkina Faso","value":"BF"},{"label":"Burundi","value":"BI"},{"label":"Cambodia","value":"KH"},{"label":"Cameroon","value":"CM"},{"label":"Canada","value":"CA"},{"label":"Cape Verde","value":"CV"},{"label":"Cayman Islands","value":"KY"},{"label":"Central African Republic","value":"CF"},{"label":"Chad","value":"TD"},{"label":"Chile","value":"CL"},{"label":"China","value":"CN"},{"label":"Christmas Island","value":"CX"},{"label":"Cocos (Keeling) Islands","value":"CC"},{"label":"Colombia","value":"CO"},{"label":"Comoros","value":"KM"},{"label":"Congo - Brazzaville","value":"CG"},{"label":"Congo - Kinshasa","value":"CD"},{"label":"Cook Islands","value":"CK"},{"label":"Costa Rica","value":"CR"},{"label":"Croatia","value":"HR"},{"label":"Cuba","value":"CU"},{"label":"Curaçao","value":"CW"},{"label":"Cyprus","value":"CY"},{"label":"Czech Republic","value":"CZ"},{"label":"Côte d’Ivoire","value":"CI"},{"label":"Denmark","value":"DK"},{"label":"Djibouti","value":"DJ"},{"label":"Dominica","value":"DM"},{"label":"Dominican Republic","value":"DO"},{"label":"Ecuador","value":"EC"},{"label":"Egypt","value":"EG"},{"label":"El Salvador","value":"SV"},{"label":"Equatorial Guinea","value":"GQ"},{"label":"Eritrea","value":"ER"},{"label":"Estonia","value":"EE"},{"label":"Ethiopia","value":"ET"},{"label":"Falkland Islands","value":"FK"},{"label":"Faroe Islands","value":"FO"},{"label":"Fiji","value":"FJ"},{"label":"Finland","value":"FI"},{"label":"France","value":"FR"},{"label":"French Guiana","value":"GF"},{"label":"French Polynesia","value":"PF"},{"label":"French Southern Territories","value":"TF"},{"label":"Gabon","value":"GA"},{"label":"Gambia","value":"GM"},{"label":"Georgia","value":"GE"},{"label":"Germany","value":"DE"},{"label":"Ghana","value":"GH"},{"label":"Gibraltar","value":"GI"},{"label":"Greece","value":"GR"},{"label":"Greenland","value":"GL"},{"label":"Grenada","value":"GD"},{"label":"Guadeloupe","value":"GP"},{"label":"Guatemala","value":"GT"},{"label":"Guernsey","value":"GG"},{"label":"Guinea","value":"GN"},{"label":"Guinea-Bissau","value":"GW"},{"label":"Guyana","value":"GY"},{"label":"Haiti","value":"HT"},{"label":"Heard & McDonald Islands","value":"HM"},{"label":"Honduras","value":"HN"},{"label":"Hong Kong SAR China","value":"HK"},{"label":"Hungary","value":"HU"},{"label":"Iceland","value":"IS"},{"label":"India","value":"IN"},{"label":"Indonesia","value":"ID"},{"label":"Iran","value":"IR"},{"label":"Iraq","value":"IQ"},{"label":"Ireland","value":"IE"},{"label":"Isle of Man","value":"IM"},{"label":"Israel","value":"IL"},{"label":"Italy","value":"IT"},{"label":"Jamaica","value":"JM"},{"label":"Japan","value":"JP"},{"label":"Jersey","value":"JE"},{"label":"Jordan","value":"JO"},{"label":"Kazakhstan","value":"KZ"},{"label":"Kenya","value":"KE"},{"label":"Kiribati","value":"KI"},{"label":"Kosovo","value":"KV"},{"label":"Kuwait","value":"KW"},{"label":"Kyrgyzstan","value":"KG"},{"label":"Laos","value":"LA"},{"label":"Latvia","value":"LV"},{"label":"Lebanon","value":"LB"},{"label":"Lesotho","value":"LS"},{"label":"Liberia","value":"LR"},{"label":"Libya","value":"LY"},{"label":"Liechtenstein","value":"LI"},{"label":"Lithuania","value":"LT"},{"label":"Luxembourg","value":"LU"},{"label":"Macau SAR China","value":"MO"},{"label":"Macedonia","value":"MK"},{"label":"Madagascar","value":"MG"},{"label":"Malawi","value":"MW"},{"label":"Malaysia","value":"MY"},{"label":"Maldives","value":"MV"},{"label":"Mali","value":"ML"},{"label":"Malta","value":"MT"},{"label":"Martinique","value":"MQ"},{"label":"Mauritania","value":"MR"},{"label":"Mauritius","value":"MU"},{"label":"Mayotte","value":"YT"},{"label":"Mexico","value":"MX"},{"label":"Moldova","value":"MD"},{"label":"Monaco","value":"MC"},{"label":"Mongolia","value":"MN"},{"label":"Montenegro","value":"ME"},{"label":"Montserrat","value":"MS"},{"label":"Morocco","value":"MA"},{"label":"Mozambique","value":"MZ"},{"label":"Myanmar (Burma)","value":"MM"},{"label":"Namibia","value":"NA"},{"label":"Nauru","value":"NR"},{"label":"Nepal","value":"NP"},{"label":"Netherlands","value":"NL"},{"label":"Netherlands Antilles","value":"AN"},{"label":"New Caledonia","value":"NC"},{"label":"New Zealand","value":"NZ"},{"label":"Nicaragua","value":"NI"},{"label":"Niger","value":"NE"},{"label":"Nigeria","value":"NG"},{"label":"Niue","value":"NU"},{"label":"Norfolk Island","value":"NF"},{"label":"North Korea","value":"KP"},{"label":"Norway","value":"NO"},{"label":"Oman","value":"OM"},{"label":"Pakistan","value":"PK"},{"label":"Palestinian Territories","value":"PS"},{"label":"Panama","value":"PA"},{"label":"Papua New Guinea","value":"PG"},{"label":"Paraguay","value":"PY"},{"label":"Peru","value":"PE"},{"label":"Philippines","value":"PH"},{"label":"Pitcairn Islands","value":"PN"},{"label":"Poland","value":"PL"},{"label":"Portugal","value":"PT"},{"label":"Qatar","value":"QA"},{"label":"Réunion","value":"RE"},{"label":"Romania","value":"RO"},{"label":"Russia","value":"RU"},{"label":"Rwanda","value":"RW"},{"label":"Samoa","value":"WS"},{"label":"San Marino","value":"SM"},{"label":"São Tomé & Príncipe","value":"ST"},{"label":"Saudi Arabia","value":"SA"},{"label":"Senegal","value":"SN"},{"label":"Serbia","value":"RS"},{"label":"Seychelles","value":"SC"},{"label":"Sierra Leone","value":"SL"},{"label":"Singapore","value":"SG"},{"label":"Sint Maarten","value":"SX"},{"label":"Slovakia","value":"SK"},{"label":"Slovenia","value":"SI"},{"label":"Solomon Islands","value":"SB"},{"label":"Somalia","value":"SO"},{"label":"South Africa","value":"ZA"},{"label":"South Georgia & South Sandwich Islands","value":"GS"},{"label":"South Korea","value":"KR"},{"label":"Spain","value":"ES"},{"label":"Sri Lanka","value":"LK"},{"label":"St. Barthélemy","value":"BL"},{"label":"St. Helena","value":"SH"},{"label":"St. Kitts & Nevis","value":"KN"},{"label":"St. Lucia","value":"LC"},{"label":"St. Martin","value":"MF"},{"label":"St. Pierre & Miquelon","value":"PM"},{"label":"St. Vincent & Grenadines","value":"VC"},{"label":"Sudan","value":"SD"},{"label":"Suriname","value":"SR"},{"label":"Svalbard & Jan Mayen","value":"SJ"},{"label":"Swaziland","value":"SZ"},{"label":"Sweden","value":"SE"},{"label":"Switzerland","value":"CH"},{"label":"Syria","value":"SY"},{"label":"Taiwan","value":"TW"},{"label":"Tajikistan","value":"TJ"},{"label":"Tanzania","value":"TZ"},{"label":"Thailand","value":"TH"},{"label":"Timor-Leste","value":"TL"},{"label":"Togo","value":"TG"},{"label":"Tokelau","value":"TK"},{"label":"Tonga","value":"TO"},{"label":"Trinidad & Tobago","value":"TT"},{"label":"Tunisia","value":"TN"},{"label":"Turkey","value":"TR"},{"label":"Turkmenistan","value":"TM"},{"label":"Turks & Caicos Islands","value":"TC"},{"label":"Tuvalu","value":"TV"},{"label":"U.S. Outlying Islands","value":"UM"},{"label":"Uganda","value":"UG"},{"label":"Ukraine","value":"UA"},{"label":"United Arab Emirates","value":"AE"},{"label":"United Kingdom","value":"GB"},{"label":"United States","value":"US"},{"label":"Uruguay","value":"UY"},{"label":"Uzbekistan","value":"UZ"},{"label":"Vanuatu","value":"VU"},{"label":"Vatican City","value":"VA"},{"label":"Venezuela","value":"VE"},{"label":"Vietnam","value":"VN"},{"label":"Wallis & Futuna","value":"WF"},{"label":"Western Sahara","value":"EH"},{"label":"Yemen","value":"YE"},{"label":"Zambia","value":"ZM"},{"label":"Zimbabwe","value":"ZW"}];
|
427
|
+
|
428
|
+
return (
|
429
|
+
<InputSelect options={countryOptions} value={condition} onChange={handleChange} label="Value" labelHidden={true} />
|
430
|
+
);
|
431
|
+
|
432
|
+
};
|
@@ -0,0 +1,13 @@
|
|
1
|
+
const ShopFilterQuery = ({ filter, onFilterSet }) => {
|
2
|
+
|
3
|
+
const onChange = (value) => {
|
4
|
+
onFilterSet('filter[query]', value);
|
5
|
+
};
|
6
|
+
|
7
|
+
return (
|
8
|
+
<CardSection>
|
9
|
+
<InputText label="Search" placeholder="Start typing to search for stores..." labelHidden={true} value={filter.query} onChange={onChange} />
|
10
|
+
</CardSection>
|
11
|
+
);
|
12
|
+
|
13
|
+
};
|
@@ -0,0 +1,34 @@
|
|
1
|
+
var ShopFilterTab = React.createClass({
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Handle a click event on the individual tab link.
|
5
|
+
* @param e
|
6
|
+
*/
|
7
|
+
handleClick: function(e) {
|
8
|
+
e.preventDefault();
|
9
|
+
|
10
|
+
// Don't do anything if this is already the currently selected tab.
|
11
|
+
if(this.isActive()) return;
|
12
|
+
|
13
|
+
this.props.onFilterTabSelected(this.props.filterTab);
|
14
|
+
},
|
15
|
+
|
16
|
+
/**
|
17
|
+
* Return true if this is the currently active tab, determined by whether the filter values for this tab match the
|
18
|
+
* currently active filter.
|
19
|
+
* @returns {boolean}
|
20
|
+
*/
|
21
|
+
isActive: function() {
|
22
|
+
return (JSON.stringify(this.props.filterTab.filter) == JSON.stringify(this.props.filter));
|
23
|
+
},
|
24
|
+
|
25
|
+
render: function() {
|
26
|
+
var tabClassName = this.isActive() ? 'next-tab next-tab--is-active' : 'next-tab';
|
27
|
+
return (
|
28
|
+
<li role="presentation">
|
29
|
+
<a href="#" className={tabClassName} onClick={this.handleClick}>{this.props.filterTab.label}</a>
|
30
|
+
</li>
|
31
|
+
)
|
32
|
+
}
|
33
|
+
|
34
|
+
});
|