mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-23 02:41:39 +00:00
Address errors and checks
This commit is contained in:
@@ -273,30 +273,26 @@ async function configureHostedWithAAD(config: AAD): Promise<Explorer> {
|
||||
}
|
||||
}
|
||||
try {
|
||||
if(LocalStorageUtility.hasItem(StorageKey.DataPlaneRbacEnabled)) {
|
||||
var isDataPlaneRbacSetting = LocalStorageUtility.getEntryString(StorageKey.DataPlaneRbacEnabled);
|
||||
if (isDataPlaneRbacSetting == Constants.RBACOptions.setAutomaticRBACOption)
|
||||
{
|
||||
if (!account.properties.disableLocalAuth) {
|
||||
keys = await listKeys(subscriptionId, resourceGroup, account.name);
|
||||
}
|
||||
else {
|
||||
updateUserContext({
|
||||
dataPlaneRbacEnabled: true
|
||||
});
|
||||
}
|
||||
}
|
||||
else if(isDataPlaneRbacSetting == Constants.RBACOptions.setTrueRBACOption) {
|
||||
updateUserContext({
|
||||
dataPlaneRbacEnabled: true
|
||||
});
|
||||
}
|
||||
else {
|
||||
if (LocalStorageUtility.hasItem(StorageKey.DataPlaneRbacEnabled)) {
|
||||
const isDataPlaneRbacSetting = LocalStorageUtility.getEntryString(StorageKey.DataPlaneRbacEnabled);
|
||||
if (isDataPlaneRbacSetting === Constants.RBACOptions.setAutomaticRBACOption) {
|
||||
if (!account.properties.disableLocalAuth) {
|
||||
keys = await listKeys(subscriptionId, resourceGroup, account.name);
|
||||
} else {
|
||||
updateUserContext({
|
||||
dataPlaneRbacEnabled: false
|
||||
dataPlaneRbacEnabled: true,
|
||||
});
|
||||
}
|
||||
} else if (isDataPlaneRbacSetting === Constants.RBACOptions.setTrueRBACOption) {
|
||||
updateUserContext({
|
||||
dataPlaneRbacEnabled: true,
|
||||
});
|
||||
} else {
|
||||
keys = await listKeys(subscriptionId, resourceGroup, account.name);
|
||||
updateUserContext({
|
||||
dataPlaneRbacEnabled: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
if (userContext.features.enableAadDataPlane) {
|
||||
@@ -418,10 +414,9 @@ async function configurePortal(): Promise<Explorer> {
|
||||
updateUserContext({
|
||||
authType: AuthType.AAD,
|
||||
});
|
||||
|
||||
|
||||
|
||||
let explorer: Explorer;
|
||||
return new Promise(async (resolve) => {
|
||||
return new Promise((resolve) => {
|
||||
// In development mode, try to load the iframe message from session storage.
|
||||
// This allows webpack hot reload to function properly in the portal
|
||||
if (process.env.NODE_ENV === "development" && !window.location.search.includes("disablePortalInitCache")) {
|
||||
@@ -435,7 +430,6 @@ async function configurePortal(): Promise<Explorer> {
|
||||
updateContextsFromPortalMessage(message);
|
||||
explorer = new Explorer();
|
||||
|
||||
|
||||
// In development mode, save the iframe message from the portal in session storage.
|
||||
// This allows webpack hot reload to funciton properly
|
||||
if (process.env.NODE_ENV === "development") {
|
||||
@@ -459,7 +453,7 @@ async function configurePortal(): Promise<Explorer> {
|
||||
|
||||
// Check for init message
|
||||
const message: PortalMessage = event.data?.data;
|
||||
const inputs = message?.inputs;
|
||||
const inputs = message?.inputs;
|
||||
const openAction = message?.openAction;
|
||||
if (inputs) {
|
||||
if (
|
||||
@@ -478,39 +472,34 @@ async function configurePortal(): Promise<Explorer> {
|
||||
setTimeout(() => explorer.openNPSSurveyDialog(), 3000);
|
||||
}
|
||||
|
||||
let keys: DatabaseAccountListKeysResult = {};
|
||||
const account = userContext.databaseAccount;
|
||||
const subscriptionId = userContext.subscriptionId;
|
||||
const resourceGroup = userContext.resourceGroup;
|
||||
|
||||
if(LocalStorageUtility.hasItem(StorageKey.DataPlaneRbacEnabled)) {
|
||||
var isDataPlaneRbacSetting = LocalStorageUtility.getEntryString(StorageKey.DataPlaneRbacEnabled);
|
||||
if (isDataPlaneRbacSetting == Constants.RBACOptions.setAutomaticRBACOption)
|
||||
{
|
||||
if (!account.properties.disableLocalAuth) {
|
||||
keys = await listKeys(subscriptionId, resourceGroup, account.name);
|
||||
}
|
||||
else {
|
||||
updateUserContext({
|
||||
dataPlaneRbacEnabled: true,
|
||||
authorizationToken: message.inputs.authorizationToken
|
||||
});
|
||||
}
|
||||
}
|
||||
else if(isDataPlaneRbacSetting == Constants.RBACOptions.setTrueRBACOption) {
|
||||
if (LocalStorageUtility.hasItem(StorageKey.DataPlaneRbacEnabled)) {
|
||||
const isDataPlaneRbacSetting = LocalStorageUtility.getEntryString(StorageKey.DataPlaneRbacEnabled);
|
||||
if (isDataPlaneRbacSetting === Constants.RBACOptions.setAutomaticRBACOption) {
|
||||
if (!account.properties.disableLocalAuth) {
|
||||
await listKeys(subscriptionId, resourceGroup, account.name);
|
||||
} else {
|
||||
updateUserContext({
|
||||
dataPlaneRbacEnabled: true,
|
||||
authorizationToken: message.inputs.authorizationToken
|
||||
});
|
||||
}
|
||||
else {
|
||||
keys = await listKeys(subscriptionId, resourceGroup, account.name);
|
||||
updateUserContext({
|
||||
dataPlaneRbacEnabled: false
|
||||
authorizationToken: message.inputs.authorizationToken,
|
||||
});
|
||||
}
|
||||
} else if (isDataPlaneRbacSetting === Constants.RBACOptions.setTrueRBACOption) {
|
||||
updateUserContext({
|
||||
dataPlaneRbacEnabled: true,
|
||||
authorizationToken: message.inputs.authorizationToken,
|
||||
});
|
||||
} else {
|
||||
await listKeys(subscriptionId, resourceGroup, account.name);
|
||||
updateUserContext({
|
||||
dataPlaneRbacEnabled: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (openAction) {
|
||||
handleOpenAction(openAction, useDatabases.getState().databases, explorer);
|
||||
}
|
||||
@@ -531,11 +520,9 @@ async function configurePortal(): Promise<Explorer> {
|
||||
},
|
||||
false,
|
||||
);
|
||||
|
||||
|
||||
sendReadyMessage();
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function shouldForwardMessage(message: PortalMessage, messageOrigin: string) {
|
||||
|
||||
Reference in New Issue
Block a user