Skip to content

Commit

Permalink
Update designs to match DSM
Browse files Browse the repository at this point in the history
  • Loading branch information
bergice committed Mar 15, 2021
1 parent 3869821 commit 5e4d4ea
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 24 deletions.
2 changes: 1 addition & 1 deletion client/dist/js/bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion client/dist/styles/bundle.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion client/lang/src/en/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"SessionManager.CURRENT": "Current",
"SessionManager.AUTHENTICATED": "authenticated {createdElapsed}...",
"SessionManager.LAST_ACTIVE": "last active {lastAccessedElapsed}...",
"SessionManager.LOG_OUT": "Log Out",
"SessionManager.LOG_OUT": "Log out",
"SessionManager.LOGGING_OUT": "Logging out...",
"SessionManager.LOG_OUT_CONFIRMED": "Successfully logged out of device.",
"SessionManager.ACTIVITY_TOOLTIP_TEXT": "Signed in {signedIn}, Last active {lastActive}",
}
51 changes: 31 additions & 20 deletions client/src/components/LoginSession/LoginSession.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import backend from 'lib/Backend';
import moment from 'moment';
import i18n from 'i18n';
import PropTypes from 'prop-types';
import jQuery from 'jquery';

function LoginSession(props) {
const [loading, setLoading] = useState({ complete: false, failed: false, submitting: false });
Expand Down Expand Up @@ -45,25 +46,33 @@ function LoginSession(props) {
submitting: false
});
if (response.success) {
jQuery.noticeAdd({
text: i18n._t(
'SessionManager.LOG_OUT_CONFIRMED',
'Successfully logged out of device.'
),
stay: false,
type: 'success'
});
setTimeout(() => {
setLoading({
complete: true,
failed: !!response.error && !response.success,
fadeOutComplete: true,
submitting: false
});
jQuery.noticeAdd({
text: i18n._t(
'SessionManager.LOG_OUT_CONFIRMED',
'Successfully logged out of device.'
),
stay: false,
type: 'success'
});
}, 2000);
}
})
.catch((error) => {
setLoading({ complete: true, failed: true, submitting: false });
error.response.json().then(response => {
jQuery.noticeAdd({text: response.errors, stay: false, type: 'error'});
jQuery.noticeAdd({ text: response.errors, stay: false, type: 'error' });
});
});
}

if ((loading.complete && !loading.failed) || loading.submitting) {
if (loading.fadeOutComplete) {
return null;
}

Expand All @@ -75,13 +84,15 @@ function LoginSession(props) {
const lastActiveStr = props.IsCurrent ?
i18n.inject(
i18n._t('SessionManager.AUTHENTICATED', 'authenticated {createdElapsed}...'),
{createdElapsed}
{ createdElapsed }
)
: i18n.inject(
i18n._t('SessionManager.LAST_ACTIVE', 'last active {lastAccessedElapsed}...'),
{lastAccessedElapsed}
{ lastAccessedElapsed }
);
const logOutStr = i18n._t('SessionManager.LOG_OUT', 'Log Out');
const logOutStr = (loading.submitting || (loading.complete && !loading.failed)) ?
i18n._t('SessionManager.LOGGING_OUT', 'Logging out...')
: i18n._t('SessionManager.LOG_OUT', 'Log out');

const activityTooltip = i18n.inject(
i18n._t('Admin.ACTIVITY_TOOLTIP_TEXT', 'Signed in {signedIn}, Last active {lastActive}'),
Expand All @@ -92,24 +103,24 @@ function LoginSession(props) {
);

return (
<div className="login-session">
<div className={`login-session ${(loading.complete && !loading.failed) && 'hidden'}`}>
<div>{props.UserAgent}</div>
{props.IsCurrent &&
<strong className={'text-success'} data-toggle="tooltip" data-placement="top" title={activityTooltip}>
{currentStr}
</strong>
}
<div className="text-muted">
{props.IPAddress}
<span data-toggle="tooltip" data-placement="top" title={activityTooltip}>
, {lastActiveStr}
</span>
</div>
{props.IsCurrent &&
<strong className={'text-success'}>
{currentStr}
</strong>
}
{!props.IsCurrent && <a
role={'button'}
tabIndex={'0'}
className={'login-session__logout'}
onClick={logOut}
onClick={loading.submitting ? null : logOut}
>{logOutStr}</a>}
</div>
);
Expand Down
8 changes: 8 additions & 0 deletions client/src/components/LoginSession/LoginSession.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
.login-session {
&.hidden {
visibility: hidden;
opacity: 0;
transition: visibility 0s 2s, opacity 2s linear;
}
}

.login-session__logout:not([href]) {
cursor: pointer;
color: $link-color;
Expand Down
2 changes: 1 addition & 1 deletion src/Extensions/MemberExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function updateCMSFields(FieldList $fields)
'Root.Main',
$sessionManagerField = SessionManagerField::create(
'SessionManagerField',
_t(__CLASS__ . '.SESSION_MANAGER_SETTINGS_FIELD_LABEL', 'Devices'),
_t(__CLASS__ . '.SESSION_MANAGER_SETTINGS_FIELD_LABEL', 'Authenticated devices'),
$this->owner->ID
)
);
Expand Down

0 comments on commit 5e4d4ea

Please sign in to comment.