summaryrefslogtreecommitdiffstats
path: root/core/js
diff options
context:
space:
mode:
Diffstat (limited to 'core/js')
-rw-r--r--core/js/files/client.js36
-rw-r--r--core/js/js.js46
-rw-r--r--core/js/mimetypelist.js1
-rw-r--r--core/js/oc-dialogs.js16
-rw-r--r--core/js/sharedialogresharerinfoview.js2
-rw-r--r--core/js/sharedialogshareelistview.js199
-rw-r--r--core/js/shareitemmodel.js34
-rw-r--r--core/js/systemtags/systemtagmodel.js21
-rw-r--r--core/js/tests/specs/coreSpec.js30
-rw-r--r--core/js/tests/specs/sharedialogviewSpec.js23
-rw-r--r--core/js/tests/specs/shareitemmodelSpec.js5
-rw-r--r--core/js/update.js2
-rw-r--r--core/js/visitortimezone.js2
13 files changed, 327 insertions, 90 deletions
diff --git a/core/js/files/client.js b/core/js/files/client.js
index 87559b2084c..cde3afde9d7 100644
--- a/core/js/files/client.js
+++ b/core/js/files/client.js
@@ -31,9 +31,9 @@
this._root = this._root.substr(0, this._root.length - 1);
}
- var url = 'http://';
+ var url = Client.PROTOCOL_HTTP + '://';
if (options.useHTTPS) {
- url = 'https://';
+ url = Client.PROTOCOL_HTTPS + '://';
}
url += options.host + this._root;
@@ -64,6 +64,19 @@
Client.NS_OWNCLOUD = 'http://owncloud.org/ns';
Client.NS_NEXTCLOUD = 'http://nextcloud.org/ns';
Client.NS_DAV = 'DAV:';
+
+ Client.PROPERTY_GETLASTMODIFIED = '{' + Client.NS_DAV + '}getlastmodified';
+ Client.PROPERTY_GETETAG = '{' + Client.NS_DAV + '}getetag';
+ Client.PROPERTY_GETCONTENTTYPE = '{' + Client.NS_DAV + '}getcontenttype';
+ Client.PROPERTY_RESOURCETYPE = '{' + Client.NS_DAV + '}resourcetype';
+ Client.PROPERTY_INTERNAL_FILEID = '{' + Client.NS_OWNCLOUD + '}fileid';
+ Client.PROPERTY_PERMISSIONS = '{' + Client.NS_OWNCLOUD + '}permissions';
+ Client.PROPERTY_SIZE = '{' + Client.NS_OWNCLOUD + '}size';
+ Client.PROPERTY_GETCONTENTLENGTH = '{' + Client.NS_DAV + '}getcontentlength';
+
+ Client.PROTOCOL_HTTP = 'http';
+ Client.PROTOCOL_HTTPS = 'https';
+
Client._PROPFIND_PROPERTIES = [
/**
* Modified time
@@ -259,23 +272,23 @@
var props = response.propStat[0].properties;
var data = {
- id: props['{' + Client.NS_OWNCLOUD + '}fileid'],
+ id: props[Client.PROPERTY_INTERNAL_FILEID],
path: OC.dirname(path) || '/',
name: OC.basename(path),
- mtime: (new Date(props['{' + Client.NS_DAV + '}getlastmodified'])).getTime()
+ mtime: (new Date(props[Client.PROPERTY_GETLASTMODIFIED])).getTime()
};
- var etagProp = props['{' + Client.NS_DAV + '}getetag'];
+ var etagProp = props[Client.PROPERTY_GETETAG];
if (!_.isUndefined(etagProp)) {
data.etag = this._parseEtag(etagProp);
}
- var sizeProp = props['{' + Client.NS_DAV + '}getcontentlength'];
+ var sizeProp = props[Client.PROPERTY_GETCONTENTLENGTH];
if (!_.isUndefined(sizeProp)) {
data.size = parseInt(sizeProp, 10);
}
- sizeProp = props['{' + Client.NS_OWNCLOUD + '}size'];
+ sizeProp = props[Client.PROPERTY_SIZE];
if (!_.isUndefined(sizeProp)) {
data.size = parseInt(sizeProp, 10);
}
@@ -294,12 +307,12 @@
data.isFavorite = false;
}
- var contentType = props['{' + Client.NS_DAV + '}getcontenttype'];
+ var contentType = props[Client.PROPERTY_GETCONTENTTYPE];
if (!_.isUndefined(contentType)) {
data.mimetype = contentType;
}
- var resType = props['{' + Client.NS_DAV + '}resourcetype'];
+ var resType = props[Client.PROPERTY_RESOURCETYPE];
var isFile = true;
if (!data.mimetype && resType) {
var xmlvalue = resType[0];
@@ -310,7 +323,7 @@
}
data.permissions = OC.PERMISSION_READ;
- var permissionProp = props['{' + Client.NS_OWNCLOUD + '}permissions'];
+ var permissionProp = props[Client.PROPERTY_PERMISSIONS];
if (!_.isUndefined(permissionProp)) {
var permString = permissionProp || '';
data.mountType = null;
@@ -752,7 +765,7 @@
},
/**
- * Returns the password
+ * Returns the password
*
* @since 11.0.0
* @return {String} password
@@ -816,4 +829,3 @@
OC.Files.Client = Client;
})(OC, OC.Files.FileInfo);
-
diff --git a/core/js/js.js b/core/js/js.js
index 972f0e63144..3651635541a 100644
--- a/core/js/js.js
+++ b/core/js/js.js
@@ -1669,6 +1669,52 @@ OC.Util = {
humanFileSize: humanFileSize,
/**
+ * Returns a file size in bytes from a humanly readable string
+ * Makes 2kB to 2048.
+ * Inspired by computerFileSize in helper.php
+ * @param {string} string file size in human readable format
+ * @return {number} or null if string could not be parsed
+ *
+ *
+ */
+ computerFileSize: function (string) {
+ if (typeof string != 'string') {
+ return null;
+ }
+
+ var s = string.toLowerCase();
+ var bytes = parseFloat(s)
+
+ if (!isNaN(bytes) && isFinite(s)) {
+ return bytes;
+ }
+
+ var bytesArray = {
+ 'b' : 1,
+ 'k' : 1024,
+ 'kb': 1024,
+ 'mb': 1024 * 1024,
+ 'm' : 1024 * 1024,
+ 'gb': 1024 * 1024 * 1024,
+ 'g' : 1024 * 1024 * 1024,
+ 'tb': 1024 * 1024 * 1024 * 1024,
+ 't' : 1024 * 1024 * 1024 * 1024,
+ 'pb': 1024 * 1024 * 1024 * 1024 * 1024,
+ 'p' : 1024 * 1024 * 1024 * 1024 * 1024
+ };
+
+ var matches = s.match(/([kmgtp]?b?)$/i);
+ if (matches[1]) {
+ bytes = bytes * bytesArray[matches[1]];
+ } else {
+ return null;
+ }
+
+ bytes = Math.round(bytes);
+ return bytes;
+ },
+
+ /**
* @param timestamp
* @param format
* @returns {string} timestamp formatted as requested
diff --git a/core/js/mimetypelist.js b/core/js/mimetypelist.js
index e1b9dba14af..89558e21086 100644
--- a/core/js/mimetypelist.js
+++ b/core/js/mimetypelist.js
@@ -86,6 +86,7 @@ OC.MimeTypeList={
"text/x-c": "text/code",
"text/x-c++src": "text/code",
"text/x-h": "text/code",
+ "text/x-ldif": "text/code",
"text/x-java-source": "text/code",
"text/x-python": "text/code",
"text/x-shellscript": "text/code",
diff --git a/core/js/oc-dialogs.js b/core/js/oc-dialogs.js
index 7476c93ba45..7e059b4bbc0 100644
--- a/core/js/oc-dialogs.js
+++ b/core/js/oc-dialogs.js
@@ -124,6 +124,14 @@ var OCdialogs = {
modal = false;
}
$('body').append($dlg);
+
+ // wrap callback in _.once():
+ // only call callback once and not twice (button handler and close
+ // event) but call it for the close event, if ESC or the x is hit
+ if (callback !== undefined) {
+ callback = _.once(callback);
+ }
+
var buttonlist = [{
text : t('core', 'No'),
click: function () {
@@ -147,7 +155,13 @@ var OCdialogs = {
$(dialogId).ocdialog({
closeOnEscape: true,
modal : modal,
- buttons : buttonlist
+ buttons : buttonlist,
+ close : function() {
+ // callback is already fired if Yes/No is clicked directly
+ if (callback !== undefined) {
+ callback(false, input.val());
+ }
+ }
});
input.focus();
OCdialogs.dialogsCounter++;
diff --git a/core/js/sharedialogresharerinfoview.js b/core/js/sharedialogresharerinfoview.js
index 654eebf4997..9a9d95cfb60 100644
--- a/core/js/sharedialogresharerinfoview.js
+++ b/core/js/sharedialogresharerinfoview.js
@@ -80,7 +80,7 @@
'core',
'Shared with you and the group {group} by {owner}',
{
- group: this.model.getReshareWith(),
+ group: this.model.getReshareWithDisplayName(),
owner: ownerDisplayName
}
);
diff --git a/core/js/sharedialogshareelistview.js b/core/js/sharedialogshareelistview.js
index 7fcda92d5fd..0fe0747dd59 100644
--- a/core/js/sharedialogshareelistview.js
+++ b/core/js/sharedialogshareelistview.js
@@ -35,47 +35,7 @@
'{{/unless}}' +
'{{/if}}' +
'<a href="#"><span class="icon icon-more"></span></a>' +
- '<div class="popovermenu bubble hidden menu">' +
- '<ul>' +
- '{{#if isResharingAllowed}} {{#if sharePermissionPossible}} {{#unless isMailShare}}' +
- '<li>' +
- '<span class="shareOption">' +
- '<input id="canShare-{{cid}}-{{shareWith}}" type="checkbox" name="share" class="permissions checkbox" {{#if hasSharePermission}}checked="checked"{{/if}} data-permissions="{{sharePermission}}" />' +
- '<label for="canShare-{{cid}}-{{shareWith}}">{{canShareLabel}}</label>' +
- '</span>' +
- '</li>' +
- '{{/unless}} {{/if}} {{/if}}' +
- '{{#if isFolder}}' +
- '{{#if createPermissionPossible}}{{#unless isMailShare}}' +
- '<li>' +
- '<span class="shareOption">' +
- '<input id="canCreate-{{cid}}-{{shareWith}}" type="checkbox" name="create" class="permissions checkbox" {{#if hasCreatePermission}}checked="checked"{{/if}} data-permissions="{{createPermission}}"/>' +
- '<label for="canCreate-{{cid}}-{{shareWith}}">{{createPermissionLabel}}</label>' +
- '</span>' +
- '</li>' +
- '{{/unless}}{{/if}}' +
- '{{#if updatePermissionPossible}}{{#unless isMailShare}}' +
- '<li>' +
- '<span class="shareOption">' +
- '<input id="canUpdate-{{cid}}-{{shareWith}}" type="checkbox" name="update" class="permissions checkbox" {{#if hasUpdatePermission}}checked="checked"{{/if}} data-permissions="{{updatePermission}}"/>' +
- '<label for="canUpdate-{{cid}}-{{shareWith}}">{{updatePermissionLabel}}</label>' +
- '</span>' +
- '</li>' +
- '{{/unless}}{{/if}}' +
- '{{#if deletePermissionPossible}}{{#unless isMailShare}}' +
- '<li>' +
- '<span class="shareOption">' +
- '<input id="canDelete-{{cid}}-{{shareWith}}" type="checkbox" name="delete" class="permissions checkbox" {{#if hasDeletePermission}}checked="checked"{{/if}} data-permissions="{{deletePermission}}"/>' +
- '<label for="canDelete-{{cid}}-{{shareWith}}">{{deletePermissionLabel}}</label>' +
- '</span>' +
- '</li>' +
- '{{/unless}}{{/if}}' +
- '{{/if}}' +
- '<li>' +
- '<a href="#" class="unshare"><span class="icon-loading-small hidden"></span><span class="icon icon-delete"></span><span>{{unshareLabel}}</span></a>' +
- '</li>' +
- '</ul>' +
- '</div>' +
+ '{{{popoverMenu}}}' +
'</span>' +
'</li>' +
'{{/each}}' +
@@ -94,6 +54,49 @@
'</ul>'
;
+ var TEMPLATE_POPOVER_MENU =
+ '<div class="popovermenu bubble hidden menu">' +
+ '<ul>' +
+ '{{#if isResharingAllowed}} {{#if sharePermissionPossible}} {{#unless isMailShare}}' +
+ '<li>' +
+ '<span class="shareOption">' +
+ '<input id="canShare-{{cid}}-{{shareWith}}" type="checkbox" name="share" class="permissions checkbox" {{#if hasSharePermission}}checked="checked"{{/if}} data-permissions="{{sharePermission}}" />' +
+ '<label for="canShare-{{cid}}-{{shareWith}}">{{canShareLabel}}</label>' +
+ '</span>' +
+ '</li>' +
+ '{{/unless}} {{/if}} {{/if}}' +
+ '{{#if isFolder}}' +
+ '{{#if createPermissionPossible}}{{#unless isMailShare}}' +
+ '<li>' +
+ '<span class="shareOption">' +
+ '<input id="canCreate-{{cid}}-{{shareWith}}" type="checkbox" name="create" class="permissions checkbox" {{#if hasCreatePermission}}checked="checked"{{/if}} data-permissions="{{createPermission}}"/>' +
+ '<label for="canCreate-{{cid}}-{{shareWith}}">{{createPermissionLabel}}</label>' +
+ '</span>' +
+ '</li>' +
+ '{{/unless}}{{/if}}' +
+ '{{#if updatePermissionPossible}}{{#unless isMailShare}}' +
+ '<li>' +
+ '<span class="shareOption">' +
+ '<input id="canUpdate-{{cid}}-{{shareWith}}" type="checkbox" name="update" class="permissions checkbox" {{#if hasUpdatePermission}}checked="checked"{{/if}} data-permissions="{{updatePermission}}"/>' +
+ '<label for="canUpdate-{{cid}}-{{shareWith}}">{{updatePermissionLabel}}</label>' +
+ '</span>' +
+ '</li>' +
+ '{{/unless}}{{/if}}' +
+ '{{#if deletePermissionPossible}}{{#unless isMailShare}}' +
+ '<li>' +
+ '<span class="shareOption">' +
+ '<input id="canDelete-{{cid}}-{{shareWith}}" type="checkbox" name="delete" class="permissions checkbox" {{#if hasDeletePermission}}checked="checked"{{/if}} data-permissions="{{deletePermission}}"/>' +
+ '<label for="canDelete-{{cid}}-{{shareWith}}">{{deletePermissionLabel}}</label>' +
+ '</span>' +
+ '</li>' +
+ '{{/unless}}{{/if}}' +
+ '{{/if}}' +
+ '<li>' +
+ '<a href="#" class="unshare"><span class="icon-loading-small hidden"></span><span class="icon icon-delete"></span><span>{{unshareLabel}}</span></a>' +
+ '</li>' +
+ '</ul>' +
+ '</div>';
+
/**
* @class OCA.Share.ShareDialogShareeListView
* @member {OC.Share.ShareItemModel} model
@@ -114,8 +117,14 @@
/** @type {Function} **/
_template: undefined,
+ /** @type {Function} **/
+ _popoverMenuTemplate: undefined,
+
_menuOpen: false,
+ /** @type {boolean|number} **/
+ _renderPermissionChange: false,
+
events: {
'click .unshare': 'onUnshare',
'click .icon-more': 'onToggleMenu',
@@ -182,8 +191,8 @@
});
},
- getShareeList: function() {
- var universal = {
+ getShareProperties: function() {
+ return {
avatarEnabled: this.configModel.areAvatarsEnabled(),
unshareLabel: t('core', 'Unshare'),
canShareLabel: t('core', 'can reshare'),
@@ -205,6 +214,15 @@
deletePermission: OC.PERMISSION_DELETE,
isFolder: this.model.isFolder()
};
+ },
+
+ /**
+ * get an array of sharees' share properties
+ *
+ * @returns {Array}
+ */
+ getShareeList: function() {
+ var universal = this.getShareProperties();
if(!this.model.hasUserShares()) {
return [];
@@ -256,29 +274,45 @@
},
render: function() {
- this.$el.html(this.template({
- cid: this.cid,
- sharees: this.getShareeList(),
- linkReshares: this.getLinkReshares()
- }));
-
- if(this.configModel.areAvatarsEnabled()) {
- this.$('.avatar').each(function() {
- var $this = $(this);
- if ($this.hasClass('imageplaceholderseed')) {
- $this.css({width: 32, height: 32});
- $this.imageplaceholder($this.data('seed'));
- } else {
- // user, size, ie8fix, hidedefault, callback, displayname
- $this.avatar($this.data('username'), 32, undefined, undefined, undefined, $this.data('displayname'));
- }
+ if(!this._renderPermissionChange) {
+ this.$el.html(this.template({
+ cid: this.cid,
+ sharees: this.getShareeList(),
+ linkReshares: this.getLinkReshares()
+ }));
+
+ if (this.configModel.areAvatarsEnabled()) {
+ this.$('.avatar').each(function () {
+ var $this = $(this);
+ if ($this.hasClass('imageplaceholderseed')) {
+ $this.css({width: 32, height: 32});
+ $this.imageplaceholder($this.data('seed'));
+ } else {
+ // user, size, ie8fix, hidedefault, callback, displayname
+ $this.avatar($this.data('username'), 32, undefined, undefined, undefined, $this.data('displayname'));
+ }
+ });
+ }
+
+ this.$('.has-tooltip').tooltip({
+ placement: 'bottom'
});
+ } else {
+ var permissionChangeShareId = parseInt(this._renderPermissionChange, 10);
+ var shareWithIndex = this.model.findShareWithIndex(permissionChangeShareId);
+ var sharee = this.getShareeObject(shareWithIndex);
+ $.extend(sharee, this.getShareProperties());
+ var $li = this.$('li[data-share-id=' + permissionChangeShareId + ']');
+ $li.find('.popovermenu').replaceWith(this.popoverMenuTemplate(sharee));
+
+ var checkBoxId = 'canEdit-' + this.cid + '-' + sharee.shareWith;
+ checkBoxId = '#' + checkBoxId.replace( /(:|\.|\[|\]|,|=|@)/g, "\\$1");
+ var $edit = $li.parent().find(checkBoxId);
+ if($edit.length === 1) {
+ $edit.prop('checked', sharee.hasEditPermission);
+ }
}
- this.$('.has-tooltip').tooltip({
- placement: 'bottom'
- });
-
var _this = this;
this.$('.popovermenu').on('afterHide', function() {
_this._menuOpen = false;
@@ -292,6 +326,8 @@
}
}
+ this._renderPermissionChange = false;
+
this.delegateEvents();
return this;
@@ -305,9 +341,28 @@
if (!this._template) {
this._template = Handlebars.compile(TEMPLATE);
}
+ var sharees = data.sharees;
+ if(_.isArray(sharees)) {
+ for (var i = 0; i < sharees.length; i++) {
+ data.sharees[i].popoverMenu = this.popoverMenuTemplate(sharees[i]);
+ }
+ }
return this._template(data);
},
+ /**
+ * renders the popover template and returns the resulting HTML
+ *
+ * @param {Object} data
+ * @returns {string}
+ */
+ popoverMenuTemplate: function(data) {
+ if(!this._popoverMenuTemplate) {
+ this._popoverMenuTemplate = Handlebars.compile(TEMPLATE_POPOVER_MENU);
+ }
+ return this._popoverMenuTemplate(data);
+ },
+
onUnshare: function(event) {
event.preventDefault();
event.stopPropagation();
@@ -367,6 +422,9 @@
checked = $element.is(':checked');
// Check/uncheck Create, Update, and Delete checkboxes if Edit is checked/unck
$($checkboxes).prop('checked', checked);
+ if (checked) {
+ permissions |= OC.PERMISSION_CREATE | OC.PERMISSION_UPDATE | OC.PERMISSION_DELETE;
+ }
} else {
var numberChecked = $checkboxes.filter(':checked').length;
checked = numberChecked > 0;
@@ -382,7 +440,20 @@
permissions |= $(checkbox).data('permissions');
});
- this.model.updateShare(shareId, {permissions: permissions});
+
+ /** disable checkboxes during save operation to avoid race conditions **/
+ $li.find('input[type=checkbox]').prop('disabled', true);
+ var enableCb = function() {
+ $li.find('input[type=checkbox]').prop('disabled', false);
+ };
+ var errorCb = function(elem, msg) {
+ OC.dialogs.alert(msg, t('core', 'Error while sharing'));
+ enableCb();
+ };
+
+ this.model.updateShare(shareId, {permissions: permissions}, {error: errorCb, success: enableCb});
+
+ this._renderPermissionChange = shareId;
},
});
diff --git a/core/js/shareitemmodel.js b/core/js/shareitemmodel.js
index a784f59f67f..9b10f067afc 100644
--- a/core/js/shareitemmodel.js
+++ b/core/js/shareitemmodel.js
@@ -345,6 +345,14 @@
},
/**
+ * @returns {string}
+ */
+ getReshareWithDisplayName: function() {
+ var reshare = this.get('reshare');
+ return reshare.share_with_displayname || reshare.share_with;
+ },
+
+ /**
* @returns {number}
*/
getReshareType: function() {
@@ -391,6 +399,26 @@
return share.share_with_displayname;
},
+ /**
+ * returns the array index of a sharee for a provided shareId
+ *
+ * @param shareId
+ * @returns {number}
+ */
+ findShareWithIndex: function(shareId) {
+ var shares = this.get('shares');
+ if(!_.isArray(shares)) {
+ throw "Unknown Share";
+ }
+ for(var i = 0; i < shares.length; i++) {
+ var shareWith = shares[i];
+ if(shareWith.id === shareId) {
+ return i;
+ }
+ }
+ throw "Unknown Sharee";
+ },
+
getShareType: function(shareIndex) {
/** @type OC.Share.Types.ShareInfo **/
var share = this.get('shares')[shareIndex];
@@ -553,7 +581,7 @@
return superShare;
},
- fetch: function() {
+ fetch: function(options) {
var model = this;
this.trigger('request', this);
@@ -577,6 +605,10 @@
shares: sharesMap,
reshare: reshare
}));
+
+ if(!_.isUndefined(options) && _.isFunction(options.success)) {
+ options.success();
+ }
});
return deferred;
diff --git a/core/js/systemtags/systemtagmodel.js b/core/js/systemtags/systemtagmodel.js
index 89728357e25..72450a2abd0 100644
--- a/core/js/systemtags/systemtagmodel.js
+++ b/core/js/systemtags/systemtagmodel.js
@@ -9,7 +9,15 @@
*/
(function(OC) {
- var NS_OWNCLOUD = 'http://owncloud.org/ns';
+
+ _.extend(OC.Files.Client, {
+ PROPERTY_FILEID: '{' + OC.Files.Client.NS_OWNCLOUD + '}id',
+ PROPERTY_CAN_ASSIGN:'{' + OC.Files.Client.NS_OWNCLOUD + '}can-assign',
+ PROPERTY_DISPLAYNAME: '{' + OC.Files.Client.NS_OWNCLOUD + '}display-name',
+ PROPERTY_USERVISIBLE: '{' + OC.Files.Client.NS_OWNCLOUD + '}user-visible',
+ PROPERTY_USERASSIGNABLE:'{' + OC.Files.Client.NS_OWNCLOUD + '}user-assignable',
+ });
+
/**
* @class OCA.SystemTags.SystemTagsCollection
* @classdesc
@@ -28,12 +36,12 @@
},
davProperties: {
- 'id': '{' + NS_OWNCLOUD + '}id',
- 'name': '{' + NS_OWNCLOUD + '}display-name',
- 'userVisible': '{' + NS_OWNCLOUD + '}user-visible',
- 'userAssignable': '{' + NS_OWNCLOUD + '}user-assignable',
+ 'id': OC.Files.Client.PROPERTY_FILEID,
+ 'name': OC.Files.Client.PROPERTY_DISPLAYNAME,
+ 'userVisible': OC.Files.Client.PROPERTY_USERVISIBLE,
+ 'userAssignable': OC.Files.Client.PROPERTY_USERASSIGNABLE,
// read-only, effective permissions computed by the server,
- 'canAssign': '{' + NS_OWNCLOUD + '}can-assign'
+ 'canAssign': OC.Files.Client.PROPERTY_CAN_ASSIGN
},
parse: function(data) {
@@ -50,4 +58,3 @@
OC.SystemTags = OC.SystemTags || {};
OC.SystemTags.SystemTagModel = SystemTagModel;
})(OC);
-
diff --git a/core/js/tests/specs/coreSpec.js b/core/js/tests/specs/coreSpec.js
index d1734a9f3d1..370ebc6ba2d 100644
--- a/core/js/tests/specs/coreSpec.js
+++ b/core/js/tests/specs/coreSpec.js
@@ -590,6 +590,36 @@ describe('Core base tests', function() {
}
});
});
+ describe('computerFileSize', function() {
+ it('correctly parses file sizes from a human readable formated string', function() {
+ var data = [
+ ['125', 125],
+ ['125.25', 125.25],
+ ['0 B', 0],
+ ['125 B', 125],
+ ['125b', 125],
+ ['125 KB', 128000],
+ ['125kb', 128000],
+ ['122.1 MB', 128031130],
+ ['122.1mb', 128031130],
+ ['119.2 GB', 127990025421],
+ ['119.2gb', 127990025421],
+ ['116.4 TB', 127983153473126],
+ ['116.4tb', 127983153473126]
+ ];
+ for (var i = 0; i < data.length; i++) {
+ expect(OC.Util.computerFileSize(data[i][0])).toEqual(data[i][1]);
+ }
+ });
+ it('returns null if the parameter is not a string', function() {
+ expect(OC.Util.computerFileSize(NaN)).toEqual(null);
+ expect(OC.Util.computerFileSize(125)).toEqual(null);
+ });
+ it('returns null if the string is unparsable', function() {
+ expect(OC.Util.computerFileSize('')).toEqual(null);
+ expect(OC.Util.computerFileSize('foobar')).toEqual(null);
+ });
+ });
describe('stripTime', function() {
it('strips time from dates', function() {
expect(OC.Util.stripTime(new Date(2014, 2, 24, 15, 4, 45, 24)))
diff --git a/core/js/tests/specs/sharedialogviewSpec.js b/core/js/tests/specs/sharedialogviewSpec.js
index 985610d51fb..cbb74714ff7 100644
--- a/core/js/tests/specs/sharedialogviewSpec.js
+++ b/core/js/tests/specs/sharedialogviewSpec.js
@@ -975,16 +975,35 @@ describe('OC.Share.ShareDialogView', function() {
dialog.render();
expect(dialog.$el.find('.shareWithField').prop('disabled')).toEqual(true);
});
- it('shows reshare owner', function() {
+ it('shows reshare owner for single user share', function() {
shareModel.set({
reshare: {
- uid_owner: 'user1'
+ uid_owner: 'user1',
+ displayname_owner: 'User One',
+ share_type: OC.Share.SHARE_TYPE_USER
},
shares: [],
permissions: OC.PERMISSION_READ
});
dialog.render();
expect(dialog.$el.find('.resharerInfoView .reshare').length).toEqual(1);
+ expect(dialog.$el.find('.resharerInfoView .reshare').text().trim()).toEqual('Shared with you by User One');
+ });
+ it('shows reshare owner for single user share', function() {
+ shareModel.set({
+ reshare: {
+ uid_owner: 'user1',
+ displayname_owner: 'User One',
+ share_with: 'group2',
+ share_with_displayname: 'Group Two',
+ share_type: OC.Share.SHARE_TYPE_GROUP
+ },
+ shares: [],
+ permissions: OC.PERMISSION_READ
+ });
+ dialog.render();
+ expect(dialog.$el.find('.resharerInfoView .reshare').length).toEqual(1);
+ expect(dialog.$el.find('.resharerInfoView .reshare').text().trim()).toEqual('Shared with you and the group Group Two by User One');
});
it('does not show reshare owner if owner is current user', function() {
shareModel.set({
diff --git a/core/js/tests/specs/shareitemmodelSpec.js b/core/js/tests/specs/shareitemmodelSpec.js
index 1cddcb2acaa..3d3baf75d15 100644
--- a/core/js/tests/specs/shareitemmodelSpec.js
+++ b/core/js/tests/specs/shareitemmodelSpec.js
@@ -190,6 +190,7 @@ describe('OC.Share.ShareItemModel', function() {
uid_owner: 'owner',
displayname_owner: 'Owner',
share_with: 'root',
+ share_with_displayname: 'Wurzel',
permissions: 1
},
{
@@ -221,7 +222,11 @@ describe('OC.Share.ShareItemModel', function() {
// user share has higher priority
expect(reshare.share_type).toEqual(OC.Share.SHARE_TYPE_USER);
expect(reshare.share_with).toEqual('root');
+ expect(reshare.share_with_displayname).toEqual('Wurzel');
expect(reshare.id).toEqual('1');
+
+ expect(model.getReshareWith()).toEqual('root');
+ expect(model.getReshareWithDisplayName()).toEqual('Wurzel');
});
it('does not parse link share when for a different file', function() {
/* jshint camelcase: false */
diff --git a/core/js/update.js b/core/js/update.js
index 32cf2ce5ecc..e849d8a16ce 100644
--- a/core/js/update.js
+++ b/core/js/update.js
@@ -72,7 +72,7 @@
var span = $('<span>')
.addClass('bold');
if(message === 'Exception: Updates between multiple major versions and downgrades are unsupported.') {
- span.append(t('core', 'The update was unsuccessful. For more information <a href="{url}">check our forum post</a> covering this issue.', {'url': 'https://forum.owncloud.org/viewtopic.php?f=17&t=32087'}));
+ span.append(t('core', 'The update was unsuccessful. For more information <a href="{url}">check our forum post</a> covering this issue.', {'url': 'https://help.nextcloud.com/t/updates-between-multiple-major-versions-are-unsupported/7094'}));
} else {
span.append(t('core', 'The update was unsuccessful. ' +
'Please report this issue to the ' +
diff --git a/core/js/visitortimezone.js b/core/js/visitortimezone.js
index e6e99ee7e20..e984c90a894 100644
--- a/core/js/visitortimezone.js
+++ b/core/js/visitortimezone.js
@@ -1,6 +1,6 @@
/* global jstz */
$(document).ready(function () {
- $('#timezone-offset').val((-new Date().getTimezoneOffset() / 60));
+ $('#timezone_offset').val((-new Date().getTimezoneOffset() / 60));
$('#timezone').val(jstz.determine().name());
// only enable the submit button once we are sure that the timezone is set