-
Notifications
You must be signed in to change notification settings - Fork 18
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 grouping in default_config page #9
Conversation
701d931
to
a45be66
Compare
7dcb3c0
to
3b7e262
Compare
@mahatoankitkumar can you add screenshots? |
a45be66
to
875e51c
Compare
let f_name = config_key.get(); | ||
let f_name = prefix | ||
.clone() | ||
.map_or_else(|| config_key.get(), |p| p + &config_key.get()); |
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.
What does |p| p + &config_key.get()
Supposed to do?
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.
Adds prefix to the key. Will change p
to prefix
more readibility.
|
||
create_effect(move |_| { | ||
let query_params_map = query_params.try_get(); | ||
if let Some(query_map) = query_params_map { |
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.
could we simplify this block of code and reduce the ifs?
875e51c
to
c558e53
Compare
@@ -23,6 +23,7 @@ pub fn default_config_form<NF>( | |||
#[prop(default = String::new())] config_pattern: String, | |||
#[prop(default = String::new())] config_value: String, | |||
#[prop(default = None)] function_name: Option<Value>, | |||
#[prop(default = None)] prefix: Option<String>, |
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.
#[prop(default = None)] prefix: Option<String>, | |
#[prop(default = String::new())] prefix: String, |
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.
Optional parameter makes more sense here.
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.
@mahatoankitkumar , can you make the folder and the file name default_config
also the component function name default_config
?
create_effect(move |_| { | ||
let query_params_map = query_params.try_get(); | ||
if let Some(query_map) = query_params_map { | ||
let opt_prefix = query_map.get("prefix"); |
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 opt_prefix = query_map.get("prefix"); | |
filters.set(query_map.get("prefix").cloned()); |
we can directly go with this, right?
|
||
let expand = move |_: &str, row: &Map<String, Value>| { | ||
let key_name = row["key"].clone().to_string().replace("\"", ""); | ||
let key_name_copy = key_name.clone(); |
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 key_name_copy = key_name.clone(); | |
let label = key_name.clone(); |
Since this is used as the cell value on the page.
|
||
let table_columns = create_memo(move |_| { | ||
let edit_col_formatter = move |_: &str, row: &Map<String, Value>| { | ||
logging::log!("{:?}", row); | ||
let row_key = row["key"].clone().to_string().replace("\"", ""); | ||
let key = row_key.clone(); |
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 key = row_key.clone(); | |
let is_folder = row_key.contains("."); |
@@ -116,10 +144,36 @@ pub fn DefaultConfig() -> impl IntoView { | |||
let edit_icon: HtmlElement<html::I> = | |||
view! { <i class="ri-pencil-line ri-xl text-blue-500"></i> }; | |||
|
|||
view! { <span class="cursor-pointer" on:click=edit_click_handler>{edit_icon}</span> }.into_view() | |||
if key.to_owned().contains(".") { |
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.
if key.to_owned().contains(".") { | |
if is_folder { |
} | ||
folder_click_handler(Some(key.clone())) | ||
}> | ||
{key_name_copy.clone()} |
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.
{key_name_copy.clone()} | |
{label} |
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.
.clone()
is not needed
vec!["".to_string(), key.to_string()] | ||
}; | ||
|
||
if let Some(filtered_key) = key_arr.get(1) { |
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.
@mahatoankitkumar , can you explain the approach here to generate a key name?
@@ -30,11 +32,37 @@ pub fn DefaultConfig() -> impl IntoView { | |||
); | |||
|
|||
let selected_config = create_rw_signal::<Option<RowData>>(None); | |||
let filters = create_rw_signal::<Option<String>>(None); |
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 filters = create_rw_signal::<Option<String>>(None); | |
let key_prefix = create_rw_signal::<Option<String>>(None); |
</DrawerBtn> | ||
<div class="flex justify-between pb-2"> | ||
<div class="flex justify-between pt-3">{ | ||
{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.
{move || { | |
```suggestion | |
{ | |
move || { | |
let data = bread_crums.get(); | |
let last_index = data.len() - 1; | |
data.iter() | |
.enumerate() | |
.map(|(index, item)| { | |
let value = item.value.clone(); | |
let is_link = item.is_link.clone(); | |
let is_last_item = index < last_index; | |
let item_classname = if item.is_link { | |
"cursor-pointer text-blue-500 underline underline-offset-2" | |
} else { | |
"" | |
}; | |
view! { | |
<div class="flex"> | |
<h2 | |
on:click=move |_| { | |
if is_link { | |
folder_click_handler(value.clone()) | |
} | |
} | |
class={item_classname} | |
> | |
{item.key.clone()} | |
</h2> | |
<h2 class="pl-4 pr-4"> | |
{if is_last_item { ">" } else { "" }} | |
</h2> | |
</div> | |
} | |
}) | |
.collect_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.
We can use derive signal like this, to solution this out
let bread_crums = Signal::derive(move || {
let filters = filters.get();
let mut default_bread_crums = vec![BreadCrums {
key: "Default Config".to_string(),
value: None,
is_link: true,
}];
let mut bread_crums = match filters {
Some(prefix) => {
let partials = prefix
.trim_matches('.')
.split(".")
.map(str::to_string)
.collect::<Vec<String>>();
partials
.into_iter()
.fold(String::new(), |mut prefix, partial| {
default_bread_crums.push(BreadCrums {
key: partial.clone(),
value: Some(prefix.clone()),
is_link: true,
});
prefix.push_str(&partial);
prefix.push('.');
prefix
});
default_bread_crums
}
None => default_bread_crums,
};
if let Some(last_crum) = bread_crums.last_mut() {
last_crum.is_link = false;
}
bread_crums
});
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.
sure will try this.
a20f321
to
5d1d379
Compare
@@ -0,0 +1 @@ | |||
pub mod default_config; |
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 stop doing these one line mod.rs files? We can just put all the code here
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.
Leave it as is for now
Deserialize, | ||
Serialize, | ||
diesel_derive_enum::DbEnum, | ||
QueryId, |
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.
@mahatoankitkumar you can get rid of QueryId here, I was trying to solve something and added it by mistake.
d4f392a
to
1264fbf
Compare
1264fbf
to
86cc900
Compare
is_link: true, | ||
}]; | ||
|
||
let mut bread_crums = match key_prefix { |
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 different variable name bread_crums
?
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.
bread_crums name serves the purpose.
ac68951
to
fed78c9
Compare
<div class="flex"> | ||
<label on:click=move |_| { | ||
folder_click_handler(None); | ||
enable_grouping.set(!enable_grouping.get());} |
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.
enable_grouping.set(!enable_grouping.get());} | |
enable_grouping.update(|prev| *prev = !(*prev)); |
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 isn't re-rendering the component.
fed78c9
to
691556a
Compare
Problem
Add grouping in default_config page
Solution
Added grouping in default_config page to show keys in folder structure.
Environment variable changes
N.A.
Pre-deployment activity
N.A.
Post-deployment activity
N.A.
API changes
N.A.
Possible Issues in the future
N.A.