summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/src
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2020-11-25 16:36:30 +0100
committerArthur Schiwon <blizzz@arthur-schiwon.de>2020-11-26 12:49:16 +0100
commitf3f819b54236e676f67b8ccdb18d76e33bd00f09 (patch)
treefb79aca1ee3b5616c98386f0aacabed795f170a7 /apps/files_sharing/src
parentbb7e1bdfb791a08132fadbebe07d65f47ef209eb (diff)
downloadnextcloud-server-f3f819b54236e676f67b8ccdb18d76e33bd00f09.tar.gz
nextcloud-server-f3f819b54236e676f67b8ccdb18d76e33bd00f09.zip
formatting remote sharer should take protocol, path into account
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps/files_sharing/src')
-rw-r--r--apps/files_sharing/src/share.js241
1 files changed, 122 insertions, 119 deletions
diff --git a/apps/files_sharing/src/share.js b/apps/files_sharing/src/share.js
index 780c581b8a5..abb0a89447e 100644
--- a/apps/files_sharing/src/share.js
+++ b/apps/files_sharing/src/share.js
@@ -34,7 +34,7 @@ import escapeHTML from 'escape-html'
* "user@example.com/path/to/owncloud"
* "user@anotherexample.com@example.com/path/to/owncloud
*/
- _REMOTE_OWNER_REGEXP: new RegExp('^(([^@]*)@(([^@^/^\\s]*)@)?)([^[\\s/]*)([/](.*))?$'),
+ _REMOTE_OWNER_REGEXP: new RegExp('^(([^@]*)@(([^@^/\\s]*)@)?)((https://)?[^[\\s/]*)([/](.*))?$'),
/**
* Initialize the sharing plugin.
@@ -343,137 +343,140 @@ import escapeHTML from 'escape-html'
}
icon.removeClass('icon-shared icon-public').addClass(iconClass)
},
- /**
- * Format a remote address
- *
- * @param {String} shareWith userid, full remote share, or whatever
- * @param {String} shareWithDisplayName
- * @param {String} message
- * @returns {String} HTML code to display
- */
- _formatRemoteShare: function(shareWith, shareWithDisplayName, message) {
- var parts = OCA.Sharing.Util._REMOTE_OWNER_REGEXP.exec(shareWith)
- if (!parts || !parts[6]) {
- // display avatar of the user
- var avatar = '<span class="avatar" data-username="' + escapeHTML(shareWith) + '" title="' + message + ' ' + escapeHTML(shareWithDisplayName) + '"></span>'
- var hidden = '<span class="hidden-visually">' + message + ' ' + escapeHTML(shareWithDisplayName) + '</span> '
- return avatar + hidden
- }
+ /**
+ * Format a remote address
+ *
+ * @param {String} shareWith userid, full remote share, or whatever
+ * @param {String} shareWithDisplayName
+ * @param {String} message
+ * @returns {String} HTML code to display
+ */
+ _formatRemoteShare: function(shareWith, shareWithDisplayName, message) {
+ var parts = OCA.Sharing.Util._REMOTE_OWNER_REGEXP.exec(shareWith)
+ console.error(parts);
+ if (!parts || !parts[7]) {
+ // display avatar of the user
+ var avatar = '<span class="avatar" data-username="' + escapeHTML(shareWith) + '" title="' + message + ' ' + escapeHTML(shareWithDisplayName) + '"></span>'
+ var hidden = '<span class="hidden-visually">' + message + ' ' + escapeHTML(shareWithDisplayName) + '</span> '
+ return avatar + hidden
+ }
var userName = parts[2]
var userDomain = parts[4]
var server = parts[5]
+ var protocol = parts[6]
+ var serverPath = parts[8] ? parts[7] : ''; // no trailing slash on root
var tooltip = message + ' ' + userName
if (userDomain) {
tooltip += '@' + userDomain
}
if (server) {
- tooltip += '@' + server
+ tooltip += '@' + server.replace(protocol, '') + serverPath
}
- var html = '<span class="remoteAddress" title="' + escapeHTML(tooltip) + '">'
- html += '<span class="username">' + escapeHTML(userName) + '</span>'
- if (userDomain) {
- html += '<span class="userDomain">@' + escapeHTML(userDomain) + '</span>'
- }
- html += '</span> '
- return html
- },
- /**
- * Loop over all recipients in the list and format them using
- * all kind of fancy magic.
- *
- * @param {Object} recipients array of all the recipients
- * @returns {String[]} modified list of recipients
- */
- _formatShareList: function(recipients) {
- var _parent = this
- recipients = _.toArray(recipients)
- recipients.sort(function(a, b) {
- return a.shareWithDisplayName.localeCompare(b.shareWithDisplayName)
- })
- return $.map(recipients, function(recipient) {
- return _parent._formatRemoteShare(recipient.shareWith, recipient.shareWithDisplayName, t('core', 'Shared with'))
- })
+ var html = '<span class="remoteAddress" title="' + escapeHTML(tooltip) + '">'
+ html += '<span class="username">' + escapeHTML(userName) + '</span>'
+ if (userDomain) {
+ html += '<span class="userDomain">@' + escapeHTML(userDomain) + '</span>'
+ }
+ html += '</span> '
+ return html
+ },
+ /**
+ * Loop over all recipients in the list and format them using
+ * all kind of fancy magic.
+ *
+ * @param {Object} recipients array of all the recipients
+ * @returns {String[]} modified list of recipients
+ */
+ _formatShareList: function(recipients) {
+ var _parent = this
+ recipients = _.toArray(recipients)
+ recipients.sort(function(a, b) {
+ return a.shareWithDisplayName.localeCompare(b.shareWithDisplayName)
+ })
+ return $.map(recipients, function(recipient) {
+ return _parent._formatRemoteShare(recipient.shareWith, recipient.shareWithDisplayName, t('core', 'Shared with'))
+ })
},
-
- /**
- * Marks/unmarks a given file as shared by changing its action icon
- * and folder icon.
- *
- * @param $tr file element to mark as shared
- * @param hasShares whether shares are available
- * @param hasLink whether link share is available
- */
- markFileAsShared: function($tr, hasShares, hasLink) {
- var action = $tr.find('.fileactions .action[data-action="Share"]')
- var type = $tr.data('type')
- var icon = action.find('.icon')
- var message, recipients, avatars
- var ownerId = $tr.attr('data-share-owner-id')
- var owner = $tr.attr('data-share-owner')
- var mountType = $tr.attr('data-mounttype')
- var shareFolderIcon
- var iconClass = 'icon-shared'
- action.removeClass('shared-style')
- // update folder icon
- if (type === 'dir' && (hasShares || hasLink || ownerId)) {
- if (typeof mountType !== 'undefined' && mountType !== 'shared-root' && mountType !== 'shared') {
- shareFolderIcon = OC.MimeType.getIconUrl('dir-' + mountType)
- } else if (hasLink) {
- shareFolderIcon = OC.MimeType.getIconUrl('dir-public')
- } else {
- shareFolderIcon = OC.MimeType.getIconUrl('dir-shared')
- }
- $tr.find('.filename .thumbnail').css('background-image', 'url(' + shareFolderIcon + ')')
- $tr.attr('data-icon', shareFolderIcon)
- } else if (type === 'dir') {
- var isEncrypted = $tr.attr('data-e2eencrypted')
- // FIXME: duplicate of FileList._createRow logic for external folder,
- // need to refactor the icon logic into a single code path eventually
- if (isEncrypted === 'true') {
- shareFolderIcon = OC.MimeType.getIconUrl('dir-encrypted')
- $tr.attr('data-icon', shareFolderIcon)
- } else if (mountType && mountType.indexOf('external') === 0) {
- shareFolderIcon = OC.MimeType.getIconUrl('dir-external')
- $tr.attr('data-icon', shareFolderIcon)
- } else {
- shareFolderIcon = OC.MimeType.getIconUrl('dir')
- // back to default
- $tr.removeAttr('data-icon')
- }
- $tr.find('.filename .thumbnail').css('background-image', 'url(' + shareFolderIcon + ')')
- }
- // update share action text / icon
- if (hasShares || ownerId) {
- recipients = $tr.data('share-recipient-data')
- action.addClass('shared-style')
-
- avatars = '<span>' + t('core', 'Shared') + '</span>'
- // even if reshared, only show "Shared by"
- if (ownerId) {
- message = t('core', 'Shared by')
- avatars = this._formatRemoteShare(ownerId, owner, message)
- } else if (recipients) {
- avatars = this._formatShareList(recipients)
- }
- action.html(avatars).prepend(icon)
-
- if (ownerId || recipients) {
- var avatarElement = action.find('.avatar')
- avatarElement.each(function() {
- $(this).avatar($(this).data('username'), 32)
- })
- action.find('span[title]').tooltip({ placement: 'top' })
- }
- } else {
- action.html('<span class="hidden-visually">' + t('core', 'Shared') + '</span>').prepend(icon)
- }
- if (hasLink) {
- iconClass = 'icon-public'
- }
- icon.removeClass('icon-shared icon-public').addClass(iconClass)
+
+ /**
+ * Marks/unmarks a given file as shared by changing its action icon
+ * and folder icon.
+ *
+ * @param $tr file element to mark as shared
+ * @param hasShares whether shares are available
+ * @param hasLink whether link share is available
+ */
+ markFileAsShared: function($tr, hasShares, hasLink) {
+ var action = $tr.find('.fileactions .action[data-action="Share"]')
+ var type = $tr.data('type')
+ var icon = action.find('.icon')
+ var message, recipients, avatars
+ var ownerId = $tr.attr('data-share-owner-id')
+ var owner = $tr.attr('data-share-owner')
+ var mountType = $tr.attr('data-mounttype')
+ var shareFolderIcon
+ var iconClass = 'icon-shared'
+ action.removeClass('shared-style')
+ // update folder icon
+ if (type === 'dir' && (hasShares || hasLink || ownerId)) {
+ if (typeof mountType !== 'undefined' && mountType !== 'shared-root' && mountType !== 'shared') {
+ shareFolderIcon = OC.MimeType.getIconUrl('dir-' + mountType)
+ } else if (hasLink) {
+ shareFolderIcon = OC.MimeType.getIconUrl('dir-public')
+ } else {
+ shareFolderIcon = OC.MimeType.getIconUrl('dir-shared')
+ }
+ $tr.find('.filename .thumbnail').css('background-image', 'url(' + shareFolderIcon + ')')
+ $tr.attr('data-icon', shareFolderIcon)
+ } else if (type === 'dir') {
+ var isEncrypted = $tr.attr('data-e2eencrypted')
+ // FIXME: duplicate of FileList._createRow logic for external folder,
+ // need to refactor the icon logic into a single code path eventually
+ if (isEncrypted === 'true') {
+ shareFolderIcon = OC.MimeType.getIconUrl('dir-encrypted')
+ $tr.attr('data-icon', shareFolderIcon)
+ } else if (mountType && mountType.indexOf('external') === 0) {
+ shareFolderIcon = OC.MimeType.getIconUrl('dir-external')
+ $tr.attr('data-icon', shareFolderIcon)
+ } else {
+ shareFolderIcon = OC.MimeType.getIconUrl('dir')
+ // back to default
+ $tr.removeAttr('data-icon')
+ }
+ $tr.find('.filename .thumbnail').css('background-image', 'url(' + shareFolderIcon + ')')
+ }
+ // update share action text / icon
+ if (hasShares || ownerId) {
+ recipients = $tr.data('share-recipient-data')
+ action.addClass('shared-style')
+
+ avatars = '<span>' + t('core', 'Shared') + '</span>'
+ // even if reshared, only show "Shared by"
+ if (ownerId) {
+ message = t('core', 'Shared by')
+ avatars = this._formatRemoteShare(ownerId, owner, message)
+ } else if (recipients) {
+ avatars = this._formatShareList(recipients)
+ }
+ action.html(avatars).prepend(icon)
+
+ if (ownerId || recipients) {
+ var avatarElement = action.find('.avatar')
+ avatarElement.each(function() {
+ $(this).avatar($(this).data('username'), 32)
+ })
+ action.find('span[title]').tooltip({ placement: 'top' })
+ }
+ } else {
+ action.html('<span class="hidden-visually">' + t('core', 'Shared') + '</span>').prepend(icon)
+ }
+ if (hasLink) {
+ iconClass = 'icon-public'
+ }
+ icon.removeClass('icon-shared icon-public').addClass(iconClass)
},
/**