X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/4ee084a36d4adf2740f84875c47d81de566ec7b1..HEAD:/src/views-components/sharing-dialog/sharing-urls-component.tsx diff --git a/src/views-components/sharing-dialog/sharing-urls-component.tsx b/src/views-components/sharing-dialog/sharing-urls-component.tsx index 5151e8a2..5facb2e3 100644 --- a/src/views-components/sharing-dialog/sharing-urls-component.tsx +++ b/src/views-components/sharing-dialog/sharing-urls-component.tsx @@ -14,7 +14,7 @@ import { withStyles } from '@material-ui/core'; import { ApiClientAuthorization } from 'models/api-client-authorization'; -import { CopyIcon, RemoveIcon } from 'components/icon/icon'; +import { CopyIcon, CloseIcon } from 'components/icon/icon'; import CopyToClipboard from 'react-copy-to-clipboard'; import { ArvadosTheme } from 'common/custom-theme'; import moment from 'moment'; @@ -55,39 +55,41 @@ export interface SharingURLsComponentActionProps { onCopy: (message: string) => void; } -type SharingURLsComponentProps = SharingURLsComponentDataProps & SharingURLsComponentActionProps; +export type SharingURLsComponentProps = SharingURLsComponentDataProps & SharingURLsComponentActionProps; export const SharingURLsComponent = withStyles(styles)((props: SharingURLsComponentProps & WithStyles) => - { props.sharingTokens.length > 0 - ? props.sharingTokens - .sort((a, b) => (new Date(a.expiresAt).getTime() - new Date(b.expiresAt).getTime())) - .map(token => { - const url = props.sharingURLsPrefix.includes('*') - ? `${props.sharingURLsPrefix.replace('*', props.collectionUuid)}/t=${token.apiToken}/_/` - : `${props.sharingURLsPrefix}/c=${props.collectionUuid}/t=${token.apiToken}/_/`; - const expDate = new Date(token.expiresAt); - const urlLabel = `Token ${token.apiToken.slice(0, 8)}... expiring at: ${expDate.toLocaleString()} (${moment(expDate).fromNow()})`; + {props.sharingTokens.length > 0 + ? props.sharingTokens + .sort((a, b) => (new Date(a.expiresAt).getTime() - new Date(b.expiresAt).getTime())) + .map(token => { + const url = props.sharingURLsPrefix.includes('*') + ? `${props.sharingURLsPrefix.replace('*', props.collectionUuid)}/t=${token.apiToken}/_/` + : `${props.sharingURLsPrefix}/c=${props.collectionUuid}/t=${token.apiToken}/_/`; + const expDate = new Date(token.expiresAt); + const urlLabel = !!token.expiresAt + ? `Token ${token.apiToken.slice(0, 8)}... expiring at: ${expDate.toLocaleString()} (${moment(expDate).fromNow()})` + : `Token ${token.apiToken.slice(0, 8)}... with no expiration date`; - return - - - {urlLabel} - - - - - - props.onCopy('Sharing URL copied')}> - - - - - props.onDeleteSharingToken(token.uuid)}> - - - - - - }) - : No sharing URLs } + return + + + {urlLabel} + + + + + + props.onCopy('Sharing URL copied')}> + + + + + props.onDeleteSharingToken(token.uuid)}> + + + + + + }) + : No sharing URLs} );