mirror of
https://github.com/Nutomic/ibis.git
synced 2024-11-22 08:41:08 +00:00
hide signup button if registrations closed
This commit is contained in:
parent
daa5412271
commit
e908d3da33
4 changed files with 22 additions and 8 deletions
|
@ -15,7 +15,7 @@ use axum_macros::debug_handler;
|
|||
pub(in crate::backend::api) async fn get_local_instance(
|
||||
data: Data<IbisData>,
|
||||
) -> MyResult<Json<InstanceView>> {
|
||||
let local_instance = DbInstance::read_local_view(&data.db_connection)?;
|
||||
let local_instance = DbInstance::read_local_view(&data)?;
|
||||
Ok(Json(local_instance))
|
||||
}
|
||||
|
||||
|
|
|
@ -61,13 +61,14 @@ impl DbInstance {
|
|||
.get_result(conn.deref_mut())?)
|
||||
}
|
||||
|
||||
pub fn read_local_view(conn: &Mutex<PgConnection>) -> MyResult<InstanceView> {
|
||||
let instance = DbInstance::read_local_instance(conn)?;
|
||||
let followers = DbInstance::read_followers(instance.id, conn)?;
|
||||
pub fn read_local_view(data: &Data<IbisData>) -> MyResult<InstanceView> {
|
||||
let instance = DbInstance::read_local_instance(&data.db_connection)?;
|
||||
let followers = DbInstance::read_followers(instance.id, &data.db_connection)?;
|
||||
|
||||
Ok(InstanceView {
|
||||
instance,
|
||||
followers,
|
||||
registration_open: data.config.registration_open,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -247,6 +247,7 @@ pub struct DbInstance {
|
|||
pub struct InstanceView {
|
||||
pub instance: DbInstance,
|
||||
pub followers: Vec<DbPerson>,
|
||||
pub registration_open: bool,
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -12,8 +12,18 @@ pub fn Nav() -> impl IntoView {
|
|||
.get_untracked()
|
||||
.update_my_profile();
|
||||
});
|
||||
let registration_open = create_local_resource(
|
||||
|| (),
|
||||
move |_| async move {
|
||||
GlobalState::api_client()
|
||||
.get_local_instance()
|
||||
.await
|
||||
.unwrap()
|
||||
.registration_open
|
||||
},
|
||||
);
|
||||
|
||||
let (search_query, set_search_query) = create_signal(String::new());
|
||||
// TODO: hide register button if disabled in config
|
||||
view! {
|
||||
<nav class="inner">
|
||||
<li>
|
||||
|
@ -62,9 +72,11 @@ pub fn Nav() -> impl IntoView {
|
|||
<li>
|
||||
<A href="/login">"Login"</A>
|
||||
</li>
|
||||
<li>
|
||||
<A href="/register">"Register"</A>
|
||||
</li>
|
||||
<Show when=move || registration_open.get().unwrap_or_default()>
|
||||
<li>
|
||||
<A href="/register">"Register"</A>
|
||||
</li>
|
||||
</Show>
|
||||
</Show>
|
||||
</nav>
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue