Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion localization/l10n/bundle.l10n.json
Original file line number Diff line number Diff line change
Expand Up @@ -1242,7 +1242,6 @@
"Search Workspaces": "Search Workspaces",
"Workspace is required": "Workspace is required",
"Insufficient Workspace Permissions": "Insufficient Workspace Permissions",
"Insufficient Capacity Permissions": "Insufficient Capacity Permissions",
"Fabric is not supported in the current cloud ({0}). Ensure setting '{1}' is configured correctly./{0} is the cloud name{1} is the setting name": {
"message": "Fabric is not supported in the current cloud ({0}). Ensure setting '{1}' is configured correctly.",
"comment": ["{0} is the cloud name", "{1} is the setting name"]
Expand Down
3 changes: 0 additions & 3 deletions localization/xliff/vscode-mssql.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1728,9 +1728,6 @@
<trans-unit id="++CODE++23175b00048139605147500e1f2eb6c43b4e938ee3dbcfebb00ae6b472284cdb">
<source xml:lang="en">Instant Container Setup</source>
</trans-unit>
<trans-unit id="++CODE++07fe70d13a25b3d4c4f7d4e64e1aaa9b9d80952a1478fb7e2da36209ccbf549f">
<source xml:lang="en">Insufficient Capacity Permissions</source>
</trans-unit>
<trans-unit id="++CODE++207b04072a822fa8e76629bcd504bc8c19525b86f444ac77a6f3be1c88a502eb">
<source xml:lang="en">Insufficient Workspace Permissions</source>
</trans-unit>
Expand Down
1 change: 0 additions & 1 deletion src/constants/locConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,6 @@ export class Fabric {
public static searchWorkspaces = l10n.t("Search Workspaces");
public static workspaceIsRequired = l10n.t("Workspace is required");
public static insufficientWorkspacePermissions = l10n.t("Insufficient Workspace Permissions");
public static insufficientCapacityPermissions = l10n.t("Insufficient Capacity Permissions");

public static fabricNotSupportedInCloud = (cloudName: string, settingName: string) => {
return l10n.t({
Expand Down
71 changes: 5 additions & 66 deletions src/deployment/fabricProvisioningHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,6 @@ export async function reloadFabricComponents(
state.formState.tenantId = getDefaultTenantId(accountId, tenants);
state.formComponents.tenantId.options = tenantOptions;
}
state.capacityIds = [];
state.userGroupIds = [];
state.workspaces = [];
state.databaseNamesInWorkspace = [];
Expand All @@ -406,18 +405,11 @@ export function getWorkspaceOptions(state: fp.FabricProvisioningState): FormItem
return orderedWorkspaces.map((workspace) => {
const hasPermission = workspace.id in state.workspacesWithPermissions;

let description = "";
if (workspace.hasCapacityPermissionsForProvisioning === false) {
description = Fabric.insufficientCapacityPermissions;
} else if (!hasPermission) {
description = Fabric.insufficientWorkspacePermissions;
}

return {
displayName: workspace.displayName,
value: workspace.id,
color: hasPermission ? "" : "colorNeutralForegroundDisabled",
description: description,
description: hasPermission ? "" : Fabric.insufficientWorkspacePermissions,
icon: hasPermission ? undefined : "Warning20Regular",
};
});
Expand All @@ -433,9 +425,6 @@ export async function getWorkspaces(

tenantId = tenantId || state.formState.tenantId;
try {
// Set user's capacities in state
await getCapacities(deploymentController, tenantId);

const workspaces = await FabricHelper.getFabricWorkspaces(tenantId);
state.workspaces = await sortWorkspacesByPermission(
deploymentController,
Expand Down Expand Up @@ -469,41 +458,6 @@ export async function getWorkspaces(
}
}

export async function getCapacities(
deploymentController: DeploymentWebviewController,
tenantId?: string,
): Promise<void> {
const state = deploymentController.state.deploymentTypeState as fp.FabricProvisioningState;
if (state.formState.tenantId === "" && !tenantId) return;
if (state.capacityIds.length !== 0) return;

const startTime = Date.now();
try {
const capacities = await FabricHelper.getFabricCapacities(
tenantId || state.formState.tenantId,
);
state.capacityIds = capacities.map((capacity) => capacity.id);
updateFabricProvisioningState(deploymentController, state);
sendActionEvent(
TelemetryViews.FabricProvisioning,
TelemetryActions.GetWorkspaces,
{},
{
capacitiesLoadTimeInMs: Date.now() - startTime,
},
);
} catch (err) {
state.errorMessage = getErrorMessage(err);
sendErrorEvent(
TelemetryViews.FabricProvisioning,
TelemetryActions.LoadCapacities,
err,
false,
);
throw err;
}
}

export async function getRoleForWorkspace(
state: fp.FabricProvisioningState,
workspace: IWorkspace,
Expand Down Expand Up @@ -565,25 +519,11 @@ export async function sortWorkspacesByPermission(
state.userGroupIds.push(userId);
}

const workspacesWithValidOrUnknownCapacities: Record<string, IWorkspace> = {};

for (const workspace of workspaces) {
// Track all workspaces in the global map
state.workspaces[workspace.id] = workspace;

if (workspace.capacityId && !state.capacityIds.includes(workspace.capacityId)) {
workspace.hasCapacityPermissionsForProvisioning = false;
state.workspacesWithoutPermissions[workspace.id] = workspace;
} else {
workspacesWithValidOrUnknownCapacities[workspace.id] = workspace;
}
}

const startTime = Date.now();
// Fetch all roles in parallel if it won't hit rate limits
if (Object.keys(workspacesWithValidOrUnknownCapacities).length < WORKSPACE_ROLE_REQUEST_LIMIT) {
if (workspaces.length < WORKSPACE_ROLE_REQUEST_LIMIT) {
const workspacesWithRoles = await Promise.all(
Object.values(workspacesWithValidOrUnknownCapacities).map(async (workspace) => {
workspaces.map(async (workspace) => {
return await getRoleForWorkspace(state, workspace, tenantId);
}),
);
Expand All @@ -594,9 +534,8 @@ export async function sortWorkspacesByPermission(
} else {
state.workspacesWithoutPermissions[workspace.id] = workspace;
}
// Also keep workspace in the global map
state.workspaces[workspace.id] = workspace;
}

sendActionEvent(
TelemetryViews.FabricProvisioning,
TelemetryActions.GetPermissionsForWorkspaces,
Expand All @@ -606,7 +545,7 @@ export async function sortWorkspacesByPermission(
},
);
} else {
state.workspacesWithPermissions = workspacesWithValidOrUnknownCapacities;
state.workspacesWithPermissions = Object.fromEntries(workspaces.map((ws) => [ws.id, ws]));
}

updateFabricProvisioningState(deploymentController, state);
Expand Down
1 change: 0 additions & 1 deletion src/sharedInterfaces/fabricProvisioning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export class FabricProvisioningState
workspacesWithPermissions: Record<string, IWorkspace> = {};
workspacesWithoutPermissions: Record<string, IWorkspace> = {};
isWorkspacesErrored: boolean = false;
capacityIds: string[] = [];
userGroupIds: string[] = [];
deploymentStartTime: string = "";
workspaces: IWorkspace[] = [];
Expand Down
6 changes: 0 additions & 6 deletions test/unit/fabricProvisioningHelpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ suite("Fabric Provisioning logic", () => {
const result = await fabricHelpers.reloadFabricComponents(deploymentController, "tenant1");

// Check that sets and arrays were reset
assert.deepStrictEqual(Array.from(result.capacityIds), []);
assert.deepStrictEqual(Array.from(result.userGroupIds), []);
assert.deepStrictEqual(result.workspaces, []);
assert.deepStrictEqual(result.databaseNamesInWorkspace, []);
Expand Down Expand Up @@ -288,11 +287,6 @@ suite("Fabric Provisioning logic", () => {
assert.strictEqual(options[1].value, "ws2");
assert.strictEqual(options[1].description, Fabric.insufficientWorkspacePermissions);
assert.strictEqual(options[1].icon, "Warning20Regular");

// ws3 has no capacity permission
assert.strictEqual(options[2].value, "ws3");
assert.strictEqual(options[2].description, Fabric.insufficientCapacityPermissions);
assert.strictEqual(options[2].icon, "Warning20Regular");
});

test("getWorkspaces updates state with workspace options", async () => {
Expand Down