Alter canvas media player failure feedback for attachment media

This should be JS tested, but LF-59 kinda got in the way, so it
would be good to figure that out, we're skipping a bunch of stuff...

closes LF-300
refs LF-59

flag=media_links_use_attachment_id

Test plan
1. Upload a media file in a course
2. Link to the media file in the RCE
3. Keep the RCE page somewhere accessible.
4. go to the files section and replace that
5. Reload the RCE page and check that you won't
see the old errors while @media_object is nil
(for me this window was like a minute)
6. Check that what you do see is a friendly
message directing the user to wai

Change-Id: I1eb4e7abeca6bb2dd430a575db787ee888c8c1c2
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/320424
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Eric Saupe <eric.saupe@instructure.com>
QA-Review: Eric Saupe <eric.saupe@instructure.com>
Product-Review: Luis Oliveira <luis.oliveira@instructure.com>
This commit is contained in:
Matheus 2023-06-13 17:57:55 -03:00 committed by Luis Oliveira
parent 664a3e5f5a
commit d2e0ef5ac3
4 changed files with 20 additions and 7 deletions

View File

@ -268,13 +268,14 @@ class MediaObjectsController < ApplicationController
@exclude_account_js = true
@embeddable = true
media_api_json = if @attachment
media_api_json = if @attachment && @media_object
media_attachment_api_json(@attachment, @media_object, @current_user, session)
elsif @media_object
media_object_api_json(@media_object, @current_user, session)
end
js_env media_object: media_api_json if media_api_json
js_env attachment: !!@attachment
js_bundle :media_player_iframe_content
css_bundle :media_player
render html: "<div id='player_container'>#{I18n.t("Loading...")}</div>".html_safe,

View File

@ -25,7 +25,7 @@ module FilesHelper
return render_unauthorized_action unless @attachment&.media_entry_id
@media_object = @attachment.media_object_by_media_id
@media_object.current_attachment = @attachment
@media_object.current_attachment = @attachment unless @media_object.nil?
@media_id = @media_object&.id
elsif params[:media_object_id].present?
@media_id = params[:media_object_id]

View File

@ -37,6 +37,7 @@ ready(() => {
const media_id = window.location.pathname.split('media_objects_iframe/').pop()
const media_href_match = window.location.search.match(/mediahref=([^&]+)/)
const media_object = ENV.media_object || {}
const is_attachment = ENV.attachment
const parsed_loc = parse(window.location.href, true)
const is_video =
/video/.test(media_object?.media_type) || /type=video/.test(window.location.search)
@ -98,6 +99,7 @@ ready(() => {
media_tracks={mediaTracks}
type={is_video ? 'video' : 'audio'}
aria_label={aria_label}
is_attachment={is_attachment}
/>,
document.getElementById('player_container')
)

View File

@ -186,11 +186,19 @@ export default function CanvasMediaPlayer(props) {
function renderNoPlayer() {
if (mediaObjNetworkErr) {
return (
<Alert key="erralert" variant="error" margin="small" liveRegion={liveRegion}>
{I18n.t('Failed retrieving media sources.')}
</Alert>
)
if (props.is_attachment) {
return (
<Alert key="bepatientalert" variant="info" margin="x-small" liveRegion={liveRegion}>
{I18n.t('Your media has been uploaded and will appear here after processing.')}
</Alert>
)
} else {
return (
<Alert key="erralert" variant="error" margin="small" liveRegion={liveRegion}>
{I18n.t('Failed retrieving media sources.')}
</Alert>
)
}
}
if (retryAttempt >= MAX_RETRY_ATTEMPTS) {
// this should be very rare
@ -319,6 +327,7 @@ CanvasMediaPlayer.propTypes = {
MAX_RETRY_ATTEMPTS: number,
SHOW_BE_PATIENT_MSG_AFTER_ATTEMPTS: number,
aria_label: string,
is_attachment: bool,
}
CanvasMediaPlayer.defaultProps = {
@ -329,4 +338,5 @@ CanvasMediaPlayer.defaultProps = {
MAX_RETRY_ATTEMPTS: DEFAULT_MAX_RETRY_ATTEMPTS,
SHOW_BE_PATIENT_MSG_AFTER_ATTEMPTS: DEFAULT_SHOW_BE_PATIENT_MSG_AFTER_ATTEMPTS,
aria_label: '',
is_attachment: false,
}