Skip to content

Commit

Permalink
fix(#2438): hide views in navigation bar (including about) (#2443)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
SteKoe and andreasfritz committed May 12, 2023
1 parent a05aa5d commit 6684502
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
:href="href"
:target="target"
class="sba-nav-item"
r
rel="noopener noreferrer"
>
<slot />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,8 @@ export function useViewRegistry() {

emitCustomRouteAddedEvent();
},
getViewByName(name: string) {
return viewRegistry.views.find((view) => view.name === name);
},
};
}
14 changes: 10 additions & 4 deletions spring-boot-admin-server-ui/src/main/frontend/shell/navbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,11 @@
@locale-changed="changeLocale"
/>
<sba-nav-usermenu v-if="sbaConfig.user" />
<sba-nav-item :to="{ name: 'about' }">
<FontAwesomeIcon icon="question-circle" />
<sba-nav-item v-if="isAboutEnabled" :to="{ name: 'about' }">
<FontAwesomeIcon
:aria-label="t('about.label')"
icon="question-circle"
/>
</sba-nav-item>
</sba-navbar-nav>
</sba-navbar>
Expand Down Expand Up @@ -94,8 +97,9 @@ defineProps({
},
});
const { views } = useViewRegistry();
const { views, getViewByName } = useViewRegistry();
const i18n = useI18n();
const t = i18n.t;
const brand = sbaConfig.uiSettings.brand;
Expand All @@ -106,7 +110,8 @@ const topLevelViews = computed(() => {
!view.parent &&
!view.name?.includes('instance') &&
!view.name?.includes('about') &&
!view.path?.includes('/instance')
!view.path?.includes('/instance') &&
view.isEnabled()
);
})
.sort(compareBy((v) => v.order));
Expand All @@ -121,6 +126,7 @@ const topLevelViews = computed(() => {
});
});
const isAboutEnabled = getViewByName('about')?.isEnabled();
const changeLocale = (locale) => {
i18n.locale.value = locale;
moment.locale(locale);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const createI18nTextVNode = (label: string) =>
// eslint-disable-next-line no-unused-vars
type ViewFilterFunction = (view: SbaView) => boolean;
type ViewConfig = {
isEnabled?: (obj?) => boolean;
[key: string]: any;
};

Expand Down

0 comments on commit 6684502

Please sign in to comment.