diff --git a/Gemfile b/Gemfile index a8a5ea449..2f72db198 100644 --- a/Gemfile +++ b/Gemfile @@ -149,7 +149,7 @@ gem "devise-two-factor" gem "rqrcode" # Admin panel -gem "avo", ">= 3.1.7" +#gem "avo", ">= 3.1.7" group :development do # Open any sent emails in your browser instead of having to setup an SMTP trap. diff --git a/Gemfile.lock b/Gemfile.lock index f038c8268..3d222baf7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -46,9 +46,6 @@ GEM rails-html-sanitizer (~> 1.6) active_hash (3.3.1) activesupport (>= 5.0.0) - active_link_to (1.0.5) - actionpack - addressable activejob (8.0.1) activesupport (= 8.0.1) globalid (>= 0.3.6) @@ -81,21 +78,6 @@ GEM public_suffix (>= 2.0.2, < 7.0) ansi (1.5.0) ast (2.4.2) - avo (3.17.5) - actionview (>= 6.1) - active_link_to - activerecord (>= 6.1) - activesupport (>= 6.1) - addressable - docile - inline_svg - meta-tags - pagy (>= 7.0.0) - prop_initializer (>= 0.2.0) - turbo-rails (>= 2.0.0) - turbo_power (>= 0.6.0) - view_component (>= 3.7.0) - zeitwerk (>= 2.6.12) base64 (0.2.0) bcrypt (3.1.20) benchmark (0.4.0) @@ -329,9 +311,6 @@ GEM concurrent-ruby (~> 1.0) indefinite_article (0.2.5) activesupport - inline_svg (1.10.0) - activesupport (>= 3.0) - nokogiri (>= 1.6) io-console (0.8.0) irb (1.15.1) pp (>= 0.6.0) @@ -379,8 +358,6 @@ GEM prism (>= 0.14.0) matrix (0.4.2) memory_profiler (1.1.0) - meta-tags (2.22.1) - actionpack (>= 6.0.0, < 8.1) method_source (1.1.0) mini_histogram (0.3.1) mini_mime (1.1.5) @@ -465,8 +442,6 @@ GEM premailer (~> 1.7, >= 1.7.9) prettyprint (0.2.0) prism (1.3.0) - prop_initializer (0.2.0) - zeitwerk (>= 2.6.18) pry (0.15.2) coderay (~> 1.1) method_source (~> 1.0) @@ -644,8 +619,6 @@ GEM turbo-rails (2.0.11) actionpack (>= 6.0.0) railties (>= 6.0.0) - turbo_power (0.7.0) - turbo-rails (>= 1.3.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) unicode-display_width (3.1.4) @@ -658,10 +631,6 @@ GEM mail (>= 2.6.1) simpleidn version_gem (1.1.4) - view_component (3.21.0) - activesupport (>= 5.2.0, < 8.1) - concurrent-ruby (~> 1.0) - method_source (~> 1.0) warden (1.2.9) rack (>= 2.0.9) web-console (4.2.1) @@ -688,7 +657,6 @@ PLATFORMS DEPENDENCIES active_hash - avo (>= 3.1.7) bootsnap bullet_train (= 1.17.1) bullet_train-api (= 1.17.1) diff --git a/app/avo/resources/avo/base_resource.rb b/app/avo/resources/avo/base_resource.rb new file mode 100644 index 000000000..14eab2503 --- /dev/null +++ b/app/avo/resources/avo/base_resource.rb @@ -0,0 +1,11 @@ +unless Object.const_defined?("Avo::Configuration") + module Avo + class BaseResource + def self.title=(new_title) + end + + def self.includes=(new_includes) + end + end + end +end diff --git a/app/avo/resources/avo/resources.rb b/app/avo/resources/avo/resources.rb new file mode 100644 index 000000000..917e9f3bf --- /dev/null +++ b/app/avo/resources/avo/resources.rb @@ -0,0 +1,7 @@ +unless Object.const_defined?("Avo::Configuration") + module Avo + module Resources + + end + end +end diff --git a/app/views/account/shared/menu/_user_items.html.erb b/app/views/account/shared/menu/_user_items.html.erb index 719e0336f..c48774c8b 100644 --- a/app/views/account/shared/menu/_user_items.html.erb +++ b/app/views/account/shared/menu/_user_items.html.erb @@ -18,7 +18,7 @@ <% end %> <% end %> -<% if current_user.developer? %> +<% if current_user.developer? && Object.const_defined?("Avo::Configuration") %> <%= render 'account/shared/menu/item', url: main_app.avo_path, label: "Admin" do |p| %> <% p.content_for :icon do %> diff --git a/config/initializers/avo.rb b/config/initializers/avo.rb index 1c3fc5ee8..e90416930 100644 --- a/config/initializers/avo.rb +++ b/config/initializers/avo.rb @@ -1,109 +1,114 @@ # For more information regarding these settings check out our docs https://docs.avohq.io -Avo.configure do |config| - ## == Routing == - config.root_path = "/admin/avo" - # used only when you have custom `map` configuration in your config.ru - # config.prefix_path = "/internal" +if Object.const_defined?("Avo::Configuration") + Avo.configure do |config| + ## == Routing == + config.root_path = "/admin/avo" + # used only when you have custom `map` configuration in your config.ru + # config.prefix_path = "/internal" - # Where should the user be redirected when visting the `/avo` url - # config.home_path = nil + # Where should the user be redirected when visting the `/avo` url + # config.home_path = nil - ## == Licensing == - # config.license_key = ENV['AVO_LICENSE_KEY'] + ## == Licensing == + # config.license_key = ENV['AVO_LICENSE_KEY'] - ## == Set the context == - config.set_context do - # Return a context object that gets evaluated in Avo::ApplicationController - end + ## == Set the context == + config.set_context do + # Return a context object that gets evaluated in Avo::ApplicationController + end - ## == Authentication == - config.current_user_method = :current_user - # config.authenticate_with do - # end + ## == Authentication == + config.current_user_method = :current_user + # config.authenticate_with do + # end - ## == Authorization == - # config.authorization_methods = { - # index: 'index?', - # show: 'show?', - # edit: 'edit?', - # new: 'new?', - # update: 'update?', - # create: 'create?', - # destroy: 'destroy?', - # search: 'search?', - # } - # config.raise_error_on_missing_policy = false - # Change the authorization_client to :pundit when using the authorization feature - config.authorization_client = nil + ## == Authorization == + # config.authorization_methods = { + # index: 'index?', + # show: 'show?', + # edit: 'edit?', + # new: 'new?', + # update: 'update?', + # create: 'create?', + # destroy: 'destroy?', + # search: 'search?', + # } + # config.raise_error_on_missing_policy = false + # Change the authorization_client to :pundit when using the authorization feature + config.authorization_client = nil - ## == Localization == - # config.locale = 'en-US' + ## == Localization == + # config.locale = 'en-US' - ## == Resource options == - # config.resource_controls_placement = :right - # config.model_resource_mapping = {} - # config.default_view_type = :table - # config.per_page = 24 - # config.per_page_steps = [12, 24, 48, 72] - # config.via_per_page = 8 - config.id_links_to_resource = true - # config.cache_resources_on_index_view = true - ## permanent enable or disable cache_resource_filters, default value is false - # config.cache_resource_filters = false - ## provide a lambda to enable or disable cache_resource_filters per user/resource. - # config.cache_resource_filters = ->(current_user:, resource:) { current_user.cache_resource_filters?} + ## == Resource options == + # config.resource_controls_placement = :right + # config.model_resource_mapping = {} + # config.default_view_type = :table + # config.per_page = 24 + # config.per_page_steps = [12, 24, 48, 72] + # config.via_per_page = 8 + config.id_links_to_resource = true + # config.cache_resources_on_index_view = true + ## permanent enable or disable cache_resource_filters, default value is false + # config.cache_resource_filters = false + ## provide a lambda to enable or disable cache_resource_filters per user/resource. + # config.cache_resource_filters = ->(current_user:, resource:) { current_user.cache_resource_filters?} - ## == Customization == - config.app_name = -> { I18n.t "application.name" } - # config.timezone = 'UTC' - # config.currency = 'USD' - # config.hide_layout_when_printing = false - # config.full_width_container = false - # config.full_width_index_view = false - # config.search_debounce = 300 - # config.view_component_path = "app/components" - # config.display_license_request_timeout_error = true - # config.disabled_features = [] - # config.buttons_on_form_footers = true - # config.field_wrapper_layout = true + ## == Customization == + config.app_name = -> { I18n.t "application.name" } + # config.timezone = 'UTC' + # config.currency = 'USD' + # config.hide_layout_when_printing = false + # config.full_width_container = false + # config.full_width_index_view = false + # config.search_debounce = 300 + # config.view_component_path = "app/components" + # config.display_license_request_timeout_error = true + # config.disabled_features = [] + # config.buttons_on_form_footers = true + # config.field_wrapper_layout = true - ## == Branding == - # config.branding = { - # colors: { - # background: "248 246 242", - # 100 => "#CEE7F8", - # 400 => "#399EE5", - # 500 => "#0886DE", - # 600 => "#066BB2", - # }, - # chart_colors: ["#0B8AE2", "#34C683", "#2AB1EE", "#34C6A8"], - # logo: "/avo-assets/logo.png", - # logomark: "/avo-assets/logomark.png", - # placeholder: "/avo-assets/placeholder.svg", - # favicon: "/avo-assets/favicon.ico" - # } + ## == Branding == + # config.branding = { + # colors: { + # background: "248 246 242", + # 100 => "#CEE7F8", + # 400 => "#399EE5", + # 500 => "#0886DE", + # 600 => "#066BB2", + # }, + # chart_colors: ["#0B8AE2", "#34C683", "#2AB1EE", "#34C6A8"], + # logo: "/avo-assets/logo.png", + # logomark: "/avo-assets/logomark.png", + # placeholder: "/avo-assets/placeholder.svg", + # favicon: "/avo-assets/favicon.ico" + # } - ## == Breadcrumbs == - # config.display_breadcrumbs = true - # config.set_initial_breadcrumbs do - # add_breadcrumb "Home", '/avo' - # end + ## == Breadcrumbs == + # config.display_breadcrumbs = true + # config.set_initial_breadcrumbs do + # add_breadcrumb "Home", '/avo' + # end - ## == Menus == - # config.main_menu = -> { - # section "Dashboards", icon: "dashboards" do - # all_dashboards - # end + ## == Menus == + # config.main_menu = -> { + # section "Dashboards", icon: "dashboards" do + # all_dashboards + # end - # section "Resources", icon: "resources" do - # all_resources - # end + # section "Resources", icon: "resources" do + # all_resources + # end - # section "Tools", icon: "tools" do - # all_tools - # end - # } - # config.profile_menu = -> { - # link "Profile", path: "/avo/profile", icon: "user-circle" - # } + # section "Tools", icon: "tools" do + # all_tools + # end + # } + # config.profile_menu = -> { + # link "Profile", path: "/avo/profile", icon: "user-circle" + # } + end +else + require_relative "../../app/avo/resources/avo/resources" + require_relative "../../app/avo/resources/avo/base_resource" end