mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-03-06 18:07:11 +00:00
Limit region selection to portal and hosted AAD auth. SQL accounts only. Could possibly enable on table and gremlin later.
This commit is contained in:
parent
a3b2a90640
commit
7e289854b4
@ -635,20 +635,38 @@ export const SettingsPane: FunctionComponent<{ explorer: Explorer }> = ({
|
|||||||
Learn more{" "}
|
Learn more{" "}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<ChoiceGroup
|
</AccordionPanel>
|
||||||
ariaLabelledBy="enableDataPlaneRBACOptions"
|
</AccordionItem>
|
||||||
options={dataPlaneRBACOptionsList}
|
)}
|
||||||
styles={choiceButtonStyles}
|
{userContext.apiType === "SQL" && userContext.authType === AuthType.AAD && (
|
||||||
selectedKey={enableDataPlaneRBACOption}
|
<AccordionItem value="3">
|
||||||
onChange={handleOnDataPlaneRBACOptionChange}
|
<AccordionHeader>
|
||||||
|
<div className={styles.header}>Region Selection</div>
|
||||||
|
</AccordionHeader>
|
||||||
|
<AccordionPanel>
|
||||||
|
<div className={styles.settingsSectionContainer}>
|
||||||
|
<div className={styles.settingsSectionDescription}>
|
||||||
|
Changes region the Cosmos Client uses to access account.
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<span className={styles.subHeader}>Select Region</span>
|
||||||
|
<InfoTooltip className={styles.headerIcon}>
|
||||||
|
Changes the account endpoint used to perform client operations.
|
||||||
|
</InfoTooltip>
|
||||||
|
</div>
|
||||||
|
<Dropdown
|
||||||
|
placeholder={regionOptions.find((option) => option.key === selectedRegion)?.text}
|
||||||
|
onChange={handleOnSelectedRegionOptionChange}
|
||||||
|
options={regionOptions}
|
||||||
|
styles={{ root: { marginBottom: "10px" } }}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</AccordionPanel>
|
</AccordionPanel>
|
||||||
</AccordionItem>
|
</AccordionItem>
|
||||||
)}
|
)}
|
||||||
{userContext.apiType === "SQL" && !isEmulator && (
|
{userContext.apiType === "SQL" && (
|
||||||
<>
|
<>
|
||||||
<AccordionItem value="3">
|
<AccordionItem value="4">
|
||||||
<AccordionHeader>
|
<AccordionHeader>
|
||||||
<div className={styles.header}>Query Timeout</div>
|
<div className={styles.header}>Query Timeout</div>
|
||||||
</AccordionHeader>
|
</AccordionHeader>
|
||||||
@ -689,7 +707,7 @@ export const SettingsPane: FunctionComponent<{ explorer: Explorer }> = ({
|
|||||||
</AccordionPanel>
|
</AccordionPanel>
|
||||||
</AccordionItem>
|
</AccordionItem>
|
||||||
|
|
||||||
<AccordionItem value="4">
|
<AccordionItem value="5">
|
||||||
<AccordionHeader>
|
<AccordionHeader>
|
||||||
<div className={styles.header}>RU Limit</div>
|
<div className={styles.header}>RU Limit</div>
|
||||||
</AccordionHeader>
|
</AccordionHeader>
|
||||||
@ -723,31 +741,6 @@ export const SettingsPane: FunctionComponent<{ explorer: Explorer }> = ({
|
|||||||
</AccordionPanel>
|
</AccordionPanel>
|
||||||
</AccordionItem>
|
</AccordionItem>
|
||||||
|
|
||||||
<AccordionItem value="5">
|
|
||||||
<AccordionHeader>
|
|
||||||
<div className={styles.header}>Region Selection</div>
|
|
||||||
</AccordionHeader>
|
|
||||||
<AccordionPanel>
|
|
||||||
<div className={styles.settingsSectionContainer}>
|
|
||||||
<div className={styles.settingsSectionDescription}>
|
|
||||||
Changes region the Cosmos Client uses to access account.
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<span className={styles.subHeader}>Select Region</span>
|
|
||||||
<InfoTooltip className={styles.headerIcon}>
|
|
||||||
Changes the account endpoint used to perform client operations.
|
|
||||||
</InfoTooltip>
|
|
||||||
</div>
|
|
||||||
<Dropdown
|
|
||||||
placeholder={regionOptions.find((option) => option.key === selectedRegion)?.text}
|
|
||||||
onChange={handleOnSelectedRegionOptionChange}
|
|
||||||
options={regionOptions}
|
|
||||||
styles={{ root: { marginBottom: "10px" } }}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</AccordionPanel>
|
|
||||||
</AccordionItem>
|
|
||||||
|
|
||||||
<AccordionItem value="6">
|
<AccordionItem value="6">
|
||||||
<AccordionHeader>
|
<AccordionHeader>
|
||||||
<div className={styles.header}>Default Query Results View</div>
|
<div className={styles.header}>Default Query Results View</div>
|
||||||
|
@ -298,24 +298,8 @@ async function configureHostedWithAAD(config: AAD): Promise<Explorer> {
|
|||||||
`Configuring Data Explorer for ${userContext.apiType} account ${account.name}`,
|
`Configuring Data Explorer for ${userContext.apiType} account ${account.name}`,
|
||||||
"Explorer/configureHostedWithAAD",
|
"Explorer/configureHostedWithAAD",
|
||||||
);
|
);
|
||||||
// TODO: Somewhere in here need to configure regional endpoint selection in the user context for the client to pull from.
|
if (userContext.apiType === "SQL") {
|
||||||
// Essentially, if the value exists in local storage, then grab the regional endpoint and load it. Only if data plane RBAC is enabled.
|
checkAndUpdateSelectedRegionalEndpoint();
|
||||||
// For now, just loading up setting from storage if it exists. If we limit to data plane rbac accounts, then we limit other client APIs besides nosql.
|
|
||||||
// TODO: Maybe just load up the regional endpoint if it exists in the local storage? Loading here makes sense since we are configuring
|
|
||||||
// user context, but introduces a lot of repetitive code.
|
|
||||||
if (
|
|
||||||
(userContext.apiType === "SQL" || userContext.apiType === "Tables" || userContext.apiType === "Gremlin") &&
|
|
||||||
LocalStorageUtility.hasItem(StorageKey.SelectedRegion)
|
|
||||||
) {
|
|
||||||
const storedRegion = LocalStorageUtility.getEntryString(StorageKey.SelectedRegion);
|
|
||||||
const location = userContext.databaseAccount?.properties?.readLocations?.find(
|
|
||||||
(loc) => loc.locationName === storedRegion,
|
|
||||||
);
|
|
||||||
updateUserContext({
|
|
||||||
// TODO: Can possible make this process better by just storing the selected region endpoint.
|
|
||||||
selectedRegionalEndpoint: location?.documentEndpoint,
|
|
||||||
refreshCosmosClient: true,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
if (!userContext.features.enableAadDataPlane) {
|
if (!userContext.features.enableAadDataPlane) {
|
||||||
Logger.logInfo(`AAD Feature flag is not enabled for account ${account.name}`, "Explorer/configureHostedWithAAD");
|
Logger.logInfo(`AAD Feature flag is not enabled for account ${account.name}`, "Explorer/configureHostedWithAAD");
|
||||||
@ -570,22 +554,9 @@ async function configurePortal(): Promise<Explorer> {
|
|||||||
updateContextsFromPortalMessage(inputs);
|
updateContextsFromPortalMessage(inputs);
|
||||||
|
|
||||||
const { databaseAccount: account, subscriptionId, resourceGroup } = userContext;
|
const { databaseAccount: account, subscriptionId, resourceGroup } = userContext;
|
||||||
// TODO: Somewhere in here need to configure regional endpoint selection in the user context for the client to pull from.
|
|
||||||
// Essentially, if the value exists in local storage, then grab the regional endpoint and load it. Only if data plane RBAC is enabled.
|
if (userContext.apiType === "SQL") {
|
||||||
// For now, just loading up setting from storage if it exists. If we limit to data plane rbac accounts, then we limit other client APIs besides nosql.
|
checkAndUpdateSelectedRegionalEndpoint();
|
||||||
if (
|
|
||||||
(userContext.apiType === "SQL" || userContext.apiType === "Tables" || userContext.apiType === "Gremlin") &&
|
|
||||||
LocalStorageUtility.hasItem(StorageKey.SelectedRegion)
|
|
||||||
) {
|
|
||||||
const storedRegion = LocalStorageUtility.getEntryString(StorageKey.SelectedRegion);
|
|
||||||
const location = userContext.databaseAccount?.properties?.readLocations?.find(
|
|
||||||
(loc) => loc.locationName === storedRegion,
|
|
||||||
);
|
|
||||||
updateUserContext({
|
|
||||||
// TODO: Can possible make this process better by just storing the selected region endpoint.
|
|
||||||
selectedRegionalEndpoint: location?.documentEndpoint,
|
|
||||||
refreshCosmosClient: true,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let dataPlaneRbacEnabled;
|
let dataPlaneRbacEnabled;
|
||||||
@ -706,6 +677,20 @@ function updateAADEndpoints(portalEnv: PortalEnv) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function checkAndUpdateSelectedRegionalEndpoint() {
|
||||||
|
//TODO: Possibly refactor userContext to store selected regional endpoint instead of selected region.
|
||||||
|
if (LocalStorageUtility.hasItem(StorageKey.SelectedRegion)) {
|
||||||
|
const storedRegion = LocalStorageUtility.getEntryString(StorageKey.SelectedRegion);
|
||||||
|
const location = userContext.databaseAccount?.properties?.readLocations?.find(
|
||||||
|
(loc) => loc.locationName === storedRegion,
|
||||||
|
);
|
||||||
|
updateUserContext({
|
||||||
|
selectedRegionalEndpoint: location?.documentEndpoint,
|
||||||
|
refreshCosmosClient: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function updateContextsFromPortalMessage(inputs: DataExplorerInputsFrame) {
|
function updateContextsFromPortalMessage(inputs: DataExplorerInputsFrame) {
|
||||||
if (
|
if (
|
||||||
configContext.PORTAL_BACKEND_ENDPOINT &&
|
configContext.PORTAL_BACKEND_ENDPOINT &&
|
||||||
|
Loading…
x
Reference in New Issue
Block a user