diff --git a/app/controllers/bot_instances_controller.rb b/app/controllers/bot_instances_controller.rb index 0f098db7..464248bd 100644 --- a/app/controllers/bot_instances_controller.rb +++ b/app/controllers/bot_instances_controller.rb @@ -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| diff --git a/app/views/bots/edit.html.haml b/app/views/bots/edit.html.haml index 27a4d9ba..ef35ea77 100644 --- a/app/views/bots/edit.html.haml +++ b/app/views/bots/edit.html.haml @@ -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