Skip to content

Commit 4efa20d

Browse files
authored
Merge branch 'develop' into refactor/file-selectors
2 parents 184d40c + baec197 commit 4efa20d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+400
-272
lines changed

client/browserHistory.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { createBrowserHistory } from 'history';
2+
3+
const browserHistory = createBrowserHistory();
4+
5+
export default browserHistory;

client/common/Button.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
33
import styled from 'styled-components';
4-
import { Link } from 'react-router';
4+
import { Link } from 'react-router-dom';
55

66
import { remSize, prop } from '../theme';
77

client/common/ButtonOrLink.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { Link } from 'react-router';
2+
import { Link } from 'react-router-dom';
33
import PropTypes from 'prop-types';
44

55
/**

client/components/Nav.jsx

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
33
import React from 'react';
44
import { withTranslation } from 'react-i18next';
55
import { connect } from 'react-redux';
6-
import { Link, withRouter } from 'react-router';
6+
import { Link } from 'react-router-dom';
77
import { availableLanguages, languageKeyToLabel } from '../i18n';
88
import * as IDEActions from '../modules/IDE/actions/ide';
99
import * as toastActions from '../modules/IDE/actions/toast';
@@ -38,12 +38,12 @@ class Nav extends React.PureComponent {
3838
}
3939

4040
handleNew() {
41-
const { unsavedChanges, warnIfUnsavedChanges } = this.props;
41+
const { unsavedChanges } = this.props;
4242
if (!unsavedChanges) {
4343
this.props.showToast(1500);
4444
this.props.setToastText('Toast.OpenedNewSketch');
4545
this.props.newProject();
46-
} else if (warnIfUnsavedChanges && warnIfUnsavedChanges()) {
46+
} else if (window.confirm(this.props.t('Nav.WarningUnsavedChanges'))) {
4747
this.props.showToast(1500);
4848
this.props.setToastText('Toast.OpenedNewSketch');
4949
this.props.newProject();
@@ -74,11 +74,10 @@ class Nav extends React.PureComponent {
7474
}
7575

7676
handleShare() {
77-
const { username } = this.props.params;
7877
this.props.showShareModal(
7978
this.props.project.id,
8079
this.props.project.name,
81-
username
80+
this.props.project.owner.username
8281
);
8382
}
8483

@@ -352,14 +351,14 @@ Nav.propTypes = {
352351
id: PropTypes.string,
353352
name: PropTypes.string,
354353
owner: PropTypes.shape({
355-
id: PropTypes.string
354+
id: PropTypes.string,
355+
username: PropTypes.string
356356
})
357357
}),
358358
logoutUser: PropTypes.func.isRequired,
359359
showShareModal: PropTypes.func.isRequired,
360360
showErrorModal: PropTypes.func.isRequired,
361361
unsavedChanges: PropTypes.bool.isRequired,
362-
warnIfUnsavedChanges: PropTypes.func,
363362
showKeyboardShortcutModal: PropTypes.func.isRequired,
364363
cmController: PropTypes.shape({
365364
tidyCode: PropTypes.func,
@@ -375,9 +374,6 @@ Nav.propTypes = {
375374
rootFile: PropTypes.shape({
376375
id: PropTypes.string.isRequired
377376
}).isRequired,
378-
params: PropTypes.shape({
379-
username: PropTypes.string
380-
}),
381377
t: PropTypes.func.isRequired,
382378
setLanguage: PropTypes.func.isRequired,
383379
language: PropTypes.string.isRequired,
@@ -392,10 +388,6 @@ Nav.defaultProps = {
392388
},
393389
cmController: {},
394390
layout: 'project',
395-
warnIfUnsavedChanges: undefined,
396-
params: {
397-
username: undefined
398-
},
399391
editorLink: '/'
400392
};
401393

@@ -421,6 +413,6 @@ const mapDispatchToProps = {
421413
};
422414

423415
export default withTranslation()(
424-
withRouter(connect(mapStateToProps, mapDispatchToProps)(Nav))
416+
connect(mapStateToProps, mapDispatchToProps)(Nav)
425417
);
426418
export { Nav as NavComponent };

client/components/PreviewNav.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import PropTypes from 'prop-types';
22
import React from 'react';
3-
import { Link } from 'react-router';
3+
import { Link } from 'react-router-dom';
44
import { useTranslation } from 'react-i18next';
55

66
import LogoIcon from '../images/p5js-logo-small.svg';

client/components/__snapshots__/Nav.unit.test.jsx.snap

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ exports[`Nav renders correctly 1`] = `
5757
<li
5858
class="nav__dropdown-item"
5959
>
60-
<a />
60+
<a
61+
href="/new-user/sketches"
62+
/>
6163
</li>
6264
</ul>
6365
</li>
@@ -195,7 +197,9 @@ exports[`Nav renders correctly 1`] = `
195197
<li
196198
class="nav__dropdown-item"
197199
>
198-
<a />
200+
<a
201+
href="/about"
202+
/>
199203
</li>
200204
</ul>
201205
</li>
@@ -229,6 +233,7 @@ exports[`Nav renders dashboard version 1`] = `
229233
>
230234
<a
231235
class="nav__back-link"
236+
href="/"
232237
>
233238
<test-file-stub
234239
aria-hidden="true"
@@ -447,7 +452,9 @@ exports[`Nav renders editor version 1`] = `
447452
<li
448453
class="nav__dropdown-item"
449454
>
450-
<a>
455+
<a
456+
href="/about"
457+
>
451458
About
452459
</a>
453460
</li>

client/components/createRedirectWithUsername.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import { connect } from 'react-redux';
3-
import { browserHistory } from 'react-router';
3+
import browserHistory from '../browserHistory';
44

55
const RedirectToUser = ({ username, url = '/:username/sketches' }) => {
66
React.useEffect(() => {

client/components/mobile/Tab.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import styled from 'styled-components';
2-
import { Link } from 'react-router';
2+
import { Link } from 'react-router-dom';
33
import { prop, remSize } from '../../theme';
44

55
export default styled(Link)`

client/index.integration.test.jsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
import { setupServer } from 'msw/node';
22
import { rest } from 'msw';
33
import React from 'react';
4-
import { Router, browserHistory } from 'react-router';
4+
import Routing from './routes';
55

66
import { reduxRender, act, waitFor, screen, within } from './test-utils';
77
import configureStore from './store';
8-
import routes from './routes';
98
import * as Actions from './modules/User/actions';
109
import { userResponse } from './testData/testServerResponses';
1110

1211
// setup for the app
13-
const history = browserHistory;
1412
const initialState = window.__INITIAL_STATE__;
1513
const store = configureStore(initialState);
1614

@@ -56,8 +54,7 @@ document.createRange = () => {
5654
// start testing
5755
describe('index.jsx integration', () => {
5856
// the subject under test
59-
const subject = () =>
60-
reduxRender(<Router history={history} routes={routes(store)} />, { store });
57+
const subject = () => reduxRender(<Routing />, { store });
6158

6259
// spy on this function and wait for it to be called before making assertions
6360
const spy = jest.spyOn(Actions, 'getUser');

client/index.jsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ import React, { Suspense } from 'react';
22
import { render } from 'react-dom';
33
import { hot } from 'react-hot-loader/root';
44
import { Provider } from 'react-redux';
5-
import { Router, browserHistory } from 'react-router';
5+
import { Router } from 'react-router-dom';
66

7+
import browserHistory from './browserHistory';
78
import configureStore from './store';
8-
import routes from './routes';
9+
import Routing from './routes';
910
import ThemeProvider from './modules/App/components/ThemeProvider';
1011
import Loader from './modules/App/components/loader';
1112
import './i18n';
@@ -15,15 +16,16 @@ require('./styles/main.scss');
1516
// Load the p5 png logo, so that webpack will use it
1617
require('./images/p5js-square-logo.png');
1718

18-
const history = browserHistory;
1919
const initialState = window.__INITIAL_STATE__;
2020

2121
const store = configureStore(initialState);
2222

2323
const App = () => (
2424
<Provider store={store}>
2525
<ThemeProvider>
26-
<Router history={history} routes={routes(store)} />
26+
<Router history={browserHistory}>
27+
<Routing />
28+
</Router>
2729
</ThemeProvider>
2830
</Provider>
2931
);

0 commit comments

Comments
 (0)