-
Notifications
You must be signed in to change notification settings - Fork 0
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
Feat integrations #102
Merged
Merged
Feat integrations #102
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
d3118ed
initial structure for integrations code
Chocksy b6d475e
add integrations table and write the base for intercom integration wi…
Chocksy f8d7c41
add integration model
Chocksy 93bd2de
add integrations base code
Chocksy 124d813
code specs for base_driver and integration delegation
Chocksy 0b88973
add the integrations yml file for storing app keys and secrets
Chocksy 048b0a6
add configuration for omniauth to the integrations
Chocksy 2ea5cb6
remove unneded helpers and clen auth controllers
Chocksy 018e224
add the new auth_controller for creating integrations
Chocksy 68067b4
add integration configuration setting
Chocksy 1314590
add authentication and connect base methods
Chocksy 84bfb24
add the connect method config assignment
Chocksy bedf7ce
create account with github and save integrations to db
hyperionel 962f1d2
use env variable in the integrations.yml
hyperionel 6fd523c
made changes to allow for integration configuration to be saved
Chocksy a655582
add rest-client for api calls
Chocksy 7ba1edc
added omniauth-intercom gem
hyperionel f8a1ecf
some progress on the github integration
hyperionel f3d7a56
some specs for the auth_controller
hyperionel a4ac1ff
functionality for adding applications from the provider
hyperionel 2aac817
use hstore as the datatype for the configuration column
hyperionel 5af2abf
some changes to the methods we use to get the applications from the p…
hyperionel 6dd8810
functionality for creating a github issue
hyperionel 40bebc4
changed the name for the environment variables
hyperionel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
.remove-button{ | ||
display: inline-block; | ||
font-size: 12px; | ||
padding: 3px 6px; | ||
} | ||
|
||
.integrations{ | ||
.panel-heading{ | ||
min-height: 45px; | ||
.button_to{ | ||
display: inline-block; | ||
float: right; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
class AuthController < ApplicationController | ||
skip_before_filter :verify_authenticity_token, only: [:success] | ||
skip_before_action :authenticate!, only: [:success] | ||
|
||
def create | ||
unless Integrations.supports?(integration_params[:provider]) | ||
redirect_to settings_path(main_tab: 'integrations'), notice: 'Invalid Integration' | ||
return | ||
end | ||
|
||
@integration = Integration.new(integration_params) | ||
if @integration.valid? | ||
@integration.website = current_website | ||
session['integration'] = integration_params | ||
redirect_to "/auth/#{@integration.provider}" | ||
else | ||
redirect_to settings_path(main_tab: 'integrations'), notice: 'Integration parameters are invalid!' | ||
end | ||
end | ||
|
||
def success | ||
unless authenticated? | ||
user = User.find_by_provider_and_uid(provider, auth_hash['uid']) || User.create_with_omniauth(auth_hash) | ||
if user | ||
authenticate!(provider.to_sym) | ||
set_website(current_user.websites.first) unless current_user.websites.empty? | ||
end | ||
end | ||
if integration_session | ||
# create integration | ||
begin | ||
Integration.transaction do | ||
@integration = current_website.integrations.build(integration_session) | ||
@integration.assign_configuration(auth_hash) | ||
@integration.save! | ||
redirect_to settings_path(main_tab: 'integrations', integration_tab: provider ), notice: 'Integration created' | ||
end | ||
rescue | ||
redirect_to settings_path(main_tab: 'integrations'), flash: { error: 'Error creating integration' } | ||
ensure | ||
session['integration'] = nil | ||
end | ||
else | ||
after_login_redirect | ||
end | ||
end | ||
|
||
private | ||
|
||
def auth_hash | ||
request.env['omniauth.auth'] | ||
end | ||
|
||
def provider | ||
auth_hash['provider'] | ||
end | ||
|
||
def integration_session | ||
session['integration'] | ||
end | ||
|
||
def integration_params | ||
@params ||= params.require(:integration).permit(:integration_type, :name, :provider) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
class IntegrationsController < ApplicationController | ||
load_and_authorize_resource | ||
|
||
def update | ||
if @integration.update_attributes(integration_params) | ||
redirect_to settings_path(main_tab: 'integrations', integration_tab: @integration.provider), notice: 'Integration updated!' | ||
end | ||
end | ||
|
||
def destroy | ||
if @integration.destroy | ||
redirect_to settings_path(main_tab: 'integrations', integration_tab: @integration.provider), notice: 'Integration deleted!' | ||
end | ||
end | ||
|
||
def create_task | ||
begin | ||
task = @integration.driver.create_task(params[:title]) | ||
redirect_to error_path(params[:error_id], task: task) | ||
rescue | ||
redirect_to error_path(params[:error_id], task: task), flash: { error: "Operation failed!" } | ||
end | ||
end | ||
|
||
def integration_params | ||
@integration_params ||= params.require(:integration).permit(:application) | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's better to do
if @integration.save
than to do save and thenvalid?
.