/usr/share/grafana/public/app/features/scopes/selector
import { useEffect, useState } from 'react'; import { ScopeNode } from '@grafana/data'; import { useScopesServices } from '../ScopesContextProvider'; // Light wrapper around the scopesSelectorService.getScopeNode to make it easier to use in the UI. export function useScopeNode(scopeNodeId?: string) { const [node, setNode] = useState<ScopeNode | undefined>(undefined); const [isLoading, setIsLoading] = useState(false); const scopesSelectorService = useScopesServices()?.scopesSelectorService; useEffect(() => { const loadNode = async () => { if (!scopeNodeId || !scopesSelectorService) { setNode(undefined); return; } setIsLoading(true); try { const node = await scopesSelectorService.getScopeNode(scopeNodeId); setNode(node); } catch (error) { console.error('Failed to load node', error); } finally { setIsLoading(false); } }; loadNode(); }, [scopeNodeId, scopesSelectorService]); return { node, isLoading }; }
.
Edit
..
Edit
RecentScopes.tsx
Edit
ScopesInput.tsx
Edit
ScopesSelector.tsx
Edit
ScopesSelectorService.test.ts
Edit
ScopesSelectorService.ts
Edit
ScopesTree.tsx
Edit
ScopesTreeHeadline.tsx
Edit
ScopesTreeItem.tsx
Edit
ScopesTreeItemList.tsx
Edit
ScopesTreeSearch.tsx
Edit
scopesTreeUtils.test.ts
Edit
scopesTreeUtils.ts
Edit
types.ts
Edit
useKeyboardInteractions.test.tsx
Edit
useKeyboardInteractions.tsx
Edit
useScopeNode.ts
Edit
useScopesHighlighting.tsx
Edit