Merge pull request #2656 from chrisgarrity/issue/2628-remix-loading-project

Don’t allow remixing if the project is not loaded
This commit is contained in:
chrisgarrity 2019-01-10 14:41:52 -05:00 committed by GitHub
commit cebdd0a17d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 3 deletions

View file

@ -70,6 +70,7 @@ const PreviewPresentation = ({
isFullScreen, isFullScreen,
isLoggedIn, isLoggedIn,
isNewScratcher, isNewScratcher,
isProjectLoaded,
isRemixing, isRemixing,
isScratcher, isScratcher,
isShared, isShared,
@ -91,6 +92,7 @@ const PreviewPresentation = ({
onLoadMoreReplies, onLoadMoreReplies,
onLoveClicked, onLoveClicked,
onOpenAdminPanel, onOpenAdminPanel,
onProjectLoaded,
onRemix, onRemix,
onRemixing, onRemixing,
onReportClicked, onReportClicked,
@ -251,10 +253,11 @@ const PreviewPresentation = ({
className={classNames([ className={classNames([
'remix-button', 'remix-button',
{ {
remixing: isRemixing, disabled: isRemixing || !isProjectLoaded,
spin: isRemixing remixing: isRemixing
} }
])} ])}
disabled={isRemixing || !isProjectLoaded}
title={intl.formatMessage({id: 'project.remixButton.altText'})} title={intl.formatMessage({id: 'project.remixButton.altText'})}
onClick={onRemix} onClick={onRemix}
> >
@ -302,6 +305,7 @@ const PreviewPresentation = ({
projectHost={projectHost} projectHost={projectHost}
projectId={projectId} projectId={projectId}
onGreenFlag={onGreenFlag} onGreenFlag={onGreenFlag}
onProjectLoaded={onProjectLoaded}
onRemixing={onRemixing} onRemixing={onRemixing}
onUpdateProjectId={onUpdateProjectId} onUpdateProjectId={onUpdateProjectId}
onUpdateProjectThumbnail={onUpdateProjectThumbnail} onUpdateProjectThumbnail={onUpdateProjectThumbnail}
@ -626,6 +630,7 @@ PreviewPresentation.propTypes = {
isFullScreen: PropTypes.bool, isFullScreen: PropTypes.bool,
isLoggedIn: PropTypes.bool, isLoggedIn: PropTypes.bool,
isNewScratcher: PropTypes.bool, isNewScratcher: PropTypes.bool,
isProjectLoaded: PropTypes.bool,
isRemixing: PropTypes.bool, isRemixing: PropTypes.bool,
isScratcher: PropTypes.bool, isScratcher: PropTypes.bool,
isShared: PropTypes.bool, isShared: PropTypes.bool,
@ -650,6 +655,7 @@ PreviewPresentation.propTypes = {
onLoadMoreReplies: PropTypes.func, onLoadMoreReplies: PropTypes.func,
onLoveClicked: PropTypes.func, onLoveClicked: PropTypes.func,
onOpenAdminPanel: PropTypes.func, onOpenAdminPanel: PropTypes.func,
onProjectLoaded: PropTypes.func,
onRemix: PropTypes.func, onRemix: PropTypes.func,
onRemixing: PropTypes.func, onRemixing: PropTypes.func,
onReportClicked: PropTypes.func.isRequired, onReportClicked: PropTypes.func.isRequired,

View file

@ -283,9 +283,11 @@ $stage-width: 480px;
background-image: url("/svgs/project/remix-white.svg"); background-image: url("/svgs/project/remix-white.svg");
} }
} }
.remix-button.disabled {
opacity: .6;
}
.remix-button.remixing { .remix-button.remixing {
opacity: .6;
&:before { &:before {
animation-name: remix-intro, remix-spin; animation-name: remix-intro, remix-spin;

View file

@ -75,6 +75,7 @@ class Preview extends React.Component {
'handleAddToStudioClick', 'handleAddToStudioClick',
'handleAddToStudioClose', 'handleAddToStudioClose',
'handleGreenFlag', 'handleGreenFlag',
'handleProjectLoaded',
'handleRemix', 'handleRemix',
'handleSeeAllComments', 'handleSeeAllComments',
'handleSeeInside', 'handleSeeInside',
@ -109,6 +110,7 @@ class Preview extends React.Component {
clientLoved: false, clientLoved: false,
extensions: [], extensions: [],
favoriteCount: 0, favoriteCount: 0,
isProjectLoaded: false,
isRemixing: false, isRemixing: false,
invalidProject: parts.length === 1, invalidProject: parts.length === 1,
justRemixed: false, justRemixed: false,
@ -383,6 +385,11 @@ class Preview extends React.Component {
this.props.setFullScreen(fullScreen); this.props.setFullScreen(fullScreen);
} }
} }
handleProjectLoaded () {
// Currently project view only needs to know when the project becomes loaded. It
// does not currently handle (or need to handle) the case where a project becomes unloaded.
this.setState({isProjectLoaded: true});
}
pushHistory (push) { pushHistory (push) {
// update URI to match mode // update URI to match mode
const idPath = this.state.projectId ? `${this.state.projectId}/` : ''; const idPath = this.state.projectId ? `${this.state.projectId}/` : '';
@ -617,6 +624,7 @@ class Preview extends React.Component {
isFullScreen={this.state.isFullScreen} isFullScreen={this.state.isFullScreen}
isLoggedIn={this.props.isLoggedIn} isLoggedIn={this.props.isLoggedIn}
isNewScratcher={this.props.isNewScratcher} isNewScratcher={this.props.isNewScratcher}
isProjectLoaded={this.state.isProjectLoaded}
isRemixing={this.state.isRemixing} isRemixing={this.state.isRemixing}
isScratcher={this.props.isScratcher} isScratcher={this.props.isScratcher}
isShared={this.props.isShared} isShared={this.props.isShared}
@ -653,6 +661,7 @@ class Preview extends React.Component {
onLoadMoreReplies={this.handleLoadMoreReplies} onLoadMoreReplies={this.handleLoadMoreReplies}
onLoveClicked={this.handleLoveToggle} onLoveClicked={this.handleLoveToggle}
onOpenAdminPanel={this.handleOpenAdminPanel} onOpenAdminPanel={this.handleOpenAdminPanel}
onProjectLoaded={this.handleProjectLoaded}
onRemix={this.handleRemix} onRemix={this.handleRemix}
onRemixing={this.handleIsRemixing} onRemixing={this.handleIsRemixing}
onReportClicked={this.handleReportClick} onReportClicked={this.handleReportClick}
@ -698,6 +707,7 @@ class Preview extends React.Component {
onGreenFlag={this.handleGreenFlag} onGreenFlag={this.handleGreenFlag}
onLogOut={this.props.handleLogOut} onLogOut={this.props.handleLogOut}
onOpenRegistration={this.props.handleOpenRegistration} onOpenRegistration={this.props.handleOpenRegistration}
onProjectLoaded={this.handleProjectLoaded}
onRemixing={this.handleIsRemixing} onRemixing={this.handleIsRemixing}
onSetLanguage={this.handleSetLanguage} onSetLanguage={this.handleSetLanguage}
onShare={this.handleShare} onShare={this.handleShare}