Add fix for MPAC Tables account issue

This commit is contained in:
Senthamil Sindhu 2024-07-04 16:01:35 -07:00
parent caf4e9f51f
commit 039136794d
3 changed files with 33 additions and 35 deletions

View File

@ -419,13 +419,18 @@ function configureEmulator(): Explorer {
async function fetchAndUpdateKeys(subscriptionId: string, resourceGroup: string, account: string) { async function fetchAndUpdateKeys(subscriptionId: string, resourceGroup: string, account: string) {
try { try {
updateUserContext({ listKeysFetchInProgress: true }); console.log("Starting to fetch keys...");
const keys = await listKeys(subscriptionId, resourceGroup, account); const keys = await listKeys(subscriptionId, resourceGroup, account);
console.log("Keys fetched:", keys);
updateUserContext({ masterKey: keys.primaryMasterKey, listKeysFetchInProgress: false }); updateUserContext({
masterKey: keys.primaryMasterKey,
});
console.log("User context updated with master key.");
} catch (error) { } catch (error) {
updateUserContext({ listKeysFetchInProgress: false });
console.error("Error during fetching keys or updating user context:", error); console.error("Error during fetching keys or updating user context:", error);
throw error;
} }
} }
@ -483,12 +488,6 @@ async function configurePortal(): Promise<Explorer> {
} }
updateContextsFromPortalMessage(inputs); updateContextsFromPortalMessage(inputs);
explorer = new Explorer();
resolve(explorer);
if (userContext.apiType === "Postgres" || userContext.apiType === "SQL" || userContext.apiType === "Mongo") {
setTimeout(() => explorer.openNPSSurveyDialog(), 3000);
}
const { databaseAccount: account, subscriptionId, resourceGroup } = userContext; const { databaseAccount: account, subscriptionId, resourceGroup } = userContext;
@ -503,9 +502,7 @@ async function configurePortal(): Promise<Explorer> {
dataPlaneRbacEnabled = isDataPlaneRbacSetting === Constants.RBACOptions.setTrueRBACOption; dataPlaneRbacEnabled = isDataPlaneRbacSetting === Constants.RBACOptions.setTrueRBACOption;
} }
if (!dataPlaneRbacEnabled) { if (!dataPlaneRbacEnabled) {
(async () => {
await fetchAndUpdateKeys(subscriptionId, resourceGroup, account.name); await fetchAndUpdateKeys(subscriptionId, resourceGroup, account.name);
})();
} }
updateUserContext({ dataPlaneRbacEnabled }); updateUserContext({ dataPlaneRbacEnabled });
@ -514,19 +511,20 @@ async function configurePortal(): Promise<Explorer> {
const dataPlaneRbacEnabled = account.properties.disableLocalAuth; const dataPlaneRbacEnabled = account.properties.disableLocalAuth;
if (!dataPlaneRbacEnabled) { if (!dataPlaneRbacEnabled) {
(async () => {
await fetchAndUpdateKeys(subscriptionId, resourceGroup, account.name); await fetchAndUpdateKeys(subscriptionId, resourceGroup, account.name);
})();
} }
updateUserContext({ dataPlaneRbacEnabled }); updateUserContext({ dataPlaneRbacEnabled });
useDataPlaneRbac.setState({ dataPlaneRbacEnabled: dataPlaneRbacEnabled }); useDataPlaneRbac.setState({ dataPlaneRbacEnabled: dataPlaneRbacEnabled });
} }
} } else {
else {
(async () => {
await fetchAndUpdateKeys(subscriptionId, resourceGroup, account.name); await fetchAndUpdateKeys(subscriptionId, resourceGroup, account.name);
})(); }
explorer = new Explorer();
resolve(explorer);
if (userContext.apiType === "Postgres" || userContext.apiType === "SQL" || userContext.apiType === "Mongo") {
setTimeout(() => explorer.openNPSSurveyDialog(), 3000);
} }
if (openAction) { if (openAction) {