summaryrefslogtreecommitdiffstats
path: root/apps/files/js
diff options
context:
space:
mode:
authorDaniel Calviño Sánchez <danxuliu@gmail.com>2018-01-05 19:06:06 +0100
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2018-01-05 19:06:06 +0100
commit3113ee1129598d303446f3e1d4f1ccbbfc7c538d (patch)
tree3b943cecaacb5f523730614a5f7bfe6e3332ac77 /apps/files/js
parent68e205e827c3bac7dcd3d392823e367fb58b66f7 (diff)
downloadnextcloud-server-3113ee1129598d303446f3e1d4f1ccbbfc7c538d.tar.gz
nextcloud-server-3113ee1129598d303446f3e1d4f1ccbbfc7c538d.zip
Hide favourite icon in details view if favourite action is not available
When the favourite icon in the details view is clicked the "Favorite" action is triggered. However, if the action name given to "triggerAction" is not found then the "Download" action is triggered instead. As the "Favorite" action is not available in some file lists (like "Recents") the "Download" action was executed instead in those cases, which was a strange behaviour. Now the favourite icon is hidden if its action is not available. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'apps/files/js')
-rw-r--r--apps/files/js/mainfileinfodetailview.js9
1 files changed, 9 insertions, 0 deletions
diff --git a/apps/files/js/mainfileinfodetailview.js b/apps/files/js/mainfileinfodetailview.js
index ea3063f6176..626ab86ded3 100644
--- a/apps/files/js/mainfileinfodetailview.js
+++ b/apps/files/js/mainfileinfodetailview.js
@@ -20,9 +20,11 @@
'</a>' +
'</div>' +
' <div class="file-details ellipsis">' +
+ ' {{#if hasFavoriteAction}}' +
' <a href="#" class="action action-favorite favorite permanent">' +
' <span class="icon {{starClass}}" title="{{starAltText}}"></span>' +
' </a>' +
+ ' {{/if}}' +
' {{#if hasSize}}<span class="size" title="{{altSize}}">{{size}}</span>, {{/if}}<span class="date live-relative-timestamp" data-timestamp="{{timestamp}}" title="{{altDate}}">{{date}}</span>' +
' </div>' +
'</div>' +
@@ -175,6 +177,12 @@
if (this.model) {
var isFavorite = (this.model.get('tags') || []).indexOf(OC.TAG_FAVORITE) >= 0;
+ var availableActions = this._fileActions.get(
+ this.model.get('mimetype'),
+ this.model.get('type'),
+ this.model.get('permissions')
+ );
+ var hasFavoriteAction = 'Favorite' in availableActions;
this.$el.html(this.template({
type: this.model.isImage()? 'image': '',
nameLabel: t('files', 'Name'),
@@ -189,6 +197,7 @@
altDate: OC.Util.formatDate(this.model.get('mtime')),
timestamp: this.model.get('mtime'),
date: OC.Util.relativeModifiedDate(this.model.get('mtime')),
+ hasFavoriteAction: hasFavoriteAction,
starAltText: isFavorite ? t('files', 'Favorited') : t('files', 'Favorite'),
starClass: isFavorite ? 'icon-starred' : 'icon-star',
permalink: this._makePermalink(this.model.get('id')),