|
@@ -1,16 +1,18 @@
|
|
|
-import {Fragment} from 'react';
|
|
|
import type {RouteComponentProps} from 'react-router';
|
|
|
import styled from '@emotion/styled';
|
|
|
|
|
|
import ListLink from 'sentry/components/links/listLink';
|
|
|
+import LoadingError from 'sentry/components/loadingError';
|
|
|
+import LoadingIndicator from 'sentry/components/loadingIndicator';
|
|
|
import NavTabs from 'sentry/components/navTabs';
|
|
|
import Panel from 'sentry/components/panels/panel';
|
|
|
import PanelBody from 'sentry/components/panels/panelBody';
|
|
|
import PanelHeader from 'sentry/components/panels/panelHeader';
|
|
|
+import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle';
|
|
|
import {t} from 'sentry/locale';
|
|
|
import type {InternetProtocol} from 'sentry/types';
|
|
|
+import {useApiQuery} from 'sentry/utils/queryClient';
|
|
|
import recreateRoute from 'sentry/utils/recreateRoute';
|
|
|
-import DeprecatedAsyncView from 'sentry/views/deprecatedAsyncView';
|
|
|
import SettingsPageHeader from 'sentry/views/settings/components/settingsPageHeader';
|
|
|
|
|
|
import SessionRow from './sessionRow';
|
|
@@ -18,64 +20,60 @@ import {tableLayout} from './utils';
|
|
|
|
|
|
type Props = RouteComponentProps<{}, {}>;
|
|
|
|
|
|
-type State = {
|
|
|
- ipList: Array<InternetProtocol> | null;
|
|
|
-} & DeprecatedAsyncView['state'];
|
|
|
+type IpListType = Array<InternetProtocol> | null;
|
|
|
|
|
|
-class SessionHistory extends DeprecatedAsyncView<Props, State> {
|
|
|
- getTitle() {
|
|
|
- return t('Session History');
|
|
|
- }
|
|
|
+function SessionHistory({routes, params, location}: Props) {
|
|
|
+ const {
|
|
|
+ data: ipList,
|
|
|
+ isLoading,
|
|
|
+ isError,
|
|
|
+ } = useApiQuery<IpListType>(['/users/me/ips/'], {staleTime: 0});
|
|
|
|
|
|
- getEndpoints(): ReturnType<DeprecatedAsyncView['getEndpoints']> {
|
|
|
- return [['ipList', '/users/me/ips/']];
|
|
|
+ if (isError) {
|
|
|
+ return <LoadingError />;
|
|
|
}
|
|
|
|
|
|
- renderBody() {
|
|
|
- const {ipList} = this.state;
|
|
|
+ if (isLoading) {
|
|
|
+ return <LoadingIndicator />;
|
|
|
+ }
|
|
|
|
|
|
- if (!ipList) {
|
|
|
- return null;
|
|
|
- }
|
|
|
+ if (!ipList) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
|
|
|
- const {routes, params, location} = this.props;
|
|
|
- const recreateRouteProps = {routes, params, location};
|
|
|
+ const recreateRouteProps = {routes, params, location};
|
|
|
|
|
|
- return (
|
|
|
- <Fragment>
|
|
|
- <SettingsPageHeader
|
|
|
- title={t('Security')}
|
|
|
- tabs={
|
|
|
- <NavTabs underlined>
|
|
|
- <ListLink
|
|
|
- to={recreateRoute('', {...recreateRouteProps, stepBack: -1})}
|
|
|
- index
|
|
|
- >
|
|
|
- {t('Settings')}
|
|
|
- </ListLink>
|
|
|
- <ListLink to={recreateRoute('', recreateRouteProps)}>
|
|
|
- {t('Session History')}
|
|
|
- </ListLink>
|
|
|
- </NavTabs>
|
|
|
- }
|
|
|
- />
|
|
|
+ return (
|
|
|
+ <SentryDocumentTitle title={t('Session History')}>
|
|
|
+ <SettingsPageHeader
|
|
|
+ title={t('Security')}
|
|
|
+ tabs={
|
|
|
+ <NavTabs underlined>
|
|
|
+ <ListLink to={recreateRoute('', {...recreateRouteProps, stepBack: -1})} index>
|
|
|
+ {t('Settings')}
|
|
|
+ </ListLink>
|
|
|
+ <ListLink to={recreateRoute('', recreateRouteProps)}>
|
|
|
+ {t('Session History')}
|
|
|
+ </ListLink>
|
|
|
+ </NavTabs>
|
|
|
+ }
|
|
|
+ />
|
|
|
|
|
|
- <Panel>
|
|
|
- <SessionPanelHeader>
|
|
|
- <div>{t('Sessions')}</div>
|
|
|
- <div>{t('First Seen')}</div>
|
|
|
- <div>{t('Last Seen')}</div>
|
|
|
- </SessionPanelHeader>
|
|
|
+ <Panel>
|
|
|
+ <SessionPanelHeader>
|
|
|
+ <div>{t('Sessions')}</div>
|
|
|
+ <div>{t('First Seen')}</div>
|
|
|
+ <div>{t('Last Seen')}</div>
|
|
|
+ </SessionPanelHeader>
|
|
|
|
|
|
- <PanelBody>
|
|
|
- {ipList.map(({id, ...ipObj}) => (
|
|
|
- <SessionRow key={id} {...ipObj} />
|
|
|
- ))}
|
|
|
- </PanelBody>
|
|
|
- </Panel>
|
|
|
- </Fragment>
|
|
|
- );
|
|
|
- }
|
|
|
+ <PanelBody>
|
|
|
+ {ipList.map(({id, ...ipObj}) => (
|
|
|
+ <SessionRow key={id} {...ipObj} />
|
|
|
+ ))}
|
|
|
+ </PanelBody>
|
|
|
+ </Panel>
|
|
|
+ </SentryDocumentTitle>
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
export default SessionHistory;
|