]> source.dussan.org Git - nextcloud-server.git/commitdiff
Added mountType attribute and adapted Delete action text
authorVincent Petry <pvince81@owncloud.com>
Thu, 10 Jul 2014 15:25:46 +0000 (17:25 +0200)
committerVincent Petry <pvince81@owncloud.com>
Mon, 14 Jul 2014 08:36:04 +0000 (10:36 +0200)
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
apps/files/js/filelist.js
apps/files/lib/helper.php
apps/files_external/js/mountsfilelist.js
apps/files_sharing/js/sharedfilelist.js

index fd038765ea51c6c5396f87632365bc5cc042adc7..4aefd61a19a005c3265c1bf16cf7b4759e9e17f5 100644 (file)
                        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);
index 96436d33a2c72cff513f4260c202cddf7a75af9b..61e73b7bebc9f94e73514f42622a62caf569c7f3 100644 (file)
                                "data-permissions": fileData.permissions || this.getDirectoryPermissions()
                        });
 
+                       if (fileData.mountType) {
+                               tr.attr('data-mounttype', fileData.mountType);
+                       }
+
                        if (!_.isUndefined(path)) {
                                tr.attr('data-path', path);
                        }
index b84b6c06d30c22e70885a4ca43e3026949f1c40c..be0992b19854b967f7a9b7f0db7f6084813b2169 100644 (file)
@@ -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;
        }
 
index 0f61f78aac81e0fb7f0138a3881721c85179ac63..20bf0f785db6670e61c19dff9153dd5ce1189252 100644 (file)
                _makeFiles: function(data) {
                        var files = _.map(data, function(fileData) {
                                fileData.icon = OC.imagePath('core', 'filetypes/folder-external');
+                               fileData.mountType = 'external';
                                return fileData;
                        });
 
index 861bbaff5de6f7aec89eba2a9c83052afcf1df5a..d5c65a6c6813b98b9c1d7efdc7a854c527dffd93 100644 (file)
                                .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,