Skip to content
Open
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
45 changes: 0 additions & 45 deletions apps/meteor/client/components/TextCopy.tsx

This file was deleted.

11 changes: 7 additions & 4 deletions apps/meteor/client/views/account/security/TwoFactorTOTP.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Box, Button, TextInput, Margins, Field, FieldRow, FieldLabel, ToggleSwitch } from '@rocket.chat/fuselage';
import { useEffectEvent, useSafely } from '@rocket.chat/fuselage-hooks';
import { Box, Button, TextInput, Margins, Field, FieldRow, FieldLabel, ToggleSwitch, CodeSnippet } from '@rocket.chat/fuselage';
import { useEffectEvent, useSafely, useClipboard } from '@rocket.chat/fuselage-hooks';
import { useSetModal, useToastMessageDispatch, useUser, useMethod } from '@rocket.chat/ui-contexts';
import type { ReactElement, ComponentPropsWithoutRef, FormEvent } from 'react';
import { useState, useCallback, useEffect, useId } from 'react';
Expand All @@ -8,7 +8,6 @@ import { useTranslation } from 'react-i18next';
import qrcode from 'yaqrcode';

import BackupCodesModal from './BackupCodesModal';
import TextCopy from '../../../components/TextCopy';
import TwoFactorTotpModal from '../../../components/TwoFactorModal/TwoFactorTotpModal';

type TwoFactorTOTPFormData = {
Expand Down Expand Up @@ -36,6 +35,8 @@ const TwoFactorTOTP = (props: TwoFactorTOTPProps): ReactElement => {

const { register, handleSubmit } = useForm<TwoFactorTOTPFormData>({ defaultValues: { authCode: '' } });

const { copy, hasCopied } = useClipboard(totpSecret || '');

Comment on lines +38 to +39
Copy link

Copilot AI Mar 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This refactor changes copy feedback: the previous TextCopy used useClipboardWithToast, which dispatches a success toast on copy. The new useClipboard usage only updates hasCopied/button label, so the toast is lost. If the intent is to preserve existing UX (and match the PR description), switch to useClipboardWithToast(totpSecret ?? '') or pass onCopySuccess/onCopyError options to useClipboard to keep the toast behavior.

Copilot uses AI. Check for mistakes.
const totpEnabled = user?.services?.totp?.enabled;

const closeModal = useCallback(() => setModal(null), [setModal]);
Expand Down Expand Up @@ -153,7 +154,9 @@ const TwoFactorTOTP = (props: TwoFactorTOTPProps): ReactElement => {
<>
<Box>{t('Scan_QR_code')}</Box>
<Box>{t('Scan_QR_code_alternative_s')}</Box>
<TextCopy text={totpSecret || ''} />
<CodeSnippet buttonText={hasCopied ? t('Copied') : t('Copy')} buttonDisabled={hasCopied} onClick={() => copy()}>
{totpSecret || ''}
</CodeSnippet>
<Box mis='-16px' mb='-16px' is='img' size='x200' src={qrCode} aria-hidden='true' />
<Field>
<FieldLabel htmlFor={totpCodeId}>{t('Enter_code_provided_by_authentication_app')}</FieldLabel>
Expand Down
Loading