diff --git a/package.json b/package.json index 049be2fe6d..906c7b6605 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "react-dnd": "~2.0.2", "react-dnd-html5-backend": "~2.0.0", "react-dom": "^0.14.0", - "react-router": "1.0.0-rc1" + "react-router": "2.0.0" }, "devDependencies": { "babel-core": "~5.8.12", diff --git a/src/components/CategoryList/CategoryList.react.js b/src/components/CategoryList/CategoryList.react.js index 10977477cd..9851e10a3d 100644 --- a/src/components/CategoryList/CategoryList.react.js +++ b/src/components/CategoryList/CategoryList.react.js @@ -61,7 +61,7 @@ export default class CategoryList extends React.Component { (this.props.linkPrefix || '') + (c.link || id) ); return ( - + {count} {c.name} diff --git a/src/components/FileTree/FileTree.react.js b/src/components/FileTree/FileTree.react.js index 93c6aa4293..bd6e9a987f 100644 --- a/src/components/FileTree/FileTree.react.js +++ b/src/components/FileTree/FileTree.react.js @@ -74,7 +74,7 @@ export default class FileTree extends React.Component { + to={{ pathname: this.props.linkPrefix + path }}> {f} ); diff --git a/src/components/Popover/Popover.react.js b/src/components/Popover/Popover.react.js index ac2c4c2e2b..ec8b76ac99 100644 --- a/src/components/Popover/Popover.react.js +++ b/src/components/Popover/Popover.react.js @@ -22,7 +22,8 @@ class ContextProxy extends React.Component { } ContextProxy.childContextTypes = { - history: React.PropTypes.object + history: React.PropTypes.object, + router: React.PropTypes.object }; export default class Popover extends React.Component { @@ -93,5 +94,6 @@ export default class Popover extends React.Component { } Popover.contextTypes = { - history: React.PropTypes.object + history: React.PropTypes.object, + router: React.PropTypes.object }; diff --git a/src/components/Sidebar/AppsSelector.react.js b/src/components/Sidebar/AppsSelector.react.js index 5b2d295902..45f82c148d 100644 --- a/src/components/Sidebar/AppsSelector.react.js +++ b/src/components/Sidebar/AppsSelector.react.js @@ -59,7 +59,7 @@ export default class AppsSelector extends React.Component { if (sections[0] === '') { sections.shift(); } - history.pushState(null, `/apps/${value}/${sections[2]}`); + history.push(null, `/apps/${value}/${sections[2]}`); } }); } diff --git a/src/components/Sidebar/SidebarHeader.react.js b/src/components/Sidebar/SidebarHeader.react.js index 82bbc6d3a4..bb34dad113 100644 --- a/src/components/Sidebar/SidebarHeader.react.js +++ b/src/components/Sidebar/SidebarHeader.react.js @@ -13,7 +13,7 @@ import styles from 'components/Sidebar/Sidebar.scss'; let SidebarHeader = ({}) =>
- + diff --git a/src/components/Sidebar/SidebarSection.react.js b/src/components/Sidebar/SidebarSection.react.js index 8b65940d08..4071f9ed1b 100644 --- a/src/components/Sidebar/SidebarSection.react.js +++ b/src/components/Sidebar/SidebarSection.react.js @@ -23,7 +23,7 @@ let SidebarSection = ({ active, children, name, link, icon, style }) => {
{active ?
{iconContent}{name}
: - {iconContent}{name}} + {iconContent}{name}} {children ?
{children}
: null}
diff --git a/src/components/Sidebar/SidebarSubItem.react.js b/src/components/Sidebar/SidebarSubItem.react.js index 9216535614..776e270ccd 100644 --- a/src/components/Sidebar/SidebarSubItem.react.js +++ b/src/components/Sidebar/SidebarSubItem.react.js @@ -28,7 +28,7 @@ let SidebarSubItem = ({ active, name, action, link, children }) => {
+ to={{ pathname: link }}> {name}
diff --git a/src/dashboard/AppData.react.js b/src/dashboard/AppData.react.js index 851a1ba568..080486566d 100644 --- a/src/dashboard/AppData.react.js +++ b/src/dashboard/AppData.react.js @@ -38,7 +38,7 @@ let AppData = React.createClass({ if (current) { current.setParseKeys(); } else { - history.replaceState(null, '/apps'); + history.replace('/apps'); return
; } return ( diff --git a/src/dashboard/AppSelector.react.js b/src/dashboard/AppSelector.react.js index bc2a23eac5..d4d3fe7a84 100644 --- a/src/dashboard/AppSelector.react.js +++ b/src/dashboard/AppSelector.react.js @@ -26,11 +26,11 @@ export default class AppSelector extends React.Component { handleConfirm() { let newPath = location.pathname.replace(/\/_(\/|$)/, '/' + this.state.slug + '/'); - history.pushState(null, newPath); + history.push(newPath); } handleCancel() { - history.pushState(null, '/apps'); + history.push('/apps'); } render() { diff --git a/src/dashboard/Apps/AppsIndex.react.js b/src/dashboard/Apps/AppsIndex.react.js index 9e20e99c5f..5a67e2ff42 100644 --- a/src/dashboard/Apps/AppsIndex.react.js +++ b/src/dashboard/Apps/AppsIndex.react.js @@ -64,7 +64,7 @@ let AppCard = ({ app, icon, }) => { - let canBrowse = app.serverInfo.error ? null : () => history.pushState(null, html`/apps/${app.slug}/browser`); + let canBrowse = app.serverInfo.error ? null : () => history.push(html`/apps/${app.slug}/browser`); let versionMessage = app.serverInfo.error ?
Server not reachable: {app.serverInfo.error.toString()}
:
Server version: {app.serverInfo.parseServerVersion || 'unknown'}
; diff --git a/src/dashboard/Data/Browser/Browser.react.js b/src/dashboard/Data/Browser/Browser.react.js index c31dcf027e..87ab6278b1 100644 --- a/src/dashboard/Data/Browser/Browser.react.js +++ b/src/dashboard/Data/Browser/Browser.react.js @@ -130,7 +130,7 @@ export default class Browser extends DashboardView { } return a.toUpperCase() < b.toUpperCase() ? -1 : 1; }); - history.replaceState(null, this.context.generatePath('browser/' + classes[0])); + history.replace(this.context.generatePath('browser/' + classes[0])); } } @@ -164,7 +164,7 @@ export default class Browser extends DashboardView { createClass(className) { this.props.schema.dispatch(ActionTypes.CREATE_CLASS, { className }).then(() => { this.state.counts[className] = 0; - history.pushState(null, this.context.generatePath('browser/' + className)); + history.push(this.context.generatePath('browser/' + className)); }).always(() => { this.setState({ showCreateClassDialog: false }); }); @@ -174,7 +174,7 @@ export default class Browser extends DashboardView { this.props.schema.dispatch(ActionTypes.DROP_CLASS, { className }).then(() => { this.setState({showDropClassDialog: false }); delete this.state.counts[className]; - history.pushState(null, this.context.generatePath('browser')); + history.push(this.context.generatePath('browser')); }, (error) => { let msg = typeof error === 'string' ? error : error.message; if (msg) { @@ -308,7 +308,7 @@ export default class Browser extends DashboardView { let _filters = JSON.stringify(filters.toJSON()); let url = `browser/${source}` + (filters.size === 0 ? '' : `?filters=${encodeURIComponent(_filters)}`); // filters param change is making the fetch call - history.pushState(null, this.context.generatePath(url)); + history.push(this.context.generatePath(url)); } updateOrdering(ordering) { @@ -332,7 +332,7 @@ export default class Browser extends DashboardView { constraint: 'eq', compareTo: id }]); - history.pushState(null, this.context.generatePath(`browser/${className}?filters=${encodeURIComponent(filters)}`)); + history.push(this.context.generatePath(`browser/${className}?filters=${encodeURIComponent(filters)}`)); } updateRow(row, attr, value) { diff --git a/src/dashboard/Data/CloudCode/CloudCode.react.js b/src/dashboard/Data/CloudCode/CloudCode.react.js index b989ad2e75..388953c5b8 100644 --- a/src/dashboard/Data/CloudCode/CloudCode.react.js +++ b/src/dashboard/Data/CloudCode/CloudCode.react.js @@ -54,7 +54,7 @@ export default class CloudCode extends DashboardView { if (!fileName || release.files[fileName] === undefined) { // Means we're still in /cloud_code/. Let's redirect to /cloud_code/main.js - history.replaceState(null, this.context.generatePath('cloud_code/main.js')) + history.replace(this.context.generatePath('cloud_code/main.js')) } else { // Means we can load /cloud_code/ app.getSource(fileName).then( diff --git a/src/dashboard/Data/Jobs/JobEdit.react.js b/src/dashboard/Data/Jobs/JobEdit.react.js index 37c49ce051..c7e705b485 100644 --- a/src/dashboard/Data/Jobs/JobEdit.react.js +++ b/src/dashboard/Data/Jobs/JobEdit.react.js @@ -53,7 +53,7 @@ class JobEdit extends React.Component { let promise = this.props.params.jobId ? this.props.jobs.dispatch(ActionTypes.EDIT, { jobId: this.props.params.jobId, updates: schedule }) : this.props.jobs.dispatch(ActionTypes.CREATE, { schedule }); - promise.then(() => {history.pushState(null, this.context.generatePath('jobs/scheduled'))}); + promise.then(() => {history.push(this.context.generatePath('jobs/scheduled'))}); return promise; } diff --git a/src/dashboard/Data/Jobs/Jobs.react.js b/src/dashboard/Data/Jobs/Jobs.react.js index 04f6e268d7..eb150f1c31 100644 --- a/src/dashboard/Data/Jobs/Jobs.react.js +++ b/src/dashboard/Data/Jobs/Jobs.react.js @@ -92,11 +92,11 @@ export default class Jobs extends TableView { } navigateToNew() { - history.pushState(null, this.context.generatePath('jobs/new')); + history.push(this.context.generatePath('jobs/new')); } navigateToJob(jobId) { - history.pushState(null, this.context.generatePath(`jobs/edit/${jobId}`)) + history.push(this.context.generatePath(`jobs/edit/${jobId}`)) } renderSidebar() { diff --git a/src/dashboard/Push/PushAudiencesIndex.react.js b/src/dashboard/Push/PushAudiencesIndex.react.js index 521bbf447f..29d77a244d 100644 --- a/src/dashboard/Push/PushAudiencesIndex.react.js +++ b/src/dashboard/Push/PushAudiencesIndex.react.js @@ -113,7 +113,7 @@ export default class PushAudiencesIndex extends DashboardView { } handleSendPush(objectId) { - history.pushState(null, this.context.generatePath(`push/new?audienceId=${objectId}`)); + history.push(this.context.generatePath(`push/new?audienceId=${objectId}`)); } renderRow(audience) { diff --git a/src/dashboard/Push/PushDetails.react.js b/src/dashboard/Push/PushDetails.react.js index c129cb6a10..14bfdf45f3 100644 --- a/src/dashboard/Push/PushDetails.react.js +++ b/src/dashboard/Push/PushDetails.react.js @@ -465,7 +465,7 @@ export default class PushDetails extends DashboardView { prevLaunchGroup = (
- This push is the Launch Group for a previous experiment. + This push is the Launch Group for a previous experiment.
); @@ -562,7 +562,7 @@ export default class PushDetails extends DashboardView { if (error) { promise.reject({ error }); } else { - history.pushState(null, this.context.generatePath('push/activity')); + history.push(this.context.generatePath('push/activity')); } }, (error) => { promise.reject({ error }); diff --git a/src/dashboard/Push/PushIndex.react.js b/src/dashboard/Push/PushIndex.react.js index 7e9adda398..79a05594dc 100644 --- a/src/dashboard/Push/PushIndex.react.js +++ b/src/dashboard/Push/PushIndex.react.js @@ -281,11 +281,11 @@ export default class PushIndex extends DashboardView { } navigateToNew() { - history.pushState(null, this.context.generatePath('push/new')); + history.push(this.context.generatePath('push/new')); } navigateToDetails(objectId) { - history.pushState(null, this.context.generatePath(`push/${objectId}`)); + history.push(this.context.generatePath(`push/${objectId}`)); } handleShowMore(page) { diff --git a/src/dashboard/Push/PushNew.react.js b/src/dashboard/Push/PushNew.react.js index 09cb5e77e4..57d844d09a 100644 --- a/src/dashboard/Push/PushNew.react.js +++ b/src/dashboard/Push/PushNew.react.js @@ -188,7 +188,7 @@ export default class PushNew extends DashboardView { promise.reject({ error }); } else { //TODO: global success message banner for passing successful creation - store should also be cleared - history.pushState(null, this.context.generatePath('push/activity')); + history.push(this.context.generatePath('push/activity')); } }, (error) => { promise.reject(error); @@ -663,7 +663,7 @@ export default class PushNew extends DashboardView {
- +
diff --git a/src/dashboard/Settings/GeneralSettings.react.js b/src/dashboard/Settings/GeneralSettings.react.js index e19d38211c..5daa1b6b3b 100644 --- a/src/dashboard/Settings/GeneralSettings.react.js +++ b/src/dashboard/Settings/GeneralSettings.react.js @@ -228,7 +228,7 @@ let ManageAppFields = ({ description='View your migration progress.' />} input={ history.pushState(null, '/apps/' + appSlug + '/migration')} + onClick={() => history.push('/apps/' + appSlug + '/migration')} value='View progress' />} /> } else { migrateAppField = [ -
{cloneAppMessage} Check out the progress on your apps page!
+
{cloneAppMessage} Check out the progress on your apps page!
: null} {!isCollaborator ? history.pushState(null, '/apps/' + this.context.currentApp.slug + '/migration')} + onSuccess={() => history.push('/apps/' + this.context.currentApp.slug + '/migration')} clearFields={() => this.setState({ migrationMongoURL: '', migrationWarnings: [], @@ -538,7 +538,7 @@ export default class GeneralSettings extends DashboardView { inProgressText={'Deleting\u2026'} enabled={this.state.password.length > 0} onSubmit={() => AppsManager.deleteApp(this.context.currentApp.slug, this.state.password)} - onSuccess={result => history.pushState(null, '/apps')} + onSuccess={result => history.push('/apps')} onClose={() => this.setState({showDeleteAppModal: false})} clearFields={() => this.setState({password: ''})}> {passwordField} diff --git a/src/dashboard/history.js b/src/dashboard/history.js index 79223afa4b..028b4afc50 100644 --- a/src/dashboard/history.js +++ b/src/dashboard/history.js @@ -5,7 +5,8 @@ * This source code is licensed under the license found in the LICENSE file in * the root directory of this source tree. */ -import createBrowserHistory from 'history/lib/createBrowserHistory'; -let history = createBrowserHistory(); -export default history; \ No newline at end of file +// Use the singleton history in react-router v2 +import { browserHistory } from 'react-router' + +export default browserHistory;