Skip to content

Commit 551d8bb

Browse files
committed
chore: fix user menu
1 parent a6fb631 commit 551d8bb

File tree

4 files changed

+74
-84
lines changed

4 files changed

+74
-84
lines changed

spring-boot-admin-samples/spring-boot-admin-sample-custom-ui/src/index.js

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -15,76 +15,77 @@
1515
*/
1616

1717
/* global SBA */
18-
import custom from './custom.vue';
19-
import customSubitem from './custom-subitem.vue';
20-
import customEndpoint from './custom-endpoint.vue';
18+
import customEndpoint from "./custom-endpoint.vue";
19+
import customSubitem from "./custom-subitem.vue";
20+
import custom from "./custom.vue";
2121

2222
// tag::customization-ui-toplevel[]
2323
SBA.use({
24-
install({viewRegistry}) {
24+
install({ viewRegistry }) {
2525
viewRegistry.addView({
26-
name: 'custom', //<1>
27-
path: '/custom', //<2>
26+
name: "custom", //<1>
27+
path: "/custom", //<2>
2828
component: custom, //<3>
29-
label: 'Custom', //<4>
29+
label: "Custom", //<4>
3030
order: 1000, //<5>
3131
});
32-
}
32+
},
3333
});
3434
// end::customization-ui-toplevel[]
3535

3636
// tag::customization-ui-child[]
3737
SBA.use({
38-
install({viewRegistry}) {
38+
install({ viewRegistry }) {
3939
viewRegistry.addView({
40-
name: 'customSub',
41-
parent: 'custom', // <1>
42-
path: '/customSub', // <2>
40+
name: "customSub",
41+
parent: "custom", // <1>
42+
path: "/customSub", // <2>
4343
isChildRoute: false, // <3>
4444
component: customSubitem,
45-
label: 'Custom Sub',
45+
label: "Custom Sub",
4646
order: 1000,
4747
});
48-
}
48+
},
4949
});
5050
// end::customization-ui-child[]
5151

5252
SBA.use({
53-
install({viewRegistry}) {
53+
install({ viewRegistry }) {
5454
viewRegistry.addView({
55-
name: 'customSubUser',
56-
parent: 'user', // <1>
57-
path: '/customSub', // <2>
55+
name: "customSubUser",
56+
parent: "user", // <1>
57+
path: "/customSub", // <2>
5858
isChildRoute: false, // <3>
5959
component: customSubitem,
60-
label: 'Custom Sub',
60+
label: "Custom Sub In Usermenu",
6161
order: 1000,
6262
});
63-
}
63+
},
6464
});
6565

