Skip to content

Commit

Permalink
remove component_name arg from get_component_by_id
Browse files Browse the repository at this point in the history
  • Loading branch information
harshdoesdev authored and amitu committed Mar 8, 2024
1 parent fdf29a6 commit bf7b519
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
8 changes: 2 additions & 6 deletions ftd/src/interpreter/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1096,14 +1096,10 @@ impl Document {
.collect_vec()
}

pub fn get_component_by_id(
&self,
component_name: &str,
component_id: &str,
) -> Option<&ftd::interpreter::Component> {
pub fn get_component_by_id(&self, component_id: &str) -> Option<&ftd::interpreter::Component> {
self.tree.iter().find(|v| {
if let Some(id) = &v.id {
return v.name.eq(component_name) && id.eq(component_id);
return id.eq(component_id);
}

false
Expand Down
2 changes: 1 addition & 1 deletion ftd/src/interpreter/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ fn test_extract_kwargs() {
)
.unwrap();

let component = doc.get_component_by_id("foo#fizz", "test").unwrap();
let component = doc.get_component_by_id("test").unwrap();
let data = component.get_kwargs(&doc, "data").unwrap();

assert_eq!(data.get("bar"), Some(&String::from("Hello")));
Expand Down

0 comments on commit bf7b519

Please sign in to comment.