Skip to content

Commit

Permalink
add hide_default_launcher to config
Browse files Browse the repository at this point in the history
  • Loading branch information
mmartinic committed Oct 3, 2016
1 parent 3a4d7f0 commit b123293
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 4 deletions.
6 changes: 6 additions & 0 deletions README.mdown
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,12 @@ You can customize the CSS selector, by setting
config.inbox.custom_activator = '.intercom-link'
```

You can hide default launcher button, by setting

```ruby
config.hide_default_launcher = true
```

You can read more about configuring the messenger in your applications settings, within Intercom.

### Environments
Expand Down
1 change: 1 addition & 0 deletions lib/intercom-rails/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def self.reset!
config_accessor :library_url
config_accessor :enabled_environments, &ARRAY_VALIDATOR
config_accessor :include_for_logged_out_users
config_accessor :hide_default_launcher

def self.api_key=(*)
warn "Setting an Intercom API key is no longer supported; remove the `config.api_key = ...` line from config/initializers/intercom.rb"
Expand Down
2 changes: 1 addition & 1 deletion lib/intercom-rails/script_tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def intercom_settings
hsh[:session_duration] = @session_duration if @session_duration.present?
hsh[:widget] = widget_options if widget_options.present?
hsh[:company] = company_details if company_details.present?
hsh[:hide_default_launcher] = Config.inbox.style == :custom
hsh[:hide_default_launcher] = Config.hide_default_launcher if Config.hide_default_launcher
hsh
end

Expand Down
3 changes: 3 additions & 0 deletions lib/rails/generators/intercom/config/intercom.rb.erb
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,7 @@ IntercomRails.config do |config|
# uncomment this line and clicks on any element that matches the query will
# open the messenger
# config.inbox.custom_activator = '.intercom'
#
# If you'd like to hide default launcher button uncomment this line
# config.hide_default_launcher = true
end
5 changes: 5 additions & 0 deletions spec/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@
expect(IntercomRails.config.inbox.custom_activator).to eq('.intercom')
end

it 'gets/sets hide_default_launcher' do
IntercomRails.config.hide_default_launcher = true
expect(IntercomRails.config.hide_default_launcher).to eq(true)
end

it 'raises error if current user not a proc' do
expect { IntercomRails.config.user.current = 1 }.to raise_error(ArgumentError)
end
Expand Down
2 changes: 1 addition & 1 deletion spec/script_tag_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
:email => '[email protected]',
:user_id => 'marco',
})
expect(script_tag.csp_sha256).to eq("'sha256-QmMmBpC2AxZc9zd18FvMACQwKPbnGG/kGMN4dGJeB3w='")
expect(script_tag.csp_sha256).to eq("'sha256-qLRbekKD6dEDMyLKPNFYpokzwYCz+WeNPqJE603mT24='")
end

it 'inserts a valid nonce if present' do
Expand Down
6 changes: 4 additions & 2 deletions spec/script_tag_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,14 @@ def sha256_hmac(secret, input)
it 'knows about :custom' do
IntercomRails.config.inbox.style = :custom
expect(ScriptTag.new.intercom_settings['widget']).to eq({'activator' => '#Intercom'})
expect(ScriptTag.new.intercom_settings['hide_default_launcher']).to eq(true)
end
it 'knows about :custom_activator' do
IntercomRails.config.inbox.style = :custom
IntercomRails.config.inbox.custom_activator = '.intercom'
expect(ScriptTag.new.intercom_settings['widget']).to eq({'activator' => '.intercom'})
end
it 'knows about :hide_default_launcher' do
IntercomRails.config.hide_default_launcher = true
expect(ScriptTag.new.intercom_settings['hide_default_launcher']).to eq(true)
end
end
Expand Down Expand Up @@ -171,7 +173,7 @@ def sha256_hmac(secret, input)
:email => '[email protected]',
:user_id => 'marco',
})
expect(script_tag.csp_sha256).to eq("'sha256-QmMmBpC2AxZc9zd18FvMACQwKPbnGG/kGMN4dGJeB3w='")
expect(script_tag.csp_sha256).to eq("'sha256-qLRbekKD6dEDMyLKPNFYpokzwYCz+WeNPqJE603mT24='")
end

it 'inserts a valid nonce if present' do
Expand Down

0 comments on commit b123293

Please sign in to comment.