Skip to content

Commit

Permalink
Disabling search bar
Browse files Browse the repository at this point in the history
Disabling search box when there are no access grants to show
  • Loading branch information
garciafdezpatricia committed May 7, 2024
1 parent 73effa2 commit f418586
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions __test__/__snapshots__/Manage.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ exports[`login page renders a manage page 1`] = `
<input
class="header-input form-control"
data-testid="agent-search-input"
disabled=""
placeholder="Search"
type="search"
value=""
Expand Down
3 changes: 3 additions & 0 deletions pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import AuthenticatedRoute from "../src/authentication/context/AuthenticatedRoute

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

export default function ListAgentsWithVCs({
onDetails,
searchString,
onEmptyAgents,
}: {
onDetails: (_agent: string) => void;
searchString: string;
onEmptyAgents?: () => void;
}) {
const { session, accessEndpoint, endpointConfiguration } =
useContext(SessionContext);
Expand Down Expand Up @@ -115,6 +120,7 @@ export default function ListAgentsWithVCs({
agents={agents}
onDetails={onDetails}
searchString={searchString}
onEmptyAgents={onEmptyAgents}
/>
);
}

0 comments on commit f418586

Please sign in to comment.