mirror of
https://github.com/Nutomic/ibis.git
synced 2024-11-22 06:31:09 +00:00
Also show connect button on article page
This commit is contained in:
parent
627b0067b5
commit
a099181085
4 changed files with 53 additions and 43 deletions
25
src/frontend/components/connect.rs
Normal file
25
src/frontend/components/connect.rs
Normal file
|
@ -0,0 +1,25 @@
|
|||
use crate::frontend::app::GlobalState;
|
||||
use leptos::{component, *};
|
||||
use url::Url;
|
||||
|
||||
#[component]
|
||||
pub fn ConnectView<T: Clone + 'static, R: 'static>(res: Resource<T, R>) -> impl IntoView {
|
||||
let connect_ibis_wiki = create_action(move |_: &()| async move {
|
||||
GlobalState::api_client()
|
||||
.resolve_instance(Url::parse("https://ibis.wiki").unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
res.refetch();
|
||||
});
|
||||
|
||||
view! {
|
||||
<div class="flex justify-center h-screen">
|
||||
<button
|
||||
class="btn btn-primary place-self-center"
|
||||
on:click=move |_| connect_ibis_wiki.dispatch(())
|
||||
>
|
||||
Connect with ibis.wiki
|
||||
</button>
|
||||
</div>
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
pub mod article_nav;
|
||||
pub mod connect;
|
||||
pub mod credentials;
|
||||
pub mod editor;
|
||||
pub mod instance_follow_button;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::{
|
||||
common::ListArticlesForm,
|
||||
frontend::{app::GlobalState, article_link, article_title},
|
||||
frontend::{app::GlobalState, article_link, article_title, components::connect::ConnectView},
|
||||
};
|
||||
use html::Input;
|
||||
use leptos::*;
|
||||
|
@ -50,26 +50,31 @@ pub fn ListArticles() -> impl IntoView {
|
|||
}
|
||||
/>
|
||||
</div>
|
||||
<ul class="list-none my-4">
|
||||
{move || {
|
||||
articles
|
||||
.get()
|
||||
.map(|a| {
|
||||
a.into_iter()
|
||||
.map(|a| {
|
||||
view! {
|
||||
<li>
|
||||
<a class="link text-lg" href=article_link(&a)>
|
||||
{article_title(&a)}
|
||||
</a>
|
||||
</li>
|
||||
}
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
})
|
||||
}}
|
||||
<Show
|
||||
when=move || { articles.get().unwrap_or_default().len() > 1 || only_local.get() }
|
||||
fallback=move || view! { <ConnectView res=articles /> }
|
||||
>
|
||||
<ul class="list-none my-4">
|
||||
{move || {
|
||||
articles
|
||||
.get()
|
||||
.map(|a| {
|
||||
a.into_iter()
|
||||
.map(|a| {
|
||||
view! {
|
||||
<li>
|
||||
<a class="link text-lg" href=article_link(&a)>
|
||||
{article_title(&a)}
|
||||
</a>
|
||||
</li>
|
||||
}
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
})
|
||||
}}
|
||||
|
||||
</ul>
|
||||
</ul>
|
||||
</Show>
|
||||
</Suspense>
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use crate::frontend::app::GlobalState;
|
||||
use crate::frontend::{app::GlobalState, components::connect::ConnectView};
|
||||
use leptos::*;
|
||||
use url::Url;
|
||||
|
||||
#[component]
|
||||
pub fn ListInstances() -> impl IntoView {
|
||||
|
@ -9,32 +8,12 @@ pub fn ListInstances() -> impl IntoView {
|
|||
|_| async move { GlobalState::api_client().list_instances().await.unwrap() },
|
||||
);
|
||||
|
||||
let connect_ibis_wiki = create_action(move |_: &()| async move {
|
||||
GlobalState::api_client()
|
||||
.resolve_instance(Url::parse("https://ibis.wiki").unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
instances.refetch();
|
||||
});
|
||||
let fallback = move || {
|
||||
view! {
|
||||
<div class="flex justify-center h-screen">
|
||||
<button
|
||||
class="btn btn-primary place-self-center"
|
||||
on:click=move |_| connect_ibis_wiki.dispatch(())
|
||||
>
|
||||
Connect with ibis.wiki
|
||||
</button>
|
||||
</div>
|
||||
}
|
||||
};
|
||||
|
||||
view! {
|
||||
<h1 class="text-4xl font-bold font-serif my-4">Instances</h1>
|
||||
<Suspense fallback=|| view! { "Loading..." }>
|
||||
<Show
|
||||
when=move || { !instances.get().unwrap_or_default().is_empty() }
|
||||
fallback=fallback
|
||||
fallback=move || view! { <ConnectView res=instances /> }
|
||||
>
|
||||
<ul class="list-none my-4">
|
||||
{move || {
|
||||
|
|
Loading…
Reference in a new issue