feat(admin): open controller-link settings entries from the settings index
A settings entry with a controller opens that controller's route from its card (settingsPath); singleton cards still open /settings/<code>. On a linked controller with no navigation entry of its own the rail marks Settings current, the breadcrumbs read Settings > entry label (plus the record title on record and create routes) and the page title uses the entry label. The settings docs describe the admin behaviour; the embedded admin shell is rebuilt.
This commit is contained in:
@@ -6,6 +6,8 @@ import {
|
||||
settings,
|
||||
settingsEntry,
|
||||
settingsGroups,
|
||||
settingsLinkFor,
|
||||
settingsPath,
|
||||
useSettings,
|
||||
} from '../../src/state/useSettings'
|
||||
import { settingsFixture } from '../fixtures/typed'
|
||||
@@ -44,4 +46,22 @@ describe('useSettings (D-21)', () => {
|
||||
['System', ['mail', 'search']],
|
||||
])
|
||||
})
|
||||
|
||||
it('links a singleton to its form and a controller link to the controller route', () => {
|
||||
const singleton = settingsFixture.list.data[0]!
|
||||
expect(settingsPath({ ...singleton, code: 'a b' })).toBe('/settings/a%20b')
|
||||
expect(settingsPath({ ...singleton, code: 'locales', model: '', controller: 'acme.demo.locales' })).toBe('/acme/demo/locales')
|
||||
expect(settingsPath({ ...singleton, code: 'broken', model: '', controller: 'acme.demo' })).toBe('/settings')
|
||||
expect(useSettings().settingsPath).toBe(settingsPath)
|
||||
})
|
||||
|
||||
it('finds the link entry that opens a controller, never a singleton', () => {
|
||||
const link = { ...settingsFixture.list.data[0]!, code: 'locales', model: '', controller: 'acme.demo.locales' }
|
||||
setSettings([...settingsFixture.list.data, link])
|
||||
expect(settingsLinkFor('acme.demo.locales')?.code).toBe('locales')
|
||||
expect(settingsLinkFor('acme.demo.widgets')).toBeNull()
|
||||
expect(settingsLinkFor('')).toBeNull()
|
||||
expect(settingsLinkFor(null)).toBeNull()
|
||||
expect(useSettings().settingsLinkFor).toBe(settingsLinkFor)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user