Skip to content

Commit 2bf53de

Browse files
committed
Merge pull request #107 from durunvo/master
Upgrade react-router to v2
2 parents dfeaab4 + 6b04790 commit 2bf53de

21 files changed

+39
-36
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"react-dnd": "~2.0.2",
2929
"react-dnd-html5-backend": "~2.0.0",
3030
"react-dom": "^0.14.0",
31-
"react-router": "1.0.0-rc1"
31+
"react-router": "2.0.0"
3232
},
3333
"devDependencies": {
3434
"babel-core": "~5.8.12",

src/components/CategoryList/CategoryList.react.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export default class CategoryList extends React.Component {
6161
(this.props.linkPrefix || '') + (c.link || id)
6262
);
6363
return (
64-
<Link title={c.name} to={link} className={className} key={id} >
64+
<Link title={c.name} to={{ pathname: link }} className={className} key={id} >
6565
<span>{count}</span>
6666
<span>{c.name}</span>
6767
</Link>

src/components/FileTree/FileTree.react.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export default class FileTree extends React.Component {
7474
<Link
7575
key={'f_' + f}
7676
className={[styles.file, isCurrent ? styles.current : ''].join(' ')}
77-
to={this.props.linkPrefix + path}>
77+
to={{ pathname: this.props.linkPrefix + path }}>
7878
{f}
7979
</Link>
8080
);

src/components/Popover/Popover.react.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ class ContextProxy extends React.Component {
2222
}
2323

2424
ContextProxy.childContextTypes = {
25-
history: React.PropTypes.object
25+
history: React.PropTypes.object,
26+
router: React.PropTypes.object
2627
};
2728

2829
export default class Popover extends React.Component {
@@ -93,5 +94,6 @@ export default class Popover extends React.Component {
9394
}
9495

9596
Popover.contextTypes = {
96-
history: React.PropTypes.object
97+
history: React.PropTypes.object,
98+
router: React.PropTypes.object
9799
};

src/components/Sidebar/AppsSelector.react.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export default class AppsSelector extends React.Component {
5959
if (sections[0] === '') {
6060
sections.shift();
6161
}
62-
history.pushState(null, `/apps/${value}/${sections[2]}`);
62+
history.push(null, `/apps/${value}/${sections[2]}`);
6363
}
6464
});
6565
}

src/components/Sidebar/SidebarHeader.react.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import styles from 'components/Sidebar/Sidebar.scss';
1313

1414
let SidebarHeader = ({}) =>
1515
<div className={styles.header}>
16-
<Link className={styles.logo} to='/apps'>
16+
<Link className={styles.logo} to={{ pathname: '/apps' }}>
1717
<Icon width={28} height={28} name='infinity' fill={'#ffffff'} />
1818
</Link>
1919
<Link to='/apps'>

src/components/Sidebar/SidebarSection.react.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ let SidebarSection = ({ active, children, name, link, icon, style }) => {
2323
<div className={classes.join(' ')}>
2424
{active ?
2525
<div style={style} className={styles.section_header}>{iconContent}{name}</div> :
26-
<Link style={style} className={styles.section_header} to={link || ''}>{iconContent}{name}</Link>}
26+
<Link style={style} className={styles.section_header} to={{ pathname: link || '' }}>{iconContent}{name}</Link>}
2727

2828
{children ? <div className={styles.section_contents}>{children}</div> : null}
2929
</div>

