1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-08-04 13:48:56 +02:00
Nuno Góis 2023-01-11 15:08:50 +00:00 committed by GitHub
parent eb7e82dff2
commit 7f3ec5acb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 50 additions and 26 deletions

View File

@ -25,6 +25,13 @@ export const ServiceAccountDeleteDialog = ({
setOpen, setOpen,
onConfirm, onConfirm,
}: IServiceAccountDeleteDialogProps) => { }: IServiceAccountDeleteDialogProps) => {
const deleteMessage = (
<>
You are about to delete service account:{' '}
<strong>{serviceAccount?.name}</strong>
</>
);
return ( return (
<Dialogue <Dialogue
title="Delete service account?" title="Delete service account?"
@ -36,15 +43,16 @@ export const ServiceAccountDeleteDialog = ({
setOpen(false); setOpen(false);
}} }}
> >
<Alert severity="error">
Deleting this service account may break any existing
implementations currently using it.
</Alert>
<ConditionallyRender <ConditionallyRender
condition={Boolean(serviceAccount?.tokens.length)} condition={Boolean(serviceAccount?.tokens.length)}
show={ show={
<> <>
<StyledLabel>Service account tokens</StyledLabel> <Alert severity="error">
Deleting this service account may break any existing
implementations currently using it.
</Alert>
<StyledLabel>{deleteMessage}</StyledLabel>
<StyledLabel>Service account tokens:</StyledLabel>
<StyledTableContainer> <StyledTableContainer>
<ServiceAccountTokens <ServiceAccountTokens
serviceAccount={serviceAccount!} serviceAccount={serviceAccount!}
@ -53,11 +61,8 @@ export const ServiceAccountDeleteDialog = ({
</StyledTableContainer> </StyledTableContainer>
</> </>
} }
elseShow={<p>{deleteMessage}</p>}
/> />
<StyledLabel>
You are about to delete service account:{' '}
<strong>{serviceAccount?.name}</strong>
</StyledLabel>
</Dialogue> </Dialogue>
); );
}; };

View File

@ -5,6 +5,7 @@ import { HtmlTooltip } from 'component/common/HtmlTooltip/HtmlTooltip';
import { Highlighter } from 'component/common/Highlighter/Highlighter'; import { Highlighter } from 'component/common/Highlighter/Highlighter';
import { useSearchHighlightContext } from 'component/common/Table/SearchHighlightContext/SearchHighlightContext'; import { useSearchHighlightContext } from 'component/common/Table/SearchHighlightContext/SearchHighlightContext';
import { IServiceAccount } from 'interfaces/service-account'; import { IServiceAccount } from 'interfaces/service-account';
import { LinkCell } from 'component/common/Table/cells/LinkCell/LinkCell';
const StyledItem = styled(Typography)(({ theme }) => ({ const StyledItem = styled(Typography)(({ theme }) => ({
fontSize: theme.fontSizes.smallerBody, fontSize: theme.fontSizes.smallerBody,
@ -17,27 +18,27 @@ const StyledLink = styled(Link, {
})); }));
interface IServiceAccountTokensCellProps { interface IServiceAccountTokensCellProps {
row: { serviceAccount: IServiceAccount;
original: IServiceAccount;
};
value: string; value: string;
onCreateToken: () => void;
} }
export const ServiceAccountTokensCell: VFC<IServiceAccountTokensCellProps> = ({ export const ServiceAccountTokensCell: VFC<IServiceAccountTokensCellProps> = ({
row, serviceAccount,
value, value,
onCreateToken,
}) => { }) => {
const { searchQuery } = useSearchHighlightContext(); const { searchQuery } = useSearchHighlightContext();
if (!row.original.tokens || row.original.tokens.length === 0) if (!serviceAccount.tokens || serviceAccount.tokens.length === 0)
return <TextCell />; return <LinkCell title="Create token" onClick={onCreateToken} />;
return ( return (
<TextCell> <TextCell>
<HtmlTooltip <HtmlTooltip
title={ title={
<> <>
{row.original.tokens?.map(({ id, description }) => ( {serviceAccount.tokens?.map(({ id, description }) => (
<StyledItem key={id}> <StyledItem key={id}>
<Highlighter search={searchQuery}> <Highlighter search={searchQuery}>
{description} {description}
@ -54,9 +55,9 @@ export const ServiceAccountTokensCell: VFC<IServiceAccountTokensCellProps> = ({
value.toLowerCase().includes(searchQuery.toLowerCase()) value.toLowerCase().includes(searchQuery.toLowerCase())
} }
> >
{row.original.tokens?.length === 1 {serviceAccount.tokens?.length === 1
? '1 token' ? '1 token'
: `${row.original.tokens?.length} tokens`} : `${serviceAccount.tokens?.length} tokens`}
</StyledLink> </StyledLink>
</HtmlTooltip> </HtmlTooltip>
</TextCell> </TextCell>

View File

@ -65,9 +65,9 @@ export const ServiceAccountsTable = () => {
{ {
Header: 'Avatar', Header: 'Avatar',
accessor: 'imageUrl', accessor: 'imageUrl',
Cell: ({ row: { original: user } }: any) => ( Cell: ({ row: { original: serviceAccount } }: any) => (
<TextCell> <TextCell>
<UserAvatar user={user} /> <UserAvatar user={serviceAccount} />
</TextCell> </TextCell>
), ),
disableSortBy: true, disableSortBy: true,
@ -78,8 +78,11 @@ export const ServiceAccountsTable = () => {
Header: 'Name', Header: 'Name',
accessor: (row: any) => row.name || '', accessor: (row: any) => row.name || '',
minWidth: 200, minWidth: 200,
Cell: ({ row: { original: user } }: any) => ( Cell: ({ row: { original: serviceAccount } }: any) => (
<HighlightCell value={user.name} subtitle={user.username} /> <HighlightCell
value={serviceAccount.name}
subtitle={serviceAccount.username}
/>
), ),
searchable: true, searchable: true,
}, },
@ -98,7 +101,22 @@ export const ServiceAccountsTable = () => {
row.tokens row.tokens
?.map(({ description }) => description) ?.map(({ description }) => description)
.join('\n') || '', .join('\n') || '',
Cell: ServiceAccountTokensCell, Cell: ({
row: { original: serviceAccount },
value,
}: {
row: { original: IServiceAccount };
value: string;
}) => (
<ServiceAccountTokensCell
serviceAccount={serviceAccount}
value={value}
onCreateToken={() => {
setSelectedServiceAccount(serviceAccount);
setModalOpen(true);
}}
/>
),
searchable: true, searchable: true,
}, },
{ {
@ -126,14 +144,14 @@ export const ServiceAccountsTable = () => {
Header: 'Actions', Header: 'Actions',
id: 'Actions', id: 'Actions',
align: 'center', align: 'center',
Cell: ({ row: { original: user } }: any) => ( Cell: ({ row: { original: serviceAccount } }: any) => (
<ServiceAccountsActionsCell <ServiceAccountsActionsCell
onEdit={() => { onEdit={() => {
setSelectedServiceAccount(user); setSelectedServiceAccount(serviceAccount);
setModalOpen(true); setModalOpen(true);
}} }}
onDelete={() => { onDelete={() => {
setSelectedServiceAccount(user); setSelectedServiceAccount(serviceAccount);
setDeleteOpen(true); setDeleteOpen(true);
}} }}
/> />