Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,12 @@ export const SwitchAccountDrawer = (props: Props) => {
userType: isProxyUserType ? 'proxy' : 'delegate',
});
onClose(event);
location.reload();
} catch (error) {
location.replace('/linodes');
} catch {
// Error is handled by createTokenError.
}
},
[createToken, updateCurrentToken, revokeToken]
[createToken, isProxyUserType, updateCurrentToken, revokeToken]
);

const [isSwitchingChildAccounts, setIsSwitchingChildAccounts] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import * as React from 'react';

import { DebouncedSearchTextField } from 'src/components/DebouncedSearchTextField';
import { PaginationFooter } from 'src/components/PaginationFooter/PaginationFooter';
import { MIN_PAGE_SIZE } from 'src/components/PaginationFooter/PaginationFooter.constants';
import { Table } from 'src/components/Table';
import { TableBody } from 'src/components/TableBody';
import { TableCell } from 'src/components/TableCell';
Expand All @@ -25,11 +26,13 @@ import { usePaginationV2 } from 'src/hooks/usePaginationV2';

import type { Theme } from '@mui/material';

const USER_DELEGATION_ROUTE = '/iam/users/$username/delegations';

export const UserDelegationsTable = () => {
const { username } = useParams({ from: '/iam/users/$username' });
const { isIAMDelegationEnabled } = useIsIAMDelegationEnabled();
const { company } = useSearch({
from: '/iam/users/$username/delegations',
from: USER_DELEGATION_ROUTE,
});
const navigate = useNavigate();

Expand All @@ -39,13 +42,13 @@ export const UserDelegationsTable = () => {
order: 'asc',
orderBy: 'company',
},
from: '/iam/users/$username/delegations',
from: USER_DELEGATION_ROUTE,
},
preferenceKey: 'user-delegations',
});

const pagination = usePaginationV2({
currentRoute: '/iam/users/$username/delegations',
currentRoute: USER_DELEGATION_ROUTE,
preferenceKey: 'user-delegations',
initialPage: 1,
searchParams: (prev) => ({
Expand Down Expand Up @@ -79,7 +82,7 @@ export const UserDelegationsTable = () => {
const handleSearch = (value: string) => {
pagination.handlePageChange(1);
navigate({
to: '/iam/users/$username/delegations',
to: USER_DELEGATION_ROUTE,
params: { username },
search: { company: value || undefined },
});
Expand Down Expand Up @@ -134,7 +137,7 @@ export const UserDelegationsTable = () => {
<TableCell>{childAccount.company}</TableCell>
</TableRow>
))}
{(childAccounts?.results ?? 0) > pagination.pageSize && (
{(childAccounts?.results ?? 0) > MIN_PAGE_SIZE && (
<TableRow>
<TableCell
colSpan={1}
Expand Down Expand Up @@ -162,4 +165,4 @@ export const UserDelegationsTable = () => {
</Stack>
</Paper>
);
};
};
13 changes: 1 addition & 12 deletions packages/manager/src/features/TopMenu/UserMenu/UserMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,6 @@ export const UserMenu = React.memo(() => {
profile,
});

// Used for fetching parent profile and account data by making a request with the parent's token.
const proxyHeaders = isProxyOrDelegateUserType
? {
Authorization: getStorage(`authentication/parent_token/token`),
}
: undefined;

const { data: parentProfile } = useProfile({ headers: proxyHeaders });

const userName =
(isProxyOrDelegateUserType ? parentProfile : profile)?.username ?? '';

const matchesSmDown = useMediaQuery((theme: Theme) =>
theme.breakpoints.down('sm')
Expand Down Expand Up @@ -133,7 +122,7 @@ export const UserMenu = React.memo(() => {
>
<TruncatedUsername
sx={{ font: theme.font.semibold }}
username={userName}
username={profile?.username ?? ''}
/>
{companyNameOrEmail && (
<Typography
Expand Down