src/components/Sidebar/SidebarSubItem.react.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ let SidebarSubItem = ({ active, name, action, link, children }) => {
2828
<div>
2929
<Link
3030
className={styles.subitem}
31-
to={link}>
31+
to={{ pathname: link }}>
3232
{name}
3333
</Link>
3434
</div>

src/dashboard/AppData.react.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ let AppData = React.createClass({
3838
if (current) {
3939
current.setParseKeys();
4040
} else {
41-
history.replaceState(null, '/apps');
41+
history.replace('/apps');
4242
return <div />;
4343
}
4444
return (

src/dashboard/AppSelector.react.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ export default class AppSelector extends React.Component {
2626

2727
handleConfirm() {
2828
let newPath = location.pathname.replace(/\/_(\/|$)/, '/' + this.state.slug + '/');
29-
history.pushState(null, newPath);
29+
history.push(newPath);
3030
}
3131

3232
handleCancel() {
33-
history.pushState(null, '/apps');
33+
history.push('/apps');
3434
}
3535

3636
render() {

src/dashboard/Apps/AppsIndex.react.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ let AppCard = ({
6464
app,
6565
icon,
6666
}) => {
67-
let canBrowse = app.serverInfo.error ? null : () => history.pushState(null, html`/apps/${app.slug}/browser`);
67+
let canBrowse = app.serverInfo.error ? null : () => history.push(html`/apps/${app.slug}/browser`);
6868
let versionMessage = app.serverInfo.error ?
6969
<div className={styles.serverVersion}>Server not reachable: <span className={styles.ago}>{app.serverInfo.error.toString()}</span></div>:
7070
<div className={styles.serverVersion}>Server version: <span className={styles.ago}>{app.serverInfo.parseServerVersion || 'unknown'}</span></div>;

src/dashboard/Data/Browser/Browser.react.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export default class Browser extends DashboardView {
130130
}
131131
return a.toUpperCase() < b.toUpperCase() ? -1 : 1;
132132
});
133-
history.replaceState(null, this.context.generatePath('browser/' + classes[0]));
133+
history.replace(this.context.generatePath('browser/' + classes[0]));
134134
}
135135
}
136136

@@ -164,7 +164,7 @@ export default class Browser extends DashboardView {
164164
createClass(className) {
165165
this.props.schema.dispatch(ActionTypes.CREATE_CLASS, { className }).then(() => {
166166
this.state.counts[className] = 0;
167-
history.pushState(null, this.context.generatePath('browser/' + className));
167+
history.push(this.context.generatePath('browser/' + className));
168168
}).always(() => {
169169
this.setState({ showCreateClassDialog: false });
170170
});
@@ -174,7 +174,7 @@ export default class Browser extends DashboardView {
174174
this.props.schema.dispatch(ActionTypes.DROP_CLASS, { className }).then(() => {
175175
this.setState({showDropClassDialog: false });
176176
delete this.state.counts[className];
177-
history.pushState(null, this.context.generatePath('browser'));
177+
history.push(this.context.generatePath('browser'));
178178
}, (error) => {
179179
let msg = typeof error === 'string' ? error : error.message;
180180
if (msg) {
@@ -308,7 +308,7 @@ export default class Browser extends DashboardView {
308308
let _filters = JSON.stringify(filters.toJSON());
309309
let url = `browser/${source}` + (filters.size === 0 ? '' : `?filters=${encodeURIComponent(_filters)}`);
310310
// filters param change is making the fetch call
311-
history.pushState(null, this.context.generatePath(url));
311+
history.push(this.context.generatePath(url));
312312
}
313313

314314
updateOrdering(ordering) {
@@ -332,7 +332,7 @@ export default class Browser extends DashboardView {
332332
constraint: 'eq',
333333
compareTo: id
334334
}]);
335-
history.pushState(null, this.context.generatePath(`browser/${className}?filters=${encodeURIComponent(filters)}`));
335+
history.push(this.context.generatePath(`browser/${className}?filters=${encodeURIComponent(filters)}`));
336336
}
337337

338338
updateRow(row, attr, value) {

src/dashboard/Data/CloudCode/CloudCode.react.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export default class CloudCode extends DashboardView {
5454

5555
if (!fileName || release.files[fileName] === undefined) {
5656
// Means we're still in /cloud_code/. Let's redirect to /cloud_code/main.js
57-
history.replaceState(null, this.context.generatePath('cloud_code/main.js'))
57+
history.replace(this.context.generatePath('cloud_code/main.js'))
5858
} else {
5959
// Means we can load /cloud_code/<fileName>
6060
app.getSource(fileName).then(

src/dashboard/Data/Jobs/JobEdit.react.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class JobEdit extends React.Component {
5353
let promise = this.props.params.jobId ?
5454
this.props.jobs.dispatch(ActionTypes.EDIT, { jobId: this.props.params.jobId, updates: schedule }) :
5555
this.props.jobs.dispatch(ActionTypes.CREATE, { schedule });
56-
promise.then(() => {history.pushState(null, this.context.generatePath('jobs/scheduled'))});
56+
promise.then(() => {history.push(this.context.generatePath('jobs/scheduled'))});
5757
return promise;
5858
}
5959

src/dashboard/Data/Jobs/Jobs.react.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,11 @@ export default class Jobs extends TableView {
9292
}
9393

9494
navigateToNew() {
95-
history.pushState(null, this.context.generatePath('jobs/new'));
95+
history.push(this.context.generatePath('jobs/new'));
9696
}
9797

9898
navigateToJob(jobId) {
99-
history.pushState(null, this.context.generatePath(`jobs/edit/${jobId}`))
99+
history.push(this.context.generatePath(`jobs/edit/${jobId}`))
100100
}
101101

102102
renderSidebar() {

src/dashboard/Push/PushAudiencesIndex.react.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export default class PushAudiencesIndex extends DashboardView {
113113
}
114114

115115
handleSendPush(objectId) {
116-
history.pushState(null, this.context.generatePath(`push/new?audienceId=${objectId}`));
116+
history.push(this.context.generatePath(`push/new?audienceId=${objectId}`));
117117
}
118118

119119
renderRow(audience) {

src/dashboard/Push/PushDetails.react.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ export default class PushDetails extends DashboardView {
465465
prevLaunchGroup = (
466466
<div className={styles.header}>
467467
<div className={styles.headline}>
468-
This push is the Launch Group for a previous <Link to={getPushDetailUrl(this.context, pushDetails.experiment_push_id)}>experiment</Link>.
468+
This push is the Launch Group for a previous <Link to={{ pathname: getPushDetailUrl(this.context, pushDetails.experiment_push_id) }}>experiment</Link>.
469469
</div>
470470
</div>
471471
);
@@ -562,7 +562,7 @@ export default class PushDetails extends DashboardView {
562562
if (error) {
563563
promise.reject({ error });
564564
} else {
565-
history.pushState(null, this.context.generatePath('push/activity'));
565+
history.push(this.context.generatePath('push/activity'));
566566
}
567567
}, (error) => {
568568
promise.reject({ error });

src/dashboard/Push/PushIndex.react.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,11 +281,11 @@ export default class PushIndex extends DashboardView {
281281
}
282282

283283
navigateToNew() {
284-
history.pushState(null, this.context.generatePath('push/new'));
284+
history.push(this.context.generatePath('push/new'));
285285
}
286286

287287
navigateToDetails(objectId) {
288-
history.pushState(null, this.context.generatePath(`push/${objectId}`));
288+
history.push(this.context.generatePath(`push/${objectId}`));
289289
}
290290

291291
handleShowMore(page) {

src/dashboard/Push/PushNew.react.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ export default class PushNew extends DashboardView {
188188
promise.reject({ error });
189189
} else {
190190
//TODO: global success message banner for passing successful creation - store should also be cleared
191-
history.pushState(null, this.context.generatePath('push/activity'));
191+
history.push(this.context.generatePath('push/activity'));
192192
}
193193
}, (error) => {
194194
promise.reject(error);
@@ -663,7 +663,7 @@ export default class PushNew extends DashboardView {
663663
<Fieldset
664664
legend='Preview'
665665
description='Double check that everything looks good!'>
666-
<PushPreview pushState={fields} audiences={this.props.pushaudiences} />
666+
<PushPreview push={fields} audiences={this.props.pushaudiences} />
667667
</Fieldset>
668668

669669
<Toolbar section='Push' subsection='Send a new campaign' />

src/dashboard/Settings/GeneralSettings.react.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ let ManageAppFields = ({
228228
description='View your migration progress.' />}
229229
input={<FormButton
230230
color='blue'
231-
onClick={() => history.pushState(null, '/apps/' + appSlug + '/migration')}
231+
onClick={() => history.push('/apps/' + appSlug + '/migration')}
232232
value='View progress' />} />
233233
} else {
234234
migrateAppField = [<Field
@@ -308,7 +308,7 @@ let ManageAppFields = ({
308308
{cloneAppMessage ? <FormNote
309309
show={true}
310310
color='green'>
311-
<div>{cloneAppMessage} Check out the progress on your <Link to='/apps'>apps page</Link>!</div>
311+
<div>{cloneAppMessage} Check out the progress on your <Link to={{ pathname: '/apps' }}>apps page</Link>!</div>
312312
</FormNote> : null}
313313
{!isCollaborator ? <Field
314314
labelWidth={DEFAULT_SETTINGS_LABEL_WIDTH}
@@ -427,7 +427,7 @@ export default class GeneralSettings extends DashboardView {
427427
return promise;
428428
}}
429429
onClose={closeModalWithConnectionString}
430-
onSuccess={() => history.pushState(null, '/apps/' + this.context.currentApp.slug + '/migration')}
430+
onSuccess={() => history.push('/apps/' + this.context.currentApp.slug + '/migration')}
431431
clearFields={() => this.setState({
432432
migrationMongoURL: '',
433433
migrationWarnings: [],
@@ -538,7 +538,7 @@ export default class GeneralSettings extends DashboardView {
538538
inProgressText={'Deleting\u2026'}
539539
enabled={this.state.password.length > 0}
540540
onSubmit={() => AppsManager.deleteApp(this.context.currentApp.slug, this.state.password)}
541-
onSuccess={result => history.pushState(null, '/apps')}
541+
onSuccess={result => history.push('/apps')}
542542
onClose={() => this.setState({showDeleteAppModal: false})}
543543
clearFields={() => this.setState({password: ''})}>
544544
{passwordField}

src/dashboard/history.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
* This source code is licensed under the license found in the LICENSE file in
66
* the root directory of this source tree.
77
*/
8-
import createBrowserHistory from 'history/lib/createBrowserHistory';
9-
let history = createBrowserHistory();
108

11-
export default history;
9+
// Use the singleton history in react-router v2
10+
import { browserHistory } from 'react-router'
11+
12+
export default browserHistory;

0 commit comments

Comments
 (0)