remove doc-previews package

closes CFA-50

Change-Id: I548a72737071cb0988b7e9a9cac2044bfd750c8c
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/339231
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jackson Huang <jackson.huang@instructure.com>
QA-Review: Aaron Shafovaloff <ashafovaloff@instructure.com>
Product-Review: Aaron Shafovaloff <ashafovaloff@instructure.com>
This commit is contained in:
Aaron Shafovaloff 2024-01-30 08:57:44 -07:00
parent c39706be9f
commit 85afff9a97
8 changed files with 15 additions and 73 deletions

View File

@ -127,6 +127,10 @@ export function loadDocPreview($container, options) {
if (!$container) return // an issue in specs
if (!($container instanceof HTMLElement)) {
throw new Error('loadDocPreview requires a DOM element as first argument')
}
function tellAppIViewedThisInline() {
// if I have a url to ping back to the app that I viewed this file inline, ping it.
if (opts.attachment_view_inline_ping_url) {

View File

@ -5501,36 +5501,12 @@ QUnit.module('SpeedGrader', rootHooks => {
delete SpeedGrader.EG.currentStudent
})
// it is difficult to test that a bound function is passed the correct parameters without
// fully simulating SpeedGrader so instead let's ensure that both ajax_valid() is true
// and currentStudent was not undefined
test('ajax_valid returns', () => {
const loadDocPreview = sinon.stub($.fn, 'loadDocPreview')
SpeedGrader.EG.currentStudent = alphaStudent
const attachment = {content_type: 'application/rtf'}
SpeedGrader.EG.renderAttachment(attachment)
strictEqual(loadDocPreview.firstCall.args[0].ajax_valid(), true)
loadDocPreview.restore()
})
test('currentStudent is present', () => {
SpeedGrader.EG.currentStudent = alphaStudent
const attachment = {content_type: 'application/rtf'}
SpeedGrader.EG.renderAttachment(attachment)
strictEqual(SpeedGrader.EG.currentStudent.anonymous_id, alphaStudent.anonymous_id)
})
test('calls loadDocPreview for canvadoc documents with iframe_min_height set to 0', () => {
const loadDocPreview = sinon.stub($.fn, 'loadDocPreview')
SpeedGrader.EG.currentStudent = alphaStudent
const attachment = {content_type: 'application/pdf', canvadoc_url: 'fake_url'}
SpeedGrader.EG.renderAttachment(attachment)
const [documentParams] = loadDocPreview.firstCall.args
strictEqual(documentParams.iframe_min_height, 0)
loadDocPreview.restore()
})
})
QUnit.module('#showRubric', hooks => {

View File

@ -31,5 +31,5 @@ const previewDefaults = {
ready(() => {
const previewDiv = $('#doc_preview')
previewDiv.fillWindowWithMe()
loadDocPreview($.merge(previewDefaults, previewDiv.data()))
loadDocPreview(previewDiv[0], $.merge(previewDefaults, previewDiv.data()))
})

View File

@ -132,7 +132,7 @@ import vericiteScoreTemplate from '@canvas/grading/jst/_vericiteScore.handlebars
import 'jqueryui/draggable'
import '@canvas/jquery/jquery.ajaxJSON' /* getJSON, ajaxJSON */
import '@canvas/jquery/jquery.instructure_forms' /* ajaxJSONFiles */
import '@canvas/doc-previews' /* loadDocPreview */
import {loadDocPreview} from '@instructure/canvas-rce/es/enhance-user-content/doc_previews'
import '@canvas/datetime/jquery' /* datetimeString */
import 'jqueryui/dialog'
import 'jqueryui/menu'
@ -2859,7 +2859,9 @@ EG = {
this.displayExpirationWarnings(aggressiveWarnings, 10, canvadocMessage)
}
$iframe_holder.show().loadDocPreview(
$iframe_holder.show()
loadDocPreview(
$iframe_holder[0],
$.extend(previewOptions, {
crocodoc_session_url: attachment.provisional_crocodoc_url || attachment.crocodoc_url,
})
@ -2868,7 +2870,9 @@ EG = {
const aggressiveWarnings = this.generateWarningTimings(10)
this.displayExpirationWarnings(aggressiveWarnings, 10, canvadocMessage)
$iframe_holder.show().loadDocPreview(
$iframe_holder.show()
loadDocPreview(
$iframe_holder[0],
$.extend(previewOptions, {
canvadoc_session_url: attachment.provisional_canvadoc_url || attachment.canvadoc_url,
iframe_min_height: 0,
@ -2881,7 +2885,8 @@ EG = {
previewOptions = $.extend(previewOptions, {
ajax_valid: () => currentStudentIDAsOfAjaxCall === this.currentStudent[anonymizableId],
})
$iframe_holder.show().loadDocPreview(previewOptions)
$iframe_holder.show()
loadDocPreview($iframe_holder[0], previewOptions)
} else if (browserableCssClasses.test(attachment.mime_class)) {
// xsslint safeString.identifier iframeHolderContents
const iframeHolderContents = this.attachmentIframeContents(attachment)

View File

@ -48,7 +48,7 @@ $(document).ready(() => {
width: $(document).width() * 0.95,
height: $(document).height() * 0.75,
})
loadDocPreview(dialog, $.extend({height: '100%'}, $(this).data()))
loadDocPreview(dialog[0], $.extend({height: '100%'}, $(this).data()))
$('.submission_annotation.unread_indicator').hide()
$('.file-upload-submission-attachment .modal_preview_link').attr(
'title',

View File

@ -1,35 +0,0 @@
/*
* Copyright (C) 2011 - present Instructure, Inc.
*
* This file is part of Canvas.
*
* Canvas is free software: you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License as published by the Free
* Software Foundation, version 3 of the License.
*
* Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import $ from 'jquery'
import '@canvas/jquery/jquery.ajaxJSON'
import '@canvas/jquery/jquery.instructure_misc_helpers' /* /\$\.uniq/, capitalize */
import '@canvas/loading-image'
import {isPreviewable, loadDocPreview} from '@instructure/canvas-rce'
// check to see if a file of a certan mimeType is previewable inline in the browser by either scribd or googleDocs
// ex: $.isPreviewable("application/mspowerpoint") -> true
$.isPreviewable = (type, service = undefined) => {
if (service === 'google' && INST?.disableGooglePreviews) return false
return isPreviewable(type)
}
$.fn.loadDocPreview = function (options) {
const $this = $(this)
loadDocPreview($this[0], options)
}

View File

@ -1,7 +0,0 @@
{
"name": "@canvas/doc-previews",
"private": true,
"version": "1.0.0",
"author": "neme",
"main": "./jquery/index.js"
}

View File

@ -26,7 +26,6 @@ import {enhanceUserContent, makeAllExternalLinksExternalLinks} from '@instructur
import './instructure_helper'
import 'jqueryui/draggable'
import '@canvas/jquery/jquery.ajaxJSON'
import '@canvas/doc-previews' /* loadDocPreview */
import '@canvas/datetime/jquery' /* datetimeString, dateString, fudgeDateForProfileTimezone */
import '@canvas/jquery/jquery.instructure_forms' /* formSubmit, fillFormData, formErrors */
import 'jqueryui/dialog'