app: Set a key for user/group creation buttons

That prevents them from jumping around when changing pages.
This commit is contained in:
Webysther Sperandio
2025-10-05 06:06:45 +02:00
committed by nitnelave
parent 3f9880ec11
commit 9a83e68667
+18 -16
View File
@@ -197,17 +197,19 @@ impl App {
<CreateUserForm/> <CreateUserForm/>
}, },
AppRoute::Index | AppRoute::ListUsers => { AppRoute::Index | AppRoute::ListUsers => {
let user_button = html! { let user_button = |key| {
<Link classes="btn btn-primary" to={AppRoute::CreateUser}> html! {
<i class="bi-person-plus me-2"></i> <Link classes="btn btn-primary" key={key} to={AppRoute::CreateUser}>
{"Create a user"} <i class="bi-person-plus me-2"></i>
</Link> {"Create a user"}
</Link>
}
}; };
html! { html! {
<div> <div>
{ user_button.clone() } { user_button("top-create-user") }
<UserTable /> <UserTable />
{ user_button } { user_button("bottom-create-user") }
</div> </div>
} }
} }
@@ -221,19 +223,19 @@ impl App {
<CreateGroupAttributeForm/> <CreateGroupAttributeForm/>
}, },
AppRoute::ListGroups => { AppRoute::ListGroups => {
let group_button = html! { let group_button = |key| {
<Link classes="btn btn-primary" to={AppRoute::CreateGroup}> html! {
<i class="bi-plus-circle me-2"></i> <Link classes="btn btn-primary" key={key} to={AppRoute::CreateGroup}>
{"Create a group"} <i class="bi-plus-circle me-2"></i>
</Link> {"Create a group"}
</Link>
}
}; };
// Note: There's a weird bug when switching from the users page to the groups page
// where the two groups buttons are at the bottom. I don't know why.
html! { html! {
<div> <div>
{ group_button.clone() } { group_button("top-create-group") }
<GroupTable /> <GroupTable />
{ group_button } { group_button("bottom-create-group") }
</div> </div>
} }
} }