Start Setting app_center_id via API POST and find installed apps via the app_center_id property

Fixes PLAT-1109

Dependent on PLAT-1111 (https://gerrit.instructure.com/#/c/56044/)

Test Plan
 - Add a tool from the app center to a course
 - Check the POST request sent (external_tool) when 'add app' is clicked
 - Make sure the request payload contains a k/v pair named 'app_center_id'
 - Check to make sure the newly added ContextExternalTool has the property 'app_center_id' set to the same value sent in the POST
 - Make sure the newly added app is in the 'installed' category

Change-Id: Ibf0e7f31967dc5482dea518b386df60272cbfe23
Reviewed-on: https://gerrit.instructure.com/56152
Tested-by: Jenkins
Reviewed-by: Nathan Mills <nathanm@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Product-Review: Weston Dransfield <wdransfield@instructure.com>
This commit is contained in:
Weston Dransfield 2015-06-10 14:41:57 -06:00
parent 0ca6a0f379
commit 9e691abb83
3 changed files with 4 additions and 2 deletions

View File

@ -23,7 +23,8 @@ class AppCenterController < ApplicationController
return unless apps
ContextExternalTool.all_tools_for(context).each do |tool|
app = nil
app = apps.find{|a| tool.tool_id == a['short_name'] } if tool.tool_id
app_center_id = tool.app_center_id || tool.tool_id
app = apps.find{|a| app_center_id == a['short_name'] } if app_center_id
app['is_installed'] = true if app
end
end

View File

@ -757,7 +757,7 @@ class ExternalToolsController < ApplicationController
def set_tool_attributes(tool, params)
attrs = ContextExternalTool::EXTENSION_TYPES
attrs += [:name, :description, :url, :icon_url, :domain, :privacy_level, :consumer_key, :shared_secret,
:custom_fields, :custom_fields_string, :text, :config_type, :config_url, :config_xml, :not_selectable]
:custom_fields, :custom_fields_string, :text, :config_type, :config_url, :config_xml, :not_selectable, :app_center_id]
attrs.each do |prop|
tool.send("#{prop}=", params[prop]) if params.has_key?(prop)
end

View File

@ -154,6 +154,7 @@ define([
newTool.set('config_url', this.configUrl());
newTool.set('config_type', 'by_url');
newTool.set('name', this.state.fields.name.value);
newTool.set('app_center_id', this.props.app.short_name);
$(e.target).attr('disabled', 'disabled');