|
@@ -2,47 +2,17 @@ import React from 'react';
|
|
import styled from '@emotion/styled';
|
|
import styled from '@emotion/styled';
|
|
import {RouteComponentProps} from 'react-router/lib/Router';
|
|
import {RouteComponentProps} from 'react-router/lib/Router';
|
|
|
|
|
|
-import {Panel, PanelBody, PanelHeader, PanelItem} from 'app/components/panels';
|
|
|
|
|
|
+import {Panel, PanelBody, PanelHeader} from 'app/components/panels';
|
|
import {t} from 'app/locale';
|
|
import {t} from 'app/locale';
|
|
import AsyncView from 'app/views/asyncView';
|
|
import AsyncView from 'app/views/asyncView';
|
|
import ListLink from 'app/components/links/listLink';
|
|
import ListLink from 'app/components/links/listLink';
|
|
import NavTabs from 'app/components/navTabs';
|
|
import NavTabs from 'app/components/navTabs';
|
|
import SettingsPageHeader from 'app/views/settings/components/settingsPageHeader';
|
|
import SettingsPageHeader from 'app/views/settings/components/settingsPageHeader';
|
|
-import TimeSince from 'app/components/timeSince';
|
|
|
|
import recreateRoute from 'app/utils/recreateRoute';
|
|
import recreateRoute from 'app/utils/recreateRoute';
|
|
-import space from 'app/styles/space';
|
|
|
|
|
|
+import {InternetProtocol} from 'app/types';
|
|
|
|
|
|
-type InternetProtocol = {
|
|
|
|
- id: string;
|
|
|
|
- ipAddress: string;
|
|
|
|
- lastSeen: string;
|
|
|
|
- firstSeen: string;
|
|
|
|
- countryCode: string | null;
|
|
|
|
- regionCode: string | null;
|
|
|
|
-};
|
|
|
|
-
|
|
|
|
-function SessionRow({
|
|
|
|
- ipAddress,
|
|
|
|
- lastSeen,
|
|
|
|
- firstSeen,
|
|
|
|
- countryCode,
|
|
|
|
- regionCode,
|
|
|
|
-}: Omit<InternetProtocol, 'id'>) {
|
|
|
|
- return (
|
|
|
|
- <SessionPanelItem>
|
|
|
|
- <IpAndLocation>
|
|
|
|
- <div>
|
|
|
|
- <IpAddress>{ipAddress}</IpAddress>
|
|
|
|
- {countryCode && regionCode && (
|
|
|
|
- <CountryCode>{`${countryCode} (${regionCode})`}</CountryCode>
|
|
|
|
- )}
|
|
|
|
- </div>
|
|
|
|
- </IpAndLocation>
|
|
|
|
- <StyledTimeSince date={firstSeen} />
|
|
|
|
- <StyledTimeSince date={lastSeen} />
|
|
|
|
- </SessionPanelItem>
|
|
|
|
- );
|
|
|
|
-}
|
|
|
|
|
|
+import SessionRow from './sessionRow';
|
|
|
|
+import {tableLayout} from './utils';
|
|
|
|
|
|
type Props = RouteComponentProps<{}, {}>;
|
|
type Props = RouteComponentProps<{}, {}>;
|
|
|
|
|
|
@@ -50,7 +20,7 @@ type State = {
|
|
ipList: Array<InternetProtocol> | null;
|
|
ipList: Array<InternetProtocol> | null;
|
|
} & AsyncView['state'];
|
|
} & AsyncView['state'];
|
|
|
|
|
|
-class AccountSecuritySessionHistory extends AsyncView<Props, State> {
|
|
|
|
|
|
+class SessionHistory extends AsyncView<Props, State> {
|
|
getTitle() {
|
|
getTitle() {
|
|
return t('Session History');
|
|
return t('Session History');
|
|
}
|
|
}
|
|
@@ -94,9 +64,10 @@ class AccountSecuritySessionHistory extends AsyncView<Props, State> {
|
|
<div>{t('First Seen')}</div>
|
|
<div>{t('First Seen')}</div>
|
|
<div>{t('Last Seen')}</div>
|
|
<div>{t('Last Seen')}</div>
|
|
</SessionPanelHeader>
|
|
</SessionPanelHeader>
|
|
|
|
+
|
|
<PanelBody>
|
|
<PanelBody>
|
|
- {ipList.map(({id, ...ip}) => (
|
|
|
|
- <SessionRow key={id} {...ip} />
|
|
|
|
|
|
+ {ipList.map(({id, ...ipObj}) => (
|
|
|
|
+ <SessionRow key={id} {...ipObj} />
|
|
))}
|
|
))}
|
|
</PanelBody>
|
|
</PanelBody>
|
|
</Panel>
|
|
</Panel>
|
|
@@ -105,39 +76,9 @@ class AccountSecuritySessionHistory extends AsyncView<Props, State> {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-export default AccountSecuritySessionHistory;
|
|
|
|
-
|
|
|
|
-const IpAddress = styled('div')`
|
|
|
|
- margin-bottom: ${space(0.5)};
|
|
|
|
- font-weight: bold;
|
|
|
|
-`;
|
|
|
|
-
|
|
|
|
-const CountryCode = styled('div')`
|
|
|
|
- font-size: ${p => p.theme.fontSizeRelativeSmall};
|
|
|
|
-`;
|
|
|
|
-
|
|
|
|
-const StyledTimeSince = styled(TimeSince)`
|
|
|
|
- font-size: ${p => p.theme.fontSizeRelativeSmall};
|
|
|
|
-`;
|
|
|
|
-
|
|
|
|
-const IpAndLocation = styled('div')`
|
|
|
|
- display: flex;
|
|
|
|
- flex-direction: column;
|
|
|
|
- flex: 1;
|
|
|
|
-`;
|
|
|
|
-
|
|
|
|
-const getTableLayout = `
|
|
|
|
- display: grid;
|
|
|
|
- grid-template-columns: auto 140px 140px;
|
|
|
|
- grid-gap ${space(1)};
|
|
|
|
- align-items: center;
|
|
|
|
-`;
|
|
|
|
|
|
+export default SessionHistory;
|
|
|
|
|
|
const SessionPanelHeader = styled(PanelHeader)`
|
|
const SessionPanelHeader = styled(PanelHeader)`
|
|
- ${getTableLayout}
|
|
|
|
|
|
+ ${tableLayout}
|
|
justify-content: initial;
|
|
justify-content: initial;
|
|
`;
|
|
`;
|
|
-
|
|
|
|
-const SessionPanelItem = styled(PanelItem)`
|
|
|
|
- ${getTableLayout}
|
|
|
|
-`;
|
|
|