mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-23 07:38:07 -05:00
pass project title to GUI, and disable submit when editing title
This commit is contained in:
parent
3c6530fe85
commit
478a30efcb
3 changed files with 20 additions and 3 deletions
|
@ -37,7 +37,7 @@ const render = (jsx, element, reducers, initialState, enhancer) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const allReducers = reducer(reducers);
|
const allReducers = reducer(reducers);
|
||||||
|
|
||||||
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || redux.compose;
|
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || redux.compose;
|
||||||
const enhancers = enhancer ?
|
const enhancers = enhancer ?
|
||||||
composeEnhancers(
|
composeEnhancers(
|
||||||
|
|
|
@ -27,6 +27,16 @@ const ExtensionChip = require('./extension-chip.jsx');
|
||||||
const projectShape = require('./projectshape.jsx').projectShape;
|
const projectShape = require('./projectshape.jsx').projectShape;
|
||||||
require('./preview.scss');
|
require('./preview.scss');
|
||||||
|
|
||||||
|
// disable enter key submission on formsy input fields; otherwise formsy thinks
|
||||||
|
// we meant to trigger the "See inside" button. Instead, treat these keypresses
|
||||||
|
// as a blur, which will trigger a save.
|
||||||
|
const onKeyPress = e => {
|
||||||
|
if (e.target.type === 'text' && e.which === 13 /* Enter */) {
|
||||||
|
e.preventDefault();
|
||||||
|
e.target.blur();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const PreviewPresentation = ({
|
const PreviewPresentation = ({
|
||||||
assetHost,
|
assetHost,
|
||||||
backpackOptions,
|
backpackOptions,
|
||||||
|
@ -70,7 +80,7 @@ const PreviewPresentation = ({
|
||||||
<ShareBanner shared={isShared} />
|
<ShareBanner shared={isShared} />
|
||||||
|
|
||||||
{ projectInfo && projectInfo.author && projectInfo.author.id && (
|
{ projectInfo && projectInfo.author && projectInfo.author.id && (
|
||||||
<Formsy>
|
<Formsy onKeyPress={onKeyPress}>
|
||||||
<div className="inner">
|
<div className="inner">
|
||||||
<FlexRow className="preview-row">
|
<FlexRow className="preview-row">
|
||||||
<FlexRow className="project-header">
|
<FlexRow className="project-header">
|
||||||
|
@ -135,6 +145,7 @@ const PreviewPresentation = ({
|
||||||
previewInfoVisible="false"
|
previewInfoVisible="false"
|
||||||
projectHost={projectHost}
|
projectHost={projectHost}
|
||||||
projectId={projectId}
|
projectId={projectId}
|
||||||
|
projectTitle={projectInfo.title}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<FlexRow className="project-notes">
|
<FlexRow className="project-notes">
|
||||||
|
|
|
@ -42,6 +42,7 @@ class Preview extends React.Component {
|
||||||
'handleAddToStudioClick',
|
'handleAddToStudioClick',
|
||||||
'handleAddToStudioClose',
|
'handleAddToStudioClose',
|
||||||
'handleSeeInside',
|
'handleSeeInside',
|
||||||
|
'handleUpdateProjectTitle',
|
||||||
'handleUpdate',
|
'handleUpdate',
|
||||||
'initCounts',
|
'initCounts',
|
||||||
'isShared',
|
'isShared',
|
||||||
|
@ -277,6 +278,11 @@ class Preview extends React.Component {
|
||||||
this.props.user.token
|
this.props.user.token
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
handleUpdateProjectTitle (title) {
|
||||||
|
this.handleUpdate({
|
||||||
|
title: title
|
||||||
|
});
|
||||||
|
}
|
||||||
initCounts (favorites, loves) {
|
initCounts (favorites, loves) {
|
||||||
this.setState({
|
this.setState({
|
||||||
favoriteCount: favorites,
|
favoriteCount: favorites,
|
||||||
|
@ -456,7 +462,6 @@ const consolidateStudiosInfo = (curatedStudios, projectStudios, currentStudioIds
|
||||||
};
|
};
|
||||||
|
|
||||||
const mapStateToProps = state => ({
|
const mapStateToProps = state => ({
|
||||||
projectInfo: state.preview.projectInfo,
|
|
||||||
comments: state.preview.comments,
|
comments: state.preview.comments,
|
||||||
faved: state.preview.faved,
|
faved: state.preview.faved,
|
||||||
loved: state.preview.loved,
|
loved: state.preview.loved,
|
||||||
|
@ -465,6 +470,7 @@ const mapStateToProps = state => ({
|
||||||
remixes: state.preview.remixes,
|
remixes: state.preview.remixes,
|
||||||
replies: state.preview.replies,
|
replies: state.preview.replies,
|
||||||
sessionStatus: state.session.status,
|
sessionStatus: state.session.status,
|
||||||
|
projectInfo: state.preview.projectInfo,
|
||||||
projectStudios: state.preview.projectStudios,
|
projectStudios: state.preview.projectStudios,
|
||||||
studios: consolidateStudiosInfo(state.preview.curatedStudios,
|
studios: consolidateStudiosInfo(state.preview.curatedStudios,
|
||||||
state.preview.projectStudios, state.preview.currentStudioIds,
|
state.preview.projectStudios, state.preview.currentStudioIds,
|
||||||
|
|
Loading…
Reference in a new issue