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

feat(team-selector): Implement useTeams hook for searching #28547

Conversation

evanpurkhiser
Copy link
Member

@evanpurkhiser evanpurkhiser commented Sep 13, 2021

This react hook allows us to easily implement type-ahead for teams.

In the future this will also support loading specific teams, and loading teams that you're a part of. We may potentially even add support to incrementally load results via pagination.

@evanpurkhiser evanpurkhiser force-pushed the evanpurkhiser/feat-team-selector-implement-useteams-hook-for-searching branch from 246697c to 4a0e3ba Compare September 13, 2021 22:09
@evanpurkhiser evanpurkhiser force-pushed the evanpurkhiser/feat-team-selector-implement-useteams-hook-for-searching branch from 4a0e3ba to c36f31a Compare September 14, 2021 20:14
@evanpurkhiser evanpurkhiser requested a review from a team as a code owner September 14, 2021 20:14
@evanpurkhiser evanpurkhiser force-pushed the evanpurkhiser/feat-team-selector-implement-useteams-hook-for-searching branch from c36f31a to a9d7bd7 Compare September 14, 2021 22:24
@evanpurkhiser evanpurkhiser force-pushed the evanpurkhiser/feat-team-selector-implement-useteams-hook-for-searching branch from a9d7bd7 to 130790e Compare September 14, 2021 22:32
@evanpurkhiser evanpurkhiser force-pushed the evanpurkhiser/feat-team-selector-implement-useteams-hook-for-searching branch from 130790e to ea928c5 Compare September 15, 2021 01:24
@evanpurkhiser evanpurkhiser requested a review from a team as a code owner September 15, 2021 01:24
@evanpurkhiser evanpurkhiser force-pushed the evanpurkhiser/feat-team-selector-implement-useteams-hook-for-searching branch from ea928c5 to 75ef088 Compare September 15, 2021 01:29
@evanpurkhiser evanpurkhiser force-pushed the evanpurkhiser/feat-team-selector-implement-useteams-hook-for-searching branch from 75ef088 to 60ae8b4 Compare September 15, 2021 01:30
Copy link
Contributor

@davidenwang davidenwang left a comment

Choose a reason for hiding this comment

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

✨ HOOKS 🎣

nice work im excited for this

@@ -249,12 +251,14 @@ function TeamSelector(props: Props) {
<SelectControl
ref={selectRef}
options={options}
onInputChange={debounce(val => void onSearch(val), DEFAULT_DEBOUNCE_DURATION)}
Copy link
Contributor

Choose a reason for hiding this comment

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

is the void here just for typing or does debounce do something with the return value of the debounced func?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah the onInputChange will actually try and render what is returned here, hence the void.

I could also write as { ... }

teams: Team[];
/**
* This is an action provided to consumers for them to update the current
* teams result set using a simple search query. You can allow the new
Copy link
Contributor

Choose a reason for hiding this comment

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

this comment can be changed to remove the bit about appending/replacing

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah yea

@@ -26,16 +27,11 @@ const teamData = [
];
const teams = teamData.map(data => TestStubs.Team(data));
const project = TestStubs.Project({teams: [teams[0]]});
const organization = TestStubs.Organization({access: ['project:write']});
Copy link
Contributor

Choose a reason for hiding this comment

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

oh shoot thanks for this, looks much better

Copy link
Member Author

Choose a reason for hiding this comment

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

needed to update it since it doesn't take those as props now :)

expect(mockRequest).toHaveBeenCalled();
expect(result.current.teams).toEqual([...mockTeams, newTeam2, newTeam3]);

// de-duplicates itesm in the query results
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: items*

@evanpurkhiser evanpurkhiser force-pushed the evanpurkhiser/feat-team-selector-implement-useteams-hook-for-searching branch from 60ae8b4 to d008acd Compare September 15, 2021 09:38
@evanpurkhiser evanpurkhiser merged commit 4e9181a into master Sep 15, 2021
@evanpurkhiser evanpurkhiser deleted the evanpurkhiser/feat-team-selector-implement-useteams-hook-for-searching branch September 15, 2021 20:00
@github-actions github-actions bot locked and limited conversation to collaborators Oct 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants