Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azure: Make static and export generalizedLocationName #1760

Merged
merged 12 commits into from
Aug 7, 2024
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
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
Loading