mirror of
https://github.com/langgenius/dify.git
synced 2026-09-08 11:04:27 +08:00
fix(skills): hide main navigation on detail pages
This commit is contained in:
parent
f3853f48df
commit
779f57902e
@ -196,6 +196,31 @@ describe('MainNavLayout', () => {
|
||||
expect(screen.getByRole('main')).toHaveTextContent('new knowledge detail')
|
||||
})
|
||||
|
||||
it('hides the global main nav on a skill detail route', () => {
|
||||
;(usePathname as Mock).mockReturnValue('/skills/skill-1')
|
||||
|
||||
render(
|
||||
<MainNavLayout>
|
||||
<div>skill detail</div>
|
||||
</MainNavLayout>,
|
||||
)
|
||||
|
||||
expect(screen.queryByTestId('main-nav')).not.toBeInTheDocument()
|
||||
expect(screen.getByRole('main')).toHaveTextContent('skill detail')
|
||||
})
|
||||
|
||||
it('keeps the global main nav on the skills collection route', () => {
|
||||
;(usePathname as Mock).mockReturnValue('/skills')
|
||||
|
||||
render(
|
||||
<MainNavLayout>
|
||||
<div>skills collection</div>
|
||||
</MainNavLayout>,
|
||||
)
|
||||
|
||||
expect(screen.getByTestId('main-nav')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it.each([
|
||||
'/datasets/create',
|
||||
'/datasets/new/create',
|
||||
|
||||
@ -151,14 +151,21 @@ function isDatasetDetailPathname(pathname: string) {
|
||||
return true
|
||||
}
|
||||
|
||||
function isSkillDetailPathname(pathname: string) {
|
||||
const [section, skillId] = pathname.split('/').filter(Boolean)
|
||||
|
||||
return section === 'skills' && !!skillId
|
||||
}
|
||||
|
||||
export function shouldHideMainNavigation(pathname: string) {
|
||||
const [section, namespace, knowledgeSpaceId] = pathname.split('/').filter(Boolean)
|
||||
|
||||
return (
|
||||
section === 'datasets' &&
|
||||
namespace === 'new' &&
|
||||
!!knowledgeSpaceId &&
|
||||
knowledgeSpaceId !== 'create'
|
||||
(section === 'datasets' &&
|
||||
namespace === 'new' &&
|
||||
!!knowledgeSpaceId &&
|
||||
knowledgeSpaceId !== 'create') ||
|
||||
isSkillDetailPathname(pathname)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user