import { Badge } from '@automattic/ui'; import { useQuery, useMutation } from '@tanstack/react-query'; import { __experimentalHStack as HStack, __experimentalVStack as VStack, __experimentalText as Text, BaseControl, Button, Card, CardBody, ExternalLink, SelectControl, ToggleControl, } from '@wordpress/components'; import { useDispatch } from '@wordpress/data'; import { DataForm } from '@wordpress/dataviews'; import { createInterpolateElement } from '@wordpress/element'; import { sprintf, __ } from '@wordpress/i18n'; import { trash } from '@wordpress/icons'; import { store as noticesStore } from '@wordpress/notices'; import { useMemo, useState } from 'react'; import { useAuth } from '../../app/auth'; import { siteSshAccessEnableMutation, siteSshAccessDisableMutation, siteSshKeysQuery, siteSshKeysAttachMutation, siteSshKeysDetachMutation, } from '../../app/queries/site-ssh'; import { sshKeysQuery } from '../../app/queries/ssh'; import ClipboardInputControl from '../../components/clipboard-input-control'; import InlineSupportLink from '../../components/inline-support-link'; import { SectionHeader } from '../../components/section-header'; import type { SftpUser, SiteSshKey, UserSshKey } from '../../data/types'; import type { DataFormControlProps, Field } from '@wordpress/dataviews'; type SshCardFormData = { connection_command: string; ssh_key: string; }; const SshKeyCard = ( { siteSshKey, userLocale, isBusy, onDetach, }: { siteSshKey: SiteSshKey; userLocale: string; isBusy: boolean; onDetach: ( siteSshKey: SiteSshKey ) => void; } ) => { return ( { `${ siteSshKey.user_login }-${ siteSshKey.name }` } { siteSshKey.sha256 } { sprintf( /* translators: %s is when the SSH key was attached. */ __( 'Attached on %s' ), new Intl.DateTimeFormat( userLocale, { dateStyle: 'long', timeStyle: 'medium', } ).format( new Date( siteSshKey.attached_at ) ) ) } ) } ); }