From 78a52c04a87081b3e3e37fe15d7fc1addb1ded80 Mon Sep 17 00:00:00 2001 From: Oluwatobi Bamidele Date: Tue, 29 Oct 2024 13:55:45 +0100 Subject: [PATCH 1/2] fix: change swarm naming format --- src/bin/super/superapp/src/Remotes.svelte | 59 +++++++++++------------ 1 file changed, 27 insertions(+), 32 deletions(-) diff --git a/src/bin/super/superapp/src/Remotes.svelte b/src/bin/super/superapp/src/Remotes.svelte index cb3506c0..8b2192c9 100644 --- a/src/bin/super/superapp/src/Remotes.svelte +++ b/src/bin/super/superapp/src/Remotes.svelte @@ -59,10 +59,9 @@ let name = ""; let vanity_address = ""; let domain = ".sphinx.chat"; - let swarm_name_suffix = "-Swarm"; + let swarm_name_prefix = "s-"; const max_input_with = 600; let vanity_input_width = max_input_with; - let swarm_name_width = max_input_with; let aws_instance_types = []; let selected_instance = ""; let vanity_address_error = ""; @@ -470,7 +469,6 @@ vanity_address = ""; selected_instance = ""; vanity_input_width = max_input_with; - swarm_name_width = max_input_with; } async function handleSubmitCreateEc2() { @@ -482,7 +480,7 @@ try { const data = { - name: `${name}${swarm_name_suffix}`, + name: `${swarm_name_prefix}${name}`, vanity_address, instance_type: selected_instance, }; @@ -495,7 +493,6 @@ vanity_address = ""; selected_instance = ""; vanity_input_width = max_input_with; - swarm_name_width = max_input_with; show_notification = true; await getConfig(); @@ -524,11 +521,6 @@ function updateSwarmnameWidth(event) { name = event.target.value.replace(/\s+/g, ""); - const span = document.querySelector(".swarm_name_measure"); - swarm_name_width = span.offsetWidth; - if (!swarm_name_width) { - swarm_name_width = max_input_with; - } } @@ -718,20 +710,16 @@
-
- {name} - -
{#if name.length > 0} - {swarm_name_suffix} + {swarm_name_prefix} {/if} +
@@ -810,30 +798,37 @@ margin-left: -2px; } - .custom_input { + .prefix { + font-size: 1rem; + font-family: "Barlow"; + color: #49c998; + } + + .instance_name_input { border: none; outline: none; margin: 0; font-size: 1rem; font-family: "Barlow"; background-color: transparent; - width: auto; + width: 100%; color: white; padding: 0; } - .vanity_address_measure { - visibility: hidden; - position: absolute; - white-space: nowrap; - font-family: "Barlow"; - font-size: 1rem; - padding: 0; + .custom_input { border: none; + outline: none; margin: 0; + font-size: 1rem; + font-family: "Barlow"; + background-color: transparent; + width: auto; + color: white; + padding: 0; } - .swarm_name_measure { + .vanity_address_measure { visibility: hidden; position: absolute; white-space: nowrap; From 92a87945ee3eb77d19578f8453f69153f4f798a3 Mon Sep 17 00:00:00 2001 From: Oluwatobi Bamidele Date: Tue, 29 Oct 2024 15:17:23 +0100 Subject: [PATCH 2/2] chore: validate swarm name on the backend --- src/bin/super/util.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/bin/super/util.rs b/src/bin/super/util.rs index b1494f3f..4d40739a 100644 --- a/src/bin/super/util.rs +++ b/src/bin/super/util.rs @@ -605,6 +605,10 @@ pub async fn create_swarm_ec2( info: &CreateEc2InstanceInfo, state: &mut Super, ) -> Result<(), Error> { + if !&info.name.starts_with("s-") { + return Err(anyhow!("swarm name does not match naming convention")); + } + let mut actual_vanity_address: Option = None; let instance_type = get_instance(&info.instance_type);