Skip to content

Commit

Permalink
azure: Make static and export generalizedLocationName (#1760)
Browse files Browse the repository at this point in the history
  • Loading branch information
MicroFish91 authored Aug 7, 2024
1 parent 50f299b commit 54092fe
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 2 additions & 0 deletions azure/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ export declare class LocationListStep<T extends ILocationWizardContext> extends

protected getQuickPicks(wizardContext: T): Promise<IAzureQuickPickItem<AzExtLocation>[]>;

public static generalizeLocationName(name: string | undefined): string;

/**
* Implement this to set descriptions on location quick pick items.
*/
Expand Down
14 changes: 7 additions & 7 deletions azure/src/wizard/LocationListStep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,13 @@ export class LocationListStep<T extends ILocationWizardContextInternal> extends
const locationSubsets: string[][] = await Promise.all(providerLocationsMap.values());
// Filter to locations supported by every provider
return (await allLocationsTask).filter(l1 => (l1.type === 'EdgeZone' && wizardContext.includeExtendedLocations) || locationSubsets.every(subset =>
subset.find(l2 => generalizeLocationName(l1.name) === generalizeLocationName(l2))
subset.find(l2 => LocationListStep.generalizeLocationName(l1.name) === LocationListStep.generalizeLocationName(l2))
));
}

public static locationMatchesName(location: types.AzExtLocation, name: string): boolean {
name = generalizeLocationName(name);
return name === generalizeLocationName(location.name) || name === generalizeLocationName(location.displayName);
name = LocationListStep.generalizeLocationName(name);
return name === LocationListStep.generalizeLocationName(location.name) || name === LocationListStep.generalizeLocationName(location.displayName);
}

public async prompt(wizardContext: T): Promise<void> {
Expand Down Expand Up @@ -212,11 +212,11 @@ export class LocationListStep<T extends ILocationWizardContextInternal> extends
});
}

public static getQuickPickDescription?: (location: types.AzExtLocation) => string | undefined;
}
public static generalizeLocationName(name: string | undefined): string {
return (name || '').toLowerCase().replace(/[^a-z0-9]/gi, '');
}

function generalizeLocationName(name: string | undefined): string {
return (name || '').toLowerCase().replace(/[^a-z0-9]/gi, '');
public static getQuickPickDescription?: (location: types.AzExtLocation) => string | undefined;
}

async function getAllLocations(wizardContext: types.ILocationWizardContext): Promise<types.AzExtLocation[]> {
Expand Down

0 comments on commit 54092fe

Please sign in to comment.