only use display=in_rce with inline LTI launches

why:
* using display=in_rce instead of borderless allows inline/iframed
LTI launches inside an active RCE to work and use postMessages
* this was mistakenly also using in_rce with link-type
LTI launches, which open in a new tab
* which meant that the new tab never replaced the iframe
with the tool entirely, so there was still a canvas wrapper
* continue using display=borderless with links that open
an LTI tool in a new tab

closes INTEROP-8379
refs INTEROP-8205
flag=none

test plan:
* in a docker container:
```
cd packages/canvas-rce
yarn build:watch
```
* you can also restart your webpack container to make sure the changes
are picked up
* install the lti 1.3 test tool or 1.1 test tool with the editor_button
placement
* launch the tool from a page that has the RCE, like a new wiki page
* pass back a content item with no iframe attribute so that it makes
a link
* change to the HTML editor - the <a> tag should have
display=borderless
* save the page, and hover over the link
* it should include display=borderless, not display=in_rce
* click on the link
* it should open in a new tab, and the URL in the address bar
should eventually be for the tool, not canvas

Change-Id: I49a7d99cc21d77540f9ea9023f4d371ad509a104
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/335741
Reviewed-by: Paul Gray <paul.gray@instructure.com>
QA-Review: Paul Gray <paul.gray@instructure.com>
Product-Review: Alexis Nast <alexis.nast@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
This commit is contained in:
Xander Moffatt 2023-12-20 11:23:31 -07:00
parent a872bbeb80
commit d5e6c6f2fb
3 changed files with 8 additions and 6 deletions

View File

@ -214,7 +214,7 @@ describe('processEditorContentItems', () => {
it('creates content for an LTI ResourceLink content item', () => {
expect(rceWrapper.insertCode).toHaveBeenNthCalledWith(
2,
'<a href="test?display=in_rce" title="link title" target="_blank">link text</a>'
'<a href="test?display=borderless" title="link title" target="_blank">link text</a>'
)
})
@ -232,7 +232,7 @@ describe('processEditorContentItems', () => {
it('inserts an ltiEndpoint link for content items with a lookup_uuid', () => {
expect(rceWrapper.insertCode).toHaveBeenNthCalledWith(
5,
'<a href="test?display=in_rce&amp;resource_link_lookup_uuid=somerandomuuid" title="link title" target="_blank">link text</a>'
'<a href="test?display=borderless&amp;resource_link_lookup_uuid=somerandomuuid" title="link title" target="_blank">link text</a>'
)
})
})
@ -263,7 +263,7 @@ describe('processEditorContentItems', () => {
it('creates content for an LTI ResourceLink content item', () => {
expect(rceWrapper.insertCode).toHaveBeenNthCalledWith(
2,
'<a href="test?display=in_rce" title="link title" target="_blank">user selection</a>'
'<a href="test?display=borderless" title="link title" target="_blank">user selection</a>'
)
})
})

View File

@ -40,8 +40,10 @@ export default class ResourceLinkContentItem extends BaseLinkContentItem<Resourc
}
override buildUrl() {
// iframed launches need canvas wrapped around them for postMessages to work
const display = this.iframe != null ? 'in_rce' : 'borderless'
return addQueryParamsToUrl(this.context.ltiEndpoint, {
display: 'in_rce',
display,
resource_link_lookup_uuid: this.lookup_uuid,
[PARENT_FRAME_CONTEXT_PARAM]: this.context.containingCanvasLtiToolId,
})

View File

@ -46,7 +46,7 @@ describe('ResourceLinkContentItem', () => {
describe('constructor', () => {
it('sets the url to the canvas launch endpoint', () => {
expect(resourceLinkContentItem({}, {ltiEndpoint: endpoint}).buildUrl()).toEqual(
`${endpoint}?display=in_rce&resource_link_lookup_uuid=0b8fbc86-fdd7-4950-852d-ffa789b37ff2`
`${endpoint}?display=borderless&resource_link_lookup_uuid=0b8fbc86-fdd7-4950-852d-ffa789b37ff2`
)
})
@ -57,7 +57,7 @@ describe('ResourceLinkContentItem', () => {
{ltiEndpoint: endpoint, containingCanvasLtiToolId: 'sometool'}
).buildUrl()
).toEqual(
`${endpoint}?display=in_rce&resource_link_lookup_uuid=0b8fbc86-fdd7-4950-852d-ffa789b37ff2&parent_frame_context=sometool`
`${endpoint}?display=borderless&resource_link_lookup_uuid=0b8fbc86-fdd7-4950-852d-ffa789b37ff2&parent_frame_context=sometool`
)
})
})