Skip to content
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: rename designer variable #411

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions core/src/ten_manager/designer_frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ interface ApiResponse<T> {
meta?: any;
}

interface DevServerVersion {
interface DesignerVersion {
version: string;
}

Expand All @@ -40,7 +40,7 @@ const App: React.FC = () => {
}
return response.json();
})
.then((payload: ApiResponse<DevServerVersion>) => {
.then((payload: ApiResponse<DesignerVersion>) => {
if (payload.status === "ok" && payload.data.version) {
setVersion(payload.data.version);
} else {
Expand Down
8 changes: 4 additions & 4 deletions core/src/ten_manager/src/cmd/cmd_designer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use crate::{
};

#[derive(Debug)]
pub struct DevServerCommand {
pub struct DesignerCommand {
pub ip_address: String,
pub port: u16,
pub base_dir: Option<String>,
Expand Down Expand Up @@ -83,8 +83,8 @@ pub fn create_sub_cmd(_args_cfg: &crate::cmd_line::ArgsCfg) -> Command {

pub fn parse_sub_cmd(
sub_cmd_args: &ArgMatches,
) -> crate::cmd::cmd_designer::DevServerCommand {
let cmd = crate::cmd::cmd_designer::DevServerCommand {
) -> crate::cmd::cmd_designer::DesignerCommand {
let cmd = crate::cmd::cmd_designer::DesignerCommand {
ip_address: sub_cmd_args
.get_one::<String>("IP_ADDRESS")
.unwrap()
Expand All @@ -101,7 +101,7 @@ pub fn parse_sub_cmd(

pub async fn execute_cmd(
tman_config: &TmanConfig,
command_data: DevServerCommand,
command_data: DesignerCommand,
) -> Result<()> {
tman_verbose_println!(tman_config, "Executing designer command");
tman_verbose_println!(tman_config, "{:?}", command_data);
Expand Down
4 changes: 2 additions & 2 deletions core/src/ten_manager/src/cmd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub enum CommandData {
Package(self::cmd_package::PackageCommand),
Publish(self::cmd_publish::PublishCommand),
Delete(self::cmd_delete::DeleteCommand),
DevServer(self::cmd_designer::DevServerCommand),
Designer(self::cmd_designer::DesignerCommand),
Check(self::cmd_check::CheckCommandData),
}

Expand All @@ -46,7 +46,7 @@ pub async fn execute_cmd(
CommandData::Delete(cmd) => {
crate::cmd::cmd_delete::execute_cmd(tman_config, cmd).await
}
CommandData::DevServer(cmd) => {
CommandData::Designer(cmd) => {
crate::cmd::cmd_designer::execute_cmd(tman_config, cmd).await
}
CommandData::Check(cmd) => {
Expand Down
2 changes: 1 addition & 1 deletion core/src/ten_manager/src/cmd_line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ pub fn parse_cmd(
Some(("delete", sub_cmd_args)) => crate::cmd::CommandData::Delete(
crate::cmd::cmd_delete::parse_sub_cmd(sub_cmd_args),
),
Some(("designer", sub_cmd_args)) => crate::cmd::CommandData::DevServer(
Some(("designer", sub_cmd_args)) => crate::cmd::CommandData::Designer(
crate::cmd::cmd_designer::parse_sub_cmd(sub_cmd_args),
),
Some(("check", sub_cmd_args)) => crate::cmd::CommandData::Check(
Expand Down
118 changes: 59 additions & 59 deletions core/src/ten_manager/src/designer/addons/extensions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,25 @@ use crate::designer::{
get_designer_property_hashmap_from_pkg,
},
get_all_pkgs::get_all_pkgs,
graphs::nodes::DevServerApi,
graphs::nodes::DesignerApi,
response::{ApiResponse, ErrorResponse, Status},
DesignerState,
};

#[derive(Serialize, Deserialize, Debug, PartialEq)]
struct DevServerExtensionAddon {
struct DesignerExtensionAddon {
#[serde(rename = "name")]
addon_name: String,

url: String,

#[serde(skip_serializing_if = "Option::is_none")]
pub api: Option<DevServerApi>,
pub api: Option<DesignerApi>,
}

fn retrieve_extension_addons(
state: &mut DesignerState,
) -> Result<Vec<DevServerExtensionAddon>, ErrorResponse> {
) -> Result<Vec<DesignerExtensionAddon>, ErrorResponse> {
if let Err(err) = get_all_pkgs(state) {
return Err(ErrorResponse::from_error(
&err,
Expand Down Expand Up @@ -66,11 +66,11 @@ fn retrieve_extension_addons(

fn map_pkg_to_extension_addon(
pkg_info_with_src: &PkgInfo,
) -> DevServerExtensionAddon {
DevServerExtensionAddon {
) -> DesignerExtensionAddon {
DesignerExtensionAddon {
addon_name: pkg_info_with_src.pkg_identity.name.clone(),
url: pkg_info_with_src.url.clone(),
api: pkg_info_with_src.api.as_ref().map(|api| DevServerApi {
api: pkg_info_with_src.api.as_ref().map(|api| DesignerApi {
property: if api.property.is_empty() {
None
} else {
Expand Down Expand Up @@ -193,8 +193,8 @@ mod tests {
config::TmanConfig,
designer::{
graphs::nodes::{
DevServerApiCmdLike, DevServerApiDataLike,
DevServerPropertyAttributes, DevServerPropertyItem,
DesignerApiCmdLike, DesignerApiDataLike,
DesignerPropertyAttributes, DesignerPropertyItem,
},
mock::tests::inject_all_pkgs_for_mock,
},
Expand Down Expand Up @@ -257,44 +257,44 @@ mod tests {
let body = test::read_body(resp).await;
let body_str = std::str::from_utf8(&body).unwrap();

let addons: ApiResponse<Vec<DevServerExtensionAddon>> =
let addons: ApiResponse<Vec<DesignerExtensionAddon>> =
serde_json::from_str(body_str).unwrap();

let expected_addons = vec![
DevServerExtensionAddon {
DesignerExtensionAddon {
addon_name: "extension_addon_1".to_string(),
url: "".to_string(),
api: Some(DevServerApi {
api: Some(DesignerApi {
property: None,
cmd_in: None,
cmd_out: Some(vec![
DevServerApiCmdLike {
DesignerApiCmdLike {
name: "test_cmd".to_string(),
property: Some(vec![DevServerPropertyItem {
property: Some(vec![DesignerPropertyItem {
name: "test_property".to_string(),
attributes: DevServerPropertyAttributes {
attributes: DesignerPropertyAttributes {
prop_type: "int8".to_string(),
},
}]),
required: None,
result: None,
},
DevServerApiCmdLike {
DesignerApiCmdLike {
name: "has_required".to_string(),
property: Some(vec![DevServerPropertyItem {
property: Some(vec![DesignerPropertyItem {
name: "foo".to_string(),
attributes: DevServerPropertyAttributes {
attributes: DesignerPropertyAttributes {
prop_type: "string".to_string(),
},
}]),
required: Some(vec!["foo".to_string()]),
result: None,
},
DevServerApiCmdLike {
DesignerApiCmdLike {
name: "has_required_mismatch".to_string(),
property: Some(vec![DevServerPropertyItem {
property: Some(vec![DesignerPropertyItem {
name: "foo".to_string(),
attributes: DevServerPropertyAttributes {
attributes: DesignerPropertyAttributes {
prop_type: "string".to_string(),
},
}]),
Expand All @@ -310,50 +310,50 @@ mod tests {
video_frame_out: None,
}),
},
DevServerExtensionAddon {
DesignerExtensionAddon {
addon_name: "extension_addon_2".to_string(),
url: "".to_string(),
api: Some(DevServerApi {
api: Some(DesignerApi {
property: None,
cmd_in: Some(vec![
DevServerApiCmdLike {
DesignerApiCmdLike {
name: "test_cmd".to_string(),
property: Some(vec![DevServerPropertyItem {
property: Some(vec![DesignerPropertyItem {
name: "test_property".to_string(),
attributes: DevServerPropertyAttributes {
attributes: DesignerPropertyAttributes {
prop_type: "int32".to_string(),
},
}]),
required: None,
result: None,
},
DevServerApiCmdLike {
DesignerApiCmdLike {
name: "another_test_cmd".to_string(),
property: Some(vec![DevServerPropertyItem {
property: Some(vec![DesignerPropertyItem {
name: "test_property".to_string(),
attributes: DevServerPropertyAttributes {
attributes: DesignerPropertyAttributes {
prop_type: "int8".to_string(),
},
}]),
required: None,
result: None,
},
DevServerApiCmdLike {
DesignerApiCmdLike {
name: "has_required".to_string(),
property: Some(vec![DevServerPropertyItem {
property: Some(vec![DesignerPropertyItem {
name: "foo".to_string(),
attributes: DevServerPropertyAttributes {
attributes: DesignerPropertyAttributes {
prop_type: "string".to_string(),
},
}]),
required: Some(vec!["foo".to_string()]),
result: None,
},
DevServerApiCmdLike {
DesignerApiCmdLike {
name: "has_required_mismatch".to_string(),
property: Some(vec![DevServerPropertyItem {
property: Some(vec![DesignerPropertyItem {
name: "foo".to_string(),
attributes: DevServerPropertyAttributes {
attributes: DesignerPropertyAttributes {
prop_type: "string".to_string(),
},
}]),
Expand All @@ -363,11 +363,11 @@ mod tests {
]),
cmd_out: None,
data_in: None,
data_out: Some(vec![DevServerApiDataLike {
data_out: Some(vec![DesignerApiDataLike {
name: "data_has_required".to_string(),
property: Some(vec![DevServerPropertyItem {
property: Some(vec![DesignerPropertyItem {
name: "foo".to_string(),
attributes: DevServerPropertyAttributes {
attributes: DesignerPropertyAttributes {
prop_type: "int8".to_string(),
},
}]),
Expand All @@ -379,28 +379,28 @@ mod tests {
video_frame_out: None,
}),
},
DevServerExtensionAddon {
DesignerExtensionAddon {
addon_name: "extension_addon_3".to_string(),
url: "".to_string(),
api: Some(DevServerApi {
api: Some(DesignerApi {
property: None,
cmd_in: Some(vec![DevServerApiCmdLike {
cmd_in: Some(vec![DesignerApiCmdLike {
name: "test_cmd".to_string(),
property: Some(vec![DevServerPropertyItem {
property: Some(vec![DesignerPropertyItem {
name: "test_property".to_string(),
attributes: DevServerPropertyAttributes {
attributes: DesignerPropertyAttributes {
prop_type: "string".to_string(),
},
}]),
required: None,
result: None,
}]),
cmd_out: None,
data_in: Some(vec![DevServerApiDataLike {
data_in: Some(vec![DesignerApiDataLike {
name: "data_has_required".to_string(),
property: Some(vec![DevServerPropertyItem {
property: Some(vec![DesignerPropertyItem {
name: "foo".to_string(),
attributes: DevServerPropertyAttributes {
attributes: DesignerPropertyAttributes {
prop_type: "int8".to_string(),
},
}]),
Expand All @@ -417,7 +417,7 @@ mod tests {

assert_eq!(addons.data, expected_addons);

let json: ApiResponse<Vec<DevServerExtensionAddon>> =
let json: ApiResponse<Vec<DesignerExtensionAddon>> =
serde_json::from_str(body_str).unwrap();
let pretty_json = serde_json::to_string_pretty(&json).unwrap();
println!("Response body: {}", pretty_json);
Expand Down Expand Up @@ -479,43 +479,43 @@ mod tests {
let body = test::read_body(resp).await;
let body_str = std::str::from_utf8(&body).unwrap();

let addon: ApiResponse<DevServerExtensionAddon> =
let addon: ApiResponse<DesignerExtensionAddon> =
serde_json::from_str(body_str).unwrap();

let expected_addon = DevServerExtensionAddon {
let expected_addon = DesignerExtensionAddon {
addon_name: "extension_addon_1".to_string(),
url: "".to_string(),
api: Some(DevServerApi {
api: Some(DesignerApi {
property: None,
cmd_in: None,
cmd_out: Some(vec![
DevServerApiCmdLike {
DesignerApiCmdLike {
name: "test_cmd".to_string(),
property: Some(vec![DevServerPropertyItem {
property: Some(vec![DesignerPropertyItem {
name: "test_property".to_string(),
attributes: DevServerPropertyAttributes {
attributes: DesignerPropertyAttributes {
prop_type: "int8".to_string(),
},
}]),
required: None,
result: None,
},
DevServerApiCmdLike {
DesignerApiCmdLike {
name: "has_required".to_string(),
property: Some(vec![DevServerPropertyItem {
property: Some(vec![DesignerPropertyItem {
name: "foo".to_string(),
attributes: DevServerPropertyAttributes {
attributes: DesignerPropertyAttributes {
prop_type: "string".to_string(),
},
}]),
required: Some(vec!["foo".to_string()]),
result: None,
},
DevServerApiCmdLike {
DesignerApiCmdLike {
name: "has_required_mismatch".to_string(),
property: Some(vec![DevServerPropertyItem {
property: Some(vec![DesignerPropertyItem {
name: "foo".to_string(),
attributes: DevServerPropertyAttributes {
attributes: DesignerPropertyAttributes {
prop_type: "string".to_string(),
},
}]),
Expand Down
8 changes: 4 additions & 4 deletions core/src/ten_manager/src/designer/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,24 @@ use ten_rust::pkg_info::api::{
};

use super::graphs::nodes::{
DevServerApiCmdLike, DevServerApiDataLike, DevServerPropertyAttributes,
DesignerApiCmdLike, DesignerApiDataLike, DesignerPropertyAttributes,
};

pub fn get_designer_property_hashmap_from_pkg(
items: HashMap<String, PkgPropertyAttributes>,
) -> HashMap<String, DevServerPropertyAttributes> {
) -> HashMap<String, DesignerPropertyAttributes> {
items.into_iter().map(|(k, v)| (k, v.into())).collect()
}

pub fn get_designer_api_cmd_likes_from_pkg(
items: Vec<PkgApiCmdLike>,
) -> Vec<DevServerApiCmdLike> {
) -> Vec<DesignerApiCmdLike> {
items.into_iter().map(|v| v.into()).collect()
}

pub fn get_designer_api_data_likes_from_pkg(
items: Vec<PkgApiDataLike>,
) -> Vec<DevServerApiDataLike> {
) -> Vec<DesignerApiDataLike> {
items.into_iter().map(|v| v.into()).collect()
}

Expand Down
Loading
Loading