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

Show labels for invalid app services #373

Merged
merged 12 commits into from
Mar 29, 2018
7 changes: 7 additions & 0 deletions resources/dark/WebApp_grayscale.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: 7 additions & 0 deletions resources/light/WebApp_grayscale.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions src/explorer/InvalidWebAppTreeItem.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import * as path from 'path';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the Microsoft copyright header - I'm not an expert on the legalese but you can check out this section for more info: https://github.com/Microsoft/vscode-azureappservice#contributing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

import { IAzureTreeItem } from 'vscode-azureextensionui';

export class InvalidWebAppTreeItem implements IAzureTreeItem {
public static contextValue: string = 'invalidAppService';
public readonly contextValue: string = InvalidWebAppTreeItem.contextValue;

constructor(readonly label: string, readonly description: string) {
}

public get iconPath(): { light: string, dark: string } {
const iconName = 'WebApp_grayscale.svg';
return {
light: path.join(__filename, '..', '..', '..', '..', 'resources', 'light', iconName),
dark: path.join(__filename, '..', '..', '..', '..', 'resources', 'dark', iconName)
};
}
}
25 changes: 12 additions & 13 deletions src/explorer/WebAppProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { AppServicePlan, Site, WebAppCollection } from 'azure-arm-website/lib/mo
import { createWebApp, SiteClient } from 'vscode-azureappservice';
import { IActionContext, IAzureNode, IAzureTreeItem, IChildProvider, UserCancelledError } from 'vscode-azureextensionui';
import * as util from '../util';
import { InvalidWebAppTreeItem } from './InvalidWebAppTreeItem';
import { WebAppTreeItem } from './WebAppTreeItem';

export class WebAppProvider implements IChildProvider {
Expand All @@ -31,22 +32,20 @@ export class WebAppProvider implements IChildProvider {

this._nextLink = webAppCollection.nextLink;

return await Promise.all(webAppCollection
.filter((s: Site) => {
const treeItems: IAzureTreeItem[] = [];
await Promise.all(webAppCollection
.map(async (s: Site) => {
try {
const siteClient = new SiteClient(s, node);
return siteClient !== undefined;
// tslint:disable-next-line:no-unsafe-any
} catch (err) {
return false;
const siteClient: SiteClient = new SiteClient(s, node);
if (!siteClient.isFunctionApp) {
const appServicePlan: AppServicePlan = await siteClient.getAppServicePlan();
treeItems.push(new WebAppTreeItem(siteClient, appServicePlan));
}
} catch {
treeItems.push(new InvalidWebAppTreeItem(s.name, 'Invalid'));
}
})
.map((s: Site) => new SiteClient(s, node))
.filter((s: SiteClient) => !s.isFunctionApp)
.map(async (s: SiteClient) => {
const appServicePlan: AppServicePlan = await s.getAppServicePlan();
return new WebAppTreeItem(s, appServicePlan);
}));
return treeItems;
}

public async createChild(node: IAzureNode<IAzureTreeItem>, showCreatingNode: (label: string) => void, actionContext: IActionContext): Promise<IAzureTreeItem> {
Expand Down