Skip to content

Commit

Permalink
less impact change
Browse files Browse the repository at this point in the history
  • Loading branch information
garciafdezpatricia committed May 9, 2024
1 parent 06cea83 commit aa1644f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
4 changes: 2 additions & 2 deletions pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import AuthenticatedRoute from "../src/authentication/context/AuthenticatedRoute

export default function ManagePage() {
const [value, setValue] = useState("");
const [disableSearch, setDisableSearch] = useState(false);
const [disableSearch, setDisableSearch] = useState(true);
const { push } = useRouter();
return (
<AuthenticatedRoute>
Expand Down Expand Up @@ -61,7 +61,7 @@ export default function ManagePage() {
})
}
searchString={value}
onEmptyAgents={() => setDisableSearch(true)}
onNotEmptyAgents={() => setDisableSearch(false)}
/>
</div>
</main>
Expand Down
5 changes: 0 additions & 5 deletions src/components/ListAgents/ListAgents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,17 +126,12 @@ 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 <EmptyAgentPage />;
}
return (
Expand Down
16 changes: 10 additions & 6 deletions src/components/ListAgents/ListAgentsWithVCs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,10 @@ function SuspendedList({
onDetails,
searchString,
agents,
onEmptyAgents,
}: {
onDetails: (_agent: string) => void;
searchString: string;
agents?: string[];
onEmptyAgents?: () => void;
}) {
if (agents === undefined) {
return <Loader />;
Expand All @@ -78,19 +76,18 @@ function SuspendedList({
agents={agents}
onDetails={onDetails}
searchString={searchString}
onEmptyAgents={onEmptyAgents}
/>
);
}

export default function ListAgentsWithVCs({
onDetails,
searchString,
onEmptyAgents,
onNotEmptyAgents,
}: {
onDetails: (_agent: string) => void;
searchString: string;
onEmptyAgents?: () => void;
onNotEmptyAgents?: () => void;
}) {
const { session, accessEndpoint, endpointConfiguration } =
useContext(SessionContext);
Expand All @@ -115,12 +112,19 @@ export default function ListAgentsWithVCs({
}
}, [accessEndpoint, endpointConfiguration, session, isValidAccessGrant]);

useEffect(() => {
if (agents !== undefined && agents.length > 0) {
if (onNotEmptyAgents) {
onNotEmptyAgents();
}
}
}, [agents]);

return (
<SuspendedList
agents={agents}
onDetails={onDetails}
searchString={searchString}
onEmptyAgents={onEmptyAgents}
/>
);
}

0 comments on commit aa1644f

Please sign in to comment.