From b4f4aa34cf98ee1c577b78a7fea5a3f13f8ce063 Mon Sep 17 00:00:00 2001 From: Greg Smulko Date: Sat, 20 Jan 2024 22:56:46 +0000 Subject: [PATCH 1/8] Show children nodes when filtering I find it extremely confusing when they were filtered out. --- .../microsoft-kiota/src/openApiTreeProvider.ts | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/vscode/microsoft-kiota/src/openApiTreeProvider.ts b/vscode/microsoft-kiota/src/openApiTreeProvider.ts index 38dd7eafc9..b6c66aec31 100644 --- a/vscode/microsoft-kiota/src/openApiTreeProvider.ts +++ b/vscode/microsoft-kiota/src/openApiTreeProvider.ts @@ -278,20 +278,15 @@ export class OpenApiTreeNode extends vscode.TreeItem { const lowerCaseSegment = this.label.toLowerCase(); const splatPath = trimOperation(this.path); if (tokenizedFilter.some(x => lowerCaseSegment.includes(x.toLowerCase()))) { - if (this.isOperation &&tokenizedFilter.some(x => operationsNames.has(x)) && !tokenizedFilter.some(x => splatPath.includes(x))) { + if (this.isOperation && tokenizedFilter.some(x => operationsNames.has(x)) && !tokenizedFilter.some(x => splatPath.includes(x))) { return false; } return true; } - - if (this.isOperation) { - const segments = getPathSegments(splatPath); - if (segments.length === 0) { - return false; - } - const parentSegment = segments[segments.length - 1].toLowerCase(); - return tokenizedFilter.some(x => parentSegment.includes(x)); - } - return this.children.some(x => x.isNodeVisible(tokenizedFilter)); + + const segments = getPathSegments(splatPath); + + return tokenizedFilter.some(x => segments.some(s => s.includes(x))) + || this.children.some(x => x.isNodeVisible(tokenizedFilter)); } } \ No newline at end of file From 00e2665916ef80b9f4f19e12650f8a176fad6a38 Mon Sep 17 00:00:00 2001 From: Greg Smulko Date: Sun, 21 Jan 2024 00:09:08 +0000 Subject: [PATCH 2/8] Collapse filtered nodes The idea is to expand nodes up to the filtered node (so it's visible), but collapse itself and its children (to avoid clutter). --- .../src/openApiTreeProvider.ts | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/vscode/microsoft-kiota/src/openApiTreeProvider.ts b/vscode/microsoft-kiota/src/openApiTreeProvider.ts index b6c66aec31..e164816b7c 100644 --- a/vscode/microsoft-kiota/src/openApiTreeProvider.ts +++ b/vscode/microsoft-kiota/src/openApiTreeProvider.ts @@ -214,19 +214,26 @@ export class OpenApiTreeProvider implements vscode.TreeDataProvider 0; + if (!hasChildren) { + return vscode.TreeItemCollapsibleState.None; + } + if (this.tokenizedFilter.length === 0) { + return vscode.TreeItemCollapsibleState.Expanded; + } + + if (this.tokenizedFilter.some(x => node.children.some(c => c.segment.includes(x) || this.getCollapsedState(c) === vscode.TreeItemCollapsibleState.Expanded))) { + return vscode.TreeItemCollapsibleState.Expanded; + } + return vscode.TreeItemCollapsibleState.Collapsed; } getTreeNodeFromKiotaNode(node: KiotaOpenApiNode): OpenApiTreeNode { return new OpenApiTreeNode( node.path, node.segment === pathSeparator && this.apiTitle ? pathSeparator + " (" + this.apiTitle + ")" : node.segment, node.selected ?? false, - this.getCollapsedState(node.children.length > 0), + this.getCollapsedState(node), node.isOperation ?? false, node.children.map(x => this.getTreeNodeFromKiotaNode(x)), node.documentationUrl From 9c44e58000399c33f808f57b2cb938a9dc7f2a24 Mon Sep 17 00:00:00 2001 From: Greg Smulko Date: Fri, 26 Jan 2024 20:44:01 +0000 Subject: [PATCH 3/8] Make collapsibleState prop readonly --- vscode/microsoft-kiota/src/openApiTreeProvider.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/vscode/microsoft-kiota/src/openApiTreeProvider.ts b/vscode/microsoft-kiota/src/openApiTreeProvider.ts index e164816b7c..7c0e723cd1 100644 --- a/vscode/microsoft-kiota/src/openApiTreeProvider.ts +++ b/vscode/microsoft-kiota/src/openApiTreeProvider.ts @@ -228,12 +228,12 @@ export class OpenApiTreeProvider implements vscode.TreeDataProvider this.getTreeNodeFromKiotaNode(x)), node.documentationUrl @@ -246,8 +246,7 @@ export class OpenApiTreeProvider implements vscode.TreeDataProvider x.isNodeVisible(this.tokenizedFilter)); } else { - const result = this.getTreeNodeFromKiotaNode(this.rawRootNode); - result.collapsibleState = vscode.TreeItemCollapsibleState.Expanded; + const result = this.getTreeNodeFromKiotaNode(this.rawRootNode, vscode.TreeItemCollapsibleState.Expanded); return [result]; } } @@ -269,7 +268,7 @@ export class OpenApiTreeNode extends vscode.TreeItem { public readonly path: string, public readonly label: string, selected: boolean, - public collapsibleState: vscode.TreeItemCollapsibleState, + public readonly collapsibleState: vscode.TreeItemCollapsibleState, private readonly isOperation: boolean, public readonly children: OpenApiTreeNode[] = [], public readonly documentationUrl?: string, From aaade8e8d3333f55e661b8ca8a6d023ea999774f Mon Sep 17 00:00:00 2001 From: Greg Smulko Date: Fri, 26 Jan 2024 21:06:00 +0000 Subject: [PATCH 4/8] Change getChildren() func signature As per https://code.visualstudio.com/api/extension-guides/tree-view --- vscode/microsoft-kiota/src/openApiTreeProvider.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vscode/microsoft-kiota/src/openApiTreeProvider.ts b/vscode/microsoft-kiota/src/openApiTreeProvider.ts index 7c0e723cd1..7f0ee90261 100644 --- a/vscode/microsoft-kiota/src/openApiTreeProvider.ts +++ b/vscode/microsoft-kiota/src/openApiTreeProvider.ts @@ -239,7 +239,7 @@ export class OpenApiTreeProvider implements vscode.TreeDataProvider { if (!this.rawRootNode) { return []; } From f2164aaed3ec9d9fb4f7c4109c0968f582f9ffc9 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Mon, 29 Jan 2024 13:57:38 -0500 Subject: [PATCH 5/8] - updates kiota releases in vscode extension --- vscode/microsoft-kiota/package-lock.json | 4 ++-- vscode/microsoft-kiota/package.json | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/vscode/microsoft-kiota/package-lock.json b/vscode/microsoft-kiota/package-lock.json index c869f8cea9..a3270c1e63 100644 --- a/vscode/microsoft-kiota/package-lock.json +++ b/vscode/microsoft-kiota/package-lock.json @@ -1,12 +1,12 @@ { "name": "kiota", - "version": "1.9.100000001", + "version": "1.10.100000002", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "kiota", - "version": "1.9.100000001", + "version": "1.10.100000002", "dependencies": { "@vscode/extension-telemetry": "^0.9.2", "@vscode/l10n": "^0.0.18", diff --git a/vscode/microsoft-kiota/package.json b/vscode/microsoft-kiota/package.json index 5359add695..d93ff03042 100644 --- a/vscode/microsoft-kiota/package.json +++ b/vscode/microsoft-kiota/package.json @@ -3,8 +3,8 @@ "displayName": "Microsoft Kiota", "publisher": "ms-graph", "description": "Client generator for HTTP REST APIs described by OpenAPI which helps eliminate the need to take a dependency on a different API client for every API that you need to call, as well as limiting the generation to the exact API surface area you're interested in, thanks to a filtering capability.", - "version": "1.9.100000001", - "kiotaVersion": "1.9.0", + "version": "1.10.100000002", + "kiotaVersion": "1.10.1", "telemetryInstrumentationKey": "4c6357e0-daf9-42b5-bdfb-67878f8957b5", "icon": "images/logo.png", "engines": { @@ -450,23 +450,23 @@ "runtimeDependencies": [ { "platformId": "win-x64", - "sha256": "16FE8B6E48A23EE00F89697EB34714C57E996EAFB57476C0F5BFD3D473C17A83" + "sha256": "F14DA204DBB513B12995C006DD4A356C8498EFF087BA77EE84E06C18AE92A947" }, { "platformId": "win-x86", - "sha256": "FF0F55CEA4520C6B8EE8308820847C20CE5C1123B9146E943D29BBAF1BF6E8A9" + "sha256": "1E55DDEBC4EC8AC8B527C7681FD342A2CFB74150914DD1E9669B84DAF26E18D5" }, { "platformId": "linux-x64", - "sha256": "E9A445B61B9A1B2F733FAC2A47E7D0C530241535137BA98EA8AD5514CA1D5350" + "sha256": "311F765AEC73477501B1C6EA97C0EAF108144318CB1C7C39D20B3CEE4C5DF848" }, { "platformId": "osx-x64", - "sha256": "74DCC6F65D7D9FF9AC2DBA3875EFE4CBE38ADB8888D909AA206E3D67872EB8DB" + "sha256": "82843F91BEC078C9344BAFFE7D8B7FB87BDAD7160329AF221BCEBA2C10DD0B50" }, { "platformId": "osx-arm64", - "sha256": "FE98BDEB3D606016592C41ED4765D089C30F09DAF24CF1DFAC9F5392FFC57980" + "sha256": "FD8EE5E60432E2885B4DE0E650D92829EE5EA4D20C50E7CB7D3E7B2FCDCDCB9B" } ] } From aaf948b3646d86b122b26ff298d41f6cc04371d2 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Mon, 29 Jan 2024 15:02:45 -0500 Subject: [PATCH 6/8] - reverts changes to initial collapsed state Signed-off-by: Vincent Biret --- .../microsoft-kiota/src/openApiTreeProvider.ts | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/vscode/microsoft-kiota/src/openApiTreeProvider.ts b/vscode/microsoft-kiota/src/openApiTreeProvider.ts index 7f0ee90261..6973d04308 100644 --- a/vscode/microsoft-kiota/src/openApiTreeProvider.ts +++ b/vscode/microsoft-kiota/src/openApiTreeProvider.ts @@ -215,18 +215,11 @@ export class OpenApiTreeProvider implements vscode.TreeDataProvider 0; - if (!hasChildren) { - return vscode.TreeItemCollapsibleState.None; - } - if (this.tokenizedFilter.length === 0) { - return vscode.TreeItemCollapsibleState.Expanded; - } - - if (this.tokenizedFilter.some(x => node.children.some(c => c.segment.includes(x) || this.getCollapsedState(c) === vscode.TreeItemCollapsibleState.Expanded))) { - return vscode.TreeItemCollapsibleState.Expanded; - } - return vscode.TreeItemCollapsibleState.Collapsed; + return node.children.length === 0 ? + vscode.TreeItemCollapsibleState.None : + (this.tokenizedFilter.length === 0 ? + vscode.TreeItemCollapsibleState.Collapsed : + vscode.TreeItemCollapsibleState.Expanded); } getTreeNodeFromKiotaNode(node: KiotaOpenApiNode, collapsibleStateOverride: vscode.TreeItemCollapsibleState | undefined = undefined): OpenApiTreeNode { return new OpenApiTreeNode( From 2b1903524d3175633b5d67d1a78c3df59c650310 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Mon, 29 Jan 2024 15:14:32 -0500 Subject: [PATCH 7/8] - adds changelog entry for vscode filtering behavior changes Signed-off-by: Vincent Biret --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 17625b210b..b746b9b1fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Switched to proxy generation for TypeScript, leading to about ~44% bundle sizes reduction. [#3642](https://github.com/microsoft/kiota/issues/3642) - Fixed a bug where TypeScript models factory methods would be missing return types. - Fixed a bug where generated paths would possibly get too long. [#3854](https://github.com/microsoft/kiota/issues/3854) +- The vscode extension now also displays the children nodes when filtering. [#3998](https://github.com/microsoft/kiota/issues/3998) ## [1.10.1] - 2024-01-12 From 477c25422d2d952a8081570bd2a4f04b53cccbfb Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Tue, 30 Jan 2024 09:02:28 -0500 Subject: [PATCH 8/8] - fixes collapsed state not being reset between filters --- vscode/microsoft-kiota/src/openApiTreeProvider.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/vscode/microsoft-kiota/src/openApiTreeProvider.ts b/vscode/microsoft-kiota/src/openApiTreeProvider.ts index 6973d04308..881be00ba2 100644 --- a/vscode/microsoft-kiota/src/openApiTreeProvider.ts +++ b/vscode/microsoft-kiota/src/openApiTreeProvider.ts @@ -170,7 +170,7 @@ export class OpenApiTreeProvider implements vscode.TreeDataProvider x !== '').map(x => x.trim().toLowerCase()); + this.tokenizedFilter = filterText.length === 0 ? [] : filterText.split(' ').filter(x => x !== '').map(x => x.trim().toLowerCase()).sort(); this.refreshView(); } public get filter(): string { @@ -228,6 +228,7 @@ export class OpenApiTreeProvider implements vscode.TreeDataProvider this.getTreeNodeFromKiotaNode(x)), node.documentationUrl ); @@ -263,10 +264,12 @@ export class OpenApiTreeNode extends vscode.TreeItem { selected: boolean, public readonly collapsibleState: vscode.TreeItemCollapsibleState, private readonly isOperation: boolean, + filterTokens: string[], public readonly children: OpenApiTreeNode[] = [], public readonly documentationUrl?: string, ) { super(label, collapsibleState); + this.id = `${path}_${filterTokens.join('_')}`; // so the collapsed state is NOT persisted between filter changes this.contextValue = documentationUrl; this.iconPath = selected ? OpenApiTreeNode.selectedSet : OpenApiTreeNode.unselectedSet; }