Skip to content

Commit

Permalink
Convenience API for contributing standard folders (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
itowlson authored May 1, 2019
1 parent 7325e11 commit ebd88fa
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vscode-kubernetes-tools-api",
"version": "0.0.6",
"version": "0.0.7",
"description": "Documents and encapsulates the API for the Kubernetes extension for Visual Studio Code",
"main": "js/index.js",
"types": "js/index.d.ts",
Expand Down
56 changes: 56 additions & 0 deletions ts/cluster-explorer/v1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ function onFooCommand(commandTarget?: any) {
* @param nodeContributor An object which can add nodes to the Cluster Explorer.
*/
registerNodeContributor(nodeContributor: ClusterExplorerV1.NodeContributor): void;
/**
* Exposes built-in node types for reuse as custom NodeContributors.
*/
readonly nodeSources: ClusterExplorerV1.NodeSources;
/**
* Registers an object to customize the appearance of nodes in the Cluster Explorer. The object will be
* consulted every time the Kubernetes extension displays a tree node.
Expand Down Expand Up @@ -315,4 +319,56 @@ export namespace ClusterExplorerV1 {
*/
readonly abbreviation: string;
}

/**
* Represents a source of tree nodes.
*/
export interface NodeSource {
/**
* Creates a NodeContributor which contributes the nodes from the source at a
* given location.
* @param parentFolder The name of the folder under which the nodes should be contributed,
* or undefined if the nodes should be contributed directly under the context tree node.
* @returns A NodeContributor which, when registered, adds the nodes from the source
* under the specified folder.
*/
at(parentFolder: string | undefined): NodeContributor;
/**
* Creates a new NodeSource which will return the same node(s) as this, but
* only if a condition holds.
* @param condition The condition under which the new NodeSource will return node(s).
* @returns A NodeSource which will return the same node(s) as this, but
* only if the specified condition holds.
*/
if(condition: () => boolean | Thenable<boolean>): NodeSource;
/**
* Gets tree nodes from the source.
* @returns The set of tree nodes obtained from the source.
*/
nodes(): Promise<Node[]>;
}

/**
* Exposes built-in node types for reuse as custom NodeContributors.
*/
export interface NodeSources {
/**
* A NodeSet consisting of a single folder node which, when expanded, shows all resources of a
* specific type.
* @param displayName The singular display name of the resource type. Example: Stateful Set.
* @param pluralDisplayName The plural display name of the resource type - used as the folder display name. Example: Stateful Sets.
* @param manifestKind The string used to identify the resource type in Kubernetes manifests. Example: StatefulSet.
* @param abbreviation The string used to identify the resource type on the kubectl command line. Example: sts.
* @returns A NodeSet which provides the requested folder node.
*/
resourceFolder(displayName: string, pluralDisplayName: string, manifestKind: string, abbreviation: string): NodeSource;
/**
* A NodeSet consisting of a single folder node which, when expanded, displays an arbitrary set of nodes.
* @param displayName The display name of the folder.
* @param contextValue The context value for the folder's TreeItem, if you need to associate commands with the folder.
* @param children The nodes to display under the grouping folder.
* @returns A NodeSet which provides the requested folder node.
*/
groupingFolder(displayName: string, contextValue: string | undefined, ...children: NodeSource[]): NodeSource;
}
}

0 comments on commit ebd88fa

Please sign in to comment.