-
Notifications
You must be signed in to change notification settings - Fork 95
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
Changes from 8 commits
91ecdd0
0823608
fbe4026
b7e8c39
31479de
8ff617e
1ad2fee
66402a2
60aecef
43e0b77
975cdf0
6e412d9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +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 { WebAppTreeItem } from './WebAppTreeItem'; | ||
import { InvalidWebAppTreeItem, WebAppTreeItem } from './WebAppTreeItem'; | ||
|
||
export class WebAppProvider implements IChildProvider { | ||
public readonly childTypeLabel: string = 'Web App'; | ||
|
@@ -31,22 +31,18 @@ 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); | ||
const appServicePlan: AppServicePlan = await siteClient.getAppServicePlan(); | ||
treeItems.push(new WebAppTreeItem(siteClient, appServicePlan)); | ||
} catch { | ||
treeItems.push(new InvalidWebAppTreeItem(`${s.name} (invalid)`)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like 'invalid'. However, rather than doing the formatting yourself, please specify That will ensure its displayed in the same format as our other description properties (which as of today is the same format that you did, but could change in the future) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Description property added. |
||
} | ||
}) | ||
.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> { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ export class WebAppTreeItem extends SiteTreeItem { | |
public readonly appSettingsNode: IAzureTreeItem; | ||
public readonly webJobsNode: IAzureTreeItem; | ||
public readonly folderNode: IAzureTreeItem; | ||
public readonly invalidAppServiceNode: IAzureTreeItem; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove this property - its never used There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed |
||
|
||
constructor(client: SiteClient, appServicePlan: AppServicePlan) { | ||
super(client); | ||
|
@@ -126,3 +127,20 @@ export class WebAppTreeItem extends SiteTreeItem { | |
return await fs.readFile(templatePath, 'utf8'); | ||
} | ||
} | ||
|
||
export class InvalidWebAppTreeItem implements IAzureTreeItem { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please move this to a separate file "InvalidWebAppTreeItem.ts" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I included it here, as that's the same way the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah @nturinski did that, not me 😊 I generally prefer one exported class per file, since you never know how much a class will grow as time goes on That being said - this is kind of a stylistic preference and I wouldn't block a PR just for this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Went ahead and moved it to it's own file (I prefer it that way as well, lol). |
||
public static contextValue: string = 'file'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assume you copied this from the FileTreeItem haha? Please make the context value something like 'invalidWebApp' or 'invalidAppService' There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lol, yeah, my bad... copy/paste got me. Renamed to 'invalidAppService' (matches the WebAppTreeItem better). |
||
public readonly contextValue: string = InvalidWebAppTreeItem.contextValue; | ||
public readonly commandId: string = 'appService.showFile'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove the commandId property - it was only used in the FileTreeItem There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. |
||
|
||
constructor(readonly label: string) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you didn't know, the contextValue is used to determine which commands are shown in the context menu. See the 'viewItem' property in package.json: If you want to support OpenInPortal, just do the same thing in package.json except use this treeItem's contextValue as the viewItem instead of 'appService'. You also have to specify the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, site.id doesn't exist for these either, so that's not going to work. I'd love for it to just open to the "WebApps" blade in the portal, but I'm not sure how to get a direct link for that (when I go there in the portal, my tenant id is in the URL). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wouldn't worry about it then. Judging by these screenshots, the Portal wasn't that helpful anyways: #370 (comment) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Roger that! |
||
} | ||
|
||
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) | ||
}; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrap
getAppServicePlan
andtreeItems.push
inif (!siteClient.isFunctionApp)
We have a completely separate extension that handles function apps: https://github.com/Microsoft/vscode-azurefunctions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugh, fixed... forgot about that.