Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combine sessions and app passwords view into one single view #5166

Merged
merged 1 commit into from
Jun 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 14 additions & 30 deletions settings/css/settings.css
Original file line number Diff line number Diff line change
Expand Up @@ -300,35 +300,29 @@ table.nostyle td {
padding: 0.2em 0;
}

#sessions table,
#apppasswords table {
#sessions table {
width: 100%;
min-height: 50px;
padding-top: 5px;
max-width: 580px;
}

#sessions table th,
#apppasswords table th {
#sessions table th{
opacity: .5;
}

#sessions table th,
#sessions table td,
#apppasswords table th,
#apppasswords table td {
#sessions table td {
padding: 10px 10px 10px 0;
}

#sessions .token-list td.more,
#apppasswords .token-list td.more {
#sessions .token-list td.more {
overflow: visible;
position: relative;
width: 16px;
}

#sessions .token-list td,
#apppasswords .token-list td {
#sessions .token-list td {
border-top: 1px solid #DDD;
text-overflow: ellipsis;
max-width: 200px;
Expand All @@ -338,58 +332,48 @@ table.nostyle td {
position: relative;
}

#sessions tr > *:nth-child(2),
#apppasswords tr > *:nth-child(2) {
#sessions tr > *:nth-child(2) {
text-align: right;
}

#sessions .token-list td > a.icon,
#apppasswords .token-list td > a.icon {
#sessions .token-list td > a.icon {
opacity: 0;
transition: opacity 0.5s;
}

#sessions .token-list a.icon,
#apppasswords .token-list a.icon {
#sessions .token-list a.icon {
margin-top: 4px;
display: block;
}

#sessions .token-list tr:hover td > a.icon,
#apppasswords .token-list tr:hover td > a.icon,
#sessions .token-list tr.active td > a.icon,
#apppasswords .token-list tr.active td > a.icon {
#sessions .token-list tr.active td > a.icon {
opacity: 0.6;
}

#sessions .token-list td div.configure,
#apppasswords .token-list td div.configure {
#sessions .token-list td div.configure {
display: none;
}

#sessions .token-list tr.active div.configure,
#apppasswords .token-list tr.active div.configure {
#sessions .token-list tr.active div.configure {
display: block;
position: absolute;
top: 45px;
right: -5px;
padding: 10px;
}

#sessions .token-list div.configure:after,
#apppasswords .token-list div.configure:after {
#sessions .token-list div.configure:after {
right: 13px;
}

#sessions .token-list tr.active div.configure > *,
#apppasswords .token-list tr.active div.configure > * {
#sessions .token-list tr.active div.configure > * {
margin-top: 5px;
margin-bottom: 5px;
display: inline-block;
}

