-
Notifications
You must be signed in to change notification settings - Fork 361
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: [M3-7883] - Add search and alphabetical sorting to Switch Account drawer #10515
Changes from 13 commits
c6532b2
c125a17
a092870
f0848a5
84cbb1c
11013b1
50b8fc0
b28e597
bc99281
8aea3a2
cf731df
45b43b9
b6e531b
9708b60
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@linode/manager": Added | ||
--- | ||
|
||
Alphabetical account sorting and search capabilities to Switch Account drawer ([#10515](https://github.com/linode/manager/pull/10515)) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,10 +11,11 @@ import { Stack } from 'src/components/Stack'; | |
import { Typography } from 'src/components/Typography'; | ||
import { useChildAccountsInfiniteQuery } from 'src/queries/account/account'; | ||
|
||
import type { UserType } from '@linode/api-v4'; | ||
import type { Filter, UserType } from '@linode/api-v4'; | ||
|
||
interface ChildAccountListProps { | ||
currentTokenWithBearer: string; | ||
filter: Filter; | ||
mjac0bs marked this conversation as resolved.
Show resolved
Hide resolved
|
||
isLoading?: boolean; | ||
onClose: () => void; | ||
onSwitchAccount: (props: { | ||
|
@@ -30,6 +31,7 @@ interface ChildAccountListProps { | |
export const ChildAccountList = React.memo( | ||
({ | ||
currentTokenWithBearer, | ||
filter, | ||
isLoading, | ||
onClose, | ||
onSwitchAccount, | ||
|
@@ -46,18 +48,26 @@ export const ChildAccountList = React.memo( | |
isError, | ||
isFetchingNextPage, | ||
isInitialLoading, | ||
isRefetching, | ||
refetch: refetchChildAccounts, | ||
} = useChildAccountsInfiniteQuery({ | ||
filter, | ||
headers: | ||
userType === 'proxy' | ||
? { | ||
Authorization: currentTokenWithBearer, | ||
} | ||
: undefined, | ||
}); | ||
// Sort the list of child accounts alphabetically. | ||
mjac0bs marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const childAccounts = data?.pages.flatMap((page) => page.data); | ||
|
||
if (isInitialLoading) { | ||
if ( | ||
isInitialLoading || | ||
isLoading || | ||
isSwitchingChildAccounts || | ||
isRefetching | ||
) { | ||
return ( | ||
<Box display="flex" justifyContent="center"> | ||
<CircleProgress mini size={70} /> | ||
|
@@ -67,7 +77,13 @@ export const ChildAccountList = React.memo( | |
|
||
if (childAccounts?.length === 0) { | ||
return ( | ||
<Notice variant="info">There are no indirect customer accounts.</Notice> | ||
<Notice variant="info"> | ||
There are no child accounts | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We're not using "indirect customer", so updated the terminology here. |
||
{filter.hasOwnProperty('company') | ||
? ' that match this query' | ||
: undefined} | ||
. | ||
</Notice> | ||
); | ||
} | ||
|
||
|
@@ -119,11 +135,6 @@ export const ChildAccountList = React.memo( | |
|
||
return ( | ||
<Stack alignItems={'flex-start'} data-testid="child-account-list"> | ||
{(isSwitchingChildAccounts || isLoading) && ( | ||
<Box display="flex" justifyContent="center" width={'100%'}> | ||
<CircleProgress mini size={70} /> | ||
</Box> | ||
)} | ||
Comment on lines
-122
to
-126
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure why we were setting up loading spinners in two different places, but I removed this and added all conditions to L67-72. The addition of isRefetching handles loading state for the search queries. Reviewers should check that they're not seeing any unexpected behavior in our handling of loading state. |
||
{!isSwitchingChildAccounts && !isLoading && renderChildAccounts} | ||
{hasNextPage && <Waypoint onEnter={() => fetchNextPage()} />} | ||
{isFetchingNextPage && <CircleProgress mini />} | ||
|
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.
Thanks for adding this test