forked from microsoft/vscode-docker
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rutusamai/list build tasks for each registry (#37)
* tslint updates, transfered from old branch * updated icon * Addressed PR comments- mostly styling/code efficiency * Changed url to aka.ms link * changed Error window to Info message for no build tasks in your registry * Changed default sku and unified parsing resource group into a new method, getResourceGroup in acrTools.ts * Changed build task icon
- Loading branch information
Showing
7 changed files
with
110 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import { ResourceManagementClient, SubscriptionClient, SubscriptionModels } from 'azure-arm-resource'; | ||
import * as opn from 'opn'; | ||
import * as path from 'path'; | ||
import * as vscode from 'vscode'; | ||
import * as ContainerModels from '../../node_modules/azure-arm-containerregistry/lib/models'; | ||
import { AzureAccount, AzureSession } from '../../typings/azure-account.api'; | ||
import * as acrTools from '../../utils/Azure/acrTools'; | ||
import { AzureUtilityManager } from '../../utils/azureUtilityManager'; | ||
import { NodeBase } from './nodeBase'; | ||
|
||
/* Single TaskRootNode under each Repository. Labeled "Build Tasks" */ | ||
export class TaskRootNode extends NodeBase { | ||
constructor( | ||
public readonly label: string, | ||
public readonly azureAccount: AzureAccount, | ||
public readonly subscription: SubscriptionModels.Subscription, | ||
public readonly registry: ContainerModels.Registry, | ||
//public readonly iconPath: any = null, | ||
) { | ||
super(label); | ||
} | ||
|
||
public readonly contextValue: string = 'taskRootNode'; | ||
public name: string; | ||
public readonly iconPath: { light: string | vscode.Uri; dark: string | vscode.Uri } = { | ||
light: path.join(__filename, '..', '..', '..', '..', 'images', 'light', 'tasks_light.svg'), | ||
dark: path.join(__filename, '..', '..', '..', '..', 'images', 'dark', 'tasks_dark.svg') | ||
}; | ||
|
||
public getTreeItem(): vscode.TreeItem { | ||
return { | ||
label: this.label, | ||
collapsibleState: vscode.TreeItemCollapsibleState.Collapsed, | ||
contextValue: this.contextValue, | ||
iconPath: this.iconPath | ||
} | ||
} | ||
|
||
/* Making a list view of TaskNodes, or the Tasks of the current registry */ | ||
|
||
public async getChildren(element: TaskRootNode): Promise<TaskNode[]> { | ||
const taskNodes: TaskNode[] = []; | ||
let tasks: ContainerModels.Task[] = []; | ||
const client = AzureUtilityManager.getInstance().getContainerRegistryManagementClient(element.subscription); | ||
const resourceGroup: string = acrTools.getResourceGroupName(element.registry); | ||
tasks = await client.tasks.list(resourceGroup, element.registry.name); | ||
if (tasks.length === 0) { | ||
vscode.window.showInformationMessage(`You do not have any Tasks in the registry, '${element.registry.name}'. You can create one with ACR Task. `, "Learn More").then(val => { | ||
if (val === "Learn More") { | ||
opn('https://aka.ms/acr/task'); | ||
} | ||
}) | ||
} | ||
|
||
for (let task of tasks) { | ||
let node = new TaskNode(task, element.registry, element.subscription, element); | ||
taskNodes.push(node); | ||
} | ||
return taskNodes; | ||
} | ||
} | ||
export class TaskNode extends NodeBase { | ||
constructor( | ||
public task: ContainerModels.Task, | ||
public registry: ContainerModels.Registry, | ||
|
||
public subscription: SubscriptionModels.Subscription, | ||
public parent: NodeBase | ||
|
||
) { | ||
super(task.name); | ||
} | ||
|
||
public label: string; | ||
public readonly contextValue: string = 'taskNode'; | ||
|
||
public getTreeItem(): vscode.TreeItem { | ||
return { | ||
label: this.label, | ||
collapsibleState: vscode.TreeItemCollapsibleState.None, | ||
contextValue: this.contextValue, | ||
iconPath: null | ||
} | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters