feat(quick-261022-imo): settings section panel scoped to the current category
- settingsSectionOf returns the current entry's category group (null for one-entry categories) - SettingsPanel mirrors the plugin side menu, collapse included - AppShell shows it on settings forms and settings-linked controllers without own navigation - docs/backend/settings.md describes moving between settings pages
This commit is contained in:
@@ -64,6 +64,39 @@ export const settingsGroups = computed(() => {
|
||||
return groups
|
||||
})
|
||||
|
||||
export function useSettings() {
|
||||
return { settings, hasSettings, settingsGroups, loadSettings, settingsEntry, settingsPath, settingsLinkFor }
|
||||
/** The settings pages of one category, with the page on screen. */
|
||||
export interface SettingsSection {
|
||||
category: string
|
||||
current: SettingsEntry
|
||||
entries: SettingsEntry[]
|
||||
}
|
||||
|
||||
/**
|
||||
* The category group of the given entry for the shell's settings panel, in
|
||||
* settingsGroups order and without entries of any other category. Null when
|
||||
* there is no current entry or its category holds a single page: there is
|
||||
* nothing to switch to.
|
||||
*/
|
||||
export function settingsSectionOf(current: SettingsEntry | null): SettingsSection | null {
|
||||
if (!current) {
|
||||
return null
|
||||
}
|
||||
const group = settingsGroups.value.find((item) => item.category === current.category)
|
||||
if (!group || group.entries.length < 2) {
|
||||
return null
|
||||
}
|
||||
return { category: group.category, current, entries: group.entries }
|
||||
}
|
||||
|
||||
export function useSettings() {
|
||||
return {
|
||||
settings,
|
||||
hasSettings,
|
||||
settingsGroups,
|
||||
loadSettings,
|
||||
settingsEntry,
|
||||
settingsPath,
|
||||
settingsLinkFor,
|
||||
settingsSectionOf,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user