mirror of
https://github.com/Nutomic/ibis.git
synced 2024-11-26 04:01:10 +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 article_nav;
|
||||||
|
pub mod connect;
|
||||||
pub mod credentials;
|
pub mod credentials;
|
||||||
pub mod editor;
|
pub mod editor;
|
||||||
pub mod instance_follow_button;
|
pub mod instance_follow_button;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
common::ListArticlesForm,
|
common::ListArticlesForm,
|
||||||
frontend::{app::GlobalState, article_link, article_title},
|
frontend::{app::GlobalState, article_link, article_title, components::connect::ConnectView},
|
||||||
};
|
};
|
||||||
use html::Input;
|
use html::Input;
|
||||||
use leptos::*;
|
use leptos::*;
|
||||||
|
@ -50,6 +50,10 @@ pub fn ListArticles() -> impl IntoView {
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<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">
|
<ul class="list-none my-4">
|
||||||
{move || {
|
{move || {
|
||||||
articles
|
articles
|
||||||
|
@ -70,6 +74,7 @@ pub fn ListArticles() -> impl IntoView {
|
||||||
}}
|
}}
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
|
</Show>
|
||||||
</Suspense>
|
</Suspense>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use crate::frontend::app::GlobalState;
|
use crate::frontend::{app::GlobalState, components::connect::ConnectView};
|
||||||
use leptos::*;
|
use leptos::*;
|
||||||
use url::Url;
|
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
pub fn ListInstances() -> impl IntoView {
|
pub fn ListInstances() -> impl IntoView {
|
||||||
|
@ -9,32 +8,12 @@ pub fn ListInstances() -> impl IntoView {
|
||||||
|_| async move { GlobalState::api_client().list_instances().await.unwrap() },
|
|_| 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! {
|
view! {
|
||||||
<h1 class="text-4xl font-bold font-serif my-4">Instances</h1>
|
<h1 class="text-4xl font-bold font-serif my-4">Instances</h1>
|
||||||
<Suspense fallback=|| view! { "Loading..." }>
|
<Suspense fallback=|| view! { "Loading..." }>
|
||||||
<Show
|
<Show
|
||||||
when=move || { !instances.get().unwrap_or_default().is_empty() }
|
when=move || { !instances.get().unwrap_or_default().is_empty() }
|
||||||
fallback=fallback
|
fallback=move || view! { <ConnectView res=instances /> }
|
||||||
>
|
>
|
||||||
<ul class="list-none my-4">
|
<ul class="list-none my-4">
|
||||||
{move || {
|
{move || {
|
||||||
|
|
Loading…
Reference in a new issue