diff options
author | Vincent Petry <pvince81@owncloud.com> | 2014-05-20 16:01:34 +0200 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2014-05-30 10:06:29 +0200 |
commit | ef59c69dc822c9ff69c564c41e0dfdce142b9cdf (patch) | |
tree | a99667ab22daba65cbbd77ac591fccac234f06eb /apps/files_sharing/js | |
parent | fa32243d84e1801c379a5e8956ba2f3de236c718 (diff) | |
download | nextcloud-server-ef59c69dc822c9ff69c564c41e0dfdce142b9cdf.tar.gz nextcloud-server-ef59c69dc822c9ff69c564c41e0dfdce142b9cdf.zip |
Distinguish legacy file actions from regular file actions
Legacy file actions are registered by legacy apps through
window.FileActions.register(). These actions can only be used by the
main file list ("all files") because legacy apps can only deal with a
single list / container.
New file actions of compatible apps must be registered through
OCA.Files.fileActions. These will be used for other lists like the
sharing overview.
Fixed versions and sharing actions to use OCA.Files.fileActions, which
makes them available in the sharing overview list.
Diffstat (limited to 'apps/files_sharing/js')
-rw-r--r-- | apps/files_sharing/js/app.js | 22 | ||||
-rw-r--r-- | apps/files_sharing/js/public.js | 18 | ||||
-rw-r--r-- | apps/files_sharing/js/share.js | 11 |
3 files changed, 31 insertions, 20 deletions
diff --git a/apps/files_sharing/js/app.js b/apps/files_sharing/js/app.js index 57551237a34..7a71684f1a1 100644 --- a/apps/files_sharing/js/app.js +++ b/apps/files_sharing/js/app.js @@ -23,11 +23,11 @@ OCA.Sharing.App = { $el, { scrollContainer: $('#app-content'), - sharedWithUser: true + sharedWithUser: true, + fileActions: this._createFileActions() } ); - this._initFileActions(this._inFileList); this._extendFileList(this._inFileList); this._inFileList.appName = t('files_sharing', 'Shared with you'); this._inFileList.$el.find('#emptycontent').text(t('files_sharing', 'No files have been shared with you yet.')); @@ -41,25 +41,31 @@ OCA.Sharing.App = { $el, { scrollContainer: $('#app-content'), - sharedWithUser: false + sharedWithUser: false, + fileActions: this._createFileActions() } ); - this._initFileActions(this._outFileList); this._extendFileList(this._outFileList); this._outFileList.appName = t('files_sharing', 'Shared with others'); this._outFileList.$el.find('#emptycontent').text(t('files_sharing', 'You haven\'t shared any files yet.')); }, - _initFileActions: function(fileList) { - var fileActions = OCA.Files.FileActions.clone(); + _createFileActions: function() { + // inherit file actions from the files app + var fileActions = new OCA.Files.FileActions(); + // note: not merging the legacy actions because legacy apps are not + // compatible with the sharing overview and need to be adapted first + fileActions.merge(OCA.Files.fileActions); + // when the user clicks on a folder, redirect to the corresponding - // folder in the files app + // folder in the files app instead of opening it directly fileActions.register('dir', 'Open', OC.PERMISSION_READ, '', function (filename, context) { OCA.Files.App.setActiveView('files', {silent: true}); OCA.Files.App.fileList.changeDirectory(context.$file.attr('data-path') + '/' + filename, true, true); }); - fileList.setFileActions(fileActions); + fileActions.setDefault('dir', 'Open'); + return fileActions; }, _extendFileList: function(fileList) { diff --git a/apps/files_sharing/js/public.js b/apps/files_sharing/js/public.js index d825ee9de15..446f3f2442b 100644 --- a/apps/files_sharing/js/public.js +++ b/apps/files_sharing/js/public.js @@ -19,9 +19,18 @@ OCA.Sharing.PublicApp = { initialize: function($el) { var self = this; + var fileActions; if (this._initialized) { return; } + fileActions = new OCA.Files.FileActions(); + // default actions + fileActions.registerDefaultActions(); + // legacy actions + fileActions.merge(window.FileActions); + // regular actions + fileActions.merge(OCA.Files.fileActions); + this._initialized = true; this.initialDir = $('#dir').val(); @@ -32,7 +41,8 @@ OCA.Sharing.PublicApp = { { scrollContainer: $(window), dragOptions: dragOptions, - folderDropOptions: folderDropOptions + folderDropOptions: folderDropOptions, + fileActions: fileActions } ); this.files = OCA.Files.Files; @@ -121,10 +131,8 @@ OCA.Sharing.PublicApp = { }; }); - this.fileActions = _.extend({}, OCA.Files.FileActions); - this.fileActions.registerDefaultActions(this.fileList); - delete this.fileActions.actions.all.Share; - this.fileList.setFileActions(this.fileActions); + // do not allow sharing from the public page + delete this.fileList.fileActions.actions.all.Share; this.fileList.changeDirectory(this.initialDir || '/', false, true); diff --git a/apps/files_sharing/js/share.js b/apps/files_sharing/js/share.js index 28586a179a4..1fcb1f088bf 100644 --- a/apps/files_sharing/js/share.js +++ b/apps/files_sharing/js/share.js @@ -9,10 +9,7 @@ */ $(document).ready(function() { - - var sharesLoaded = false; - - if (typeof OC.Share !== 'undefined' && typeof FileActions !== 'undefined') { + if (!_.isUndefined(OC.Share) && !_.isUndefined(OCA.Files)) { // TODO: make a separate class for this or a hook or jQuery event ? if (OCA.Files.FileList) { var oldCreateRow = OCA.Files.FileList.prototype._createRow; @@ -64,18 +61,18 @@ $(document).ready(function() { } }) - if (!sharesLoaded){ + if (!OCA.Sharing.sharesLoaded){ OC.Share.loadIcons('file', $fileList); // assume that we got all shares, so switching directories // will not invalidate that list - sharesLoaded = true; + OCA.Sharing.sharesLoaded = true; } else{ OC.Share.updateIcons('file', $fileList); } }); - OCA.Files.FileActions.register( + OCA.Files.fileActions.register( 'all', 'Share', OC.PERMISSION_SHARE, |