Add logic to reset regional endpoint when global is selected.

This commit is contained in:
Craig Boger (from Dev Box) 2025-01-17 17:51:29 -08:00
parent dbfbceb03e
commit 29e5f16065
2 changed files with 16 additions and 7 deletions

View File

@ -120,8 +120,8 @@ export const endpoint = () => {
return configContext.EMULATOR_ENDPOINT || location.origin; return configContext.EMULATOR_ENDPOINT || location.origin;
} }
return ( return (
userContext.endpoint ||
userContext.selectedRegionalEndpoint || userContext.selectedRegionalEndpoint ||
userContext.endpoint ||
userContext?.databaseAccount?.properties?.documentEndpoint userContext?.databaseAccount?.properties?.documentEndpoint
); );
}; };

View File

@ -308,11 +308,21 @@ export const SettingsPane: FunctionComponent<{ explorer: Explorer }> = ({
} }
// TODO: Check if region selection has been updated. Update database account in user context accordingly. // TODO: Check if region selection has been updated. Update database account in user context accordingly.
updateUserContext({ // If global is selected, then remove the region selection from local storage.
selectedRegionalEndpoint: regionOptions.find((option) => option.key === selectedRegion)?.data?.endpoint, if (selectedRegion !== LocalStorageUtility.getEntryString(StorageKey.SelectedRegion)) {
refreshCosmosClient: true, LocalStorageUtility.setEntryString(StorageKey.SelectedRegion, selectedRegion);
}); let selectedRegionalEndpoint: string | undefined;
// TODO: If Global selected, then clear out region selection, but keep change variable enabled. if (selectedRegion === Constants.RegionSelectionOptions.Global) {
selectedRegionalEndpoint = undefined;
} else {
selectedRegionalEndpoint = regionOptions.find((option) => option.key === selectedRegion)?.data?.endpoint;
}
updateUserContext({
selectedRegionalEndpoint: selectedRegionalEndpoint,
refreshCosmosClient: true,
});
}
console.log( console.log(
`userContext?.databaseAccount?.properties?.documentEndpoint details: ${JSON.stringify( `userContext?.databaseAccount?.properties?.documentEndpoint details: ${JSON.stringify(
userContext?.databaseAccount?.properties?.documentEndpoint, userContext?.databaseAccount?.properties?.documentEndpoint,
@ -321,7 +331,6 @@ export const SettingsPane: FunctionComponent<{ explorer: Explorer }> = ({
LocalStorageUtility.setEntryBoolean(StorageKey.RUThresholdEnabled, ruThresholdEnabled); LocalStorageUtility.setEntryBoolean(StorageKey.RUThresholdEnabled, ruThresholdEnabled);
LocalStorageUtility.setEntryBoolean(StorageKey.QueryTimeoutEnabled, queryTimeoutEnabled); LocalStorageUtility.setEntryBoolean(StorageKey.QueryTimeoutEnabled, queryTimeoutEnabled);
LocalStorageUtility.setEntryString(StorageKey.SelectedRegion, selectedRegion);
LocalStorageUtility.setEntryNumber(StorageKey.RetryAttempts, retryAttempts); LocalStorageUtility.setEntryNumber(StorageKey.RetryAttempts, retryAttempts);
LocalStorageUtility.setEntryNumber(StorageKey.RetryInterval, retryInterval); LocalStorageUtility.setEntryNumber(StorageKey.RetryInterval, retryInterval);
LocalStorageUtility.setEntryNumber(StorageKey.MaxWaitTimeInSeconds, MaxWaitTimeInSeconds); LocalStorageUtility.setEntryNumber(StorageKey.MaxWaitTimeInSeconds, MaxWaitTimeInSeconds);