summaryrefslogtreecommitdiffstats
path: root/apps/files/src/views/Sidebar.vue
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files/src/views/Sidebar.vue')
-rw-r--r--apps/files/src/views/Sidebar.vue33
1 files changed, 32 insertions, 1 deletions
diff --git a/apps/files/src/views/Sidebar.vue b/apps/files/src/views/Sidebar.vue
index 4b9e7b514ff..1758b510b17 100644
--- a/apps/files/src/views/Sidebar.vue
+++ b/apps/files/src/views/Sidebar.vue
@@ -274,11 +274,42 @@ export default {
}
})
},
+
getPreviewIfAny(fileInfo) {
if (fileInfo.hasPreview) {
return OC.generateUrl(`/core/preview?fileId=${fileInfo.id}&x=${screen.width}&y=${screen.height}&a=true`)
}
- return OCA.Files.App.fileList._getIconUrl(fileInfo)
+ return this.getIconUrl(fileInfo)
+ },
+
+ /**
+ * Copied from https://github.com/nextcloud/server/blob/16e0887ec63591113ee3f476e0c5129e20180cde/apps/files/js/filelist.js#L1377
+ * TODO: We also need this as a standalone library
+ *
+ * @param {Object} fileInfo the fileinfo
+ * @returns {string} Url to the icon for mimeType
+ */
+ getIconUrl(fileInfo) {
+ var mimeType = fileInfo.mimetype || 'application/octet-stream'
+ if (mimeType === 'httpd/unix-directory') {
+ // use default folder icon
+ if (fileInfo.mountType === 'shared' || fileInfo.mountType === 'shared-root') {
+ return OC.MimeType.getIconUrl('dir-shared')
+ } else if (fileInfo.mountType === 'external-root') {
+ return OC.MimeType.getIconUrl('dir-external')
+ } else if (fileInfo.mountType !== undefined && fileInfo.mountType !== '') {
+ return OC.MimeType.getIconUrl('dir-' + fileInfo.mountType)
+ } else if (fileInfo.shareTypes && (
+ fileInfo.shareTypes.indexOf(OC.Share.SHARE_TYPE_LINK) > -1
+ || fileInfo.shareTypes.indexOf(OC.Share.SHARE_TYPE_EMAIL) > -1)
+ ) {
+ return OC.MimeType.getIconUrl('dir-public')
+ } else if (fileInfo.shareTypes && fileInfo.shareTypes.length > 0) {
+ return OC.MimeType.getIconUrl('dir-shared')
+ }
+ return OC.MimeType.getIconUrl('dir')
+ }
+ return OC.MimeType.getIconUrl(mimeType)
},
tabComponent(tab) {