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
ServiceAccount : use InteractiveTable
#85203
ServiceAccount : use InteractiveTable
#85203
Conversation
… ServiceAccountsListItem
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.
Looks good! 🎉 Left a few minor comments. Also I think somebody from the Identity access team should give this a look.
) : ( | ||
<Stack alignItems="center"> | ||
<Icon name="key-skeleton-alt"></Icon> | ||
<TextLink href={href} aria-label={ariaLabel} color="primary"> |
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.
I don't think this needs to be a link, the first three columns should be enough.
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.
🤷 I copied it from the original code. It is how it works on main
. Maybe a question for the identity team?
public/app/features/serviceaccounts/ServiceAccountsListPage.tsx
Outdated
Show resolved
Hide resolved
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.
Could you extract some of the cell rendering functionality into separate functions? I think that would increase readability.
Yes, they will be added automatically when the PR turn into a normal one, not a draft. But wanted to check if I was in the right direction 😅 |
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.
You still need to extract roles
and actions
columns. Since you need contextSrv stuff, it might be easier to create the cells in separate function (at least these two).
const getCellContent = ( | ||
value: string, | ||
original: ServiceAccountDTO, | ||
isLoading: boolean, | ||
columnName?: Column<ServiceAccountDTO>['id'] | ||
) => { | ||
if (isLoading) { | ||
return columnName === 'avatarUrl' ? <Skeleton circle width={24} height={24} /> : <Skeleton width={100} />; | ||
} | ||
const href = `/org/serviceaccounts/${original.id}`; | ||
const ariaLabel = `Edit service account's ${name} details`; | ||
switch (columnName) { | ||
case 'avatarUrl': | ||
return ( | ||
<a aria-label={ariaLabel} href={href}> | ||
<Avatar src={value} alt={'User avatar'} /> | ||
</a> | ||
); | ||
case 'id': | ||
return ( | ||
<TextLink href={href} aria-label={ariaLabel} color="secondary"> | ||
{original.login} | ||
</TextLink> | ||
); | ||
case 'tokens': | ||
return ( | ||
<Stack alignItems="center"> | ||
<Icon name="key-skeleton-alt"></Icon> | ||
<TextLink href={href} aria-label={ariaLabel} color="primary"> | ||
{value || 'No tokens'} | ||
</TextLink> | ||
</Stack> | ||
); | ||
default: | ||
return ( | ||
<TextLink href={href} aria-label={ariaLabel} color="primary"> | ||
{value} | ||
</TextLink> | ||
); | ||
} | ||
}; |
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.
Does this need to be inside the component body? I was initially thinking that each cell type would have a separate function, but I think this works from a readability point of view, especially with the loading state.
Co-authored-by: Tobias Skarhed <1438972+tskarhed@users.noreply.github.com>
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.
It crashes when I try to sort by ID.
TypeError: a.split is not a function
Screen.Recording.2024-04-02.at.15.01.29.mov
cell: ({ cell: { value }, row: { original } }: Cell<'role'>) => { | ||
return getCellContent(value, original, isLoading, 'avatarUrl'); | ||
}, | ||
sortType: 'string', |
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.
Do you actually need sort type here? I don't think it makes sense to have sorting enabled for this column
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.
Nope, I took a look at the original table and it does not sort so I think we could keep just sorting by 'account'. Wdyt?
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.
Sounds like an idea :)
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.
Done ;) LGTY?
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.
Good job! 👍
What is this feature?
We modify the
ServiceAccount
to use theInteractiveTable
Why do we need this feature?
To be consistent as
OrgUserTable
orUserTable
already use it.Who is this feature for?
[Add information on what kind of user the feature is for.]
Which issue(s) does this PR fix?:
Fixes #85000
Special notes for your reviewer:
Please check that: