-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
feat(team-selector): Implement useTeams hook for searching #28547
Conversation
246697c
to
4a0e3ba
Compare
4a0e3ba
to
c36f31a
Compare
c36f31a
to
a9d7bd7
Compare
a9d7bd7
to
130790e
Compare
130790e
to
ea928c5
Compare
ea928c5
to
75ef088
Compare
75ef088
to
60ae8b4
Compare
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.
✨ 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)} |
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.
is the void here just for typing or does debounce do something with the return value of the debounced func?
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.
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 |
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.
this comment can be changed to remove the bit about appending/replacing
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.
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']}); |
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.
oh shoot thanks for this, looks much better
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.
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 |
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.
nit: items*
60ae8b4
to
d008acd
Compare
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.