From ba352f06cb229ce0d93bd4c01666598928e7789d Mon Sep 17 00:00:00 2001 From: Mohammad Al Shakoush Date: Sun, 15 Dec 2024 00:56:06 +0100 Subject: [PATCH] Add title to update modal as well --- warpgate-admin/src/api/public_key_credentials.rs | 1 + warpgate-web/src/admin/CredentialEditor.svelte | 3 +-- warpgate-web/src/admin/PublicKeyCredentialModal.svelte | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/warpgate-admin/src/api/public_key_credentials.rs b/warpgate-admin/src/api/public_key_credentials.rs index ef093203..607521f9 100644 --- a/warpgate-admin/src/api/public_key_credentials.rs +++ b/warpgate-admin/src/api/public_key_credentials.rs @@ -158,6 +158,7 @@ impl DetailApi { let model = PublicKeyCredential::ActiveModel { id: Set(id.0), user_id: Set(*user_id), + openssh_public_key_title: Set(body.openssh_public_key_title.clone()), ..<_>::from(UserPublicKeyCredential::try_from(&*body)?) } .update(&*db) diff --git a/warpgate-web/src/admin/CredentialEditor.svelte b/warpgate-web/src/admin/CredentialEditor.svelte index 207d5016..fdfc8e36 100644 --- a/warpgate-web/src/admin/CredentialEditor.svelte +++ b/warpgate-web/src/admin/CredentialEditor.svelte @@ -185,9 +185,8 @@ } async function savePublicKeyCredential (opensshPublicKeyTitle: string, opensshPublicKey: string) { - // TODO: If it is an existing key, update it - // Otherwise, create a new one if (editingPublicKeyCredentialInstance) { + editingPublicKeyCredentialInstance.opensshPublicKeyTitle = opensshPublicKeyTitle editingPublicKeyCredentialInstance.opensshPublicKey = opensshPublicKey await api.updatePublicKeyCredential({ userId, diff --git a/warpgate-web/src/admin/PublicKeyCredentialModal.svelte b/warpgate-web/src/admin/PublicKeyCredentialModal.svelte index 78ac1f25..1a3c2eaf 100644 --- a/warpgate-web/src/admin/PublicKeyCredentialModal.svelte +++ b/warpgate-web/src/admin/PublicKeyCredentialModal.svelte @@ -4,7 +4,6 @@ Form, FormGroup, Input, - Label, Modal, ModalBody, ModalFooter, @@ -49,6 +48,7 @@ { if (instance) { + opensshPublicKeyTitle = instance.opensshPublicKeyTitle opensshPublicKey = instance.opensshPublicKey } field?.focus()