From ed71122c855c47e977f64c6c2202beba97d70775 Mon Sep 17 00:00:00 2001 From: Carl Kibler Date: Fri, 18 Oct 2019 15:01:47 -0600 Subject: [PATCH] send parameters to wiki_index_menu LTI launch closes ADMIN-2891 flag=none test plan: - Set up new LTI Tool to accept the 4 custom parameters - On Pages index, trigger LTI from kabob menu - See the 4 new parameters are correctly sent to LTI Change-Id: Ib3a17d2d9a5d6c5117671061a00365ca86a57d4f Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/213879 Tested-by: Jenkins Reviewed-by: Jeremy Stanley Reviewed-by: Marc Phillips QA-Review: Anju Reddy Product-Review: Carl Kibler --- .../views/wiki/ContentTypeExternalToolTray.js | 52 +++++++++++++++++-- .../views/wiki/WikiPageIndexView.js | 10 +++- .../ContentTypeExternalToolTray.test.js | 48 +++++++++++++++-- doc/api/tools_variable_substitutions.md | 48 +++++++++++++++++ lib/lti/variable_expander.rb | 52 +++++++++++++++++++ spec/lib/lti/capabilities_helper_spec.rb | 6 ++- spec/lib/lti/variable_expander_spec.rb | 35 +++++++++++++ 7 files changed, 241 insertions(+), 10 deletions(-) diff --git a/app/coffeescripts/views/wiki/ContentTypeExternalToolTray.js b/app/coffeescripts/views/wiki/ContentTypeExternalToolTray.js index b56abbf341f..3e01ab09513 100644 --- a/app/coffeescripts/views/wiki/ContentTypeExternalToolTray.js +++ b/app/coffeescripts/views/wiki/ContentTypeExternalToolTray.js @@ -16,8 +16,9 @@ // along with this program. If not, see . import React from 'react' -import {string, number, shape, func} from 'prop-types' +import {arrayOf, oneOf, bool, string, shape, func} from 'prop-types' import CanvasTray from 'jsx/shared/components/CanvasTray' +import $ from 'jquery' const iframeStyle = { border: 'none', @@ -27,23 +28,64 @@ const iframeStyle = { } const toolShape = shape({ - id: number.isRequired, + id: string.isRequired, title: string.isRequired, base_url: string.isRequired, icon_url: string }) +const knownResourceTypes = [ + 'assignment', + 'assignment_group', + 'audio', + 'discussion_topic', + 'document', + 'image', + 'module', + 'quiz', + 'page', + 'video' +] + ContentTypeExternalToolTray.propTypes = { tool: toolShape, + placement: string.isRequired, + acceptedResourceTypes: arrayOf(oneOf(knownResourceTypes)).isRequired, + targetResourceType: oneOf(knownResourceTypes).isRequired, + allowItemSelection: bool.isRequired, + selectableItems: arrayOf(oneOf(knownResourceTypes)).isRequired, onDismiss: func } -export default function ContentTypeExternalToolTray({tool, onDismiss}) { - const iframeUrl = tool.base_url + '&display=borderless' +export default function ContentTypeExternalToolTray({ + tool, + placement, + acceptedResourceTypes, + targetResourceType, + allowItemSelection, + selectableItems, + onDismiss +}) { + const queryParams = { + com_instructure_course_accept_canvas_resource_types: acceptedResourceTypes, + com_instructure_course_canvas_resource_type: targetResourceType, + com_instructure_course_allow_canvas_resource_selection: allowItemSelection, + com_instructure_course_available_canvas_resources: selectableItems, + display: 'borderless', + placement + } + const prefix = tool.base_url.indexOf('?') === -1 ? '?' : '&' + const iframeUrl = `${tool.base_url}${prefix}${$.param(queryParams)}` return ( -