Skip to content
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

Merged
merged 6 commits into from
May 14, 2024
Merged

Disabling search bar #12

merged 6 commits into from
May 14, 2024

Conversation

garciafdezpatricia
Copy link
Contributor

Disable search Box

Disabling search box when there are no access grants to show

User testing instructions

Commit checklist

  • All acceptance criteria are met.
  • Includes tests to ensure functionality, accessibility and prevent regressions, including E2E tests for supported browsers.
  • Relevant documentation, if any, has been written/updated.
  • The changelog has been updated, if applicable.
  • A changeset version has been created, if applicable.
  • Meets Inrupt coding standards and adheres to commit conventions.

Design requirements checklist

  • Meets Inrupt API Design and UX standards
  • Is responsive to our documented minimum supported screen size + resolution
  • Code is extensible by external contributors or anyone forking

Disabling search box when there are no access grants to show
Copy link

vercel bot commented May 7, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
authorization-management-component ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 13, 2024 2:46pm

Copy link
Contributor

@NSeydoux NSeydoux left a 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.

Comment on lines 116 to 120
if (agents !== undefined && agents.length > 0) {
if (onNotEmptyAgents) {
onNotEmptyAgents();
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (agents !== undefined && agents.length > 0) {
if (onNotEmptyAgents) {
onNotEmptyAgents();
}
}
if (agents !== undefined && agents.length > 0 && typeof onNotEmptyAgents === "function") {
onNotEmptyAgents();
}

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor

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
Copy link
Contributor

@NSeydoux NSeydoux left a 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.

Comment on lines +64 to +67
onAgentUpdate={(agentCount) => {
agentCount === 0
? setDisableSearch(true)
: setDisableSearch(false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 :)

Comment on lines +117 to +121
let agentsCount = 0;
if (agents !== undefined) {
agentsCount = agents.length;
}
onAgentUpdate(agentsCount);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

@garciafdezpatricia garciafdezpatricia merged commit ed73b58 into main May 14, 2024
9 checks passed
@garciafdezpatricia garciafdezpatricia deleted the fix/disable-search-box branch May 14, 2024 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants