Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Reopen last opened class when navigating to data browser #2468

Merged
merged 1 commit into from
Jun 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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