mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 20:34:18 +01:00
Add a docked desktop tool panel with an icon rail, driven by the shared panel URL param, and keep the mobile dialogs and drawers. Extract dialog bodies into reusable content components, rename the walkthrough dialog to a sheet, and make walkthrough generation asynchronous with client polling.
28 lines
1014 B
TypeScript
28 lines
1014 B
TypeScript
import { useCallback } from 'react'
|
|
import { useLocation, useNavigate } from 'react-router-dom'
|
|
import type { MoreDrawerItem } from '@/components/navigation/moreDrawerItems'
|
|
import { getPathWithReturnTo } from '@/lib/navigation'
|
|
import { openDialogParam } from './useDialogParam'
|
|
import { useUrlParams } from './useUrlParams'
|
|
|
|
/** Opens a navigation item's route or dialog; returns false for items it does not handle. */
|
|
export function useOpenNavItem(): (item: MoreDrawerItem) => boolean {
|
|
const location = useLocation()
|
|
const navigate = useNavigate()
|
|
const { updateParams } = useUrlParams()
|
|
|
|
return useCallback((item: MoreDrawerItem) => {
|
|
if (item.to) {
|
|
navigate(item.key === 'schedules'
|
|
? getPathWithReturnTo(item.to, `${location.pathname}${location.search}`)
|
|
: item.to)
|
|
return true
|
|
}
|
|
if (item.dialog) {
|
|
openDialogParam(updateParams, item.dialog)
|
|
return true
|
|
}
|
|
return false
|
|
}, [location.pathname, location.search, navigate, updateParams])
|
|
}
|