Submit
Path:
~
/
/
usr
/
share
/
grafana
/
public
/
app
/
features
/
commandPalette
/
actions
/
File Content:
useActions.ts
import { useEffect, useState } from 'react'; import { useSelector } from 'app/types'; import { CommandPaletteAction } from '../types'; import { getRecentDashboardActions } from './dashboardActions'; import getStaticActions from './staticActions'; export default function useActions(searchQuery: string) { const [navTreeActions, setNavTreeActions] = useState<CommandPaletteAction[]>([]); const [recentDashboardActions, setRecentDashboardActions] = useState<CommandPaletteAction[]>([]); const navBarTree = useSelector((state) => state.navBarTree); // Load standard static actions useEffect(() => { const staticActionsResp = getStaticActions(navBarTree); setNavTreeActions(staticActionsResp); }, [navBarTree]); // Load recent dashboards - we don't want them to reload when the nav tree changes useEffect(() => { if (!searchQuery) { getRecentDashboardActions() .then((recentDashboardActions) => setRecentDashboardActions(recentDashboardActions)) .catch((err) => { console.error('Error loading recent dashboard actions', err); }); } }, [searchQuery]); return searchQuery ? navTreeActions : [...recentDashboardActions, ...navTreeActions]; }
Edit
Rename
Chmod
Delete
FILE
FOLDER
INFO
Name
Size
Permission
Action
dashboardActions.test.ts
5828 bytes
0644
dashboardActions.ts
4200 bytes
0644
extensionActions.ts
811 bytes
0644
staticActions.ts
3659 bytes
0644
useActions.ts
1219 bytes
0644
N4ST4R_ID | Naxtarrr