import React from 'react' ; import Table , { Cell } from 'design/DataTableNext' ; import { MenuButton , MenuItem } from 'shared/components/MenuAction' ; import cfg from 'teleport/config' ; import { Session } from 'teleport/services/ssh' ; import renderDescCell from './DescCell' ; export default function SessionList ( props ) { const { sessions , pageSize = 100 } = props ; return ( < Table data = { sessions } columns = { [ { altKey : 'description' , headerText : 'Description' , render : renderDescCell , } , { key : 'sid' , headerText : 'Session ID' , } , { altKey : 'users' , headerText : 'Users' , render : renderUsersCell , } , { altKey : 'node' , headerText : 'Node' , render : renderNodeCell , } , { key : 'durationText' , headerText : 'Duration' , } , { altKey : 'options-btn' , render : renderActionCell , } , ] } emptyText = "No Active Sessions Found" pagination = { { pageSize } } isSearchable / > ) ; } function renderActionCell ( { sid , clusterId } ) { const url = cfg . getSshSessionRoute ( { sid , clusterId } ) ; return ( < Cell align = "right" > < MenuButton > < MenuItem as = "a" href = { url } target = "_blank" > Join Session < /MenuItem> < /MenuButton> < /Cell>); } function renderNodeCell ( { hostname , addr } ) { const nodeAddr = addr ? `[${ addr }]` : '' ; return ( < Cell > { hostname } { nodeAddr } < /Cell>); } function renderUsersCell ( { parties } ) { const users = parties . map ( ( { user , remoteAddr } ) => `${ user } [${ remoteAddr }]` ) . join ( ', ' ) ; return < Cell > { users } < /Cell>; } type Props = { sessions : Session [ ] ; pageSize ? : number ; } ;