import { TreeItem , TreeView , window } from 'vscode' ; import { ClusterProvider } from '../kubernetes/kubernetesTypes' ; import { ClusterDataProvider } from './dataProviders/clusterDataProvider' ; import { DocumentationDataProvider } from './dataProviders/documentationDataProvider' ; import { SourceDataProvider } from './dataProviders/sourceDataProvider' ; import { WorkloadDataProvider } from './dataProviders/workloadDataProvider' ; import { ClusterContextNode } from './nodes/clusterContextNode' ; import { TreeNode } from './nodes/treeNode' ; import { Views } from './views' ; let clusterTreeViewProvider ; let sourceTreeViewProvider ; let workloadTreeViewProvider ; let documentationTreeViewProvider ; let clusterTreeView ; let sourceTreeView ; let workloadTreeView ; let documentationTreeView ; /**
 * Creates tree views for the GitOps sidebar.
 */ export function createTreeViews ( ) { clusterTreeViewProvider = new ClusterDataProvider ( ) ; sourceTreeViewProvider = new SourceDataProvider ( ) ; workloadTreeViewProvider = new WorkloadDataProvider ( ) ; documentationTreeViewProvider = new DocumentationDataProvider ( ) ; clusterTreeView = window . createTreeView ( Views . ClustersView , { treeDataProvider : clusterTreeViewProvider , showCollapseAll : true , } ) ; sourceTreeView = window . createTreeView ( Views . SourcesView , { treeDataProvider : sourceTreeViewProvider , showCollapseAll : true , } ) ; workloadTreeView = window . createTreeView ( Views . WorkloadsView , { treeDataProvider : workloadTreeViewProvider , showCollapseAll : true , } ) ; documentationTreeView = window . createTreeView ( Views . DocumentationView , { treeDataProvider : documentationTreeViewProvider , showCollapseAll : true , } ) ; } /**
 * Refreshes all GitOps tree views.
 */ export function refreshAllTreeViews ( ) { refreshClustersTreeView ( ) ; refreshSourcesTreeView ( ) ; refreshWorkloadsTreeView ( ) ; } /**
 * Reloads configured clusters tree view via kubectl.
 * When an argument is passed - only that tree item
 * and its children are updated.
 */ export function refreshClustersTreeView ( node ? ) { clusterTreeViewProvider . refresh ( node ) ; } /**
 * Reloads sources tree view for the selected cluster.
 */ export function refreshSourcesTreeView ( node ? ) { sourceTreeViewProvider . refresh ( node ) ; } /**
 * Reloads workloads tree view for the selected cluster.
 */ export function refreshWorkloadsTreeView ( node ? ) { workloadTreeViewProvider . refresh ( node ) ; } see clusterTreeViewProvider . getCurrentClusterNode function getCurrentClusterNode ( ) { return clusterTreeViewProvider . getCurrentClusterNode ( ) ; } /**
 * Return current cluster node & current cluster provider or undefined
 * if either of them is undefined.
 */ export async function getCurrentClusterInfo ( ) { const clusterNode = getCurrentClusterNode ( ) ; if ( ! clusterNode ) { return ; } const clusterProvider = await clusterNode . getClusterProvider ( ) ; if ( clusterProvider === ClusterProvider . Unknown ) { return ; } return { clusterNode , clusterProvider , } ; } param clusterNode export async function revealClusterNode ( clusterNode , { expand = false , focus = false , select = false , } = { } ) { return await clusterTreeView . reveal ( clusterNode , { expand , focus , select , } ) ; }