Skip to content

Commit

Permalink
Small fix for sorting currently deployed pick (#840)
Browse files Browse the repository at this point in the history
  • Loading branch information
MicroFish91 authored Jan 14, 2025
1 parent 8face28 commit 3b0b051
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions src/commands/image/imageSource/containerRegistry/acr/AcrListStep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export class AcrListStep<T extends ContainerRegistryImageSourceContext> extends

await tryConfigureResourceGroupForRegistry(context, promptSteps);

if (context.resourceGroup) {
if (!LocationListStep.hasLocation(context) && context.resourceGroup) {
await LocationListStep.setLocation(context, context.resourceGroup.location);
} else {
LocationListStep.addStep(context, promptSteps);
Expand Down Expand Up @@ -188,22 +188,18 @@ export class AcrListStep<T extends ContainerRegistryImageSourceContext> extends
};
});

// If a currently deployed registry exists, we can expect it to be in the first resource group because we already sorted the group to the front
if (i === 0 && hasCurrentRegistry) {
groupedRegistries.sort((a, b) => {
if (hasMatchingPickDescription(a, currentlyDeployedPickDescription)) {
return -1;
} else if (hasMatchingPickDescription(b, currentlyDeployedPickDescription)) {
return 1;
} else {
return 0;
}
});
}

picks.push(...groupedRegistries);
}

// If a currently deployed registry exists, bring it to the front of the list
if (hasCurrentRegistry) {
const cdIdx: number = picks.findIndex(p => hasMatchingPickDescription(p, currentlyDeployedPickDescription));
if (cdIdx !== -1) {
const currentlyDeployedPick: IAzureQuickPickItem<Registry> | undefined = picks.splice(cdIdx, 1)[0];
picks.unshift(currentlyDeployedPick);
}
}

return picks;
}

Expand Down

0 comments on commit 3b0b051

Please sign in to comment.