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

fix: [M3-7881] - Restore loading state to Users & Grants table #10303

Merged
merged 3 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/manager/.changeset/pr-10303-fixed-1710976860713.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Fixed
---

Loading state missing from Users & Grants table ([#10303](https://github.com/linode/manager/pull/10303))
8 changes: 5 additions & 3 deletions packages/manager/src/features/Users/UsersLanding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ export const UsersLanding = () => {
['user_type']: showProxyUserTable ? 'child' : undefined,
};

const { data: users, error, isLoading, refetch } = useAccountUsers({
// Since this query is disabled for restricted users, use isInitialLoading.
const { data: users, error, isInitialLoading, refetch } = useAccountUsers({
filters: usersFilter,
params: {
page: pagination.page,
Expand All @@ -59,10 +60,11 @@ export const UsersLanding = () => {

const isRestrictedUser = profile?.restricted;

// Since this query is disabled for restricted users, use isInitialLoading.
const {
data: proxyUser,
error: proxyUserError,
isLoading: isLoadingProxyUser,
isInitialLoading: isLoadingProxyUser,
} = useAccountUsers({
enabled:
flags.parentChildAccountAccess && showProxyUserTable && !isRestrictedUser,
Expand Down Expand Up @@ -162,7 +164,7 @@ export const UsersLanding = () => {
<TableBody>
<UsersLandingTableBody
error={error}
isLoading={isLoading}
isLoading={isInitialLoading}
numCols={numCols}
onDelete={handleDelete}
users={users?.data}
Expand Down
11 changes: 5 additions & 6 deletions packages/manager/src/features/Users/UsersLandingTableBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ interface Props {
export const UsersLandingTableBody = (props: Props) => {
const { error, isLoading, numCols, onDelete, users } = props;

if ((isLoading && !users) || (isLoading && users?.length === 0)) {
return <TableRowEmpty colSpan={numCols} />;
}

if (isLoading) {
return <TableRowLoading columns={numCols} rows={1} />;
}
Expand All @@ -30,10 +26,13 @@ export const UsersLandingTableBody = (props: Props) => {
return <TableRowError colSpan={numCols} message={error[0].reason} />;
}

if (!users || users.length === 0) {
return <TableRowEmpty colSpan={numCols} />;
}

return (
// eslint-disable-next-line react/jsx-no-useless-fragment
<>
{users?.map((user) => (
{users.map((user) => (
<UserRow key={user.username} onDelete={onDelete} user={user} />
))}
</>
Expand Down
Loading