From 90ea7bb4a2c6d3a69559580e29a694a1ec9b0448 Mon Sep 17 00:00:00 2001 From: dyzulk <66510723+dyzulk@users.noreply.github.com> Date: Wed, 7 Jan 2026 10:30:36 +0700 Subject: [PATCH] feat: refine CA setup UX by moving setup button to Admin and adding redirection link --- .../admin/root-ca/RootCaManagementClient.tsx | 46 +++++++++++++++---- .../certificates/CertificatesClient.tsx | 33 ++++--------- src/messages/en.json | 4 +- src/messages/id.json | 10 ++-- 4 files changed, 54 insertions(+), 39 deletions(-) diff --git a/src/app/dashboard/admin/root-ca/RootCaManagementClient.tsx b/src/app/dashboard/admin/root-ca/RootCaManagementClient.tsx index 52c205f..8da799c 100644 --- a/src/app/dashboard/admin/root-ca/RootCaManagementClient.tsx +++ b/src/app/dashboard/admin/root-ca/RootCaManagementClient.tsx @@ -25,6 +25,7 @@ export default function RootCaManagementClient() { const { addToast } = useToast(); const { data, error, mutate, isLoading } = useSWR("/api/admin/ca-certificates", fetcher); const [isRenewing, setIsRenewing] = useState(false); + const [isSettingUp, setIsSettingUp] = useState(false); const [isBulkRenewing, setIsBulkRenewing] = useState(false); const [activeSync, setActiveSync] = useState(null); const [isPromoting, setIsPromoting] = useState(false); @@ -116,6 +117,20 @@ export default function RootCaManagementClient() { } }; + const handleSetupCa = async () => { + setIsSettingUp(true); + try { + await axios.post("/api/ca/setup"); + mutate(); + addToast(t("toast_ca_setup_success"), "success"); + } catch (err: any) { + console.error(err); + addToast(err.response?.data?.message || t("toast_ca_setup_failed"), "error"); + } finally { + setIsSettingUp(false); + } + }; + if (error) return
{t("load_failed")}
; const certificates = data?.data || []; @@ -124,15 +139,28 @@ export default function RootCaManagementClient() {
- +
+ {certificates.length === 0 && !isLoading && ( + + )} + +
diff --git a/src/app/dashboard/certificates/CertificatesClient.tsx b/src/app/dashboard/certificates/CertificatesClient.tsx index 5ed0945..25d4069 100644 --- a/src/app/dashboard/certificates/CertificatesClient.tsx +++ b/src/app/dashboard/certificates/CertificatesClient.tsx @@ -44,20 +44,6 @@ export default function CertificatesClient() { } }; - const handleSetupCa = async () => { - setIsSettingUp(true); - try { - await axios.post("/api/ca/setup"); - mutate(); - addToast(t("toast_ca_setup_success"), "success"); - } catch (err: any) { - console.error(err); - addToast(err.response?.data?.message || t("toast_ca_setup_failed"), "error"); - } finally { - setIsSettingUp(false); - } - }; - if (error) return
{t("load_failed")}
; const certificates = data?.data?.data || []; @@ -86,22 +72,19 @@ export default function CertificatesClient() { {t("ca_missing_msg", { missing: caStatus?.missing?.join(", ").replace(/_/g, " ") })} - {!isAdmin && ( + {!isAdmin ? ( {t("contact_admin_msg")} + ) : ( + + {t("ca_not_setup_admin_link")} + )}
- {isAdmin && ( - - )}
)} diff --git a/src/messages/en.json b/src/messages/en.json index 36c9991..9f2af93 100644 --- a/src/messages/en.json +++ b/src/messages/en.json @@ -651,6 +651,7 @@ "toast_bulk_renew_failed": "Bulk renewal failed", "toast_renew_success": "CA Certificate renewed successfully.", "toast_renew_failed": "Failed to renew CA certificate", + "btn_initialize_ca": "Initialize Root CA", "load_failed": "Failed to load CA certificates. Admin access required.", "processing": "Processing...", "info_title": "Information", @@ -675,7 +676,7 @@ "self_signed": "Self-Signed", "renew_button": "Renew Now", "no_ca_search": "No CAs matched \"{term}\"", - "no_ca_found": "No Root CA certificates found. Run CA Setup from Certificates page." + "no_ca_found": "No Root CA certificates found. Start by initializing the Certification Authority." }, "SmtpTester": { "page_title": "SMTP Tester", @@ -821,6 +822,7 @@ "ca_not_setup_title": "CA Not Fully Setup", "ca_missing_msg": "The Certification Authority system is missing: {missing}. Certificates cannot be generated until setup is complete.", "contact_admin_msg": "Please contact your administrator to initialize the Certification Authority.", + "ca_not_setup_admin_link": "Certification Authority is not setup. Please perform setup in the [Root CA Management] page.", "btn_setup_ca": "Setup CA Now", "btn_generate_new": "Generate New", "processing": "Processing...", diff --git a/src/messages/id.json b/src/messages/id.json index 9cb76f3..4ec7601 100644 --- a/src/messages/id.json +++ b/src/messages/id.json @@ -651,7 +651,8 @@ "toast_bulk_renew_failed": "Pembaruan massal gagal", "toast_renew_success": "Sertifikat CA berhasil diperbarui.", "toast_renew_failed": "Gagal memperbarui sertifikat CA", - "load_failed": "Gagal memuat sertifikat CA. Diperlukan akses admin.", + "btn_initialize_ca": "Inisialisasi Root CA", + "load_failed": "Gagal memuat sertifikat CA. Akses admin diperlukan.", "processing": "Memproses...", "info_title": "Informasi", "info_point_1": "Memperbarui sertifikat CA menghasilkan sertifikat publik baru dengan masa berlaku 10 tahun.", @@ -675,7 +676,7 @@ "self_signed": "Self-Signed", "renew_button": "Perbarui", "no_ca_search": "Tidak ada CA yang cocok dengan \"{term}\"", - "no_ca_found": "Sertifikat Root CA tidak ditemukan. Jalankan Pengaturan CA dari halaman Sertifikat." + "no_ca_found": "Sertifikat Root CA tidak ditemukan. Mulailah dengan menginisialisasi Certification Authority." }, "SmtpTester": { "page_title": "Pengetes SMTP", @@ -820,8 +821,9 @@ "load_failed": "Gagal memuat sertifikat.", "ca_not_setup_title": "CA Belum Teratur Sepenuhnya", "ca_missing_msg": "Sistem Otoritas Sertifikasi kehilangan: {missing}. Sertifikat tidak dapat dibuat sampai pengaturan selesai.", - "contact_admin_msg": "Silakan hubungi administrator Anda untuk menginisialisasi Otoritas Sertifikasi.", - "btn_setup_ca": "Atur CA Sekarang", + "contact_admin_msg": "Silakan hubungi administrator Anda untuk menginisialisasi Certification Authority.", + "ca_not_setup_admin_link": "Certification Authority belum diatur. Silakan lakukan pengaturan di halaman [Manajemen Root CA].", + "btn_setup_ca": "Siapkan CA Sekarang", "btn_generate_new": "Terbitkan Baru", "processing": "Memproses...", "delete_title": "Hapus Sertifikat",