Wire up remaining placeholder settings, implement menu search (v2.4.0)
- Custom dashboard, Modern plugins page, and Modern comments page toggles previously had no effect at all — their respective takeovers/ redirects (DashboardTakeover, SubApps' Plugins/Comments handling, MenuSerializer's link rewrites) ran unconditionally regardless of the setting. All three now default to their previous always-on behavior but can actually be turned off. - Menu search had zero implementation. Sidebar.vue now shows a real search box (gated on the setting) that filters both the WP-native menu and the Aurora nav section by title, auto-expanding matching sections. - Removed "Modern posts table" and "Modern users page" toggles (and their now-empty Posts/Users settings categories) — both described a custom management page that was never built. A checkbox with nothing behind it is worse than no checkbox. Verified all four live: dashboard/plugins/comments toggles correctly flip between the Aurora and native experience and back; menu search filters correctly and clears back to the full menu. Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
1578481106
commit
fb93888d3f
@@ -86,13 +86,13 @@ const openId = ref(
|
||||
: null)
|
||||
);
|
||||
|
||||
const isExpanded = (item) => openId.value === item.id;
|
||||
const isExpanded = (item) => isSearching.value || openId.value === item.id;
|
||||
|
||||
const toggle = (item) => {
|
||||
openId.value = openId.value === item.id ? null : item.id;
|
||||
};
|
||||
|
||||
const auroraExpanded = computed(() => openId.value === AURORA_ID);
|
||||
const auroraExpanded = computed(() => isSearching.value || openId.value === AURORA_ID);
|
||||
const toggleAuroraNav = () => {
|
||||
openId.value = auroraExpanded.value ? null : AURORA_ID;
|
||||
// Only Aurora's own expand state needs to persist across page loads —
|
||||
@@ -101,6 +101,34 @@ const toggleAuroraNav = () => {
|
||||
localStorage.setItem('aurora-nav-expanded', auroraExpanded.value ? '1' : '0');
|
||||
};
|
||||
const isAuroraActive = (item) => normalize(item.url) === current.value;
|
||||
|
||||
// Settings > Menu > "Show a search box at the top of the admin menu" —
|
||||
// filters both the WP-native menu list and the Aurora nav section by
|
||||
// title (own item or any submenu item), auto-expanding every section with
|
||||
// a match so results are visible without also having to click into them.
|
||||
const showMenuSearch = computed(() => !!props.serverData?.settings?.menu_search);
|
||||
const searchQuery = ref('');
|
||||
const isSearching = computed(() => searchQuery.value.trim() !== '');
|
||||
const matchesQuery = (text) =>
|
||||
(text || '').toLowerCase().includes(searchQuery.value.trim().toLowerCase());
|
||||
|
||||
const filteredMenu = computed(() => {
|
||||
if (!isSearching.value) return props.menu;
|
||||
return props.menu
|
||||
.filter((item) => !item.separator)
|
||||
.map((item) => {
|
||||
const titleMatch = matchesQuery(item.title);
|
||||
const matchingSubs = (item.submenu || []).filter((sub) => matchesQuery(sub.title));
|
||||
if (!titleMatch && !matchingSubs.length) return null;
|
||||
return titleMatch ? item : { ...item, submenu: matchingSubs };
|
||||
})
|
||||
.filter(Boolean);
|
||||
});
|
||||
|
||||
const filteredAuroraNav = computed(() => {
|
||||
if (!isSearching.value) return props.auroraNav;
|
||||
return props.auroraNav.filter((item) => matchesQuery(item.title));
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -111,8 +139,13 @@ const isAuroraActive = (item) => normalize(item.url) === current.value;
|
||||
<template v-else>{{ collapsed ? 'A' : 'Aurora' }}</template>
|
||||
</div>
|
||||
|
||||
<div v-if="showMenuSearch && !collapsed" class="sidebar__menu-search">
|
||||
<span class="dashicons dashicons-search" />
|
||||
<input v-model="searchQuery" type="text" placeholder="Search menu…" />
|
||||
</div>
|
||||
|
||||
<ul class="sidebar__list">
|
||||
<template v-for="(item, index) in menu" :key="item.id || index">
|
||||
<template v-for="(item, index) in filteredMenu" :key="item.id || index">
|
||||
<li v-if="item.separator" class="sidebar__separator" />
|
||||
|
||||
<li v-else class="sidebar__item">
|
||||
@@ -139,7 +172,7 @@ const isAuroraActive = (item) => normalize(item.url) === current.value;
|
||||
<span v-if="item.count" class="sidebar__count">{{ item.count }}</span>
|
||||
</a>
|
||||
<button
|
||||
v-if="item.submenu && item.submenu.length"
|
||||
v-if="item.submenu && item.submenu.length && !isSearching"
|
||||
type="button"
|
||||
class="sidebar__chevron"
|
||||
:class="{ 'sidebar__chevron--open': isExpanded(item) }"
|
||||
@@ -173,9 +206,13 @@ const isAuroraActive = (item) => normalize(item.url) === current.value;
|
||||
</template>
|
||||
</ul>
|
||||
|
||||
<div v-if="auroraNav.length" class="sidebar__separator" />
|
||||
<p v-if="isSearching && !filteredMenu.length && !filteredAuroraNav.length" class="sidebar__no-results">
|
||||
No matching menu items.
|
||||
</p>
|
||||
|
||||
<div v-if="auroraNav.length" class="sidebar__aurora">
|
||||
<div v-if="filteredAuroraNav.length" class="sidebar__separator" />
|
||||
|
||||
<div v-if="filteredAuroraNav.length" class="sidebar__aurora">
|
||||
<div class="sidebar__row sidebar__aurora-brand" @click="toggleAuroraNav">
|
||||
<a href="#" class="sidebar__link" @click.prevent :title="collapsed ? 'Aurora' : null">
|
||||
<span class="sidebar__icon">
|
||||
@@ -184,6 +221,7 @@ const isAuroraActive = (item) => normalize(item.url) === current.value;
|
||||
<span class="sidebar__title">Aurora</span>
|
||||
</a>
|
||||
<button
|
||||
v-if="!isSearching"
|
||||
type="button"
|
||||
class="sidebar__chevron"
|
||||
:class="{ 'sidebar__chevron--open': auroraExpanded }"
|
||||
@@ -194,7 +232,7 @@ const isAuroraActive = (item) => normalize(item.url) === current.value;
|
||||
</div>
|
||||
|
||||
<ul v-if="auroraExpanded" class="sidebar__sublist">
|
||||
<li v-for="item in auroraNav" :key="item.id" class="sidebar__subitem">
|
||||
<li v-for="item in filteredAuroraNav" :key="item.id" class="sidebar__subitem">
|
||||
<a
|
||||
:href="item.url"
|
||||
class="sidebar__sublink"
|
||||
@@ -265,6 +303,41 @@ const isAuroraActive = (item) => normalize(item.url) === current.value;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
.sidebar__menu-search {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin: 0 12px 10px;
|
||||
padding: 6px 10px;
|
||||
border-radius: 8px;
|
||||
background: var(--aurora-bg-subtle);
|
||||
color: var(--aurora-text-muted);
|
||||
}
|
||||
.sidebar__menu-search .dashicons {
|
||||
font-size: 15px;
|
||||
width: 15px;
|
||||
height: 15px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.sidebar__menu-search input {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
border: none;
|
||||
background: none;
|
||||
outline: none;
|
||||
color: var(--aurora-text);
|
||||
font-size: 0.8125rem;
|
||||
}
|
||||
.sidebar__menu-search input::placeholder {
|
||||
color: var(--aurora-text-muted);
|
||||
}
|
||||
|
||||
.sidebar__no-results {
|
||||
margin: 4px 16px;
|
||||
font-size: 0.8125rem;
|
||||
color: var(--aurora-text-muted);
|
||||
}
|
||||
|
||||
.sidebar__list,
|
||||
.sidebar__sublist {
|
||||
list-style: none;
|
||||
|
||||
Reference in New Issue
Block a user