Skip to content

Commit

Permalink
Merge pull request #63 from Microsoft/saw/useropts
Browse files Browse the repository at this point in the history
Add userOptions to createChild
  • Loading branch information
StephenWeatherford authored Feb 1, 2018
2 parents 6d60c55 + df6aa56 commit ed48df2
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 12 deletions.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,17 @@ This project provides Node.js packages that make it easy to consume and manage A

In order to quickly develop and debug these packages locally, follow these instructions:
1. Navigate to the package you are developing and run `npm install`, `npm run build`, and `npm link`
1. Navigate to the project you want to reference the package and run `npm link <name of package>`
1. Navigate to the project that references the package you're developing and run `npm link <name of package>`

Example:
```
cd ~/repos/vscode-azuretools/ui
npm install
npm run build
npm link
cd ~/repos/vscode-azurestorage
npm link vscode-azureextensionui
```

## Contributing

Expand Down
2 changes: 1 addition & 1 deletion ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ For a more advanced scenario, you can also implement the `createChild` method on

![CreateNodePicker](resources/CreateNodePicker.png) ![CreatingNode](resources/CreatingNode.png)
```typescript
public async createChild(node: IAzureNode, showCreatingNode: (label: string) => void): Promise<IAzureTreeItem> {
public async createChild(node: IAzureNode, showCreatingNode: (label: string) => void, _userOptions?: {}): Promise<IAzureTreeItem> {
const webAppName = await vscode.window.showInputBox({ prompt: 'Enter the name of your new Web App' });
showCreatingNode(webAppName);
const newSite: Site | undefined = await createWebApp(webAppName, node.credentials, node.subscription);
Expand Down
5 changes: 3 additions & 2 deletions ui/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export interface IAzureParentNode<T extends IAzureTreeItem = IAzureTreeItem> ext
/**
* This class wraps IChildProvider.createChild and ensures the tree is updated correctly when an item is created
*/
createChild(): Promise<IAzureNode>;
createChild(userOptions?: any): Promise<IAzureNode>;

getCachedChildren(): Promise<IAzureNode[]>
}
Expand Down Expand Up @@ -100,8 +100,9 @@ export interface IChildProvider {

/**
* Implement this if you want the 'create' option to show up in the node picker
* @param options User-defined options that are passed to the IAzureParentTreeItem.createChild call
*/
createChild?(node: IAzureNode, showCreatingNode: (label: string) => void): Promise<IAzureTreeItem>;
createChild?(node: IAzureNode, showCreatingNode: (label: string) => void, userOptions?: any): Promise<IAzureTreeItem>;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion ui/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "vscode-azureextensionui",
"author": "Microsoft Corporation",
"version": "0.5.4",
"version": "0.5.5",
"description": "Common UI tools for developing Azure extensions for VS Code",
"tags": [
"azure",
Expand Down
17 changes: 10 additions & 7 deletions ui/src/treeDataProvider/AzureParentNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,19 @@ export class AzureParentNode<T extends IAzureParentTreeItem = IAzureParentTreeIt
this._cachedChildren = undefined;
}

public async createChild(): Promise<AzureNode> {
public async createChild(userOptions?: {}): Promise<AzureNode> {
if (this.treeItem.createChild) {
let creatingNode: AzureNode | undefined;
try {
const newTreeItem: IAzureTreeItem = await this.treeItem.createChild(this, (label: string): void => {
creatingNode = new AzureNode(this, new CreatingTreeItem(label));
this._creatingNodes.push(creatingNode);
//tslint:disable-next-line:no-floating-promises
this.treeDataProvider.refresh(this, false);
});
const newTreeItem: IAzureTreeItem = await this.treeItem.createChild(
this,
(label: string): void => {
creatingNode = new AzureNode(this, new CreatingTreeItem(label));
this._creatingNodes.push(creatingNode);
//tslint:disable-next-line:no-floating-promises
this.treeDataProvider.refresh(this, false);
},
userOptions);

const newNode: AzureNode = this.createNewNode(newTreeItem);
await this.addNodeToCache(newNode);
Expand Down

0 comments on commit ed48df2

Please sign in to comment.