diff --git a/packages/strapi-admin/admin/src/containers/Onboarding/index.js b/packages/strapi-admin/admin/src/containers/Onboarding/index.js index c6978797cb..905f0a40f6 100644 --- a/packages/strapi-admin/admin/src/containers/Onboarding/index.js +++ b/packages/strapi-admin/admin/src/containers/Onboarding/index.js @@ -15,7 +15,14 @@ import injectReducer from 'utils/injectReducer'; import OnboardingVideo from 'components/OnboardingVideo'; -import { getVideos, onClick, removeVideos, setVideoDuration, setVideoEnd, updateVideoStartTime } from './actions'; +import { + getVideos, + onClick, + removeVideos, + setVideoDuration, + setVideoEnd, + updateVideoStartTime, +} from './actions'; import makeSelectOnboarding from './selectors'; import reducer from './reducer'; import saga from './saga'; @@ -43,17 +50,17 @@ export class Onboarding extends React.Component { setVideoEnd = () => { this.setVideoEnd(); - } - + }; + didPlayVideo = (index, currTime) => { const eventName = `didPlay${index}GetStartedVideo`; - this.context.emitEvent(eventName, {timestamp: currTime}); - } + this.context.emitEvent(eventName, { timestamp: currTime }); + }; didStopVideo = (index, currTime) => { const eventName = `didStop${index}Video`; - this.context.emitEvent(eventName, {timestamp: currTime}); - } + this.context.emitEvent(eventName, { timestamp: currTime }); + }; handleOpenModal = () => this.setState({ showVideos: true }); @@ -67,10 +74,9 @@ export class Onboarding extends React.Component { }; updateCurrentTime = (index, current, duration) => { - this.props.updateVideoStartTime(index, current); - const percent = current * 100 / duration; + const percent = (current * 100) / duration; const video = this.props.videos[index]; if (percent >= 80) { @@ -80,21 +86,35 @@ export class Onboarding extends React.Component { } }; - updateEnd = (index) => { + updateEnd = index => { this.props.setVideoEnd(index, true); }; // eslint-disable-line jsx-handler-names render() { const { videos, onClick, setVideoDuration } = this.props; + const { showVideos } = this.state; + + const style = showVideos ? {} : { maxWidth: 0 }; return ( -
0 ? styles.visible : styles.hidden)}> -
+
0 ? styles.visible : styles.hidden)} + > +
-

+

+ +

{videos.length && ( -

{Math.floor((videos.filter(v => v.end).length)*100/videos.length)}

+

+ {Math.floor((videos.filter(v => v.end).length * 100) / videos.length)} + +

)}
    @@ -116,10 +136,7 @@ export class Onboarding extends React.Component {
-