From 59eb264651f628e7e8e12b7df677203254e2c0a8 Mon Sep 17 00:00:00 2001 From: kayra1 Date: Wed, 5 Jun 2024 15:14:35 +0300 Subject: [PATCH] exclusive open Action menu --- ui/src/app/certificate_requests/row.tsx | 22 ++++++++++++++++------ ui/src/app/certificate_requests/table.tsx | 4 +++- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/ui/src/app/certificate_requests/row.tsx b/ui/src/app/certificate_requests/row.tsx index fab3ef3..1c77893 100644 --- a/ui/src/app/certificate_requests/row.tsx +++ b/ui/src/app/certificate_requests/row.tsx @@ -1,4 +1,4 @@ -import { useState } from "react" +import { useState, Dispatch, SetStateAction } from "react" const extractCSR = (csrPemString: string) => { //TODO } @@ -11,10 +11,20 @@ type rowProps = { id: number, csr: string, certificate: string + + ActionMenuExpanded: number + setActionMenuExpanded: Dispatch> } -export default function Row({ id, csr, certificate }: rowProps) { - const [actionMenuOpen, setActionMenuOpen] = useState(false) +export default function Row({ id, csr, certificate, ActionMenuExpanded, setActionMenuExpanded }: rowProps) { const [detailsMenuOpen, setDetailsMenuOpen] = useState(false) + + const toggleActionMenu = () => { + if (ActionMenuExpanded == id) { + setActionMenuExpanded(0) + }else{ + setActionMenuExpanded(id) + } + } return ( {id} @@ -35,12 +45,12 @@ export default function Row({ id, csr, certificate }: rowProps) { - + diff --git a/ui/src/app/certificate_requests/table.tsx b/ui/src/app/certificate_requests/table.tsx index 78aa812..51142d4 100644 --- a/ui/src/app/certificate_requests/table.tsx +++ b/ui/src/app/certificate_requests/table.tsx @@ -34,6 +34,8 @@ function sortByCertStatus(a: CSREntry, b: CSREntry) { export function CertificateRequestsTable() { const { isOpen: isAsideOpen, setIsOpen: setAsideIsOpen } = useContext(AsideContext) + + const [actionsMenuExpanded, setActionsMenuExpanded] = useState(0) const [sortedColumn, setSortedColumn] = useState('none') const [sortDescending, setSortDescending] = useState(true) const rows = [ @@ -78,7 +80,7 @@ export function CertificateRequestsTable() { { sortedRows().map((row) => ( - + ) )}