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

Chore: Accounts/token to TS #26434

Merged
merged 5 commits into from
Aug 2, 2022
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
import { useTranslation } from '@rocket.chat/ui-contexts';
import React from 'react';
import React, { ReactElement } from 'react';

import Page from '../../../components/Page';
import { useEndpointData } from '../../../hooks/useEndpointData';
import AccountTokensTable from './AccountTokensTable';
import AddToken from './AddToken';

const AccountTokensPage = () => {
const AccountTokensPage = (): ReactElement => {
const t = useTranslation();
const { value: data, reload } = useEndpointData('/v1/users.getPersonalAccessTokens');

return (
<Page>
<Page.Header title={t('Personal_Access_Tokens')} />
<Page.Content>
<AddToken onDidAddToken={reload} />
<AccountTokensTable data={data} reload={reload} />
<AccountTokensTable />
</Page.Content>
</Page>
);
Expand Down
54 changes: 0 additions & 54 deletions apps/meteor/client/views/account/tokens/AccountTokensRow.tsx

This file was deleted.

140 changes: 0 additions & 140 deletions apps/meteor/client/views/account/tokens/AccountTokensTable.js

This file was deleted.

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;
Loading