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

Reversed the list, equivalent to sorting by date ASC #1472

Merged
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
55 changes: 29 additions & 26 deletions frontend/src/settings/authentication/AuthenticationTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import EmptyBlob from 'src/common/EmptyBlob'
import Loading from 'src/common/Loading'
import MessageAlert from 'src/MessageAlert'
import { TokenInterface } from 'types/types'
import { formatDateString } from 'utils/dateUtils'
import { formatDateString, sortByCreatedAtDescending } from 'utils/dateUtils'
import { getErrorMessage } from 'utils/fetcher'

export default function AuthenticationTab() {
Expand All @@ -25,35 +25,38 @@ export default function AuthenticationTab() {
setTokenToDelete(accessKey)
setIsConfirmationDialogOpen(true)
}, [])

const tokenList = useMemo(
() =>
tokens.length > 0 && !isTokensLoading ? (
tokens.map((token, index) => (
<Fragment key={token.accessKey}>
<Stack direction='row' alignItems='center' justifyContent='space-between'>
<Typography>{token.description}</Typography>
<Box pl={1}>
<Typography variant='caption' mr={1}>
Created on
<Typography variant='caption' fontWeight='bold'>
{` ${formatDateString(token.createdAt)}`}
tokens
.sort((token1, token2) => {
return sortByCreatedAtDescending(token1, token2)
})
.map((token, index) => (
<Fragment key={token.accessKey}>
<Stack direction='row' alignItems='center' justifyContent='space-between'>
<Typography>{token.description}</Typography>
<Box pl={1}>
<Typography variant='caption' mr={1}>
Created on
<Typography variant='caption' fontWeight='bold'>
{` ${formatDateString(token.createdAt)}`}
</Typography>
</Typography>
</Typography>
<Tooltip title='Delete token'>
<IconButton
color='primary'
onClick={() => handleOpenConfirmationDialog(token.accessKey)}
aria-label='delete access key'
>
<Delete />
</IconButton>
</Tooltip>
</Box>
</Stack>
{index !== tokens.length - 1 && <Box sx={{ borderBottom: 1, borderColor: 'divider', my: 2 }} />}
</Fragment>
))
<Tooltip title='Delete token'>
<IconButton
color='primary'
onClick={() => handleOpenConfirmationDialog(token.accessKey)}
aria-label='delete access key'
>
<Delete />
</IconButton>
</Tooltip>
</Box>
</Stack>
{index !== tokens.length - 1 && <Box sx={{ borderBottom: 1, borderColor: 'divider', my: 2 }} />}
</Fragment>
))
) : (
<EmptyBlob text='No tokens found' />
),
Expand Down
Loading