Skip to content

Commit fe7c201

Browse files
authored
Merge branch 'develop' into feature/date-i18n
2 parents 12e5278 + 144f68c commit fe7c201

33 files changed

+697
-264
lines changed

client/components/Nav.jsx

+5-6
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { logoutUser } from '../modules/User/actions';
1414

1515
import getConfig from '../utils/getConfig';
1616
import { metaKeyName, } from '../utils/metaKey';
17+
import { getIsUserOwner } from '../modules/IDE/selectors/users';
1718

1819
import CaretLeftIcon from '../images/left-arrow.svg';
1920
import TriangleIcon from '../images/down-filled-triangle.svg';
@@ -215,10 +216,6 @@ class Nav extends React.PureComponent {
215216
}
216217
}
217218

218-
isUserOwner() {
219-
return this.props.project.owner && this.props.project.owner.id === this.props.user.id;
220-
}
221-
222219
handleFocus(dropdown) {
223220
this.clearHideTimeout();
224221
this.setDropdown(dropdown);
@@ -283,7 +280,7 @@ class Nav extends React.PureComponent {
283280
{this.props.t('Nav.File.New')}
284281
</button>
285282
</li>
286-
{ getConfig('LOGIN_ENABLED') && (!this.props.project.owner || this.isUserOwner()) &&
283+
{ getConfig('LOGIN_ENABLED') && (!this.props.project.owner || this.props.isUserOwner) &&
287284
<li className="nav__dropdown-item">
288285
<button
289286
onClick={this.handleSave}
@@ -797,6 +794,7 @@ Nav.propTypes = {
797794
t: PropTypes.func.isRequired,
798795
setLanguage: PropTypes.func.isRequired,
799796
language: PropTypes.string.isRequired,
797+
isUserOwner: PropTypes.bool.isRequired
800798
};
801799

802800
Nav.defaultProps = {
@@ -818,7 +816,8 @@ function mapStateToProps(state) {
818816
user: state.user,
819817
unsavedChanges: state.ide.unsavedChanges,
820818
rootFile: state.files.filter(file => file.name === 'root')[0],
821-
language: state.preferences.language
819+
language: state.preferences.language,
820+
isUserOwner: getIsUserOwner(state)
822821
};
823822
}
824823

client/components/mobile/Explorer.jsx

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
import React from 'react';
2+
import { useTranslation } from 'react-i18next';
23
import styled from 'styled-components';
34
import PropTypes from 'prop-types';
45
import Sidebar from './Sidebar';
56
import ConnectedFileNode from '../../modules/IDE/components/FileNode';
67

78

8-
const Explorer = ({ id, canEdit, onPressClose }) => (
9-
<Sidebar title="Files" onPressClose={onPressClose}>
10-
<ConnectedFileNode id={id} canEdit={canEdit} onClickFile={() => onPressClose()} />
11-
</Sidebar>
12-
);
9+
const Explorer = ({ id, canEdit, onPressClose }) => {
10+
const { t } = useTranslation();
11+
return (
12+
<Sidebar title={t('Explorer.Files')} onPressClose={onPressClose}>
13+
<ConnectedFileNode id={id} canEdit={canEdit} onClickFile={() => onPressClose()} />
14+
</Sidebar>
15+
);
16+
};
1317

1418
Explorer.propTypes = {
1519
id: PropTypes.number.isRequired,
+22-5
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,36 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
3+
import styled from 'styled-components';
4+
import { remSize } from '../../theme';
35

4-
const Screen = ({ children, fullscreen }) => (
5-
<div className={fullscreen && 'fullscreen-preview'}>
6+
const ScreenWrapper = styled.div`
7+
.toast {
8+
font-size: ${remSize(12)};
9+
padding: ${remSize(8)};
10+
11+
border-radius: ${remSize(4)};
12+
width: 92%;
13+
top: unset;
14+
min-width: unset;
15+
bottom: ${remSize(64)}
16+
}
17+
`;
18+
19+
const Screen = ({ children, fullscreen, slimheader }) => (
20+
<ScreenWrapper className={fullscreen && 'fullscreen-preview'} slimheader={slimheader}>
621
{children}
7-
</div>
22+
</ScreenWrapper>
823
);
924

1025
Screen.defaultProps = {
11-
fullscreen: false
26+
fullscreen: false,
27+
slimheader: false,
1228
};
1329

1430
Screen.propTypes = {
1531
children: PropTypes.node.isRequired,
16-
fullscreen: PropTypes.bool
32+
fullscreen: PropTypes.bool,
33+
slimheader: PropTypes.bool
1734
};
1835

1936
export default Screen;

client/modules/App/App.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class App extends React.Component {
4141
render() {
4242
return (
4343
<div className="app">
44-
{this.state.isMounted && !window.devToolsExtension && getConfig('NODE_ENV') === 'development' && <DevTools />}
44+
{false && this.state.isMounted && !window.devToolsExtension && getConfig('NODE_ENV') === 'development' && <DevTools />}
4545
{this.props.children}
4646
</div>
4747
);

client/modules/IDE/actions/uploader.js

-3
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,6 @@ export function dropzoneSendingCallback(file, xhr, formData) {
7777
Object.keys(file.postData).forEach((key) => {
7878
formData.append(key, file.postData[key]);
7979
});
80-
formData.append('Content-type', file.type);
81-
formData.append('Content-length', '');
82-
formData.append('acl', 'public-read');
8380
}
8481
};
8582
}

client/modules/IDE/components/Editor.jsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import UnsavedChangesDotIcon from '../../../images/unsaved-changes-dot.svg';
4343
import RightArrowIcon from '../../../images/right-arrow.svg';
4444
import LeftArrowIcon from '../../../images/left-arrow.svg';
4545
import { getHTMLFile } from '../reducers/files';
46+
import { getIsUserOwner } from '../selectors/users';
4647

4748
import * as FileActions from '../actions/files';
4849
import * as IDEActions from '../actions/ide';
@@ -411,7 +412,7 @@ Editor.propTypes = {
411412
isExpanded: PropTypes.bool.isRequired,
412413
collapseSidebar: PropTypes.func.isRequired,
413414
expandSidebar: PropTypes.func.isRequired,
414-
isUserOwner: PropTypes.bool,
415+
isUserOwner: PropTypes.bool.isRequired,
415416
clearConsole: PropTypes.func.isRequired,
416417
showRuntimeErrorWarning: PropTypes.func.isRequired,
417418
hideRuntimeErrorWarning: PropTypes.func.isRequired,
@@ -421,7 +422,6 @@ Editor.propTypes = {
421422
};
422423

423424
Editor.defaultProps = {
424-
isUserOwner: false,
425425
consoleEvents: [],
426426
};
427427

@@ -447,7 +447,8 @@ function mapStateToProps(state) {
447447
...state.project,
448448
...state.editorAccessibility,
449449
isExpanded: state.ide.sidebarIsExpanded,
450-
projectSavedTime: state.project.updatedAt
450+
projectSavedTime: state.project.updatedAt,
451+
isUserOwner: getIsUserOwner(state)
451452
};
452453
}
453454

client/modules/IDE/components/ErrorModal.jsx

+21-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,19 @@ class ErrorModal extends React.Component {
1515
);
1616
}
1717

18+
oauthError() {
19+
const { t, service } = this.props;
20+
const serviceLabels = {
21+
github: 'GitHub',
22+
google: 'Google'
23+
};
24+
return (
25+
<p>
26+
{t('ErrorModal.LinkMessage', { serviceauth: serviceLabels[service] })}
27+
</p>
28+
);
29+
}
30+
1831
staleSession() {
1932
return (
2033
<p>
@@ -42,6 +55,8 @@ class ErrorModal extends React.Component {
4255
return this.staleSession();
4356
} else if (this.props.type === 'staleProject') {
4457
return this.staleProject();
58+
} else if (this.props.type === 'oauthError') {
59+
return this.oauthError();
4560
}
4661
})()}
4762
</div>
@@ -52,7 +67,12 @@ class ErrorModal extends React.Component {
5267
ErrorModal.propTypes = {
5368
type: PropTypes.string.isRequired,
5469
closeModal: PropTypes.func.isRequired,
55-
t: PropTypes.func.isRequired
70+
t: PropTypes.func.isRequired,
71+
service: PropTypes.string
72+
};
73+
74+
ErrorModal.defaultProps = {
75+
service: ''
5676
};
5777

5878
export default withTranslation()(ErrorModal);

client/modules/IDE/components/Preferences/PreferenceCreators.jsx

+13-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1-
export const optionsOnOff = (name, onLabel = 'On', offLabel = 'Off') => [
2-
{
3-
value: true, label: onLabel, ariaLabel: `${name} on`, name: `${name}`, id: `${name}-on`.replace(' ', '-')
4-
},
5-
{
6-
value: false, label: offLabel, ariaLabel: `${name} off`, name: `${name}`, id: `${name}-off`.replace(' ', '-')
7-
},
8-
];
1+
import { useTranslation } from 'react-i18next';
2+
3+
export const optionsOnOff = (name) => {
4+
const { t } = useTranslation();
5+
return [
6+
{
7+
value: true, label: t('PreferenceCreators.On'), ariaLabel: `${name} on`, name: `${name}`, id: `${name}-on`.replace(' ', '-')
8+
},
9+
{
10+
value: false, label: t('PreferenceCreators.Off'), ariaLabel: `${name} off`, name: `${name}`, id: `${name}-off`.replace(' ', '-')
11+
}
12+
];
13+
};
914

1015
export const optionsPickOne = (name, ...options) => options.map(option => ({
1116
value: option,

client/modules/IDE/pages/IDEView.jsx

+5-7
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,14 @@ import About from '../components/About';
3434
import AddToCollectionList from '../components/AddToCollectionList';
3535
import Feedback from '../components/Feedback';
3636
import { CollectionSearchbar } from '../components/Searchbar';
37+
import { getIsUserOwner } from '../selectors/users';
3738

3839

3940
function getTitle(props) {
4041
const { id } = props.project;
4142
return id ? `p5.js Web Editor | ${props.project.name}` : 'p5.js Web Editor';
4243
}
4344

44-
function isUserOwner(props) {
45-
return props.project.owner && props.project.owner.id === props.user.id;
46-
}
47-
4845
function warnIfUnsavedChanges(props) {
4946
// eslint-disable-line
5047
const { route } = props.route;
@@ -138,7 +135,7 @@ class IDEView extends React.Component {
138135
}
139136

140137
componentDidUpdate(prevProps) {
141-
if (isUserOwner(this.props) && this.props.project.id) {
138+
if (this.props.isUserOwner && this.props.project.id) {
142139
if (
143140
this.props.preferences.autosave &&
144141
this.props.ide.unsavedChanges &&
@@ -151,7 +148,6 @@ class IDEView extends React.Component {
151148
if (this.autosaveInterval) {
152149
clearTimeout(this.autosaveInterval);
153150
}
154-
console.log('will save project in 20 seconds');
155151
this.autosaveInterval = setTimeout(this.props.autosaveProject, 20000);
156152
}
157153
} else if (this.autosaveInterval && !this.props.preferences.autosave) {
@@ -182,7 +178,7 @@ class IDEView extends React.Component {
182178
e.preventDefault();
183179
e.stopPropagation();
184180
if (
185-
isUserOwner(this.props) ||
181+
this.props.isUserOwner ||
186182
(this.props.user.authenticated && !this.props.project.owner)
187183
) {
188184
this.props.saveProject(this.cmController.getContent());
@@ -603,6 +599,7 @@ IDEView.propTypes = {
603599
openUploadFileModal: PropTypes.func.isRequired,
604600
closeUploadFileModal: PropTypes.func.isRequired,
605601
t: PropTypes.func.isRequired,
602+
isUserOwner: PropTypes.bool.isRequired
606603
};
607604

608605
function mapStateToProps(state) {
@@ -620,6 +617,7 @@ function mapStateToProps(state) {
620617
project: state.project,
621618
toast: state.toast,
622619
console: state.console,
620+
isUserOwner: getIsUserOwner(state)
623621
};
624622
}
625623

0 commit comments

Comments
 (0)