From 3d7148e75a6e9eaeeb7cbb546885b5916f6025bb Mon Sep 17 00:00:00 2001 From: Ashish Baravaliya <49753983+AshishBarvaliya@users.noreply.github.com> Date: Mon, 19 Jun 2023 15:59:27 -0400 Subject: [PATCH] feat: Reopen last opened class when navigating to data browser (#2468) --- src/dashboard/Data/Browser/Browser.react.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/dashboard/Data/Browser/Browser.react.js b/src/dashboard/Data/Browser/Browser.react.js index 09bacbca65..a99cac7c18 100644 --- a/src/dashboard/Data/Browser/Browser.react.js +++ b/src/dashboard/Data/Browser/Browser.react.js @@ -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 @@ -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) {