(handle: &tauri::AppHandle<tauri::Wry>)
| 14 | use crate::{cert, docker, updater}; |
| 15 | |
| 16 | fn create_menu(handle: &tauri::AppHandle<tauri::Wry>) -> tauri::Result<Menu<tauri::Wry>> { |
| 17 | let mut menu_builder = MenuBuilder::new(handle) |
| 18 | .item(&MenuItem::with_id( |
| 19 | handle, |
| 20 | "new", |
| 21 | "New stack", |
| 22 | true, |
| 23 | Some("cmd+n"), |
| 24 | )?) |
| 25 | .separator(); |
| 26 | |
| 27 | let stacks: Result<Vec<String>, String> = |
| 28 | tauri::async_runtime::block_on(docker::list_stacks(false)); |
| 29 | |
| 30 | if let Ok(stack_list) = stacks { |
| 31 | for stack in stack_list { |
| 32 | let name = &stack; |
| 33 | menu_builder = menu_builder.item(&MenuItem::with_id( |
| 34 | handle, |
| 35 | format!("stack-{}", name), |
| 36 | format!("⛁ {}", name), |
| 37 | true, |
| 38 | None::<&str>, |
| 39 | )?); |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | menu_builder = menu_builder.separator() |
| 44 | .item( |
| 45 | // submenu |
| 46 | &SubmenuBuilder::new(handle, "More") |
| 47 | .about(Some(AboutMetadata { |
| 48 | name: Some("Stack".to_string()), |
| 49 | version: Some("Version preview".to_string()), |
| 50 | icon: Some(include_image!("icons/icon.png")), |
| 51 | // license: Some("MIT".to_string()), |
| 52 | website: Some("https://stack.lol".to_string()), |
| 53 | ..Default::default() |
| 54 | })) |
| 55 | .item(&MenuItem::with_id( |
| 56 | handle, |
| 57 | "trust_certificate", |
| 58 | "Trust Certificate 🔒", |
| 59 | true, |
| 60 | None::<&str>, |
| 61 | )?) |
| 62 | .item(&MenuItem::with_id( |
| 63 | handle, |
| 64 | "check_update", |
| 65 | "Check for Updates…", |
| 66 | false, // TODO: |
| 67 | None::<&str>, |
| 68 | )?) |
| 69 | .build()?, |
| 70 | ) |
| 71 | .quit_with_text("Quit") |
| 72 | // .item(&MenuItem::with_id( |
| 73 | // handle, |
no test coverage detected