diff options
author | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2019-10-30 15:39:31 +0100 |
---|---|---|
committer | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2019-11-05 19:03:44 +0100 |
commit | eebcf890917ca17f9e3bd00a792b89f841c824da (patch) | |
tree | 46d2767efaa1554629ef3fffce7e13f22675ce49 /apps/files_sharing/src | |
parent | 5c0ad24a6830189a36b5538ee02738a57e067637 (diff) | |
download | nextcloud-server-eebcf890917ca17f9e3bd00a792b89f841c824da.tar.gz nextcloud-server-eebcf890917ca17f9e3bd00a792b89f841c824da.zip |
Cleanup sharing leftovers
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/files_sharing/src')
-rw-r--r-- | apps/files_sharing/src/additionalScripts.js | 2 | ||||
-rw-r--r-- | apps/files_sharing/src/share.js | 81 | ||||
-rw-r--r-- | apps/files_sharing/src/sharetabview.js | 107 | ||||
-rw-r--r-- | apps/files_sharing/src/style/sharetabview.scss | 293 | ||||
-rw-r--r-- | apps/files_sharing/src/utils/SharedWithMe.js | 6 |
5 files changed, 83 insertions, 406 deletions
diff --git a/apps/files_sharing/src/additionalScripts.js b/apps/files_sharing/src/additionalScripts.js index db65a2d2085..dae47b3db12 100644 --- a/apps/files_sharing/src/additionalScripts.js +++ b/apps/files_sharing/src/additionalScripts.js @@ -1,8 +1,6 @@ import './share' -import './sharetabview' import './sharebreadcrumbview' -import './style/sharetabview.scss' import './style/sharebreadcrumb.scss' import './collaborationresourceshandler.js' diff --git a/apps/files_sharing/src/share.js b/apps/files_sharing/src/share.js index c7ef39897d0..9c63b9a9884 100644 --- a/apps/files_sharing/src/share.js +++ b/apps/files_sharing/src/share.js @@ -247,16 +247,95 @@ * @returns {boolean} true if the icon was set, false otherwise */ _updateFileActionIcon: function($tr, hasUserShares, hasLinkShares) { + console.info('object'); // if the statuses are loaded already, use them for the icon // (needed when scrolling to the next page) if (hasUserShares || hasLinkShares || $tr.attr('data-share-recipient-data') || $tr.attr('data-share-owner')) { - OC.Share.markFileAsShared($tr, true, hasLinkShares) + OCA.Sharing.Util._markFileAsShared($tr, true, hasLinkShares) return true } return false }, /** + * 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) + }, + + /** * @param {Array} fileData * @returns {String} */ diff --git a/apps/files_sharing/src/sharetabview.js b/apps/files_sharing/src/sharetabview.js deleted file mode 100644 index da0708b85a6..00000000000 --- a/apps/files_sharing/src/sharetabview.js +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2015 - * - * This file is licensed under the Affero General Public License version 3 - * or later. - * - * See the COPYING-README file. - * - */ - -/* @global Handlebars */ - -(function() { - var TEMPLATE - = '<div>' - + '<div class="dialogContainer"></div>' - + '<div id="collaborationResources"></div>' - + '</div>' - - /** - * @memberof OCA.Sharing - */ - var ShareTabView = OCA.Files.DetailTabView.extend( - /** @lends OCA.Sharing.ShareTabView.prototype */ { - id: 'shareTabView', - className: 'tab shareTabView', - - initialize: function(name, options) { - OCA.Files.DetailTabView.prototype.initialize.call(this, name, options) - OC.Plugins.attach('OCA.Sharing.ShareTabView', this) - }, - - template: function(params) { - return TEMPLATE - }, - - getLabel: function() { - return t('files_sharing', 'Sharing') - }, - - getIcon: function() { - return 'icon-shared' - }, - - /** - * Renders this details view - */ - render: function() { - var self = this - if (this._dialog) { - // remove/destroy older instance - this._dialog.model.off() - this._dialog.remove() - this._dialog = null - } - - if (this.model) { - this.$el.html(this.template()) - - if (_.isUndefined(this.model.get('sharePermissions'))) { - this.model.set('sharePermissions', OCA.Sharing.Util.getSharePermissions(this.model.attributes)) - } - - // TODO: the model should read these directly off the passed fileInfoModel - var attributes = { - itemType: this.model.isDirectory() ? 'folder' : 'file', - itemSource: this.model.get('id'), - possiblePermissions: this.model.get('sharePermissions') - } - var configModel = new OC.Share.ShareConfigModel() - var shareModel = new OC.Share.ShareItemModel(attributes, { - configModel: configModel, - fileInfoModel: this.model - }) - this._dialog = new OC.Share.ShareDialogView({ - configModel: configModel, - model: shareModel - }) - this.$el.find('.dialogContainer').append(this._dialog.$el) - this._dialog.render() - this._dialog.model.fetch() - this._dialog.model.on('change', function() { - self.trigger('sharesChanged', shareModel) - }) - - import('./collaborationresources').then((Resources) => { - var vm = new Resources.Vue({ - el: '#collaborationResources', - render: h => h(Resources.View), - data: { - model: this.model.toJSON() - } - }) - this.model.on('change', () => { vm.data = this.model.toJSON() }) - - }) - - } else { - this.$el.empty() - // TODO: render placeholder text? - } - this.trigger('rendered') - } - }) - - OCA.Sharing.ShareTabView = ShareTabView -})() diff --git a/apps/files_sharing/src/style/sharetabview.scss b/apps/files_sharing/src/style/sharetabview.scss deleted file mode 100644 index d10808a7488..00000000000 --- a/apps/files_sharing/src/style/sharetabview.scss +++ /dev/null @@ -1,293 +0,0 @@ -.app-files .shareTabView { - min-height: 100px; -} - -.share-autocomplete-item { - display: flex; - - &.merged { - margin-left: 32px; - } - .autocomplete-item-text { - margin-left: 10px; - margin-right: 10px; - white-space: nowrap; - text-overflow: ellipsis; - overflow: hidden; - line-height: 32px; - vertical-align: middle; - flex-grow: 1; - .ui-state-highlight { - border: none; - margin: 0; - } - } - &.with-description { - .autocomplete-item-text { - line-height: 100%; - } - } - .autocomplete-item-details { - display: block; - line-height: 130%; - font-size: 90%; - opacity: 0.7; - } - - .icon { - opacity: .7; - margin-right: 7px; - } - .icon.search-globally { - width: 32px; - height: 32px; - margin-right: 0; - } -} - -.shareTabView { - .oneline { - white-space: nowrap; - position: relative; - } - .shareWithLoading { - padding-left: 10px; - right: 35px; - top: 3px; - } - .shareWithConfirm { - position: absolute; - right: 2px; - top: 6px; - padding: 14px; - opacity: 0.5; - } - .shareWithField:focus ~ .shareWithConfirm { - opacity: 1; - } - .linkMore { - position: absolute; - right: -7px; - top: -4px; - padding: 14px; - } - .popovermenu { - .linkPassMenu { - input.error { - border-color: var(--color-error) !important; - &[type="submit"] { - border-left: none; - } - } - .share-pass-submit { - width: auto !important; - } - .icon-loading-small { - background-color: var(--color-main-background); - position: absolute; - right: 8px; - margin: 3px; - padding: 10px; - width: 32px; - height: 32px; - z-index: 10; - } - } - .datepicker { - margin-left: 35px; - } - .share-add { - input.share-note-delete { - border: none; - background-color: transparent; - width: 44px !important; - padding: 0; - flex: 0 0 44px; - margin-left: auto; - &.hidden { - display: none; - } - } - } - // note - .share-note-form { - span.icon-note { - position: relative; - } - textarea.share-note { - margin: 0; - width: 200px; - min-height: 70px; - resize: none; - + input.share-note-submit { - position: absolute; - width: 44px !important; - height: 44px; - bottom: 0px; - right: 10px; - margin: 0; - background-color: transparent; - border: none; - opacity: .7; - &:hover, - &:focus, - &:active { - opacity: 1; - } - } - } - // fix for popover link share - &.share-note-link { - margin-bottom: 10px; - } - } - - /* Border above last entry '+ Add another share' to separate it from current link settings */ - .new-share { - border-top: 1px solid var(--color-border); - } - } - .linkPass .icon-loading-small { - margin-right: 0px; - } - .icon { - background-size: 16px 16px; - } - .shareWithList .icon-loading-small:not(.hidden) + span, - .linkShareView .icon-loading-small:not(.hidden) + input + label:before { - /* Hide if loader is visible */ - display: none !important; - } - input { - &[type='checkbox'] { - margin: 0 3px 0 8px; - vertical-align: middle; - } - &[type='text'] { - &.shareWithField, - &.emailField { - width: 100%; - box-sizing: border-box; - padding-right: 32px; - text-overflow: ellipsis; - } - } - &[type='text'].linkText - &[type='password'].linkPassText, - &[type='password'].passwordField { - width: 180px !important; - } - } - form { - font-size: 100%; - margin-left: 0; - margin-right: 0; - } - // share note on the sidebar - .share-note { - border-radius: var(--border-radius); - margin-bottom: 10px; - margin-left: 37px; - } -} - -// Sharing tab users list -.shareWithList { - list-style-type: none; - display: flex; - flex-direction: column; - > li { - height: 44px; - white-space: normal; - display: inline-flex; - align-items: center; - position: relative; - .avatar { - width: 32px; - height: 32px; - background-color: var(--color-primary); - } - } - .unshare img { - vertical-align: text-bottom; - /* properly align icons */ - } - .sharingOptionsGroup { - margin-left: auto; - display: flex; - align-items: center; - white-space: nowrap; - - // icons - > .icon:not(.hidden), - .share-menu > .icon:not(.hidden) { - padding: 14px; - height: 44px; - width: 44px; - opacity: .5; - display: block; - cursor: pointer; - - &:hover, - &:focus, - &:active { - opacity: .7;; - } - } - - // more menu - > .share-menu { - position: relative; - display: block; - } - } - .username { - padding: 0 8px; - overflow: hidden; - white-space: nowrap; - text-overflow: ellipsis; - } -} - -.ui-autocomplete { - /* limit dropdown height to 6 1/2 entries */ - max-height: calc(36px * 6.5); - overflow-y: auto; - overflow-x: hidden; - z-index: 1550 !important; -} - -.notCreatable { - padding-left: 12px; - padding-top: 12px; - color: var(--color-text-lighter); -} - -.contactsmenu-popover { - left: -6px; - right: auto; - padding: 3px 6px; - top: 100%; - margin-top: 0; - li.hidden { - display: none !important; - } - &:after { - left: 8px; - right: auto; - } -} - -.reshare, -#link label, -#expiration label { - display: inline-flex; - align-items: center; - .avatar { - margin-right: 5px; - } -} - -.resharerInfoView.subView { - position: relative; -} diff --git a/apps/files_sharing/src/utils/SharedWithMe.js b/apps/files_sharing/src/utils/SharedWithMe.js index b2e2e34a9bb..43abddc36b4 100644 --- a/apps/files_sharing/src/utils/SharedWithMe.js +++ b/apps/files_sharing/src/utils/SharedWithMe.js @@ -27,7 +27,7 @@ * @returns {string} the title */ const shareWithTitle = function(share) { - if (share.type === OC.Share.type_GROUP) { + if (share.type === OC.Share.SHARE_TYPE_GROUP) { return t( 'files_sharing', 'Shared with you and the group {group} by {owner}', @@ -38,7 +38,7 @@ const shareWithTitle = function(share) { undefined, { escape: false } ) - } else if (share.type === OC.Share.type_CIRCLE) { + } else if (share.type === OC.Share.SHARE_TYPE_CIRCLE) { return t( 'files_sharing', 'Shared with you and {circle} by {owner}', @@ -49,7 +49,7 @@ const shareWithTitle = function(share) { undefined, { escape: false } ) - } else if (share.type === OC.Share.type_ROOM) { + } else if (share.type === OC.Share.SHARE_TYPE_ROOM) { if (this.model.get('reshare').share_with_displayname) { return t( 'files_sharing', |