diff --git a/src/Explorer/Panes/SettingsPane/SettingsPane.tsx b/src/Explorer/Panes/SettingsPane/SettingsPane.tsx index f921d507e..eff1eb7d9 100644 --- a/src/Explorer/Panes/SettingsPane/SettingsPane.tsx +++ b/src/Explorer/Panes/SettingsPane/SettingsPane.tsx @@ -8,6 +8,7 @@ import { DefaultButton, Dropdown, IChoiceGroupOption, + IDropdownOption, ISpinButtonStyles, IToggleStyles, Position, @@ -143,6 +144,16 @@ export const SettingsPane: FunctionComponent<{ explorer: Explorer }> = ({ ? LocalStorageUtility.getEntryString(StorageKey.IsGraphAutoVizDisabled) : "false", ); + const [readRegion, setReadRegion] = useState( + LocalStorageUtility.hasItem(StorageKey.ReadRegion) + ? LocalStorageUtility.getEntryString(StorageKey.ReadRegion) + : userContext?.databaseAccount?.properties?.readLocations?.[0]?.locationName, + ); + const [writeRegion, setWriteRegion] = useState( + LocalStorageUtility.hasItem(StorageKey.WriteRegion) + ? LocalStorageUtility.getEntryString(StorageKey.WriteRegion) + : userContext?.databaseAccount?.properties?.writeLocations?.[0]?.locationName, + ); const [retryAttempts, setRetryAttempts] = useState( LocalStorageUtility.hasItem(StorageKey.RetryAttempts) ? LocalStorageUtility.getEntryNumber(StorageKey.RetryAttempts) @@ -180,6 +191,14 @@ export const SettingsPane: FunctionComponent<{ explorer: Explorer }> = ({ const shouldShowCrossPartitionOption = userContext.apiType !== "Gremlin"; const shouldShowParallelismOption = userContext.apiType !== "Gremlin"; const shouldShowPriorityLevelOption = PriorityBasedExecutionUtils.isFeatureEnabled(); + const readRegionOptions = userContext?.databaseAccount?.properties?.readLocations?.map((location) => ({ + key: location.locationName, + text: location.locationName, + })); + const writeRegionOptions = userContext?.databaseAccount?.properties?.writeLocations?.map((location) => ({ + key: location.locationName, + text: location.locationName, + })); const shouldShowCopilotSampleDBOption = userContext.apiType === "SQL" && useQueryCopilot.getState().copilotEnabled && @@ -265,6 +284,8 @@ export const SettingsPane: FunctionComponent<{ explorer: Explorer }> = ({ LocalStorageUtility.setEntryBoolean(StorageKey.RUThresholdEnabled, ruThresholdEnabled); LocalStorageUtility.setEntryBoolean(StorageKey.QueryTimeoutEnabled, queryTimeoutEnabled); + LocalStorageUtility.setEntryString(StorageKey.ReadRegion, readRegion); + LocalStorageUtility.setEntryString(StorageKey.WriteRegion, writeRegion); LocalStorageUtility.setEntryNumber(StorageKey.RetryAttempts, retryAttempts); LocalStorageUtility.setEntryNumber(StorageKey.RetryInterval, retryInterval); LocalStorageUtility.setEntryNumber(StorageKey.MaxWaitTimeInSeconds, MaxWaitTimeInSeconds); @@ -412,6 +433,16 @@ export const SettingsPane: FunctionComponent<{ explorer: Explorer }> = ({ setDefaultQueryResultsView(option.key as SplitterDirection); }; + const handleOnReadRegionOptionChange = (ev: React.FormEvent, option: IDropdownOption): void => { + // TODO: Region validation? + setReadRegion(option.text); + }; + + const handleOnWriteRegionOptionChange = (ev: React.FormEvent, option: IDropdownOption): void => { + // TODO: Region Validation? + setWriteRegion(option.text); + }; + const handleOnQueryRetryAttemptsSpinButtonChange = (ev: React.MouseEvent, newValue?: string): void => { const retryAttempts = Number(newValue); if (!isNaN(retryAttempts)) { @@ -680,22 +711,28 @@ export const SettingsPane: FunctionComponent<{ explorer: Explorer }> = ({
Select region for read and write operations.
+
+ Read Region + + Changes the account endpoint used to perform read operations. + +
+
+ Write Region + + Changes the account endpoint used to perform write operations. + +
diff --git a/src/Shared/StorageUtility.ts b/src/Shared/StorageUtility.ts index f2baa85da..f77acc8bc 100644 --- a/src/Shared/StorageUtility.ts +++ b/src/Shared/StorageUtility.ts @@ -11,6 +11,8 @@ export enum StorageKey { RUThreshold, QueryTimeoutEnabled, QueryTimeout, + ReadRegion, + WriteRegion, RetryAttempts, RetryInterval, MaxWaitTimeInSeconds,