-
Notifications
You must be signed in to change notification settings - Fork 10.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Chore: Accounts/token to TS (#26434)
Co-authored-by: dougfabris <devfabris@gmail.com>
- Loading branch information
1 parent
4e25e5f
commit 8d4d684
Showing
14 changed files
with
374 additions
and
301 deletions.
There are no files selected for viewing
10 changes: 3 additions & 7 deletions
10
...views/account/tokens/AccountTokensPage.js → ...iews/account/tokens/AccountTokensPage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 0 additions & 54 deletions
54
apps/meteor/client/views/account/tokens/AccountTokensRow.tsx
This file was deleted.
Oops, something went wrong.
140 changes: 0 additions & 140 deletions
140
apps/meteor/client/views/account/tokens/AccountTokensTable.js
This file was deleted.
Oops, something went wrong.
46 changes: 46 additions & 0 deletions
46
apps/meteor/client/views/account/tokens/AccountTokensTable/AccountTokensRow.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { IPersonalAccessToken, Serialized } from '@rocket.chat/core-typings'; | ||
import { ButtonGroup, IconButton, TableRow, TableCell } from '@rocket.chat/fuselage'; | ||
import { useTranslation } from '@rocket.chat/ui-contexts'; | ||
import React, { useCallback, FC } from 'react'; | ||
|
||
import { useFormatDateAndTime } from '../../../../hooks/useFormatDateAndTime'; | ||
|
||
type AccountTokensRowProps = { | ||
isMedium: boolean; | ||
onRegenerate: (name: string) => void; | ||
onRemove: (name: string) => void; | ||
} & Serialized<Pick<IPersonalAccessToken, 'name' | 'createdAt' | 'lastTokenPart' | 'bypassTwoFactor'>>; | ||
|
||
const AccountTokensRow: FC<AccountTokensRowProps> = ({ | ||
bypassTwoFactor, | ||
createdAt, | ||
isMedium, | ||
lastTokenPart, | ||
name, | ||
onRegenerate, | ||
onRemove, | ||
}) => { | ||
const t = useTranslation(); | ||
const formatDateAndTime = useFormatDateAndTime(); | ||
const handleRegenerate = useCallback(() => onRegenerate(name), [name, onRegenerate]); | ||
const handleRemove = useCallback(() => onRemove(name), [name, onRemove]); | ||
|
||
return ( | ||
<TableRow key={name} tabIndex={0} role='link' qa-token-name={name}> | ||
<TableCell withTruncatedText color='default' fontScale='p2m'> | ||
{name} | ||
</TableCell> | ||
{isMedium && <TableCell withTruncatedText>{formatDateAndTime(createdAt)}</TableCell>} | ||
<TableCell withTruncatedText>...{lastTokenPart}</TableCell> | ||
<TableCell withTruncatedText>{bypassTwoFactor ? t('Ignore') : t('Require')}</TableCell> | ||
<TableCell withTruncatedText> | ||
<ButtonGroup> | ||
<IconButton title={t('Refresh')} icon='refresh' small secondary onClick={handleRegenerate} /> | ||
<IconButton title={t('Remove')} icon='trash' small secondary onClick={handleRemove} /> | ||
</ButtonGroup> | ||
</TableCell> | ||
</TableRow> | ||
); | ||
}; | ||
|
||
export default AccountTokensRow; |
Oops, something went wrong.