-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disabling search bar #12
Conversation
Disabling search box when there are no access grants to show
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer a different approach where the ListAgentsWithVCs
component is given a more generic callback that takes as an argument the number of agents. The useEffect
in ListAgentsWithVCs
would keep the same dependency, and call that onAgentUpdate
callback with the agent count (defaulting to 0). The logic to check if the agent count is zero could then be lifted into the AuthenticatedRoute
.
if (agents !== undefined && agents.length > 0) { | ||
if (onNotEmptyAgents) { | ||
onNotEmptyAgents(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (agents !== undefined && agents.length > 0) { | |
if (onNotEmptyAgents) { | |
onNotEmptyAgents(); | |
} | |
} | |
if (agents !== undefined && agents.length > 0 && typeof onNotEmptyAgents === "function") { | |
onNotEmptyAgents(); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it better in this case to lift the check and disabling of the search bar to the AuthenticatedRoute
? I thought that component was "responsible" of checking the authentication of the session and return the correct content in each case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I understand the current architecture, AuthenticatedRoute
is the component managing the display of the search bar. The reason I'm suggesting to lift the check up and have a more generic callback provided to ListAgentsWithVCs
is because with the current approach, you can only have a trigger when there are agents. But if the parent needs to change its behavior if there are no agents, or even more specifically if there is a given number of agents (let's say you want to change display on a large number of agents compared to a few), you would not be able to do that because the current callback is hardcoded to non-zero.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace all occurences opf AutghenticatedRoute
by index
because I don't know how to read github diffs anymore
Lifted the agents count and consequent search bar disabling to index.tsx
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some superficial suggestions, but overall looks good to me.
onAgentUpdate={(agentCount) => { | ||
agentCount === 0 | ||
? setDisableSearch(true) | ||
: setDisableSearch(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
onAgentUpdate={(agentCount) => { | |
agentCount === 0 | |
? setDisableSearch(true) | |
: setDisableSearch(false); | |
onAgentUpdate={(agentCount) => { | |
setDisableSearch(agentCount === 0) |
Often, when you have a test and then return true
or false
, you can return the test directly :)
let agentsCount = 0; | ||
if (agents !== undefined) { | ||
agentsCount = agents.length; | ||
} | ||
onAgentUpdate(agentsCount); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let agentsCount = 0; | |
if (agents !== undefined) { | |
agentsCount = agents.length; | |
} | |
onAgentUpdate(agentsCount); | |
onAgentUpdate((agents ?? []).length); |
I don't have a strong opinion on which one we should use, feel free to keep the one you find easier to read and understand.
Disable search Box
Disabling search box when there are no access grants to show
User testing instructions
Commit checklist
Design requirements checklist