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
17 changes: 17 additions & 0 deletions resources/providers/microsoft.web/logicapp.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 2 additions & 5 deletions src/azureExtensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*--------------------------------------------------------------------------------------------*/

import { GenericResource } from "@azure/arm-resources";
import { isAppServiceApp, isFunctionApp } from "./utils/azureUtils";
import { localize } from "./utils/localize";

export const azureExtensions: IAzExtMetadata[] = [
Expand All @@ -28,7 +29,7 @@ export const azureExtensions: IAzExtMetadata[] = [
resourceTypes: [
{
name: 'microsoft.web/sites',
matchesResource: r => !isFunctionApp(r)
matchesResource: isAppServiceApp
}
],
tutorial: {
Expand Down Expand Up @@ -114,7 +115,3 @@ export interface IAzExtTutorial {
label: string;
url: string;
}

function isFunctionApp(resource: GenericResource): boolean {
return !!resource.kind?.toLowerCase().includes('functionapp');
}
2 changes: 1 addition & 1 deletion src/tree/AppResourceTreeItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class AppResourceTreeItem extends ResolvableTreeItemBase implements Group
ext.resourceTypes.some((type) => {
return typeof type === 'string' ?
type.toLowerCase() === this.type?.toLowerCase() :
type.name.toLowerCase() === this.type?.toLowerCase()
type.name.toLowerCase() === this.type?.toLowerCase() && type.matchesResource(this.data)
}));
}

Expand Down
3 changes: 2 additions & 1 deletion src/tree/ResourceCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { ResourceGroup } from "@azure/arm-resources";
import { IActionContext, nonNullProp } from "@microsoft/vscode-azext-utils";
import { AppResource } from "@microsoft/vscode-azext-utils/hostapi";
import { ThemeIcon } from "vscode";
import { azureExtensions } from "../azureExtensions";
import { GroupBySettings } from "../commands/explorer/groupBy";
import { ungroupedId } from "../constants";
import { createAzureExtensionsGroupConfig } from "../utils/azureUtils";
Expand Down Expand Up @@ -82,7 +83,7 @@ export class ResourceCache {
break;
case GroupBySettings.ResourceType:
// always create the groups for extensions that we support
const azExtGroupConfigs = createAzureExtensionsGroupConfig(nonNullProp(this._subscriptionTreeItem, 'id'));
const azExtGroupConfigs = createAzureExtensionsGroupConfig(azureExtensions, nonNullProp(this._subscriptionTreeItem, 'id'));
for (const azExtGroupConfig of azExtGroupConfigs) {
if (!treeMap[azExtGroupConfig.id]) {
const groupTreeItem = new GroupTreeItemBase(this._subscriptionTreeItem, azExtGroupConfig);
Expand Down
44 changes: 30 additions & 14 deletions src/utils/azureUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { uiUtils } from '@microsoft/vscode-azext-azureutils';
import { IActionContext, nonNullProp, TreeItemIconPath } from '@microsoft/vscode-azext-utils';
import { GroupingConfig, GroupNodeConfiguration } from '@microsoft/vscode-azext-utils/hostapi';
import { ThemeIcon } from 'vscode';
import { azureExtensions } from '../azureExtensions';
import type { IAzExtMetadata } from '../azureExtensions';
import { ext } from '../extensionVariables';
import { createResourceClient } from './azureClients';
import { localize } from './localize';
Expand Down Expand Up @@ -67,9 +67,9 @@ export function createGroupConfigFromResource(resource: GenericResource, subscri
return groupConfig;
}

export function createAzureExtensionsGroupConfig(subscriptionId: string): GroupNodeConfiguration[] {
export function createAzureExtensionsGroupConfig(extensions: IAzExtMetadata[], subscriptionId: string): GroupNodeConfiguration[] {
const azExtGroupConfigs: GroupNodeConfiguration[] = [];
for (const azExt of azureExtensions) {
for (const azExt of extensions) {
for (const resourceType of azExt.resourceTypes) {
const type = typeof resourceType === 'string' ? resourceType : resourceType.name;
const kind = azExt.name === 'vscode-azurefunctions' ? 'functionapp' : undefined;
Expand Down Expand Up @@ -118,6 +118,7 @@ export async function getArmTagKeys(context: IActionContext): Promise<Set<string
// Execute `npm run listIcons` from root of repo to re-generate this list after adding an icon
export const supportedIconTypes = [
'microsoft.web/functionapp',
'microsoft.web/logicapp',
'microsoft.web/hostingenvironments',
'microsoft.web/kubeenvironments',
'microsoft.web/serverfarms',
Expand Down Expand Up @@ -183,14 +184,8 @@ interface SupportedType {
}

function getName(type?: string, kind?: string): string | undefined {
type = type?.toLowerCase();
if (isFunctionApp(type, kind)) {
type = 'microsoft.web/functionapp';
}
if (type) {
return supportedTypes[type as SupportedTypes]?.displayName;
}
return undefined;
const rType: string = getResourceType(type, kind).toLowerCase();
return supportedTypes[rType as SupportedTypes]?.displayName;
}

// intersect with Record<stirng, SupportedType> so we can add info for resources we don't have icons for
Expand All @@ -200,6 +195,7 @@ const supportedTypes: SupportedTypeMap = {
'microsoft.web/sites': { displayName: localize('webApp', 'App Services') },
'microsoft.web/staticsites': { displayName: localize('staticWebApp', 'Static Web Apps') },
'microsoft.web/functionapp': { displayName: localize('functionApp', 'Function App') },
'microsoft.web/logicapp': { displayName: localize('logicApp', 'Logic App') },
'microsoft.compute/virtualmachines': { displayName: localize('virtualMachines', 'Virtual machines') },
'microsoft.storage/storageaccounts': { displayName: localize('storageAccounts', 'Storage accounts') },
'microsoft.network/networksecuritygroups': { displayName: localize('networkSecurityGroups', 'Network security groups') },
Expand Down Expand Up @@ -230,19 +226,39 @@ const supportedTypes: SupportedTypeMap = {
'microsoft.app/containerapps': { displayName: localize('containerApp', 'Container Apps') },
}

export function isFunctionApp(type?: string, kind?: string): boolean {
export function isFunctionApp(resource: GenericResource): boolean {
const { type, kind } = resource;
if (type?.toLowerCase() === 'microsoft.web/sites') {
if (kind?.toLowerCase().includes('functionapp') && !kind?.toLowerCase().includes('workflowapp')) {
return true;
}
}
return false;
}

export function isLogicApp(resource: GenericResource): boolean {
const { type, kind } = resource;
if (type?.toLowerCase() === 'microsoft.web/sites') {
if (kind?.toLowerCase().includes('functionapp')) {
if (kind?.toLowerCase().includes('functionapp') && kind?.toLowerCase().includes('workflowapp')) {
return true;
}
}
return false;
}

export function isAppServiceApp(resource: GenericResource): boolean {
return resource.type?.toLowerCase() === 'microsoft.web/sites'
&& !isFunctionApp(resource)
&& !isLogicApp(resource);
}

function getRelevantKind(type?: string, kind?: string): string | undefined {
if (isFunctionApp(type, kind)) {
if (isFunctionApp({ type, kind })) {
return 'functionapp';
}
if (isLogicApp({ type, kind })) {
return 'logicapp';
}
return undefined;
}

Expand Down