diff --git a/src/Explorer/Explorer.tsx b/src/Explorer/Explorer.tsx index a5a2d394d..dea7f7e95 100644 --- a/src/Explorer/Explorer.tsx +++ b/src/Explorer/Explorer.tsx @@ -4,18 +4,11 @@ import { isPublicInternetAccessAllowed } from "Common/DatabaseAccountUtility"; import { Environment, getEnvironment } from "Common/EnvironmentUtility"; import { sendMessage } from "Common/MessageHandler"; import { Platform, configContext } from "ConfigContext"; -import { DataExplorerAction } from "Contracts/ActionContracts"; import { MessageTypes } from "Contracts/ExplorerContracts"; -import { handleOpenAction } from "Explorer/OpenActions/OpenActions"; import { useDataPlaneRbac } from "Explorer/Panes/SettingsPane/SettingsPane"; import { getCopilotEnabled, isCopilotFeatureRegistered } from "Explorer/QueryCopilot/Shared/QueryCopilotClient"; import { IGalleryItem } from "Juno/JunoClient"; import { scheduleRefreshDatabaseResourceToken } from "Platform/Fabric/FabricUtil"; -import { - AppStateComponentNames, - OPEN_TABS_SUBCOMPONENT_NAME, - readSubComponentState, -} from "Shared/AppStatePersistenceUtility"; import { LocalStorageUtility, StorageKey } from "Shared/StorageUtility"; import { acquireMsalTokenForAccount } from "Utils/AuthorizationUtils"; import { allowedNotebookServerUrls, validateEndpoint } from "Utils/EndpointUtils"; @@ -1166,10 +1159,6 @@ export default class Explorer { } await this.refreshSampleData(); - - if (userContext.features.restoreTabs) { - this.restoreOpenTabs(); - } } public async configureCopilot(): Promise { @@ -1216,19 +1205,4 @@ export default class Explorer { return; } } - - private restoreOpenTabs() { - const openTabsState = readSubComponentState<(DataExplorerAction | undefined)[]>( - AppStateComponentNames.DataExplorerAction, - OPEN_TABS_SUBCOMPONENT_NAME, - undefined, - [], - ); - - openTabsState.forEach((openTabState) => { - if (openTabState) { - handleOpenAction(openTabState, useDatabases.getState().databases, this); - } - }); - } } diff --git a/src/hooks/useKnockoutExplorer.ts b/src/hooks/useKnockoutExplorer.ts index eacc7f4c5..430cef277 100644 --- a/src/hooks/useKnockoutExplorer.ts +++ b/src/hooks/useKnockoutExplorer.ts @@ -7,6 +7,11 @@ import Explorer from "Explorer/Explorer"; import { useDataPlaneRbac } from "Explorer/Panes/SettingsPane/SettingsPane"; import { useSelectedNode } from "Explorer/useSelectedNode"; import { scheduleRefreshDatabaseResourceToken } from "Platform/Fabric/FabricUtil"; +import { + AppStateComponentNames, + OPEN_TABS_SUBCOMPONENT_NAME, + readSubComponentState, +} from "Shared/AppStatePersistenceUtility"; import { LocalStorageUtility, StorageKey } from "Shared/StorageUtility"; import { useNewPortalBackendEndpoint } from "Utils/EndpointUtils"; import { getNetworkSettingsWarningMessage } from "Utils/NetworkUtility"; @@ -80,6 +85,11 @@ export function useKnockoutExplorer(platform: Platform): Explorer { await updateContextForCopilot(explorer); await updateContextForSampleData(explorer); } + + if (userContext.features.restoreTabs) { + restoreOpenTabs(); + } + setExplorer(explorer); } }; @@ -816,3 +826,17 @@ async function updateContextForSampleData(explorer: Explorer): Promise { interface SampledataconnectionResponse { connectionString: string; } + +const restoreOpenTabs = () => { + const openTabsState = readSubComponentState<(DataExplorerAction | undefined)[]>( + AppStateComponentNames.DataExplorerAction, + OPEN_TABS_SUBCOMPONENT_NAME, + undefined, + [], + ); + openTabsState.forEach((openTabState) => { + if (openTabState) { + handleOpenAction(openTabState, useDatabases.getState().databases, this); + } + }); +};