Skip to content

Commit d7a6ceb

Browse files
feat: [UIE-10309] - IAM: last login text for delegates (#13437)
* feat: [UIE-10309] - IAM: last login text for delegates * Added changeset: IAM: update last login field for delegate users
1 parent 9d3c205 commit d7a6ceb

File tree

3 files changed

+33
-11
lines changed

3 files changed

+33
-11
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@linode/manager": Changed
3+
---
4+
5+
IAM: update last login field for delegate users ([#13437](https://github.com/linode/manager/pull/13437))

packages/manager/src/features/IAM/Users/UsersTable/UserRow.test.tsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,17 @@ describe('UserRow', () => {
8181
});
8282
});
8383

84-
it('renders username and user type, and does not render email for a Delegate user when isIAMDelegationEnabled flag is enabled', async () => {
84+
it('renders username and user type, and does not render email and last login for a Delegate user when isIAMDelegationEnabled flag is enabled', async () => {
8585
const delegateUser = accountUserFactory.build({
8686
user_type: 'delegate',
87+
last_login: null,
8788
});
8889

8990
queryMocks.useProfile.mockReturnValue({
9091
data: profileFactory.build({ user_type: 'child' }),
9192
});
9293

93-
const { getByText, queryByText } = renderWithTheme(
94+
const { getAllByText, getByText, queryByText } = renderWithTheme(
9495
wrapWithTableBody(<UserRow onDelete={vi.fn()} user={delegateUser} />, {
9596
flags: {
9697
iamDelegation: { enabled: true },
@@ -99,12 +100,10 @@ describe('UserRow', () => {
99100
);
100101

101102
expect(getByText(delegateUser.username)).toBeVisible();
102-
103-
await waitFor(() => {
104-
expect(queryByText(delegateUser.email)).not.toBeInTheDocument();
105-
expect(getByText('Not applicable')).toBeVisible();
106-
expect(getByText('Delegate User')).toBeVisible();
107-
});
103+
expect(queryByText(delegateUser.email)).not.toBeInTheDocument();
104+
expect(queryByText('Never')).not.toBeInTheDocument();
105+
expect(getAllByText('Not applicable').length).toBe(2);
106+
expect(getByText('Delegate User')).toBeVisible();
108107
});
109108

110109
it('renders "Never" if last_login is null', async () => {

packages/manager/src/features/IAM/Users/UsersTable/UserRow.tsx

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ export const UserRow = ({ onDelete, user }: Props) => {
118118
)}
119119
</TableCell>
120120
<TableCell sx={{ display: { lg: 'table-cell', xs: 'none' } }}>
121-
<LastLogin last_login={user.last_login} />
121+
<LastLogin last_login={user.last_login} user_type={user.user_type} />
122122
</TableCell>
123123

124124
<TableCell actionCell>
@@ -137,11 +137,29 @@ export const UserRow = ({ onDelete, user }: Props) => {
137137
* Display information about a Users last login
138138
*
139139
* - The component renders "Never" if last_login is `null`
140+
* - The component renders "Not applicable" if the user is a delegate user
140141
* - The component renders a date if last_login is a success
141142
* - The component renders a date and a status if last_login is a failure
142143
*/
143-
const LastLogin = (props: Pick<User, 'last_login'>) => {
144-
const { last_login } = props;
144+
const LastLogin = (props: Pick<User, 'last_login' | 'user_type'>) => {
145+
const { last_login, user_type } = props;
146+
147+
if (user_type === 'delegate') {
148+
return (
149+
<Typography>
150+
Not applicable
151+
<TooltipIcon
152+
status="info"
153+
sxTooltipIcon={{
154+
marginLeft: '-9px',
155+
marginTop: '-5px',
156+
}}
157+
text="Last login of delegate users is not displayed."
158+
tooltipPosition="right"
159+
/>
160+
</Typography>
161+
);
162+
}
145163

146164
if (last_login === null) {
147165
return <Typography>Never</Typography>;

0 commit comments

Comments
 (0)