Skip to content

Commit 482fee7

Browse files
authored
Merge pull request #103 from back4app/video_tutorial_test
feat: Add VideoTutorial components
2 parents b56670b + ee6d145 commit 482fee7

File tree

7 files changed

+131
-5
lines changed

7 files changed

+131
-5
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"passport-local": "^1.0.0",
5555
"popper.js": "^1.12.9",
5656
"react-file-reader": "^1.1.4",
57+
"react-player": "^1.7.0",
5758
"react-syntax-highlighter": "^9.0.0",
5859
"react-tabs": "^2.2.2",
5960
"sweetalert2": "^7.28.10",

src/components/Toolbar/Toolbar.react.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ let Toolbar = (props) => {
4545
<span className={styles.details}>
4646
{props.details}
4747
</span>
48-
{props.helplink}
48+
{props.helpsection}
4949
</div>
5050
</div>
5151
</div>
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import React, { Component } from 'react';
2+
import PropTypes from 'lib/PropTypes';
3+
import styles from 'components/VideoTutorialButton/VideoTutorialButton.scss';
4+
import Position from 'lib/Position';
5+
import Popover from 'components/Popover/Popover.react';
6+
import ReactPlayer from 'react-player';
7+
8+
export default class VideoTutorialButton extends Component {
9+
10+
constructor(props) {
11+
super(props);
12+
13+
this.state = {
14+
videoTutorialModal: null
15+
};
16+
}
17+
18+
componentWillMount() {
19+
if (this.props.playing) {
20+
this.openVideoTutorialModal();
21+
}
22+
}
23+
24+
openVideoTutorialModal() {
25+
const { url } = this.props;
26+
this.setState({
27+
videoTutorialModal: (
28+
<Popover
29+
fadeIn={true}
30+
fixed={true}
31+
position={new Position(0, 0)}
32+
modal={true}
33+
color='rgba(17,13,17,0.8)'
34+
onExternalClick={() => this.setState({ videoTutorialModal: null })}>
35+
<div className={styles.modal}>
36+
<ReactPlayer
37+
url={url}
38+
controls
39+
width="100%"
40+
height="100%"
41+
playing
42+
/>
43+
</div>
44+
</Popover>
45+
)
46+
});
47+
}
48+
49+
render() {
50+
const classes = [styles.button, styles['b4a-green'], styles.unselectable];
51+
return (
52+
<a
53+
href='javascript:;'
54+
role='button'
55+
className={classes.join(' ')}
56+
style={this.props.additionalStyles}
57+
onClick={() => this.openVideoTutorialModal()}>
58+
<span>Video Tutorial</span>
59+
{this.state.videoTutorialModal}
60+
</a>
61+
);
62+
}
63+
}
64+
65+
// Props validations
66+
VideoTutorialButton.propTypes = {
67+
url: PropTypes.string,
68+
additionalStyles: PropTypes.object.describe(
69+
'Additional styles for <a> tag.'
70+
)
71+
};
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
@import 'stylesheets/globals.scss';
2+
3+
.button {
4+
@include DosisFont;
5+
display: inline-block;
6+
height: 20px;
7+
border: 1px solid;
8+
line-height: 20px;
9+
border-radius: 5px;
10+
min-width: 90px;
11+
padding: 0 16px;
12+
font-size: 12px;
13+
font-weight: bold;
14+
color: $white;
15+
background-color: #4caf50;
16+
border-color: #4caf50!important;
17+
18+
&:hover, &:focus {
19+
color: $white;
20+
background-color: #81c784;
21+
text-decoration: none;
22+
}
23+
}
24+
25+
.modal {
26+
@include modalAnimation();
27+
position: absolute;
28+
top: 50%;
29+
left: 50%;
30+
width: 75%;
31+
height: 75%;
32+
background: black;
33+
}
34+
35+
@include modalKeyframes();

src/dashboard/Data/Browser/B4ABrowserToolbar.react.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import Separator from 'components/BrowserMenu/Separator.react';
99
import styles from 'dashboard/Data/Browser/Browser.scss';
1010
import Toolbar from 'components/Toolbar/Toolbar.react';
1111
import Button from 'components/Button/Button.react'
12+
import VideoTutorialButton from 'components/VideoTutorialButton/VideoTutorialButton.react';
1213

1314
const apiDocsButtonStyle = {
1415
display: 'inline-block',
@@ -59,7 +60,8 @@ let B4ABrowserToolbar = ({
5960
enableExportClass,
6061
enableSecurityDialog,
6162

62-
applicationId
63+
applicationId,
64+
playVideoTutorial
6365
}) => {
6466
let selectionLength = Object.keys(selection).length;
6567
let details = [];
@@ -157,6 +159,14 @@ let B4ABrowserToolbar = ({
157159
}}
158160
/>
159161
}
162+
// TODO: Set the videoTutorialUrl
163+
const videoTutorialUrl = 'https://youtu.be/0Ym9-BHI8Fg';
164+
const helpsection = (
165+
<span>
166+
{apiDocsButton}
167+
<VideoTutorialButton url={videoTutorialUrl} additionalStyles={ { marginLeft: '8px', marginBottom: '4px' } } playing={playVideoTutorial} />
168+
</span>
169+
);
160170

161171
return (
162172
<Toolbar
@@ -165,7 +175,7 @@ let B4ABrowserToolbar = ({
165175
section={relation ? `Relation <${relation.targetClassName}>` : `Class | ${details.join(' \u2022 ')}`}
166176
subsection={subsection}
167177
details={relation ? details.join(' \u2022 ') : ''}
168-
helplink={apiDocsButton}>
178+
helpsection={helpsection}>
169179
<a className={styles.toolbarButton} onClick={onAddRow}>
170180
<Icon name='plus-solid' width={14} height={14} />
171181
<span>Add Row</span>

src/dashboard/Data/Browser/Browser.react.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
* the root directory of this source tree.
77
*/
88
import { ActionTypes } from 'lib/stores/SchemaStore';
9+
import { post } from 'lib/AJAX';
10+
import AccountManager from 'lib/AccountManager';
911
import AddColumnDialog from 'dashboard/Data/Browser/AddColumnDialog.react';
1012
import CategoryList from 'components/CategoryList/CategoryList.react';
1113
import CreateClassDialog from 'dashboard/Data/Browser/CreateClassDialog.react';
@@ -942,6 +944,11 @@ export default class Browser extends DashboardView {
942944
count = this.state.counts[className];
943945
}
944946
}
947+
const user = AccountManager.currentUser();
948+
let playVideoTutorial = user && user.playDatabaseBrowserTutorial;
949+
if (playVideoTutorial) {
950+
post(`/tutorial`, { databaseBrowser: true });
951+
}
945952
browser = (
946953
<DataBrowser
947954
count={count}
@@ -979,7 +986,8 @@ export default class Browser extends DashboardView {
979986
onAddColumn={this.showAddColumn}
980987
onAddRow={this.addRow}
981988
onAddClass={this.showCreateClass}
982-
err={this.state.err}/>
989+
err={this.state.err}
990+
playVideoTutorial={playVideoTutorial}/>
983991
);
984992
}
985993
}

src/dashboard/Data/Browser/DataBrowser.react.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,8 @@ export default class DataBrowser extends React.Component {
211211
enableImport={this.context.currentApp.serverInfo.features.schemas.import}
212212
enableSecurityDialog={this.context.currentApp.serverInfo.features.schemas.editClassLevelPermissions}
213213
{...other}
214-
applicationId={applicationId}/>
214+
applicationId={applicationId}
215+
playVideoTutorial={this.props.playVideoTutorial}/>
215216
</div>
216217
);
217218
}

0 commit comments

Comments
 (0)