mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2024-11-25 06:56:38 +00:00
Move restore tabs after knockout configure step from Explorer constructor (which could be called multiple times)
This commit is contained in:
parent
22581b41a8
commit
be35a56b6b
@ -4,18 +4,11 @@ import { isPublicInternetAccessAllowed } from "Common/DatabaseAccountUtility";
|
|||||||
import { Environment, getEnvironment } from "Common/EnvironmentUtility";
|
import { Environment, getEnvironment } from "Common/EnvironmentUtility";
|
||||||
import { sendMessage } from "Common/MessageHandler";
|
import { sendMessage } from "Common/MessageHandler";
|
||||||
import { Platform, configContext } from "ConfigContext";
|
import { Platform, configContext } from "ConfigContext";
|
||||||
import { DataExplorerAction } from "Contracts/ActionContracts";
|
|
||||||
import { MessageTypes } from "Contracts/ExplorerContracts";
|
import { MessageTypes } from "Contracts/ExplorerContracts";
|
||||||
import { handleOpenAction } from "Explorer/OpenActions/OpenActions";
|
|
||||||
import { useDataPlaneRbac } from "Explorer/Panes/SettingsPane/SettingsPane";
|
import { useDataPlaneRbac } from "Explorer/Panes/SettingsPane/SettingsPane";
|
||||||
import { getCopilotEnabled, isCopilotFeatureRegistered } from "Explorer/QueryCopilot/Shared/QueryCopilotClient";
|
import { getCopilotEnabled, isCopilotFeatureRegistered } from "Explorer/QueryCopilot/Shared/QueryCopilotClient";
|
||||||
import { IGalleryItem } from "Juno/JunoClient";
|
import { IGalleryItem } from "Juno/JunoClient";
|
||||||
import { scheduleRefreshDatabaseResourceToken } from "Platform/Fabric/FabricUtil";
|
import { scheduleRefreshDatabaseResourceToken } from "Platform/Fabric/FabricUtil";
|
||||||
import {
|
|
||||||
AppStateComponentNames,
|
|
||||||
OPEN_TABS_SUBCOMPONENT_NAME,
|
|
||||||
readSubComponentState,
|
|
||||||
} from "Shared/AppStatePersistenceUtility";
|
|
||||||
import { LocalStorageUtility, StorageKey } from "Shared/StorageUtility";
|
import { LocalStorageUtility, StorageKey } from "Shared/StorageUtility";
|
||||||
import { acquireMsalTokenForAccount } from "Utils/AuthorizationUtils";
|
import { acquireMsalTokenForAccount } from "Utils/AuthorizationUtils";
|
||||||
import { allowedNotebookServerUrls, validateEndpoint } from "Utils/EndpointUtils";
|
import { allowedNotebookServerUrls, validateEndpoint } from "Utils/EndpointUtils";
|
||||||
@ -1166,10 +1159,6 @@ export default class Explorer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
await this.refreshSampleData();
|
await this.refreshSampleData();
|
||||||
|
|
||||||
if (userContext.features.restoreTabs) {
|
|
||||||
this.restoreOpenTabs();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async configureCopilot(): Promise<void> {
|
public async configureCopilot(): Promise<void> {
|
||||||
@ -1216,19 +1205,4 @@ export default class Explorer {
|
|||||||
return;
|
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);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,11 @@ import Explorer from "Explorer/Explorer";
|
|||||||
import { useDataPlaneRbac } from "Explorer/Panes/SettingsPane/SettingsPane";
|
import { useDataPlaneRbac } from "Explorer/Panes/SettingsPane/SettingsPane";
|
||||||
import { useSelectedNode } from "Explorer/useSelectedNode";
|
import { useSelectedNode } from "Explorer/useSelectedNode";
|
||||||
import { scheduleRefreshDatabaseResourceToken } from "Platform/Fabric/FabricUtil";
|
import { scheduleRefreshDatabaseResourceToken } from "Platform/Fabric/FabricUtil";
|
||||||
|
import {
|
||||||
|
AppStateComponentNames,
|
||||||
|
OPEN_TABS_SUBCOMPONENT_NAME,
|
||||||
|
readSubComponentState,
|
||||||
|
} from "Shared/AppStatePersistenceUtility";
|
||||||
import { LocalStorageUtility, StorageKey } from "Shared/StorageUtility";
|
import { LocalStorageUtility, StorageKey } from "Shared/StorageUtility";
|
||||||
import { useNewPortalBackendEndpoint } from "Utils/EndpointUtils";
|
import { useNewPortalBackendEndpoint } from "Utils/EndpointUtils";
|
||||||
import { getNetworkSettingsWarningMessage } from "Utils/NetworkUtility";
|
import { getNetworkSettingsWarningMessage } from "Utils/NetworkUtility";
|
||||||
@ -80,6 +85,11 @@ export function useKnockoutExplorer(platform: Platform): Explorer {
|
|||||||
await updateContextForCopilot(explorer);
|
await updateContextForCopilot(explorer);
|
||||||
await updateContextForSampleData(explorer);
|
await updateContextForSampleData(explorer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (userContext.features.restoreTabs) {
|
||||||
|
restoreOpenTabs();
|
||||||
|
}
|
||||||
|
|
||||||
setExplorer(explorer);
|
setExplorer(explorer);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -816,3 +826,17 @@ async function updateContextForSampleData(explorer: Explorer): Promise<void> {
|
|||||||
interface SampledataconnectionResponse {
|
interface SampledataconnectionResponse {
|
||||||
connectionString: string;
|
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);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user