Skip to content

Commit 4f8ba60

Browse files
committed
allow renaming project title from inside editor
1 parent 4236724 commit 4f8ba60

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/components/menu-bar/project-title-input.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const mapStateToProps = state => ({
5454

5555
const mapDispatchToProps = dispatch => ({
5656
onSubmitDispatch: title => dispatch(setProjectTitle(title)),
57-
titleChangedSuccess: () => dispatch(showAlertWithTimeout(dispatch, 'TitleChanged'))
57+
titleChangedSuccess: () => showAlertWithTimeout(dispatch, 'TitleChanged')
5858
});
5959

6060
const mergeProps = (stateProps, dispatchProps, ownProps) => ({

src/lib/tw-project-meta-fetcher-hoc.jsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import PropTypes from 'prop-types';
33
import {connect} from 'react-redux';
44
import log from './log';
55

6-
76
// eslint-disable-next-line import/no-commonjs
87
const {API_HOST} = require('./brand');
98

@@ -65,7 +64,8 @@ const TWProjectMetaFetcherHOC = function (WrappedComponent) {
6564
this.state = {
6665
canSave: false,
6766
canRemix: false,
68-
canUseCloud: false
67+
canUseCloud: false,
68+
canEditTitle: false
6969
};
7070
}
7171
componentDidUpdate (prevProps) {
@@ -98,10 +98,13 @@ const TWProjectMetaFetcherHOC = function (WrappedComponent) {
9898
this.props.onSetDescription(instructions, credits);
9999
}
100100

101-
this.setState({canSave: data.canSave === 'true'});
102-
// if you can save, you can edit title (it doesn't work the prop isn't passed down)
103-
// this.setState({canEditTitle: true});
104-
this.setState({canRemix: data.canRemix === 'true'});
101+
const canSave = data.canSave === 'true';
102+
this.setState({
103+
canSave: canSave,
104+
canRemix: data.canRemix === 'true',
105+
canEditTitle: canSave // Enable title editing if user has save permissions
106+
});
107+
105108
storage.setCloudOTT(data?.cloudDataOTT);
106109
storage.setCustomAchievements(data?.customAchievements);
107110
window.CollaborationRoom = data?.collaboratorRoom;
@@ -135,6 +138,7 @@ const TWProjectMetaFetcherHOC = function (WrappedComponent) {
135138
canSave={this.state.canSave}
136139
canRemix={this.state.canRemix}
137140
canUseCloud={this.state.canUseCloud}
141+
canEditTitle={this.state.canEditTitle}
138142
/>
139143
);
140144
}

0 commit comments

Comments
 (0)