Skip to content
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
23 changes: 23 additions & 0 deletions apps/files/js/breadcrumb.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,15 @@
if (options.getCrumbUrl) {
this.getCrumbUrl = options.getCrumbUrl;
}
this._detailViews = [];
};
/**
* @memberof OCA.Files
*/
BreadCrumb.prototype = {
$el: null,
dir: null,
dirInfo: null,

/**
* Total width of all breadcrumbs
Expand Down Expand Up @@ -79,6 +81,20 @@
}
},

setDirectoryInfo: function(dirInfo) {
if (dirInfo !== this.dirInfo) {
this.dirInfo = dirInfo;
this.render();
}
},

/**
* @param {Backbone.View} detailView
*/
addDetailView: function(detailView) {
this._detailViews.push(detailView);
},

/**
* Returns the full URL to the given directory
*
Expand Down Expand Up @@ -122,6 +138,13 @@
}
$crumb.addClass('last');

_.each(this._detailViews, function(view) {
view.render({
dirInfo: this.dirInfo
});
$crumb.append(view.$el);
}, this);

// in case svg is not supported by the browser we need to execute the fallback mechanism
if (!OC.Util.hasSVGSupport()) {
OC.Util.replaceSVG(this.$el);
Expand Down
27 changes: 20 additions & 7 deletions apps/files/js/filelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@
* Displays the details view for the given file and
* selects the given tab
*
* @param {string} fileName file name for which to show details
* @param {string|OCA.Files.FileInfoModel} fileName file name or FileInfoModel for which to show details
* @param {string} [tabId] optional tab id to select
*/
showDetailsView: function(fileName, tabId) {
Expand All @@ -487,7 +487,7 @@
/**
* Update the details view to display the given file
*
* @param {string} fileName file name from the current list
* @param {string|OCA.Files.FileInfoModel} fileName file name from the current list or a FileInfoModel object
* @param {boolean} [show=true] whether to open the sidebar if it was closed
*/
_updateDetailsView: function(fileName, show) {
Expand Down Expand Up @@ -518,13 +518,16 @@
OC.Apps.showAppSidebar(this._detailsView.$el);
}

var $tr = this.findFileEl(fileName);
var model = this.getModelForFile($tr);
if (fileName instanceof OCA.Files.FileInfoModel) {
var model = fileName;
} else {
var $tr = this.findFileEl(fileName);
var model = this.getModelForFile($tr);
$tr.addClass('highlighted');
}

this._currentFileModel = model;

$tr.addClass('highlighted');

this._detailsView.setFileInfo(model);
this._detailsView.$el.scrollTop(0);
},
Expand Down Expand Up @@ -1646,6 +1649,7 @@

// first entry is the root
this.dirInfo = result.shift();
this.breadcrumb.setDirectoryInfo(this.dirInfo);

if (this.dirInfo.permissions) {
this.setDirectoryPermissions(this.dirInfo.permissions);
Expand Down Expand Up @@ -2021,7 +2025,7 @@

function updateInList(fileInfo) {
self.updateRow(tr, fileInfo);
self._updateDetailsView(fileInfo.name, false);
self._updateDetailsView(fileInfo, false);
}

// TODO: too many nested blocks, move parts into functions
Expand Down Expand Up @@ -2954,6 +2958,15 @@
if (this._detailsView) {
this._detailsView.addDetailView(detailView);
}
},

/**
* Register a view to be added to the breadcrumb view
*/
registerBreadCrumbDetailView: function(detailView) {
if (this.breadcrumb) {
this.breadcrumb.addDetailView(detailView);
}
}
};

Expand Down
2 changes: 2 additions & 0 deletions apps/files_sharing/appinfo/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@
function() {
\OCP\Util::addScript('files_sharing', 'share');
\OCP\Util::addScript('files_sharing', 'sharetabview');
\OCP\Util::addScript('files_sharing', 'sharebreadcrumbview');
\OCP\Util::addStyle('files_sharing', 'sharetabview');
\OCP\Util::addStyle('files_sharing', 'sharebreadcrumb');
}
);

Expand Down
34 changes: 34 additions & 0 deletions apps/files_sharing/css/sharebreadcrumb.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* @copyright 2016 Christoph Wurst <christoph@winzerhof-wurst.at>
*
* @author 2016 Christoph Wurst <christoph@winzerhof-wurst.at>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

div.crumb span.icon-share,
div.crumb span.icon-public {
display: inline-block;
cursor: pointer;
opacity: 0.2;
margin-right: 6px;
}

div.crumb span.icon-share.shared,
div.crumb span.icon-public.shared {
opacity: 0.7;
}
38 changes: 25 additions & 13 deletions apps/files_sharing/js/share.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,7 @@
var oldCreateRow = fileList._createRow;
fileList._createRow = function(fileData) {
var tr = oldCreateRow.apply(this, arguments);
var sharePermissions = fileData.permissions;
if (fileData.mountType && fileData.mountType === "external-root"){
// for external storages we can't use the permissions of the mountpoint
// instead we show all permissions and only use the share permissions from the mountpoint to handle resharing
sharePermissions = sharePermissions | (OC.PERMISSION_ALL & ~OC.PERMISSION_SHARE);
}
if (fileData.type === 'file') {
// files can't be shared with delete permissions
sharePermissions = sharePermissions & ~OC.PERMISSION_DELETE;

// create permissions don't mean anything for files
sharePermissions = sharePermissions & ~OC.PERMISSION_CREATE;
}
var sharePermissions = OCA.Sharing.Util.getSharePermissions(fileData);
tr.attr('data-share-permissions', sharePermissions);
if (fileData.shareOwner) {
tr.attr('data-share-owner', fileData.shareOwner);
Expand Down Expand Up @@ -185,6 +173,9 @@
}
});
fileList.registerTabView(shareTab);

var breadCrumbSharingDetailView = new OCA.Sharing.ShareBreadCrumbView({shareTab: shareTab});
fileList.registerBreadCrumbDetailView(breadCrumbSharingDetailView);
},

/**
Expand Down Expand Up @@ -248,6 +239,27 @@
text += ', +' + (count - maxRecipients);
}
return text;
},

/**
* @param {Array} fileData
* @returns {String}
*/
getSharePermissions: function(fileData) {
var sharePermissions = fileData.permissions;
if (fileData.mountType && fileData.mountType === "external-root"){
// for external storages we can't use the permissions of the mountpoint
// instead we show all permissions and only use the share permissions from the mountpoint to handle resharing
sharePermissions = sharePermissions | (OC.PERMISSION_ALL & ~OC.PERMISSION_SHARE);
}
if (fileData.type === 'file') {
// files can't be shared with delete permissions
sharePermissions = sharePermissions & ~OC.PERMISSION_DELETE;

// create permissions don't mean anything for files
sharePermissions = sharePermissions & ~OC.PERMISSION_CREATE;
}
return sharePermissions;
}
};
})();
Expand Down
103 changes: 103 additions & 0 deletions apps/files_sharing/js/sharebreadcrumbview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/* global Handlebars, OC */

/**
* @copyright 2016 Christoph Wurst <christoph@winzerhof-wurst.at>
*
* @author 2016 Christoph Wurst <christoph@winzerhof-wurst.at>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

(function() {
'use strict';

var BreadCrumbView = OC.Backbone.View.extend({
tagName: 'span',
events: {
click: '_onClick'
},
_dirInfo: undefined,

/** @type OCA.Sharing.ShareTabView */
_shareTab: undefined,

initialize: function(options) {
this._shareTab = options.shareTab;
},

render: function(data) {
this._dirInfo = data.dirInfo || null;

if (this._dirInfo !== null && (this._dirInfo.path !== '/' || this._dirInfo.name !== '')) {
var isShared = data.dirInfo && data.dirInfo.shareTypes && data.dirInfo.shareTypes.length > 0;
this.$el.removeClass('shared icon-public icon-share');
if (isShared) {
this.$el.addClass('shared');
if (data.dirInfo.shareTypes.indexOf(OC.Share.SHARE_TYPE_LINK) !== -1) {
this.$el.addClass('icon-public');
} else {
this.$el.addClass('icon-share');
}
} else {
this.$el.addClass('icon-share');
}
this.$el.show();
this.delegateEvents();
} else {
this.$el.removeClass('shared icon-public icon-share');
this.$el.hide();
}

return this;
},
_onClick: function(e) {
e.preventDefault();

var fileInfoModel = new OCA.Files.FileInfoModel(this._dirInfo);
var self = this;
fileInfoModel.on('change', function() {
self.render({
dirInfo: self._dirInfo
});
});
this._shareTab.on('sharesChanged', function(shareModel) {
var shareTypes = [];
var shares = shareModel.getSharesWithCurrentItem();

for(var i = 0; i < shares.length; i++) {
if (shareTypes.indexOf(shares[i].share_type) === -1) {
shareTypes.push(shares[i].share_type);
}
}

if (shareModel.hasLinkShare()) {
shareTypes.push(OC.Share.SHARE_TYPE_LINK);
}

// Since the dirInfo isn't updated we need to do this dark hackery
self._dirInfo.shareTypes = shareTypes;

self.render({
dirInfo: self._dirInfo
});
});
OCA.Files.App.fileList.showDetailsView(fileInfoModel, 'shareTabView');
}
});

OCA.Sharing.ShareBreadCrumbView = BreadCrumbView;
})();
4 changes: 4 additions & 0 deletions apps/files_sharing/js/sharetabview.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@
if (this.model) {
this.$el.html(this.template());

if (_.isUndefined(this.model.get('sharePermissions'))) {
this.model.set('sharePermissions', OCA.Sharing.Util.getSharePermissions(this.model.attributes));
}

// TODO: the model should read these directly off the passed fileInfoModel
var attributes = {
itemType: this.model.isDirectory() ? 'folder' : 'file',
Expand Down
Loading