mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-27 01:25:52 -05:00
Merge pull request #2222 from benjiwheeler/copy-remix
Set capability flags to be passed to GUI, to support remix and save as copy
This commit is contained in:
commit
95dc611d77
1 changed files with 10 additions and 9 deletions
|
@ -436,10 +436,10 @@ class Preview extends React.Component {
|
||||||
assetHost={this.props.assetHost}
|
assetHost={this.props.assetHost}
|
||||||
backpackOptions={this.props.backpackOptions}
|
backpackOptions={this.props.backpackOptions}
|
||||||
basePath="/"
|
basePath="/"
|
||||||
|
canCreateCopy={this.props.canCreateCopy}
|
||||||
canCreateNew={this.props.canCreateNew}
|
canCreateNew={this.props.canCreateNew}
|
||||||
canRemix={this.props.canRemix}
|
canRemix={this.props.canRemix}
|
||||||
canSave={this.props.canSave}
|
canSave={this.props.canSave}
|
||||||
canSaveAsCopy={this.props.canSaveAsCopy}
|
|
||||||
canShare={this.props.canShare}
|
canShare={this.props.canShare}
|
||||||
className="gui"
|
className="gui"
|
||||||
enableCommunity={this.props.enableCommunity}
|
enableCommunity={this.props.enableCommunity}
|
||||||
|
@ -470,11 +470,11 @@ Preview.propTypes = {
|
||||||
visible: PropTypes.bool
|
visible: PropTypes.bool
|
||||||
}),
|
}),
|
||||||
canAddToStudio: PropTypes.bool,
|
canAddToStudio: PropTypes.bool,
|
||||||
|
canCreateCopy: PropTypes.bool,
|
||||||
canCreateNew: PropTypes.bool,
|
canCreateNew: PropTypes.bool,
|
||||||
canRemix: PropTypes.bool,
|
canRemix: PropTypes.bool,
|
||||||
canReport: PropTypes.bool,
|
canReport: PropTypes.bool,
|
||||||
canSave: PropTypes.bool,
|
canSave: PropTypes.bool,
|
||||||
canSaveAsCopy: PropTypes.bool,
|
|
||||||
canShare: PropTypes.bool,
|
canShare: PropTypes.bool,
|
||||||
comments: PropTypes.arrayOf(PropTypes.object),
|
comments: PropTypes.arrayOf(PropTypes.object),
|
||||||
enableCommunity: PropTypes.bool,
|
enableCommunity: PropTypes.bool,
|
||||||
|
@ -547,7 +547,8 @@ Preview.defaultProps = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const mapStateToProps = state => {
|
const mapStateToProps = state => {
|
||||||
const projectInfoPresent = Object.keys(state.preview.projectInfo).length > 0;
|
const projectInfoPresent = state.preview.projectInfo &&
|
||||||
|
Object.keys(state.preview.projectInfo).length > 0 && state.preview.projectInfo.id > 0;
|
||||||
const userPresent = state.session.session.user !== null &&
|
const userPresent = state.session.session.user !== null &&
|
||||||
typeof state.session.session.user !== 'undefined' &&
|
typeof state.session.session.user !== 'undefined' &&
|
||||||
Object.keys(state.session.session.user).length > 0;
|
Object.keys(state.session.session.user).length > 0;
|
||||||
|
@ -560,15 +561,15 @@ const mapStateToProps = state => {
|
||||||
state.session.session.user.id === state.preview.projectInfo.author.id;
|
state.session.session.user.id === state.preview.projectInfo.author.id;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
canAddToStudio: isLoggedIn && userOwnsProject,
|
canAddToStudio: userOwnsProject,
|
||||||
canCreateNew: true,
|
canCreateCopy: userOwnsProject && projectInfoPresent,
|
||||||
canRemix: false,
|
canCreateNew: isLoggedIn,
|
||||||
|
canRemix: isLoggedIn && projectInfoPresent && !userOwnsProject,
|
||||||
canReport: isLoggedIn && !userOwnsProject,
|
canReport: isLoggedIn && !userOwnsProject,
|
||||||
canSave: isLoggedIn && (userOwnsProject || !state.preview.projectInfo.id),
|
canSave: isLoggedIn && userOwnsProject,
|
||||||
canSaveAsCopy: false,
|
|
||||||
canShare: userOwnsProject && state.permissions.social,
|
canShare: userOwnsProject && state.permissions.social,
|
||||||
comments: state.preview.comments,
|
comments: state.preview.comments,
|
||||||
enableCommunity: state.preview.projectInfo && state.preview.projectInfo.id > 0,
|
enableCommunity: projectInfoPresent,
|
||||||
faved: state.preview.faved,
|
faved: state.preview.faved,
|
||||||
fullScreen: state.scratchGui.mode.isFullScreen,
|
fullScreen: state.scratchGui.mode.isFullScreen,
|
||||||
// project is editable iff logged in user is the author of the project, or
|
// project is editable iff logged in user is the author of the project, or
|
||||||
|
|
Loading…
Reference in a new issue