#sessions .token-list tr.active a.icon-delete,
#apppasswords .token-list tr.active a.icon-delete {
#sessions .token-list tr.active a.icon-delete {
background-position: left;
padding-left: 20px;
}
Expand Down
57 changes: 19 additions & 38 deletions settings/js/authtoken_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,6 @@
var SubView = OC.Backbone.View.extend({
collection: null,

/**
* token type
* - 0: browser
* - 1: device
*
* @see OC\Authentication\Token\IToken
*/
type: 0,

_template: undefined,

template: function (data) {
Expand All @@ -68,7 +59,6 @@
},

initialize: function (options) {
this.type = options.type;
this.collection = options.collection;

this.on(this.collection, 'change', this.render);
Expand All @@ -79,7 +69,7 @@

var list = this.$('.token-list');
var tokens = this.collection.filter(function (token) {
return token.get('type') === _this.type;
return true;
});
list.html('');

Expand Down Expand Up @@ -183,7 +173,7 @@
var AuthTokenView = OC.Backbone.View.extend({
collection: null,

_views: [],
_view: [],

_form: undefined,

Expand All @@ -206,34 +196,29 @@
initialize: function (options) {
this.collection = options.collection;

var tokenTypes = [0, 1];
var _this = this;
_.each(tokenTypes, function (type) {
var el = type === 0 ? '#sessions' : '#apppasswords';
_this._views.push(new SubView({
el: el,
type: type,
collection: _this.collection
}));

var $el = $(el);
$('body').on('click', _.bind(_this._hideConfigureToken, _this));
$el.on('click', '.popovermenu', function(event) {
event.stopPropagation();
});
$el.on('click', 'a.icon-delete', _.bind(_this._onDeleteToken, _this));
$el.on('click', '.icon-more', _.bind(_this._onConfigureToken, _this));
$el.on('change', 'input.filesystem', _.bind(_this._onSetTokenScope, _this));
var el = '#sessions';
this._view = new SubView({
el: el,
collection: this.collection
});

var $el = $(el);
$('body').on('click', _.bind(this._hideConfigureToken, this));
$el.on('click', '.popovermenu', function(event) {
event.stopPropagation();
});
$el.on('click', 'a.icon-delete', _.bind(this._onDeleteToken, this));
$el.on('click', '.icon-more', _.bind(this._onConfigureToken, this));
$el.on('change', 'input.filesystem', _.bind(this._onSetTokenScope, this));

this._form = $('#app-password-form');
this._tokenName = $('#app-password-name');
this._addAppPasswordBtn = $('#add-app-password');
this._addAppPasswordBtn.click(_.bind(this._addAppPassword, this));
this._appPasswordName = $('#app-password-name');
this._appPasswordName.on('keypress', function(event) {
if (event.which === 13) {
_this._addAppPassword();
this._addAppPassword();
}
});

Expand Down Expand Up @@ -287,18 +272,14 @@
},

render: function () {
_.each(this._views, function (view) {
view.render();
view.toggleLoading(false);
});
this._view.render();
this._view.toggleLoading(false);
},

reload: function () {
var _this = this;

_.each(this._views, function (view) {
view.toggleLoading(true);
});
this._view.toggleLoading(true);

var loadingTokens = this.collection.fetch();

Expand Down
1 change: 0 additions & 1 deletion settings/personal.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@
$formsAndMore = [];
$formsAndMore[]= ['anchor' => 'personal-settings', 'section-name' => $l->t('Personal info')];
$formsAndMore[]= ['anchor' => 'sessions', 'section-name' => $l->t('Sessions')];
$formsAndMore[]= ['anchor' => 'apppasswords', 'section-name' => $l->t('App passwords')];
$formsAndMore[]= ['anchor' => 'clientsbox', 'section-name' => $l->t('Sync clients')];

$forms=OC_App::getForms('personal');
Expand Down
16 changes: 0 additions & 16 deletions settings/templates/personal.php
Original file line number Diff line number Diff line change
Expand Up @@ -348,22 +348,6 @@
<tbody class="token-list">
</tbody>
</table>
</div>

<div id="apppasswords" class="section">
<h2><?php p($l->t('App passwords'));?></h2>
<p class="settings-hint"><?php p($l->t('Here you can generate individual passwords for apps so you don’t have to give out your password. You can revoke them individually too.'));?></p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The App passwords title should still be there though, no? For federated sharing we have it as a h3.

At least the settings-hint should stay since otherwise people don’t have a clue what to use the »App name« and »Create new app password« controls for, right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jancborchardt can you fix it directly please?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be good to have my questions answered beforehand. :) Do we want to abolish the heading to just make it one consistent list, or use it as a h3?

Copy link
Member

@icewind1991 icewind1991 Jun 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For activity we also have it as an <h2>.

Maybe the section should be called something like "Security", "Web, desktop mobile clients and app specific passwords that currently have access to your account."

<table class="icon-loading">
<thead class="hidden-when-empty">
<tr>
<th><?php p($l->t('Name'));?></th>
<th><?php p($l->t('Last activity'));?></th>
<th></th>
</tr>
</thead>
<tbody class="token-list">
</tbody>
</table>
<div id="app-password-form">
<input id="app-password-name" type="text" placeholder="<?php p($l->t('App name')); ?>">
<button id="add-app-password" class="button"><?php p($l->t('Create new app password')); ?></button>
Expand Down