2016-03-18 11:51:22 -04:00
|
|
|
var connect = require('react-redux').connect;
|
2015-10-20 14:42:17 -04:00
|
|
|
var injectIntl = require('react-intl').injectIntl;
|
2015-09-02 15:08:58 -04:00
|
|
|
var React = require('react');
|
|
|
|
|
2016-06-06 10:09:01 -04:00
|
|
|
var api = require('../../lib/api');
|
2016-09-08 17:23:49 -04:00
|
|
|
var log = require('../../lib/log');
|
2016-06-06 10:09:01 -04:00
|
|
|
var render = require('../../lib/render.jsx');
|
2016-05-19 16:55:25 -04:00
|
|
|
var sessionActions = require('../../redux/session.js');
|
2016-06-13 09:40:32 -04:00
|
|
|
var shuffle = require('../../lib/shuffle.js').shuffle;
|
2016-03-18 11:51:22 -04:00
|
|
|
|
2016-04-21 18:13:21 -04:00
|
|
|
var Activity = require('../../components/activity/activity.jsx');
|
|
|
|
var AdminPanel = require('../../components/adminpanel/adminpanel.jsx');
|
|
|
|
var DropdownBanner = require('../../components/dropdown-banner/banner.jsx');
|
|
|
|
var Box = require('../../components/box/box.jsx');
|
|
|
|
var Button = require('../../components/forms/button.jsx');
|
|
|
|
var Carousel = require('../../components/carousel/carousel.jsx');
|
|
|
|
var Intro = require('../../components/intro/intro.jsx');
|
2016-11-08 14:43:10 -05:00
|
|
|
var IframeModal = require('../../components/modal/iframe/modal.jsx');
|
2016-04-21 18:13:21 -04:00
|
|
|
var News = require('../../components/news/news.jsx');
|
|
|
|
var Page = require('../../components/page/www/page.jsx');
|
2016-06-08 13:47:11 -04:00
|
|
|
var TeacherBanner = require('../../components/teacher-banner/teacher-banner.jsx');
|
2016-04-21 18:13:21 -04:00
|
|
|
var Welcome = require('../../components/welcome/welcome.jsx');
|
2015-09-02 15:08:58 -04:00
|
|
|
|
2016-07-26 11:29:45 -04:00
|
|
|
var MediaQuery = require('react-responsive');
|
|
|
|
var frameless = require('../../lib/frameless');
|
|
|
|
|
2015-09-02 15:08:58 -04:00
|
|
|
require('./splash.scss');
|
|
|
|
|
2015-10-20 14:42:17 -04:00
|
|
|
var Splash = injectIntl(React.createClass({
|
2015-10-09 16:16:37 -04:00
|
|
|
type: 'Splash',
|
2015-09-02 15:08:58 -04:00
|
|
|
getInitialState: function () {
|
|
|
|
return {
|
2016-04-22 14:11:25 -04:00
|
|
|
projectCount: 14000000, // gets the shared project count
|
2016-01-14 10:25:03 -05:00
|
|
|
activity: [], // recent social actions taken by users someone is following
|
|
|
|
news: [], // gets news posts from the scratch Tumblr
|
|
|
|
featuredCustom: {}, // custom homepage rows, such as "Projects by Scratchers I'm Following"
|
|
|
|
featuredGlobal: {}, // global homepage rows, such as "Featured Projects"
|
2016-11-10 15:00:33 -05:00
|
|
|
showEmailConfirmationModal: true, // flag that determines whether to show banner to request email conf.
|
2017-04-03 14:32:38 -04:00
|
|
|
refreshCacheStatus: 'notrequested'
|
2015-09-02 15:08:58 -04:00
|
|
|
};
|
|
|
|
},
|
2016-03-18 11:51:22 -04:00
|
|
|
getDefaultProps: function () {
|
|
|
|
return {
|
2016-06-08 13:47:11 -04:00
|
|
|
session: {},
|
|
|
|
permissions: {}
|
2016-03-18 12:40:30 -04:00
|
|
|
};
|
2016-03-18 11:51:22 -04:00
|
|
|
},
|
2016-03-18 12:40:30 -04:00
|
|
|
componentDidUpdate: function (prevProps) {
|
2016-06-01 17:22:11 -04:00
|
|
|
if (this.props.session.session.user != prevProps.session.session.user) {
|
|
|
|
if (this.props.session.session.user) {
|
2015-10-20 13:18:57 -04:00
|
|
|
this.getActivity();
|
2017-04-18 06:36:39 -04:00
|
|
|
this.getFeaturedCustom();
|
2015-10-20 13:18:57 -04:00
|
|
|
this.getNews();
|
|
|
|
} else {
|
|
|
|
this.setState({featuredCustom: []});
|
2015-10-24 14:52:11 -04:00
|
|
|
this.setState({activity: []});
|
|
|
|
this.setState({news: []});
|
2015-10-21 14:12:34 -04:00
|
|
|
this.getProjectCount();
|
2015-10-25 12:05:52 -04:00
|
|
|
}
|
|
|
|
if (this.shouldShowEmailConfirmation()) {
|
|
|
|
window.addEventListener('message', this.onMessage);
|
|
|
|
} else {
|
2015-10-23 19:02:00 -04:00
|
|
|
window.removeEventListener('message', this.onMessage);
|
2015-10-20 13:18:57 -04:00
|
|
|
}
|
2015-10-07 16:23:08 -04:00
|
|
|
}
|
|
|
|
},
|
2015-09-02 15:08:58 -04:00
|
|
|
componentDidMount: function () {
|
2015-10-21 15:12:41 -04:00
|
|
|
this.getFeaturedGlobal();
|
2016-06-01 17:22:11 -04:00
|
|
|
if (this.props.session.session.user) {
|
2015-10-20 12:25:30 -04:00
|
|
|
this.getActivity();
|
2017-04-18 06:36:39 -04:00
|
|
|
this.getFeaturedCustom();
|
2015-10-20 13:18:57 -04:00
|
|
|
this.getNews();
|
2015-10-21 14:12:34 -04:00
|
|
|
} else {
|
|
|
|
this.getProjectCount();
|
2015-10-07 16:23:08 -04:00
|
|
|
}
|
2015-10-25 12:05:52 -04:00
|
|
|
if (this.shouldShowEmailConfirmation()) window.addEventListener('message', this.onMessage);
|
2015-09-02 15:08:58 -04:00
|
|
|
},
|
2015-10-23 19:02:00 -04:00
|
|
|
componentWillUnmount: function () {
|
|
|
|
window.removeEventListener('message', this.onMessage);
|
|
|
|
},
|
|
|
|
onMessage: function (e) {
|
|
|
|
if (e.origin != window.location.origin) return;
|
2016-11-10 17:13:44 -05:00
|
|
|
if (e.source != this.emailConfirmationiFrame.contentWindow) return;
|
2015-10-23 19:02:00 -04:00
|
|
|
if (e.data == 'resend-done') {
|
|
|
|
this.hideEmailConfirmationModal();
|
|
|
|
} else {
|
|
|
|
var data = JSON.parse(e.data);
|
|
|
|
if (data['action'] === 'leave-page') {
|
|
|
|
window.location.href = data['uri'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2015-10-21 15:12:41 -04:00
|
|
|
getActivity: function () {
|
2016-06-06 10:09:01 -04:00
|
|
|
api({
|
2016-06-01 17:22:11 -04:00
|
|
|
uri: '/proxy/users/' + this.props.session.session.user.username + '/activity?limit=5'
|
2015-10-20 12:25:30 -04:00
|
|
|
}, function (err, body) {
|
2016-09-08 17:23:49 -04:00
|
|
|
if (!body) return log.error('No response body');
|
|
|
|
if (!err) return this.setState({activity: body});
|
2015-10-20 12:25:30 -04:00
|
|
|
}.bind(this));
|
|
|
|
},
|
2015-10-21 15:12:41 -04:00
|
|
|
getFeaturedGlobal: function () {
|
2016-06-06 10:09:01 -04:00
|
|
|
api({
|
2015-10-21 15:12:41 -04:00
|
|
|
uri: '/proxy/featured'
|
2015-10-20 12:25:30 -04:00
|
|
|
}, function (err, body) {
|
2016-09-08 17:23:49 -04:00
|
|
|
if (!body) return log.error('No response body');
|
|
|
|
if (!err) return this.setState({featuredGlobal: body});
|
2015-10-21 15:12:41 -04:00
|
|
|
}.bind(this));
|
|
|
|
},
|
|
|
|
getFeaturedCustom: function () {
|
2016-06-06 10:09:01 -04:00
|
|
|
api({
|
2016-06-01 17:22:11 -04:00
|
|
|
uri: '/proxy/users/' + this.props.session.session.user.id + '/featured'
|
2015-10-21 15:12:41 -04:00
|
|
|
}, function (err, body) {
|
2016-09-08 17:23:49 -04:00
|
|
|
if (!body) return log.error('No response body');
|
|
|
|
if (!err) return this.setState({featuredCustom: body});
|
2015-10-21 15:12:41 -04:00
|
|
|
}.bind(this));
|
|
|
|
},
|
|
|
|
getNews: function () {
|
2016-06-06 10:09:01 -04:00
|
|
|
api({
|
2015-10-21 15:12:41 -04:00
|
|
|
uri: '/news?limit=3'
|
|
|
|
}, function (err, body) {
|
2016-09-08 17:23:49 -04:00
|
|
|
if (!body) return log.error('No response body');
|
|
|
|
if (!err) return this.setState({news: body});
|
2015-10-20 12:25:30 -04:00
|
|
|
}.bind(this));
|
|
|
|
},
|
2015-10-21 14:12:34 -04:00
|
|
|
getProjectCount: function () {
|
2016-06-06 10:09:01 -04:00
|
|
|
api({
|
2015-10-21 14:12:34 -04:00
|
|
|
uri: '/projects/count/all'
|
|
|
|
}, function (err, body) {
|
2016-09-08 17:23:49 -04:00
|
|
|
if (!body) return log.error('No response body');
|
|
|
|
if (!err) return this.setState({projectCount: body.count});
|
2015-10-21 14:12:34 -04:00
|
|
|
}.bind(this));
|
|
|
|
},
|
2015-10-28 08:57:05 -04:00
|
|
|
refreshHomepageCache: function () {
|
2016-06-06 10:09:01 -04:00
|
|
|
api({
|
2015-10-30 09:14:49 -04:00
|
|
|
host: '',
|
2015-10-28 08:57:05 -04:00
|
|
|
uri: '/scratch_admin/homepage/clear-cache/',
|
|
|
|
method: 'post',
|
|
|
|
useCsrf: true
|
|
|
|
}, function (err, body) {
|
|
|
|
if (err) return this.setState({refreshCacheStatus: 'fail'});
|
2016-09-08 17:23:49 -04:00
|
|
|
if (!body) return log.error('No response body');
|
2015-10-28 08:57:05 -04:00
|
|
|
if (!body.success) return this.setState({refreshCacheStatus: 'inprogress'});
|
|
|
|
return this.setState({refreshCacheStatus: 'pass'});
|
|
|
|
}.bind(this));
|
|
|
|
},
|
|
|
|
getHomepageRefreshStatus: function () {
|
|
|
|
var status = {
|
|
|
|
status: this.state.refreshCacheStatus,
|
|
|
|
disabled: false,
|
|
|
|
content: 'Refresh'
|
|
|
|
};
|
|
|
|
if (this.state.refreshCacheStatus === 'inprogress') {
|
|
|
|
status.disabled = true;
|
|
|
|
status.content = 'In Progress';
|
|
|
|
} else if (this.state.refreshCacheStatus === 'pass') {
|
|
|
|
status.disabled = true;
|
|
|
|
status.content = 'Requested';
|
|
|
|
} else if (this.state.refreshCacheStatus == 'fail') {
|
|
|
|
status.disabled = false;
|
|
|
|
status.content = 'Error';
|
|
|
|
}
|
|
|
|
return status;
|
|
|
|
},
|
2015-10-22 18:40:04 -04:00
|
|
|
showEmailConfirmationModal: function () {
|
2015-10-23 19:02:00 -04:00
|
|
|
this.setState({emailConfirmationModalOpen: true});
|
2015-10-22 18:40:04 -04:00
|
|
|
},
|
|
|
|
hideEmailConfirmationModal: function () {
|
2015-10-23 19:02:00 -04:00
|
|
|
this.setState({emailConfirmationModalOpen: false});
|
2015-10-22 18:40:04 -04:00
|
|
|
},
|
2015-10-22 17:17:27 -04:00
|
|
|
handleDismiss: function (cue) {
|
2017-04-03 14:32:38 -04:00
|
|
|
api({
|
|
|
|
host: '',
|
|
|
|
uri: '/site-api/users/set-template-cue/',
|
|
|
|
method: 'post',
|
|
|
|
useCsrf: true,
|
|
|
|
json: {cue: cue, value: false}
|
|
|
|
}, function (err) {
|
|
|
|
if (!err) this.props.dispatch(sessionActions.refreshSession());
|
|
|
|
}.bind(this));
|
2015-10-22 12:21:47 -04:00
|
|
|
},
|
2015-10-24 12:05:18 -04:00
|
|
|
shouldShowWelcome: function () {
|
2016-06-01 17:22:11 -04:00
|
|
|
if (!this.props.session.session.user || !this.props.session.session.flags.show_welcome) return false;
|
2015-10-24 12:05:18 -04:00
|
|
|
return (
|
2016-06-01 17:22:11 -04:00
|
|
|
new Date(this.props.session.session.user.dateJoined) >
|
2015-10-24 12:05:18 -04:00
|
|
|
new Date(new Date - 2*7*24*60*60*1000) // Two weeks ago
|
|
|
|
);
|
|
|
|
},
|
2015-10-25 12:05:52 -04:00
|
|
|
shouldShowEmailConfirmation: function () {
|
|
|
|
return (
|
2016-06-01 17:22:11 -04:00
|
|
|
this.props.session.session.user && this.props.session.session.flags.has_outstanding_email_confirmation &&
|
|
|
|
this.props.session.session.flags.confirm_email_banner);
|
2015-10-25 12:05:52 -04:00
|
|
|
},
|
2015-10-20 13:18:57 -04:00
|
|
|
renderHomepageRows: function () {
|
2015-10-20 14:42:17 -04:00
|
|
|
var formatMessage = this.props.intl.formatMessage;
|
2015-10-23 10:07:50 -04:00
|
|
|
|
2015-10-20 13:18:57 -04:00
|
|
|
var rows = [
|
2015-10-20 14:42:17 -04:00
|
|
|
<Box
|
2016-08-16 08:56:01 -04:00
|
|
|
title={formatMessage({id: 'splash.featuredProjects'})}
|
2015-10-20 14:42:17 -04:00
|
|
|
key="community_featured_projects">
|
2015-10-20 13:18:57 -04:00
|
|
|
<Carousel items={this.state.featuredGlobal.community_featured_projects} />
|
|
|
|
</Box>,
|
2015-10-20 14:42:17 -04:00
|
|
|
<Box
|
2016-08-16 08:56:01 -04:00
|
|
|
title={formatMessage({id: 'splash.featuredStudios'})}
|
2015-10-20 14:42:17 -04:00
|
|
|
key="community_featured_studios">
|
2015-10-23 10:07:50 -04:00
|
|
|
<Carousel items={this.state.featuredGlobal.community_featured_studios}
|
|
|
|
settings={{slidesToShow: 4, slidesToScroll: 4, lazyLoad: false}} />
|
2015-10-20 13:18:57 -04:00
|
|
|
</Box>
|
|
|
|
];
|
|
|
|
|
2015-10-21 16:49:50 -04:00
|
|
|
if (this.state.featuredGlobal.curator_top_projects &&
|
|
|
|
this.state.featuredGlobal.curator_top_projects.length > 4) {
|
2016-05-31 16:37:42 -04:00
|
|
|
|
2015-10-20 13:18:57 -04:00
|
|
|
rows.push(
|
|
|
|
<Box
|
|
|
|
key="curator_top_projects"
|
|
|
|
title={
|
2016-10-13 17:31:57 -04:00
|
|
|
formatMessage({id: 'splash.projectsCuratedBy'}) + ' ' +
|
2015-10-20 13:18:57 -04:00
|
|
|
this.state.featuredGlobal.curator_top_projects[0].curator_name}
|
2016-10-12 09:28:41 -04:00
|
|
|
moreTitle={formatMessage({id: 'general.learnMore'})}
|
2015-10-20 13:18:57 -04:00
|
|
|
moreHref="/studios/386359/">
|
2016-10-11 12:32:25 -04:00
|
|
|
|
2016-08-16 08:56:01 -04:00
|
|
|
<Carousel items={this.state.featuredGlobal.curator_top_projects} />
|
2015-10-20 13:18:57 -04:00
|
|
|
</Box>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2015-10-21 16:49:50 -04:00
|
|
|
if (this.state.featuredGlobal.scratch_design_studio &&
|
|
|
|
this.state.featuredGlobal.scratch_design_studio.length > 4) {
|
2016-05-31 16:37:42 -04:00
|
|
|
|
2015-10-20 13:18:57 -04:00
|
|
|
rows.push(
|
|
|
|
<Box
|
|
|
|
key="scratch_design_studio"
|
|
|
|
title={
|
2016-08-16 08:56:01 -04:00
|
|
|
formatMessage({id: 'splash.scratchDesignStudioTitle'})
|
2015-10-20 14:42:17 -04:00
|
|
|
+ ' - ' + this.state.featuredGlobal.scratch_design_studio[0].gallery_title}
|
2016-10-12 09:28:41 -04:00
|
|
|
moreTitle={formatMessage({id: 'splash.visitTheStudio'})}
|
2015-10-20 13:18:57 -04:00
|
|
|
moreHref={'/studios/' + this.state.featuredGlobal.scratch_design_studio[0].gallery_id + '/'}>
|
2016-10-11 12:32:25 -04:00
|
|
|
|
2016-08-16 08:56:01 -04:00
|
|
|
<Carousel items={this.state.featuredGlobal.scratch_design_studio} />
|
2015-10-20 13:18:57 -04:00
|
|
|
</Box>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2016-06-01 17:22:11 -04:00
|
|
|
if (this.props.session.session.user &&
|
2015-10-21 16:49:50 -04:00
|
|
|
this.state.featuredGlobal.community_newest_projects &&
|
|
|
|
this.state.featuredGlobal.community_newest_projects.length > 0) {
|
2016-05-31 16:37:42 -04:00
|
|
|
|
2015-10-20 13:18:57 -04:00
|
|
|
rows.push(
|
2016-08-16 08:56:01 -04:00
|
|
|
<Box title={formatMessage({id: 'splash.recentlySharedProjects'})}
|
|
|
|
key="community_newest_projects">
|
|
|
|
<Carousel items={this.state.featuredGlobal.community_newest_projects} />
|
2015-10-20 13:18:57 -04:00
|
|
|
</Box>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2015-10-21 16:49:50 -04:00
|
|
|
if (this.state.featuredCustom.custom_projects_by_following &&
|
|
|
|
this.state.featuredCustom.custom_projects_by_following.length > 0) {
|
2016-05-31 16:37:42 -04:00
|
|
|
|
2015-10-20 13:18:57 -04:00
|
|
|
rows.push(
|
2016-08-16 08:56:01 -04:00
|
|
|
<Box title={formatMessage({id: 'splash.projectsByScratchersFollowing'})}
|
2015-10-21 16:49:50 -04:00
|
|
|
key="custom_projects_by_following">
|
2016-10-11 12:32:25 -04:00
|
|
|
|
2015-10-20 13:18:57 -04:00
|
|
|
<Carousel items={this.state.featuredCustom.custom_projects_by_following} />
|
|
|
|
</Box>
|
|
|
|
);
|
|
|
|
}
|
2015-10-21 16:49:50 -04:00
|
|
|
if (this.state.featuredCustom.custom_projects_loved_by_following &&
|
|
|
|
this.state.featuredCustom.custom_projects_loved_by_following.length > 0) {
|
|
|
|
|
2015-10-20 13:18:57 -04:00
|
|
|
rows.push(
|
2016-08-16 08:56:01 -04:00
|
|
|
<Box title={formatMessage({id: 'splash.projectsLovedByScratchersFollowing'})}
|
2015-10-21 16:49:50 -04:00
|
|
|
key="custom_projects_loved_by_following">
|
2016-10-11 12:32:25 -04:00
|
|
|
|
2015-10-20 13:18:57 -04:00
|
|
|
<Carousel items={this.state.featuredCustom.custom_projects_loved_by_following} />
|
|
|
|
</Box>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2015-10-21 16:49:50 -04:00
|
|
|
if (this.state.featuredCustom.custom_projects_in_studios_following &&
|
|
|
|
this.state.featuredCustom.custom_projects_in_studios_following.length > 0) {
|
2016-05-31 16:37:42 -04:00
|
|
|
|
2015-10-20 13:18:57 -04:00
|
|
|
rows.push(
|
2016-08-16 08:56:01 -04:00
|
|
|
<Box title={formatMessage({id:'splash.projectsInStudiosFollowing'})}
|
2015-10-21 16:49:50 -04:00
|
|
|
key="custom_projects_in_studios_following">
|
2016-10-11 12:32:25 -04:00
|
|
|
|
2015-10-20 13:18:57 -04:00
|
|
|
<Carousel items={this.state.featuredCustom.custom_projects_in_studios_following} />
|
|
|
|
</Box>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
rows.push(
|
2016-08-16 08:56:01 -04:00
|
|
|
<Box title={formatMessage({id: 'splash.communityRemixing'})}
|
2015-10-21 16:49:50 -04:00
|
|
|
key="community_most_remixed_projects">
|
2016-05-31 16:37:42 -04:00
|
|
|
|
2016-06-13 09:40:32 -04:00
|
|
|
<Carousel items={shuffle(this.state.featuredGlobal.community_most_remixed_projects)}
|
2016-06-09 17:22:31 -04:00
|
|
|
showRemixes={true} />
|
2015-10-20 13:18:57 -04:00
|
|
|
</Box>,
|
2016-08-16 08:56:01 -04:00
|
|
|
<Box title={formatMessage({id: 'splash.communityLoving'})}
|
2015-10-21 16:49:50 -04:00
|
|
|
key="community_most_loved_projects">
|
2016-05-31 16:37:42 -04:00
|
|
|
|
2016-06-13 09:40:32 -04:00
|
|
|
<Carousel items={shuffle(this.state.featuredGlobal.community_most_loved_projects)}
|
2016-06-09 17:22:31 -04:00
|
|
|
showLoves={true} />
|
2015-10-20 13:18:57 -04:00
|
|
|
</Box>
|
|
|
|
);
|
|
|
|
|
|
|
|
return rows;
|
|
|
|
},
|
2015-09-02 15:08:58 -04:00
|
|
|
render: function () {
|
2015-10-20 13:18:57 -04:00
|
|
|
var featured = this.renderHomepageRows();
|
2015-10-28 08:57:05 -04:00
|
|
|
var homepageCacheState = this.getHomepageRefreshStatus();
|
2016-01-07 09:57:34 -05:00
|
|
|
|
2016-01-07 11:02:14 -05:00
|
|
|
var formatHTMLMessage = this.props.intl.formatHTMLMessage;
|
2016-03-22 11:00:37 -04:00
|
|
|
var formatNumber = this.props.intl.formatNumber;
|
|
|
|
var formatMessage = this.props.intl.formatMessage;
|
2016-01-07 11:02:14 -05:00
|
|
|
var messages = {
|
|
|
|
'general.viewAll': formatMessage({id: 'general.viewAll'}),
|
|
|
|
'news.scratchNews': formatMessage({id: 'news.scratchNews'}),
|
|
|
|
'welcome.welcomeToScratch': formatMessage({id: 'welcome.welcomeToScratch'}),
|
|
|
|
'welcome.learn': formatMessage({id: 'welcome.learn'}),
|
|
|
|
'welcome.tryOut': formatMessage({id: 'welcome.tryOut'}),
|
|
|
|
'welcome.connect': formatMessage({id: 'welcome.connect'}),
|
|
|
|
'intro.aboutScratch': formatMessage({id: 'intro.aboutScratch'}),
|
|
|
|
'intro.forEducators': formatMessage({id: 'intro.forEducators'}),
|
|
|
|
'intro.forParents': formatMessage({id: 'intro.forParents'}),
|
|
|
|
'intro.joinScratch': formatMessage({id: 'intro.joinScratch'}),
|
|
|
|
'intro.seeExamples': formatMessage({id: 'intro.seeExamples'}),
|
|
|
|
'intro.tagLine': formatHTMLMessage({id: 'intro.tagLine'}),
|
2016-06-13 07:47:43 -04:00
|
|
|
'intro.tryItOut': formatMessage({id: 'intro.tryItOut'}),
|
2016-06-13 09:41:12 -04:00
|
|
|
'teacherbanner.greeting': formatMessage({id: 'teacherbanner.greeting'}),
|
|
|
|
'teacherbanner.subgreeting': formatMessage({id: 'teacherbanner.subgreeting'}),
|
|
|
|
'teacherbanner.classesButton': formatMessage({id: 'teacherbanner.classesButton'}),
|
2016-08-16 11:33:07 -04:00
|
|
|
'teacherbanner.resourcesButton': formatMessage({id: 'general.resourcesTitle'}),
|
2016-06-13 09:41:12 -04:00
|
|
|
'teacherbanner.faqButton': formatMessage({id: 'teacherbanner.faqButton'})
|
2016-01-07 11:02:14 -05:00
|
|
|
};
|
2016-03-22 11:00:37 -04:00
|
|
|
if (this.state.projectCount === this.getInitialState().projectCount) {
|
|
|
|
messages['intro.description'] = formatHTMLMessage({id: 'intro.defaultDescription'});
|
|
|
|
} else {
|
|
|
|
var count = formatNumber(this.state.projectCount);
|
|
|
|
messages['intro.description'] = formatHTMLMessage({id: 'intro.description'}, {value: count});
|
|
|
|
}
|
2016-01-07 09:57:34 -05:00
|
|
|
|
2015-09-02 15:08:58 -04:00
|
|
|
return (
|
2015-10-22 17:19:31 -04:00
|
|
|
<div className="splash">
|
2015-10-25 12:05:52 -04:00
|
|
|
{this.shouldShowEmailConfirmation() ? [
|
2016-11-08 14:43:10 -05:00
|
|
|
<DropdownBanner
|
|
|
|
key="confirmedEmail"
|
|
|
|
className="warning"
|
|
|
|
onRequestDismiss={this.handleDismiss.bind(this, 'confirmed_email')}
|
|
|
|
>
|
2015-10-22 18:40:04 -04:00
|
|
|
<a href="#" onClick={this.showEmailConfirmationModal}>Confirm your email</a>
|
2015-10-23 19:02:00 -04:00
|
|
|
{' '}to enable sharing.{' '}
|
2015-10-22 17:19:31 -04:00
|
|
|
<a href="/info/faq/#accounts">Having trouble?</a>
|
2016-04-07 17:47:00 -04:00
|
|
|
</DropdownBanner>,
|
2016-11-08 14:43:10 -05:00
|
|
|
<IframeModal
|
|
|
|
isOpen={this.state.emailConfirmationModalOpen}
|
|
|
|
onRequestClose={this.hideEmailConfirmationModal}
|
|
|
|
className="mod-confirmation"
|
2016-11-10 17:13:44 -05:00
|
|
|
componentRef={
|
|
|
|
function (iframe) {
|
|
|
|
this.emailConfirmationiFrame = iframe;
|
|
|
|
}.bind(this)
|
|
|
|
}
|
2016-11-08 14:43:10 -05:00
|
|
|
src="/accounts/email_resend_standalone/"
|
|
|
|
/>
|
2015-10-22 17:19:31 -04:00
|
|
|
] : []}
|
2016-06-08 13:47:11 -04:00
|
|
|
{this.props.permissions.educator ? [
|
2016-07-03 14:49:01 -04:00
|
|
|
<TeacherBanner key="teacherbanner" messages={messages} />
|
2016-06-08 13:47:11 -04:00
|
|
|
] : []}
|
2016-11-16 08:51:57 -05:00
|
|
|
<div key="inner" className="inner mod-splash">
|
2016-06-01 16:14:58 -04:00
|
|
|
{this.props.session.status === sessionActions.Status.FETCHED ? (
|
2016-06-01 17:22:11 -04:00
|
|
|
this.props.session.session.user ? [
|
2016-05-31 16:37:42 -04:00
|
|
|
<div key="header" className="splash-header">
|
|
|
|
{this.shouldShowWelcome() ? [
|
|
|
|
<Welcome key="welcome"
|
|
|
|
onDismiss={this.handleDismiss.bind(this, 'welcome')}
|
|
|
|
messages={messages} />
|
|
|
|
] : [
|
|
|
|
<Activity key="activity" items={this.state.activity} />
|
|
|
|
]}
|
|
|
|
<News items={this.state.news} messages={messages} />
|
|
|
|
</div>
|
|
|
|
] : [
|
2016-07-26 11:29:45 -04:00
|
|
|
<MediaQuery minWidth={frameless.desktop}>
|
|
|
|
<Intro projectCount={this.state.projectCount} messages={messages} key="intro"/>
|
|
|
|
</MediaQuery>
|
2016-06-01 10:49:59 -04:00
|
|
|
]) : []
|
2016-05-31 16:37:42 -04:00
|
|
|
}
|
2015-10-20 13:18:57 -04:00
|
|
|
|
2015-10-22 17:19:31 -04:00
|
|
|
{featured}
|
2015-10-20 13:18:57 -04:00
|
|
|
|
2015-10-22 17:19:31 -04:00
|
|
|
<AdminPanel>
|
|
|
|
<dt>Tools</dt>
|
|
|
|
<dd>
|
|
|
|
<ul>
|
|
|
|
<li>
|
|
|
|
<a href="/scratch_admin/tickets">Ticket Queue</a>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<a href="/scratch_admin/ip-search/">IP Search</a>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<a href="/scratch_admin/email-search/">Email Search</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</dd>
|
|
|
|
<dt>Homepage Cache</dt>
|
|
|
|
<dd>
|
|
|
|
<ul className="cache-list">
|
|
|
|
<li>
|
2015-10-28 08:57:05 -04:00
|
|
|
<div className="button-row">
|
|
|
|
<span>Refresh row data:</span>
|
|
|
|
<Button onClick={this.refreshHomepageCache}
|
|
|
|
className={homepageCacheState.status}
|
2015-10-30 09:14:49 -04:00
|
|
|
disabled={homepageCacheState.disabled}>
|
2015-10-28 08:57:05 -04:00
|
|
|
<span>{homepageCacheState.content}</span>
|
|
|
|
</Button>
|
|
|
|
</div>
|
2015-10-22 17:19:31 -04:00
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</dd>
|
|
|
|
</AdminPanel>
|
|
|
|
</div>
|
2015-09-02 15:08:58 -04:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
2015-10-20 14:42:17 -04:00
|
|
|
}));
|
2015-09-02 15:08:58 -04:00
|
|
|
|
2016-03-18 11:51:22 -04:00
|
|
|
var mapStateToProps = function (state) {
|
|
|
|
return {
|
2016-06-08 13:47:11 -04:00
|
|
|
session: state.session,
|
|
|
|
permissions: state.permissions
|
2016-03-18 11:51:22 -04:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
var ConnectedSplash = connect(mapStateToProps)(Splash);
|
|
|
|
|
|
|
|
render(<Page><ConnectedSplash /></Page>, document.getElementById('app'));
|