Skip to content

Commit

Permalink
feat: Reopen last opened class when navigating to data browser (#2468)
Browse files Browse the repository at this point in the history
  • Loading branch information
AshishBarvaliya authored Jun 19, 2023
1 parent 29a83ac commit 3d7148e
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/dashboard/Data/Browser/Browser.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import { withRouter } from 'lib/withRouter';

// The initial and max amount of rows fetched by lazy loading
const MAX_ROWS_FETCHED = 200;
const BROWSER_LAST_LOCATION = 'brower_last_location';

@subscribeTo('Schema', 'schema')
@withRouter
Expand Down Expand Up @@ -178,6 +179,22 @@ class Browser extends DashboardView {
}
}

componentDidMount() {
if (window.localStorage) {
const pathname = window.localStorage.getItem(BROWSER_LAST_LOCATION);
window.localStorage.removeItem(BROWSER_LAST_LOCATION)
if(pathname) {
setTimeout(function() { this.props.navigate(pathname) }.bind(this))
}
}
}

componentWillUnmount() {
if (window.localStorage) {
window.localStorage.setItem(BROWSER_LAST_LOCATION, this.props.location.pathname + this.props.location.search);
}
}

componentWillReceiveProps(nextProps, nextContext) {
if (this.props.params.appId !== nextProps.params.appId || this.props.params.className !== nextProps.params.className || this.props.location.search !== nextProps.location.search || this.props.params?.relationName !== nextProps.params?.relationName) {
if (this.props.params.appId !== nextProps.params.appId || !this.props.params.className) {
Expand Down

0 comments on commit 3d7148e

Please sign in to comment.