Skip to content
This repository has been archived by the owner on Aug 15, 2019. It is now read-only.

Commit

Permalink
Merge pull request #48 from botmetrics/edit-page-access-token
Browse files Browse the repository at this point in the history
Add ability to update credentials for Facebook & Kik
  • Loading branch information
arunthampi authored Nov 9, 2016
2 parents c0c0132 + d30cc0f commit 5c1b346
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
10 changes: 5 additions & 5 deletions app/controllers/bot_instances_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,21 @@ def create
end

def edit
if @bot.provider != 'facebook'
if @bot.provider == 'slack'
redirect_to(bot_path(@bot)) && return
end

@instance = @bot.instances.find(params[:id])
@instance = @bot.instances.first
end

def update
if @bot.provider != 'facebook'
if @bot.provider == 'slack'
redirect_to(bot_path(@bot)) && return
end

@instance = @bot.instances.find(params[:id])
@instance = @bot.instances.first

if @instance.update_attributes(update_instance_params)
if @instance.present? && @instance.update_attributes(update_instance_params)
SetupBotJob.perform_async(@instance.id, current_user.id)

respond_to do |format|
Expand Down
13 changes: 13 additions & 0 deletions app/views/bots/edit.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@

= f.submit 'Save'

- if @bot.provider != 'slack' && (instance = @bot.instances.first).present?
%h2.teams
- if @bot.provider == 'facebook'
Update Page Access token
- elsif @bot.provider == 'kik'
Update API Key & Username
%hr
= simple_form_for [@bot, instance], url: bot_instance_path(@bot, instance), as: :instance, method: :patch do |f|
- if @bot.provider == 'kik'
= f.input :uid, label: "Your Bot's Username", required: true
= f.input :token, label: new_instance_token_label(@bot), required: true
= f.submit 'Update Bot'

%h2.teams Team
%hr
%ul
Expand Down

0 comments on commit 5c1b346

Please sign in to comment.