From bf7b519afaa802a1a20ee6f3bf370c85ebebc085 Mon Sep 17 00:00:00 2001 From: Harsh Singh Date: Wed, 6 Mar 2024 15:50:55 +0530 Subject: [PATCH] remove component_name arg from get_component_by_id --- ftd/src/interpreter/main.rs | 8 ++------ ftd/src/interpreter/test.rs | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/ftd/src/interpreter/main.rs b/ftd/src/interpreter/main.rs index c1610ddb5d..179c7aef18 100644 --- a/ftd/src/interpreter/main.rs +++ b/ftd/src/interpreter/main.rs @@ -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 diff --git a/ftd/src/interpreter/test.rs b/ftd/src/interpreter/test.rs index 177898704f..789c2ec39b 100644 --- a/ftd/src/interpreter/test.rs +++ b/ftd/src/interpreter/test.rs @@ -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")));