Work with scoping under /sources and single source on context

pull/10616/head
Andrew Watkins 2016-09-29 11:28:20 -07:00
parent b05219248e
commit e1bd544a88
2 changed files with 8 additions and 8 deletions

View File

@ -142,11 +142,11 @@ export function toggleTagAcceptance(queryId) {
};
}
export function createExploration(sourceLink, push) {
export function createExploration(source, push) {
return (dispatch) => {
const initialState = getInitialState();
AJAX({
url: `${sourceLink}/users/1/explorations`, // TODO: change this to use actual user link once users are introduced
url: `${source.links.self}/users/1/explorations`, // TODO: change this to use actual user link once users are introduced
method: 'POST',
data: JSON.stringify({
data: JSON.stringify(initialState),
@ -157,7 +157,7 @@ export function createExploration(sourceLink, push) {
}).then((resp) => {
const explorer = parseRawExplorer(resp.data);
dispatch(loadExplorer(explorer));
push(`/chronograf/data_explorer/${btoa(explorer.link.href)}`); // Base64 encode explorer URI
push(`/sources/${source.id}/chronograf/data_explorer/${btoa(explorer.link.href)}`); // Base64 encode explorer URI
});
};
}
@ -283,7 +283,7 @@ function saveExplorer(error) {
};
}
export function chooseExplorer(explorerID, push) {
export function chooseExplorer(explorerID, source, push) {
return (dispatch, getState) => {
// Save the previous session explicitly in case an auto-save was unable to complete.
const {panels, queryConfigs, activeExplorer} = getState();
@ -306,7 +306,7 @@ export function chooseExplorer(explorerID, push) {
}).then((resp) => {
const explorer = parseRawExplorer(resp.data);
dispatch(loadExplorer(explorer));
push(`/chronograf/data_explorer/${btoa(explorerID)}`);
push(`/sources/${source.id}/chronograf/data_explorer/${btoa(explorerID)}`);
});
};
}

View File

@ -33,7 +33,7 @@ const Header = React.createClass({
},
contextTypes: {
sources: PropTypes.arrayOf(PropTypes.shape().isRequired).isRequired,
source: PropTypes.shape(),
},
handleChooseTimeRange(bounds) {
@ -54,7 +54,7 @@ const Header = React.createClass({
// TODO: passing in this.props.router.push is a big smell, getting something like
// react-router-redux might be better here
this.props.actions.createExploration(this.context.sources[0].links.self, this.props.router.push);
this.props.actions.createExploration(this.context.source, this.props.router.push);
},
handleChooseExplorer({id}) {
@ -62,7 +62,7 @@ const Header = React.createClass({
return;
}
this.props.actions.chooseExplorer(id, this.props.router.push);
this.props.actions.chooseExplorer(id, this.context.source, this.props.router.push);
},
/**