microsoft / vscode-azuretools

Common packages for building Azure extensions for VS Code
MIT License
106 stars 66 forks source link

AzExtTreeDataProvider - Is there anyway to add pinned/favourite treeitem functionality. #1149

Open Tatsinnit opened 2 years ago

Tatsinnit commented 2 years ago

Hiya guys, This is amazing tool, and we are using this tree view in one of our project. I have a quick question regarding a small functionality I am trying to find:

for example:

Thanks heaps in advance. 🙏☕️

image

nturinski commented 2 years ago

Hi @Tatsinnit! Thanks for using our azuretools package! Currently, we don't have a way to pin/favorite a tree item through the AzExtTreeDataProvider, but it is something that we have discussed. We are definitely interested in having this functionality for our users!

However, in the meantime, you could kind of implement this feature by defining a AzExtParentTreeItem.CompareChildrenImpl that always returns your favorite/pinned resource to be on top.

Tatsinnit commented 2 years ago

Hi @Tatsinnit! Thanks for using our azuretools package! Currently, we don't have a way to pin/favorite a tree item through the AzExtTreeDataProvider, but it is something that we have discussed. We are definitely interested in having this functionality for our users!

However, in the meantime, you could kind of implement this feature by defining a AzExtParentTreeItem.CompareChildrenImpl that always returns your favorite/pinned resource to be on top.

Hiya @nturinski , Thank you @nturinski yeah it will be awesome to have that feature enabled.

Thanks for the share but do you have any sample implementation for AzExtParentTreeItem.CompareChildrenImpl using pin/fav items using compareChildrenImpl within the tree data context. I guess in order to do that I need to maintain a cached list and then implement override of compareChildrenImpl so that it return the tree items as desired. (Just thinking outlaud but in case you have any sample it will help) ❤️🥷☕️🙏

nturinski commented 2 years ago

It's actually something that you would implement on the AzExtParentTreeItem with maybe a boolean flag on the children AzExtTreeItem.

This isn't an exact 1:1 comparison, but this implements something similar: https://github.com/microsoft/vscode-azureresourcegroups/blob/main/src/tree/GroupTreeItemBase.ts#L94-L113

Basically, if the tree item has the isHidden flag, it gets automatically listed to the bottom of the group.