Skip to content

Commit 3d7148e

Browse files
feat: Reopen last opened class when navigating to data browser (#2468)
1 parent 29a83ac commit 3d7148e

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

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

+17
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import { withRouter } from 'lib/withRouter';
4242

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

4647
@subscribeTo('Schema', 'schema')
4748
@withRouter
@@ -178,6 +179,22 @@ class Browser extends DashboardView {
178179
}
179180
}
180181

182+
componentDidMount() {
183+
if (window.localStorage) {
184+
const pathname = window.localStorage.getItem(BROWSER_LAST_LOCATION);
185+
window.localStorage.removeItem(BROWSER_LAST_LOCATION)
186+
if(pathname) {
187+
setTimeout(function() { this.props.navigate(pathname) }.bind(this))
188+
}
189+
}
190+
}
191+
192+
componentWillUnmount() {
193+
if (window.localStorage) {
194+
window.localStorage.setItem(BROWSER_LAST_LOCATION, this.props.location.pathname + this.props.location.search);
195+
}
196+
}
197+
181198
componentWillReceiveProps(nextProps, nextContext) {
182199
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) {
183200
if (this.props.params.appId !== nextProps.params.appId || !this.props.params.className) {

0 commit comments

Comments
 (0)