Explore: compact state URLs

- allow positional state array in URL
- key-based parsing as fallback
- fix issue where split state was kept in URL after closing split
This commit is contained in:
David Kaltschmidt
2018-10-05 17:09:40 +02:00
parent f6d332562a
commit 5ec9adb7a7
4 changed files with 87 additions and 12 deletions

View File

@@ -275,7 +275,6 @@ export class Explore extends React.PureComponent<ExploreProps, ExploreState> {
const { onChangeSplit } = this.props;
if (onChangeSplit) {
onChangeSplit(false);
this.saveState();
}
};
@@ -292,7 +291,6 @@ export class Explore extends React.PureComponent<ExploreProps, ExploreState> {
if (onChangeSplit) {
const state = this.cloneState();
onChangeSplit(true, state);
this.saveState();
}
};
@@ -534,12 +532,12 @@ export class Explore extends React.PureComponent<ExploreProps, ExploreState> {
</a>
</div>
) : (
<div className="navbar-buttons explore-first-button">
<button className="btn navbar-button" onClick={this.onClickCloseSplit}>
Close Split
<div className="navbar-buttons explore-first-button">
<button className="btn navbar-button" onClick={this.onClickCloseSplit}>
Close Split
</button>
</div>
)}
</div>
)}
{!datasourceMissing ? (
<div className="navbar-buttons">
<Select

View File

@@ -38,10 +38,17 @@ export class Wrapper extends Component<WrapperProps, WrapperState> {
onChangeSplit = (split: boolean, splitState: ExploreState) => {
this.setState({ split, splitState });
// When closing split, remove URL state for split part
if (!split) {
delete this.urlStates[STATE_KEY_RIGHT];
this.props.updateLocation({
query: this.urlStates,
});
}
};
onSaveState = (key: string, state: ExploreState) => {
const urlState = serializeStateToUrlParam(state);
const urlState = serializeStateToUrlParam(state, true);
this.urlStates[key] = urlState;
this.props.updateLocation({
query: this.urlStates,