Skip to content

Commit 6684502

Browse files
SteKoeandreasfritz
andauthored
fix(#2438): hide views in navigation bar (including about) (#2443)
* Fix #2438 view.isEnabled() * fix(#2438): allow to hide menu elements * remove weird "r" * add missing i18n t function * remove console.log --------- Co-authored-by: Andreas Fritz <mail@andreasfritz.de>
1 parent a05aa5d commit 6684502

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

spring-boot-admin-server-ui/src/main/frontend/components/sba-nav/sba-nav-item.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
:href="href"
55
:target="target"
66
class="sba-nav-item"
7-
r
87
rel="noopener noreferrer"
98
>
109
<slot />

spring-boot-admin-server-ui/src/main/frontend/composables/ViewRegistry.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,8 @@ export function useViewRegistry() {
4545

4646
emitCustomRouteAddedEvent();
4747
},
48+
getViewByName(name: string) {
49+
return viewRegistry.views.find((view) => view.name === name);
50+
},
4851
};
4952
}

spring-boot-admin-server-ui/src/main/frontend/shell/navbar.vue

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,11 @@
6161
@locale-changed="changeLocale"
6262
/>
6363
<sba-nav-usermenu v-if="sbaConfig.user" />
64-
<sba-nav-item :to="{ name: 'about' }">
65-
<FontAwesomeIcon icon="question-circle" />
64+
<sba-nav-item v-if="isAboutEnabled" :to="{ name: 'about' }">
65+
<FontAwesomeIcon
66+
:aria-label="t('about.label')"
67+
icon="question-circle"
68+
/>
6669
</sba-nav-item>
6770
</sba-navbar-nav>
6871
</sba-navbar>
@@ -94,8 +97,9 @@ defineProps({
9497
},
9598
});
9699
97-
const { views } = useViewRegistry();
100+
const { views, getViewByName } = useViewRegistry();
98101
const i18n = useI18n();
102+
const t = i18n.t;
99103
100104
const brand = sbaConfig.uiSettings.brand;
101105
@@ -106,7 +110,8 @@ const topLevelViews = computed(() => {
106110
!view.parent &&
107111
!view.name?.includes('instance') &&
108112
!view.name?.includes('about') &&
109-
!view.path?.includes('/instance')
113+
!view.path?.includes('/instance') &&
114+
view.isEnabled()
110115
);
111116
})
112117
.sort(compareBy((v) => v.order));
@@ -121,6 +126,7 @@ const topLevelViews = computed(() => {
121126
});
122127
});
123128
129+
const isAboutEnabled = getViewByName('about')?.isEnabled();
124130
const changeLocale = (locale) => {
125131
i18n.locale.value = locale;
126132
moment.locale(locale);

spring-boot-admin-server-ui/src/main/frontend/viewRegistry.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const createI18nTextVNode = (label: string) =>
3232
// eslint-disable-next-line no-unused-vars
3333
type ViewFilterFunction = (view: SbaView) => boolean;
3434
type ViewConfig = {
35+
isEnabled?: (obj?) => boolean;
3536
[key: string]: any;
3637
};
3738

0 commit comments

Comments
 (0)