From f418586df16f0d6652f311aa9f8be8f0dd30d378 Mon Sep 17 00:00:00 2001 From: garciafdezpatricia Date: Tue, 7 May 2024 16:54:28 +0200 Subject: [PATCH] Disabling search bar Disabling search box when there are no access grants to show --- __test__/__snapshots__/Manage.test.tsx.snap | 1 + pages/index.tsx | 3 +++ src/components/ListAgents/ListAgents.tsx | 5 +++++ src/components/ListAgents/ListAgentsWithVCs.tsx | 6 ++++++ 4 files changed, 15 insertions(+) diff --git a/__test__/__snapshots__/Manage.test.tsx.snap b/__test__/__snapshots__/Manage.test.tsx.snap index 3818cdc..a09f56e 100644 --- a/__test__/__snapshots__/Manage.test.tsx.snap +++ b/__test__/__snapshots__/Manage.test.tsx.snap @@ -50,6 +50,7 @@ exports[`login page renders a manage page 1`] = ` @@ -46,6 +47,7 @@ export default function ManagePage() { value={value} onChange={(e) => setValue(e.target.value)} data-testid="agent-search-input" + disabled={disableSearch} /> @@ -59,6 +61,7 @@ export default function ManagePage() { }) } searchString={value} + onEmptyAgents={() => setDisableSearch(true)} /> diff --git a/src/components/ListAgents/ListAgents.tsx b/src/components/ListAgents/ListAgents.tsx index 85a0d65..62eaf28 100644 --- a/src/components/ListAgents/ListAgents.tsx +++ b/src/components/ListAgents/ListAgents.tsx @@ -126,12 +126,17 @@ export default function ListAgents({ agents, onDetails, searchString, + onEmptyAgents, }: { agents: string[]; searchString?: string; onDetails: (_agent: string) => void; + onEmptyAgents?: () => void; }) { if (agents.length === 0) { + if (onEmptyAgents) { + onEmptyAgents(); + } return ; } return ( diff --git a/src/components/ListAgents/ListAgentsWithVCs.tsx b/src/components/ListAgents/ListAgentsWithVCs.tsx index f0b3109..a0b64ee 100644 --- a/src/components/ListAgents/ListAgentsWithVCs.tsx +++ b/src/components/ListAgents/ListAgentsWithVCs.tsx @@ -63,10 +63,12 @@ function SuspendedList({ onDetails, searchString, agents, + onEmptyAgents }: { onDetails: (_agent: string) => void; searchString: string; agents?: string[]; + onEmptyAgents?: () => void; }) { if (agents === undefined) { return ; @@ -76,6 +78,7 @@ function SuspendedList({ agents={agents} onDetails={onDetails} searchString={searchString} + onEmptyAgents={onEmptyAgents} /> ); } @@ -83,9 +86,11 @@ function SuspendedList({ export default function ListAgentsWithVCs({ onDetails, searchString, + onEmptyAgents, }: { onDetails: (_agent: string) => void; searchString: string; + onEmptyAgents?: () => void; }) { const { session, accessEndpoint, endpointConfiguration } = useContext(SessionContext); @@ -115,6 +120,7 @@ export default function ListAgentsWithVCs({ agents={agents} onDetails={onDetails} searchString={searchString} + onEmptyAgents={onEmptyAgents} /> ); }