summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing
diff options
context:
space:
mode:
authorJan-Christoph Borchardt <hey@jancborchardt.net>2015-08-11 15:13:59 +0200
committerJan-Christoph Borchardt <hey@jancborchardt.net>2015-08-11 15:13:59 +0200
commitd04a6bce6f81df4ee4351a311a630b14e8ecd8a3 (patch)
treeaa37e75da3021abf7e9fff06c419e8cd1461970b /apps/files_sharing
parentcd0a2874de1f52827bca8d747128909099229cf4 (diff)
parent984ae8140d986e93a2fcea5951436e95c8e2c603 (diff)
downloadnextcloud-server-d04a6bce6f81df4ee4351a311a630b14e8ecd8a3.tar.gz
nextcloud-server-d04a6bce6f81df4ee4351a311a630b14e8ecd8a3.zip
Merge pull request #17709 from owncloud/fileactions-dropdown
Move file actions to dropdown
Diffstat (limited to 'apps/files_sharing')
-rw-r--r--apps/files_sharing/js/share.js96
-rw-r--r--apps/files_sharing/templates/public.php1
-rw-r--r--apps/files_sharing/tests/js/shareSpec.js6
3 files changed, 53 insertions, 50 deletions
diff --git a/apps/files_sharing/js/share.js b/apps/files_sharing/js/share.js
index 12bec0e8c9a..04700b84011 100644
--- a/apps/files_sharing/js/share.js
+++ b/apps/files_sharing/js/share.js
@@ -89,57 +89,59 @@
}
});
- fileActions.register(
- 'all',
- 'Share',
- OC.PERMISSION_SHARE,
- OC.imagePath('core', 'actions/share'),
- function(filename, context) {
-
- var $tr = context.$file;
- var itemType = 'file';
- if ($tr.data('type') === 'dir') {
- itemType = 'folder';
- }
- var possiblePermissions = $tr.data('share-permissions');
- if (_.isUndefined(possiblePermissions)) {
- possiblePermissions = $tr.data('permissions');
- }
+ fileActions.registerAction({
+ name: 'Share',
+ displayName: '',
+ mime: 'all',
+ permissions: OC.PERMISSION_SHARE,
+ icon: OC.imagePath('core', 'actions/share'),
+ type: OCA.Files.FileActions.TYPE_INLINE,
+ actionHandler: function(filename, context) {
+ var $tr = context.$file;
+ var itemType = 'file';
+ if ($tr.data('type') === 'dir') {
+ itemType = 'folder';
+ }
+ var possiblePermissions = $tr.data('share-permissions');
+ if (_.isUndefined(possiblePermissions)) {
+ possiblePermissions = $tr.data('permissions');
+ }
- var appendTo = $tr.find('td.filename');
- // Check if drop down is already visible for a different file
- if (OC.Share.droppedDown) {
- if ($tr.attr('data-id') !== $('#dropdown').attr('data-item-source')) {
- OC.Share.hideDropDown(function () {
- $tr.addClass('mouseOver');
- OC.Share.showDropDown(itemType, $tr.data('id'), appendTo, true, possiblePermissions, filename);
- });
+ var appendTo = $tr.find('td.filename');
+ // Check if drop down is already visible for a different file
+ if (OC.Share.droppedDown) {
+ if ($tr.attr('data-id') !== $('#dropdown').attr('data-item-source')) {
+ OC.Share.hideDropDown(function () {
+ $tr.addClass('mouseOver');
+ OC.Share.showDropDown(itemType, $tr.data('id'), appendTo, true, possiblePermissions, filename);
+ });
+ } else {
+ OC.Share.hideDropDown();
+ }
} else {
- OC.Share.hideDropDown();
+ $tr.addClass('mouseOver');
+ OC.Share.showDropDown(itemType, $tr.data('id'), appendTo, true, possiblePermissions, filename);
}
- } else {
- $tr.addClass('mouseOver');
- OC.Share.showDropDown(itemType, $tr.data('id'), appendTo, true, possiblePermissions, filename);
+ $('#dropdown').on('sharesChanged', function(ev) {
+ // files app current cannot show recipients on load, so we don't update the
+ // icon when changed for consistency
+ if (context.fileList.$el.closest('#app-content-files').length) {
+ return;
+ }
+ var recipients = _.pluck(ev.shares[OC.Share.SHARE_TYPE_USER], 'share_with_displayname');
+ var groupRecipients = _.pluck(ev.shares[OC.Share.SHARE_TYPE_GROUP], 'share_with_displayname');
+ recipients = recipients.concat(groupRecipients);
+ // note: we only update the data attribute because updateIcon()
+ // is called automatically after this event
+ if (recipients.length) {
+ $tr.attr('data-share-recipients', OCA.Sharing.Util.formatRecipients(recipients));
+ }
+ else {
+ $tr.removeAttr('data-share-recipients');
+ }
+ });
}
- $('#dropdown').on('sharesChanged', function(ev) {
- // files app current cannot show recipients on load, so we don't update the
- // icon when changed for consistency
- if (context.fileList.$el.closest('#app-content-files').length) {
- return;
- }
- var recipients = _.pluck(ev.shares[OC.Share.SHARE_TYPE_USER], 'share_with_displayname');
- var groupRecipients = _.pluck(ev.shares[OC.Share.SHARE_TYPE_GROUP], 'share_with_displayname');
- recipients = recipients.concat(groupRecipients);
- // note: we only update the data attribute because updateIcon()
- // is called automatically after this event
- if (recipients.length) {
- $tr.attr('data-share-recipients', OCA.Sharing.Util.formatRecipients(recipients));
- }
- else {
- $tr.removeAttr('data-share-recipients');
- }
- });
- }, t('files_sharing', 'Share'));
+ });
OC.addScript('files_sharing', 'sharetabview').done(function() {
fileList.registerTabView(new OCA.Sharing.ShareTabView('shareTabView'));
diff --git a/apps/files_sharing/templates/public.php b/apps/files_sharing/templates/public.php
index ffe0472b2b1..2962f62520d 100644
--- a/apps/files_sharing/templates/public.php
+++ b/apps/files_sharing/templates/public.php
@@ -7,6 +7,7 @@ OCP\Util::addStyle('files_sharing', 'public');
OCP\Util::addStyle('files_sharing', 'mobile');
OCP\Util::addScript('files_sharing', 'public');
OCP\Util::addScript('files', 'fileactions');
+OCP\Util::addScript('files', 'fileactionsmenu');
OCP\Util::addScript('files', 'jquery.iframe-transport');
OCP\Util::addScript('files', 'jquery.fileupload');
diff --git a/apps/files_sharing/tests/js/shareSpec.js b/apps/files_sharing/tests/js/shareSpec.js
index aa409285ca4..581e15caf93 100644
--- a/apps/files_sharing/tests/js/shareSpec.js
+++ b/apps/files_sharing/tests/js/shareSpec.js
@@ -97,7 +97,7 @@ describe('OCA.Sharing.Util tests', function() {
}]);
$tr = fileList.$el.find('tbody tr:first');
$action = $tr.find('.action-share');
- expect($action.hasClass('permanent')).toEqual(false);
+ expect($action.hasClass('permanent')).toEqual(true);
expect(OC.basename($action.find('img').attr('src'))).toEqual('share.svg');
expect(OC.basename(getImageUrl($tr.find('.filename .thumbnail')))).toEqual('folder.svg');
expect($action.find('img').length).toEqual(1);
@@ -257,7 +257,7 @@ describe('OCA.Sharing.Util tests', function() {
$action = fileList.$el.find('tbody tr:first .action-share');
$tr = fileList.$el.find('tr:first');
- expect($action.hasClass('permanent')).toEqual(false);
+ expect($action.hasClass('permanent')).toEqual(true);
$tr.find('.action-share').click();
@@ -344,7 +344,7 @@ describe('OCA.Sharing.Util tests', function() {
expect($tr.attr('data-share-recipients')).not.toBeDefined();
OC.Share.updateIcon('file', 1);
- expect($action.hasClass('permanent')).toEqual(false);
+ expect($action.hasClass('permanent')).toEqual(true);
});
it('keep share text after updating reshare', function() {
var $action, $tr;