import {Fragment, useState} from 'react'; import styled from '@emotion/styled'; import {Button, LinkButton} from 'sentry/components/button'; import Confirm from 'sentry/components/confirm'; import {DateTime} from 'sentry/components/dateTime'; import EmptyMessage from 'sentry/components/emptyMessage'; import Input from 'sentry/components/input'; import Panel from 'sentry/components/panels/panel'; import PanelBody from 'sentry/components/panels/panelBody'; import PanelHeader from 'sentry/components/panels/panelHeader'; import PanelItem from 'sentry/components/panels/panelItem'; import {Tooltip} from 'sentry/components/tooltip'; import {IconClose, IconDelete} from 'sentry/icons'; import {t} from 'sentry/locale'; import {space} from 'sentry/styles/space'; import ConfirmHeader from 'sentry/views/settings/account/accountSecurity/components/confirmHeader'; import TextBlock from 'sentry/views/settings/components/text/textBlock'; function U2fEnrolledDetails(props) { const {className, isEnrolled, devices, id, onRemoveU2fDevice, onRenameU2fDevice} = props; if (id !== 'u2f' || !isEnrolled) { return null; } const hasDevices = devices?.length; // Note Tooltip doesn't work because of bootstrap(?) pointer events for disabled buttons const isLastDevice = hasDevices === 1; return ( {t('Device name')} {!hasDevices && ( {t('You have not added any U2F devices')} )} {hasDevices && devices?.map((device, i) => ( ))} {t('Add Another Device')} ); } function Device(props) { const {device, isLastDevice, onRenameU2fDevice, onRemoveU2fDevice} = props; const [deviceName, setDeviceName] = useState(device.name); const [isEditing, setEditting] = useState(false); if (!isEditing) { return ( {device.name} onRemoveU2fDevice(device)} disabled={isLastDevice} message={ {t('Do you want to remove U2F device?')} {t('Are you sure you want to remove the U2F device "%s"?', device.name)} } > ); } return ( { setDeviceName(e.target.value); }} /> ); } const DeviceNameInput = styled(Input)` width: 50%; margin-right: ${space(2)}; `; const DevicePanelItem = styled(PanelItem)` padding: 0; `; const DeviceInformation = styled('div')` display: flex; align-items: center; justify-content: space-between; flex: 1 1; height: 72px; padding: ${space(2)}; padding-right: 0; `; const FadedDateTime = styled(DateTime)` font-size: ${p => p.theme.fontSizeRelativeSmall}; opacity: 0.6; `; const Name = styled('div')` flex: 1; `; const Actions = styled('div')` margin: ${space(2)}; `; const AddAnotherPanelItem = styled(PanelItem)` justify-content: flex-end; padding: ${space(2)}; `; export default styled(U2fEnrolledDetails)` margin-top: ${space(4)}; `;