6666
// tag::customization-ui-endpoint[]
6767
SBA.use({
68-
install({viewRegistry}) {
68+
install({ viewRegistry }) {
6969
viewRegistry.addView({
70-
name: 'instances/custom',
71-
parent: 'instances', // <1>
72-
path: 'custom',
70+
name: "instances/custom",
71+
parent: "instances", // <1>
72+
path: "custom",
7373
component: customEndpoint,
74-
label: 'Custom',
75-
group: 'custom', // <2>
74+
label: "Custom",
75+
group: "custom", // <2>
7676
order: 1000,
77-
isEnabled: ({instance}) => instance.hasEndpoint('custom') // <3>
77+
isEnabled: ({ instance }) => instance.hasEndpoint("custom"), // <3>
7878
});
7979
},
80-
configure({i18n}) {
81-
i18n.mergeLocaleMessage('en', { // <4>
80+
configure({ i18n }) {
81+
i18n.mergeLocaleMessage("en", {
82+
// <4>
8283
sidebar: {
83-
custom : {
84-
title : "My Custom Extensions"
85-
}
86-
}
84+
custom: {
85+
title: "My Custom Extensions",
86+
},
87+
},
8788
});
88-
}
89+
},
8990
});
9091
// end::customization-ui-endpoint[]
Lines changed: 32 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,36 @@
11
<template>
2-
<NavbarMenu :menu-items="['']">
3-
<template #default>
4-
<div class="px-0.5 py-0.5">
5-
<span class="sr-only"> Open user menu</span>
6-
<font-awesome-icon
7-
color="white"
8-
class="rounded-full"
9-
icon="user-circle"
10-
size="2x"
2+
<div class="link-wrapper">
3+
<div class="link" v-text="userName"></div>
4+
<NavbarMenu>
5+
<template #menuItems>
6+
<div v-if="userName" class="link link--no-hover">
7+
<span>
8+
{{ $t('navbar.signedInAs') }} <strong v-text="userName" />
9+
</span>
10+
</div>
11+
<hr class="pb-1" />
12+
<NavbarLink
13+
v-for="userSubMenuItem in submenuItems"
14+
:key="userSubMenuItem.name"
15+
:view="userSubMenuItem"
1116
/>
12-
</div>
13-
</template>
1417

15-
<template #menuItems>
16-
<div v-if="userName" class="link link--no-hover">
17-
<span>
18-
{{ $t('navbar.signedInAs') }} <strong v-text="userName" />
19-
</span>
20-
</div>
21-
22-
<NavbarLink
23-
v-for="userSubMenuItem in submenuItems"
24-
:key="userSubMenuItem.name"
25-
:view="userSubMenuItem"
26-
/>
27-
28-
<form action="logout" method="post">
29-
<input
30-
v-if="csrfToken"
31-
type="hidden"
32-
:name="csrfParameterName"
33-
:value="csrfToken"
34-
/>
35-
<button type="submit" value="logout" class="link">
36-
<font-awesome-icon icon="sign-out-alt" />&nbsp;<span
37-
v-text="$t('navbar.logout')"
18+
<form action="logout" method="post">
19+
<input
20+
v-if="csrfToken"
21+
type="hidden"
22+
:name="csrfParameterName"
23+
:value="csrfToken"
3824
/>
39-
</button>
40-
</form>
41-
</template>
42-
</NavbarMenu>
25+
<button type="submit" value="logout" class="link">
26+
<font-awesome-icon icon="sign-out-alt" />&nbsp;<span
27+
v-text="$t('navbar.logout')"
28+
/>
29+
</button>
30+
</form>
31+
</template>
32+
</NavbarMenu>
33+
</div>
4334
</template>
4435

4536
<script>
@@ -48,7 +39,7 @@ import NavbarMenu from '@/shell/NavbarMenu';
4839
4940
export default {
5041
name: 'NavbarUserMenu',
51-
components: { NavbarMenu, NavbarLink },
42+
components: { NavbarLink, NavbarMenu },
5243
props: {
5344
csrfParameterName: {
5445
type: String,
@@ -72,10 +63,10 @@ export default {
7263

7364
<style scoped>
7465
.link {
75-
@apply flex w-full items-center rounded-md px-3 py-2 text-sm hover:bg-gray-100 break-all;
66+
@apply flex w-full items-center rounded-md px-3 pt-2 break-all;
7667
}
7768
7869
.link--no-hover {
79-
@apply hover:bg-white;
70+
@apply hover:text-inherit hover:bg-inherit;
8071
}
8172
</style>

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,11 @@
1515
-->
1616

1717
<template>
18-
<div class="text-white">
19-
<NavbarLink
20-
:view="{ label: selectedLanguage.label }"
21-
:subitems="languages"
22-
@menu-item-clicked="localeChanged"
23-
/>
24-
</div>
18+
<NavbarLink
19+
:view="{ label: selectedLanguage.label }"
20+
:subitems="languages"
21+
@menu-item-clicked="localeChanged"
22+
/>
2523
</template>
2624

2725
<script>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
</div>
3232

3333
<div class="hidden lg:block">
34-
<div class="ml-4 flex items-center md:ml-6 gap-4">
34+
<div class="ml-4 flex items-center md:ml-6 gap-4 text-white">
3535
<NavbarItemLanguageSelector
3636
v-if="availableLocales.length > 1"
3737
:current-locale="$i18n.locale"
@@ -40,7 +40,7 @@
4040
/>
4141

4242
<NavbarUserMenu
43-
v-show="userName"
43+
v-if="userName"
4444
:csrf-parameter-name="csrfParameterName"
4545
:csrf-token="csrfToken"
4646
:user-name="userName"

0 commit comments

Comments
 (0)