From e614f145173b4e4eefab07d323326f52d1797010 Mon Sep 17 00:00:00 2001 From: Steven Burnett Date: Mon, 19 Aug 2019 08:46:53 -0600 Subject: [PATCH] add ability to save media objects to canvas-media fixes COMMS-2314 refs COMMS-2293 Test Plan - create a media type assignment - as a student in a2 with notorious running locally go to record a video/upload a video file - notice it works and posts back to the containing dom Change-Id: I6c00c688b33deee017b7babb3729ff57d3dd2114 Reviewed-on: https://gerrit.instructure.com/205605 Tested-by: Jenkins Reviewed-by: Landon Gilbert-Bland QA-Review: Steven Burnett Product-Review: Steven Burnett --- .../components/AttemptType/MediaAttempt.js | 73 +++++---- packages/canvas-media/package.json | 1 + packages/canvas-media/src/EmbedPanel.js | 1 + packages/canvas-media/src/MediaRecorder.js | 13 +- .../canvas-media/src/__mocks__/screenfull.js | 23 +++ .../src/__tests__/EmbedPanel.test.js | 53 +++++++ .../src/__tests__/UploadPanel.test.js | 143 ++++++++++++++++++ .../src/__tests__/saveMediaRecording.test.js | 126 +++++++++++++++ packages/canvas-media/src/index.js | 143 ++++++++++-------- .../canvas-media/src/saveMediaRecording.js | 94 ++++++++++++ 10 files changed, 576 insertions(+), 94 deletions(-) create mode 100644 packages/canvas-media/src/__mocks__/screenfull.js create mode 100644 packages/canvas-media/src/__tests__/EmbedPanel.test.js create mode 100644 packages/canvas-media/src/__tests__/UploadPanel.test.js create mode 100644 packages/canvas-media/src/__tests__/saveMediaRecording.test.js create mode 100644 packages/canvas-media/src/saveMediaRecording.js diff --git a/app/jsx/assignments_2/student/components/AttemptType/MediaAttempt.js b/app/jsx/assignments_2/student/components/AttemptType/MediaAttempt.js index a0a4def8788..47e2e8e71cd 100644 --- a/app/jsx/assignments_2/student/components/AttemptType/MediaAttempt.js +++ b/app/jsx/assignments_2/student/components/AttemptType/MediaAttempt.js @@ -21,36 +21,57 @@ import Button from '@instructure/ui-buttons/lib/components/Button' import closedCaptionLanguages from '../../../../shared/closedCaptionLanguages' import I18n from 'i18n!assignments_2_text_entry' import {IconAttachMediaLine} from '@instructure/ui-icons' -import React, {useState} from 'react' +import React from 'react' import UploadMedia from '@instructure/canvas-media' import {UploadMediaStrings, MediaCaptureStrings} from '../../../../shared/UploadMediaTranslations' import View from '@instructure/ui-layout/lib/components/View' -export default function MediaAttempt() { - const [mediaModalOpen, setMediaModalOpen] = useState(false) +const languages = Object.keys(closedCaptionLanguages).map(key => { + return {id: key, label: closedCaptionLanguages[key]} +}) - const languages = Object.keys(closedCaptionLanguages).map(key => { - return {id: key, label: closedCaptionLanguages[key]} - }) +export default class MediaAttempt extends React.Component { + state = { + mediaModalOpen: false, + mediaObjectUrl: null + } - return ( - - setMediaModalOpen(false)} - open={mediaModalOpen} - liveRegion={() => document.getElementById('flash_screenreader_holder')} - languages={languages} - /> - } - message={ - - } - /> - - ) + onDismiss = mediaObject => { + this.setState({mediaModalOpen: false, mediaObjectUrl: mediaObject.embedded_iframe_url}) + } + + render() { + if (this.state.mediaObjectUrl) { + // TODO: figure out how the heck we want to style this thing. + return