import {Fragment} from 'react'; import styled from '@emotion/styled'; import {Button} from 'sentry/components/button'; import Confirm from 'sentry/components/confirm'; import Link from 'sentry/components/links/link'; import LoadingIndicator from 'sentry/components/loadingIndicator'; import Placeholder from 'sentry/components/placeholder'; import TimeSince from 'sentry/components/timeSince'; import {Tooltip} from 'sentry/components/tooltip'; import {IconSubtract} from 'sentry/icons'; import {t, tct} from 'sentry/locale'; import {space} from 'sentry/styles/space'; import type {Organization, OrgAuthToken, Project} from 'sentry/types'; import getDynamicText from 'sentry/utils/getDynamicText'; import {tokenPreview} from 'sentry/views/settings/organizationAuthTokens'; function LastUsed({ organization, dateLastUsed, projectLastUsed, }: { organization: Organization; dateLastUsed?: Date; projectLastUsed?: Project; }) { if (dateLastUsed && projectLastUsed) { return ( {tct('[date] in project [project]', { date: ( ), project: ( {projectLastUsed.name} ), })} ); } if (dateLastUsed) { return ( ); } if (projectLastUsed) { return ( {tct('in project [project]', { project: ( {projectLastUsed.name} ), })} ); } return {t('never used')}; } export function OrganizationAuthTokensAuthTokenRow({ organization, isRevoking, token, revokeToken, projectLastUsed, isProjectLoading, }: { isRevoking: boolean; organization: Organization; token: OrgAuthToken; isProjectLoading?: boolean; projectLastUsed?: Project; revokeToken?: (token: OrgAuthToken) => void; }) { return (
{token.tokenLastCharacters && ( {tokenPreview( getDynamicText({ value: token.tokenLastCharacters, fixed: 'ABCD', }), 'sntrys_' )} )}
{isProjectLoading ? ( ) : ( )} {isProjectLoading ? ( ) : ( )} revokeToken(token) : undefined} message={t( 'Are you sure you want to revoke this token? The token will not be usable anymore, and this cannot be undone.' )} >
); } const Label = styled('div')``; const Actions = styled('div')` display: flex; justify-content: flex-end; `; const DateTime = styled('div')` display: flex; align-items: center; gap: ${space(0.5)}; `; const NeverUsed = styled('div')` color: ${p => p.theme.gray300}; `; const TokenPreview = styled('div')` color: ${p => p.theme.gray300}; `;