-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: added snapshot_list and single view UI #249
base: main
Are you sure you want to change the base?
Conversation
sauraww
commented
Sep 26, 2024
- Added Snapshot UI List Page
- Added Single Snapshot Page
crates/frontend/src/app.rs
Outdated
|
||
<Route | ||
ssr=SsrMode::Async | ||
path="/admin/:tenant/snapshots" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we keep snapshots in the url or config-versions as we are using config-versions for the endpoint and the table as as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think in UI it would become confusing if endpoints are config-versions and page shows snapshot.
crates/frontend/src/app.rs
Outdated
/> | ||
<Route | ||
ssr=SsrMode::Async | ||
path="/admin/:tenant/snapshots/:version" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
|
||
view! { | ||
<Suspense fallback=move || view! { <p>"Loading..."</p> }.into_view()> | ||
{move || { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have some kind of heading here, taking inspiration from the experiment page maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah , I will add it.
@@ -314,3 +314,19 @@ pub struct FetchTypeTemplateResponse { | |||
pub total_pages: i64, | |||
pub data: Vec<TypeTemplate>, | |||
} | |||
|
|||
#[derive(Debug, Clone, Deserialize, Serialize)] | |||
pub struct SnapshotResponse { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may have to change it similar to what i have done for the endpoint response type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use PaginatedResponse from superposition_types
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't have superposition_types in frontend , Let's move all the common types in a seperate PR.
What do you suggest?
3e1cb92
to
7bf8df3
Compare
crates/frontend/src/api.rs
Outdated
@@ -51,6 +52,24 @@ pub async fn fetch_default_config( | |||
Ok(response) | |||
} | |||
|
|||
pub async fn get_snapshots(tenant: String) -> Result<SnapshotResponse, ServerFnError> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pub async fn get_snapshots(tenant: String) -> Result<SnapshotResponse, ServerFnError> { | |
pub async fn fetch_snapshots(tenant: String) -> Result<SnapshotResponse, ServerFnError> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better to follow the same naming pattern across all functions
crates/frontend/src/api.rs
Outdated
@@ -248,3 +267,24 @@ pub async fn fetch_types( | |||
.await | |||
.map_err(err_handler) | |||
} | |||
|
|||
pub async fn get_config_by_version( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An already existing function fetch_config
can be re-purposed to fetch config by version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file can be named snapshot.rs
use leptos_router::use_params_map; | ||
|
||
#[component] | ||
pub fn SnapshotConfig() -> impl IntoView { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pub fn SnapshotConfig() -> impl IntoView { | |
pub fn snapshot() -> impl IntoView { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please run leptosfmt, indetation is off in view macro
); | ||
|
||
view! { | ||
<Suspense fallback=move || view! { <p>"Loading..."</p> }.into_view()> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the loading skeleton for fallback in Suspense
use crate::api::get_snapshots; | ||
|
||
#[derive(Serialize, Deserialize, Clone, Debug)] | ||
struct CombinedResource { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need of CombinedResource
here, we just have one resource to load i.e. snapshots
.
}); | ||
|
||
let table_columns = | ||
create_memo(move |_| snapshot_table_columns(tenant_rs.get_untracked())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create_memo(move |_| snapshot_table_columns(tenant_rs.get_untracked())); | |
create_memo(move |_| snapshot_table_columns(tenant_rs.get())); |
this has to be reactive to any changes made to tenant.
let combined_resource: Resource<String, CombinedResource> = create_blocking_resource( | ||
move || tenant_rs.get(), | ||
|current_tenant| async move { | ||
match get_snapshots(current_tenant.to_string()).await { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a paginated API and still fetching all the snapshots at once. You can refer to experiment_list.rs
to check how it can be done.
let href = format!("/admin/{}/snapshots/{}", tenant, id); | ||
view! { | ||
<div> | ||
<A href=href class="btn-link"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The hyperlink can be added directly to the id
value, that should be enough.
6594ee1
to
25eb4c6
Compare
8759b15
to
07b5d8f
Compare
Target the main branch pleasse |
f9d45c0
to
1a03a27
Compare
07b5d8f
to
094fd01
Compare
f81d64d
to
46c1b9c
Compare
crates/frontend/src/api.rs
Outdated
let client = reqwest::Client::new(); | ||
let host = use_host_server(); | ||
|
||
let url = format!("{host}/config-versions"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let url = format!("{host}/config-versions"); | |
let url = format!("{host}/config/versions"); |
@@ -314,3 +314,19 @@ pub struct FetchTypeTemplateResponse { | |||
pub total_pages: i64, | |||
pub data: Vec<TypeTemplate>, | |||
} | |||
|
|||
#[derive(Debug, Clone, Deserialize, Serialize)] | |||
pub struct SnapshotResponse { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use PaginatedResponse from superposition_types
ffa2b37
to
3281556
Compare
3281556
to
280d673
Compare