index.tsx 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. import {Fragment} from 'react';
  2. import {RouteComponentProps} from 'react-router';
  3. import styled from '@emotion/styled';
  4. import ListLink from 'sentry/components/links/listLink';
  5. import NavTabs from 'sentry/components/navTabs';
  6. import Panel from 'sentry/components/panels/panel';
  7. import PanelBody from 'sentry/components/panels/panelBody';
  8. import PanelHeader from 'sentry/components/panels/panelHeader';
  9. import {t} from 'sentry/locale';
  10. import {InternetProtocol} from 'sentry/types';
  11. import recreateRoute from 'sentry/utils/recreateRoute';
  12. import DeprecatedAsyncView from 'sentry/views/deprecatedAsyncView';
  13. import SettingsPageHeader from 'sentry/views/settings/components/settingsPageHeader';
  14. import SessionRow from './sessionRow';
  15. import {tableLayout} from './utils';
  16. type Props = RouteComponentProps<{}, {}>;
  17. type State = {
  18. ipList: Array<InternetProtocol> | null;
  19. } & DeprecatedAsyncView['state'];
  20. class SessionHistory extends DeprecatedAsyncView<Props, State> {
  21. getTitle() {
  22. return t('Session History');
  23. }
  24. getEndpoints(): ReturnType<DeprecatedAsyncView['getEndpoints']> {
  25. return [['ipList', '/users/me/ips/']];
  26. }
  27. renderBody() {
  28. const {ipList} = this.state;
  29. if (!ipList) {
  30. return null;
  31. }
  32. const {routes, params, location} = this.props;
  33. const recreateRouteProps = {routes, params, location};
  34. return (
  35. <Fragment>
  36. <SettingsPageHeader
  37. title={t('Security')}
  38. tabs={
  39. <NavTabs underlined>
  40. <ListLink
  41. to={recreateRoute('', {...recreateRouteProps, stepBack: -1})}
  42. index
  43. >
  44. {t('Settings')}
  45. </ListLink>
  46. <ListLink to={recreateRoute('', recreateRouteProps)}>
  47. {t('Session History')}
  48. </ListLink>
  49. </NavTabs>
  50. }
  51. />
  52. <Panel>
  53. <SessionPanelHeader>
  54. <div>{t('Sessions')}</div>
  55. <div>{t('First Seen')}</div>
  56. <div>{t('Last Seen')}</div>
  57. </SessionPanelHeader>
  58. <PanelBody>
  59. {ipList.map(({id, ...ipObj}) => (
  60. <SessionRow key={id} {...ipObj} />
  61. ))}
  62. </PanelBody>
  63. </Panel>
  64. </Fragment>
  65. );
  66. }
  67. }
  68. export default SessionHistory;
  69. const SessionPanelHeader = styled(PanelHeader)`
  70. ${tableLayout}
  71. justify-content: initial;
  72. `;