[Pkg-owncloud-commits] [owncloud] 05/59: Added mountType attribute and adapted Delete action text

David Prévot taffit at moszumanska.debian.org
Fri Jul 18 16:19:24 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository owncloud.

commit 1cc8be07018ec02cbc534a86f2cbb1b6a7326f97
Author: Vincent Petry <pvince81 at owncloud.com>
Date:   Thu Jul 10 17:25:46 2014 +0200

    Added mountType attribute and adapted Delete action text
    
    Added mountType attribute for files/folder to indicated whether they are
    regular, external or shared.
    
    The client side then adapts the "Delete" action hint text based on this
    information.
    
    Only the mount roots must have the delete icon hint adapted.
    To make this detectable on the client side, the mountType can now
    be null, "shared", "shared-root", "external" or "external-root".
    
    This also gives room to icon customization on the client side.
---
 apps/files/js/fileactions.js             | 16 +++++++++++-----
 apps/files/js/filelist.js                |  4 ++++
 apps/files/lib/helper.php                | 13 +++++++++++++
 apps/files_external/js/mountsfilelist.js |  1 +
 apps/files_sharing/js/sharedfilelist.js  |  1 +
 5 files changed, 30 insertions(+), 5 deletions(-)

diff --git a/apps/files/js/fileactions.js b/apps/files/js/fileactions.js
index fd03876..4aefd61 100644
--- a/apps/files/js/fileactions.js
+++ b/apps/files/js/fileactions.js
@@ -291,14 +291,20 @@
 			if (actions['Delete']) {
 				var img = self.icons['Delete'];
 				var html;
+				var mountType = $tr.attr('data-mounttype');
+				var deleteTitle = t('files', 'Delete');
+				if (mountType === 'external-root') {
+					deleteTitle = t('files', 'Disconnect storage');
+				} else if (mountType === 'shared-root') {
+					deleteTitle = t('files', 'Unshare');
+				} else if (fileList.id === 'trashbin') {
+					deleteTitle = t('files', 'Delete permanently');
+				}
+
 				if (img.call) {
 					img = img(file);
 				}
-				if (typeof trashBinApp !== 'undefined' && trashBinApp) {
-					html = '<a href="#" original-title="' + t('files', 'Delete permanently') + '" class="action delete delete-icon" />';
-				} else {
-					html = '<a href="#" original-title="' + t('files', 'Delete') + '" class="action delete delete-icon" />';
-				}
+				html = '<a href="#" original-title="' + escapeHTML(deleteTitle) + '" class="action delete delete-icon" />';
 				var element = $(html);
 				element.data('action', actions['Delete']);
 				element.on('click', {a: null, elem: parent, actionFunc: actions['Delete'].action}, actionHandler);
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js
index 96436d3..61e73b7 100644
--- a/apps/files/js/filelist.js
+++ b/apps/files/js/filelist.js
@@ -600,6 +600,10 @@
 				"data-permissions": fileData.permissions || this.getDirectoryPermissions()
 			});
 
+			if (fileData.mountType) {
+				tr.attr('data-mounttype', fileData.mountType);
+			}
+
 			if (!_.isUndefined(path)) {
 				tr.attr('data-path', path);
 			}
diff --git a/apps/files/lib/helper.php b/apps/files/lib/helper.php
index b84b6c0..be0992b 100644
--- a/apps/files/lib/helper.php
+++ b/apps/files/lib/helper.php
@@ -37,6 +37,7 @@ class Helper
 	public static function determineIcon($file) {
 		if($file['type'] === 'dir') {
 			$icon = \OC_Helper::mimetypeIcon('dir');
+			// TODO: move this part to the client side, using mountType
 			if ($file->isShared()) {
 				$icon = \OC_Helper::mimetypeIcon('dir-shared');
 			} elseif ($file->isMounted()) {
@@ -125,6 +126,18 @@ class Helper
 		if (isset($i['is_share_mount_point'])) {
 			$entry['isShareMountPoint'] = $i['is_share_mount_point'];
 		}
+		$mountType = null;
+		if ($i->isShared()) {
+			$mountType = 'shared';
+		} else if ($i->isMounted()) {
+			$mountType = 'external';
+		}
+		if ($mountType !== null) {
+			if ($i->getInternalPath() === '') {
+				$mountType .= '-root';
+			}
+			$entry['mountType'] = $mountType;
+		}
 		return $entry;
 	}
 
diff --git a/apps/files_external/js/mountsfilelist.js b/apps/files_external/js/mountsfilelist.js
index 0f61f78..20bf0f7 100644
--- a/apps/files_external/js/mountsfilelist.js
+++ b/apps/files_external/js/mountsfilelist.js
@@ -104,6 +104,7 @@
 		_makeFiles: function(data) {
 			var files = _.map(data, function(fileData) {
 				fileData.icon = OC.imagePath('core', 'filetypes/folder-external');
+				fileData.mountType = 'external';
 				return fileData;
 			});
 
diff --git a/apps/files_sharing/js/sharedfilelist.js b/apps/files_sharing/js/sharedfilelist.js
index 861bbaf..d5c65a6 100644
--- a/apps/files_sharing/js/sharedfilelist.js
+++ b/apps/files_sharing/js/sharedfilelist.js
@@ -233,6 +233,7 @@
 				.each(function(data) {
 					// convert the recipients map to a flat
 					// array of sorted names
+					data.mountType = 'shared';
 					data.recipients = _.keys(data.recipients);
 					data.recipientsDisplayName = OCA.Sharing.Util.formatRecipients(
 						data.recipients,

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list