Skip to content

Commit 30b6d71

Browse files
authored
Merge pull request #135 from ricardojudo/master
'If' Option
2 parents 9070ea5 + aa0be4b commit 30b6d71

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ Tool | Description
7979
:plural_resource_label |pluralized resource label value (default config.plural_resource_label)
8080
:error_limit |Limit the number of errors reported (default `5`, set to `nil` for all)
8181
:headers_rewrites |hash with key (csv header) - value (db column name) rows mapping
82+
:if |Controls whether the 'Import' button is displayed. It supports a proc to be evaluated into a boolean value within the activeadmin render context.
8283

8384

8485

lib/active_admin_import/dsl.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def active_admin_import(options = {}, &block)
6262
render template: options[:template]
6363
end
6464

65-
action_item :import, only: :index do
65+
action_item :import, only: :index, if: options[:if] do
6666
if authorized?(ActiveAdminImport::Auth::IMPORT, active_admin_config.resource_class)
6767
link_to(
6868
I18n.t('active_admin_import.import_model', plural_model: options[:plural_resource_label]),

lib/active_admin_import/options.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ module Options
2020
:resource_label,
2121
:plural_resource_label,
2222
:error_limit,
23-
:headers_rewrites
23+
:headers_rewrites,
24+
:if
2425
].freeze
2526

2627
def self.options_for(config, options = {})
@@ -36,7 +37,8 @@ def self.options_for(config, options = {})
3637
resource_label: config.resource_label,
3738
plural_resource_label: config.plural_resource_label,
3839
error_limit: 5,
39-
headers_rewrites: {}
40+
headers_rewrites: {},
41+
if: true
4042
}.deep_merge(options)
4143
end
4244
end

0 commit comments

Comments
 (0)