Skip to content

Commit

Permalink
feat: container rename option (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
ropali authored Oct 2, 2024
1 parent 2397788 commit 572b278
Show file tree
Hide file tree
Showing 6 changed files with 361 additions and 172 deletions.
24 changes: 23 additions & 1 deletion src-tauri/src/commands/container.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use crate::state::AppState;
use crate::utils::terminal::{get_terminal, open_terminal};
use bollard::container::{ListContainersOptions, LogsOptions, StatsOptions};
use bollard::container::{
ListContainersOptions, LogsOptions, RenameContainerOptions, StatsOptions,
};
use bollard::models::{ContainerInspectResponse, ContainerSummary};
use futures_util::StreamExt;
use std::collections::HashMap;
Expand Down Expand Up @@ -192,3 +194,23 @@ pub async fn container_stats(

Ok(())
}

#[tauri::command]
pub async fn rename_container(
state: tauri::State<'_, AppState>,
name: String,
new_name: String,
) -> Result<String, String> {
let opts = RenameContainerOptions { name: &new_name };
state
.docker
.rename_container(&name, opts)
.await
.map(|_| {
format!(
"Container '{}' successfully renamed to '{}'",
name, new_name
)
})
.map_err(|e| e.to_string())
}
16 changes: 9 additions & 7 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]


use crate::state::AppState;
use crate::utils::storage::setup_storage;
use crate::commands::container::{container_operation, container_stats, fetch_container_info, fetch_containers, get_container, stream_docker_logs};
use crate::commands::container::{
container_operation, container_stats, fetch_container_info, fetch_containers, get_container,
rename_container, stream_docker_logs,
};
use crate::commands::extra::{cancel_stream, get_version, ping};
use crate::commands::image::{delete_image, export_image, image_history, image_info, list_images};
use crate::commands::network::{inspect_network, list_networks};
use crate::commands::volume::{inspect_volume, list_volumes};
use crate::commands::terminal::get_available_terminals;
use crate::state::AppState;
use crate::utils::storage::setup_storage;

mod state;
mod utils;
mod commands;
mod constants;
mod state;
mod utils;

fn main() {
std::env::set_var("WEBKIT_DISABLE_COMPOSITING_MODE", "1");

let state = AppState::default();


tauri::Builder::default()
.manage(state)
.plugin(tauri_plugin_store::Builder::default().build())
Expand Down Expand Up @@ -50,6 +51,7 @@ fn main() {
get_version,
ping,
get_available_terminals,
rename_container
])
.run(tauri::generate_context!())
.expect("error while running tauri application");
Expand Down
55 changes: 55 additions & 0 deletions src/Icons/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -436,3 +436,58 @@ export function IconGithub(props) {
</svg>
);
}


export function IconEdit(props) {
return (
<svg
fill="none"
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2.5}
viewBox="0 0 24 24"
height="1em"
width="1em"
{...props}
>
<path d="M11 4H4a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-7"/>
<path d="M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z"/>
</svg>
)
}


export function IconTick(props) {
return (
<svg fill="none" viewBox="0 0 15 15" height="1em" width="1em" {...props}>
<path
stroke="currentColor"
strokeWidth={1.5}
d="M4 7.5L7 10l4-5m-3.5 9.5a7 7 0 110-14 7 7 0 010 14z"
/>
</svg>
);
}


export function IconCancel(props) {
return (
<svg
viewBox="0 0 16 16"
fill="currentColor"
height="1em"
width="1em"
{...props}
>
<path
fill="currentColor"
d="M8 0a8 8 0 100 16A8 8 0 008 0zm0 14.5a6.5 6.5 0 110-13 6.5 6.5 0 010 13z"
/>
<path
fill="currentColor"
d="M10.5 4L8 6.5 5.5 4 4 5.5 6.5 8 4 10.5 5.5 12 8 9.5l2.5 2.5 1.5-1.5L9.5 8 12 5.5z"
/>
</svg>
)
}
Loading

0 comments on commit 572b278

Please sign in to comment.